babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5158. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6862. import { Vector3 } from "babylonjs/Maths/math.vector";
  6863. import { Mesh } from "babylonjs/Meshes/mesh";
  6864. /**
  6865. * The options Interface for creating a Capsule Mesh
  6866. */
  6867. export interface ICreateCapsuleOptions {
  6868. /** The Orientation of the capsule. Default : Vector3.Up() */
  6869. orientation?: Vector3;
  6870. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6871. subdivisions: number;
  6872. /** Number of cylindrical segments on the capsule. */
  6873. tessellation: number;
  6874. /** Height or Length of the capsule. */
  6875. height: number;
  6876. /** Radius of the capsule. */
  6877. radius: number;
  6878. /** Height or Length of the capsule. */
  6879. capSubdivisions: number;
  6880. /** Overwrite for the top radius. */
  6881. radiusTop?: number;
  6882. /** Overwrite for the bottom radius. */
  6883. radiusBottom?: number;
  6884. /** Overwrite for the top capSubdivisions. */
  6885. topCapSubdivisions?: number;
  6886. /** Overwrite for the bottom capSubdivisions. */
  6887. bottomCapSubdivisions?: number;
  6888. }
  6889. /**
  6890. * Class containing static functions to help procedurally build meshes
  6891. */
  6892. export class CapsuleBuilder {
  6893. /**
  6894. * Creates a capsule or a pill mesh
  6895. * @param name defines the name of the mesh
  6896. * @param options The constructors options.
  6897. * @param scene The scene the mesh is scoped to.
  6898. * @returns Capsule Mesh
  6899. */
  6900. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6901. }
  6902. }
  6903. declare module "babylonjs/Collisions/intersectionInfo" {
  6904. import { Nullable } from "babylonjs/types";
  6905. /**
  6906. * @hidden
  6907. */
  6908. export class IntersectionInfo {
  6909. bu: Nullable<number>;
  6910. bv: Nullable<number>;
  6911. distance: number;
  6912. faceId: number;
  6913. subMeshId: number;
  6914. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6915. }
  6916. }
  6917. declare module "babylonjs/Culling/boundingSphere" {
  6918. import { DeepImmutable } from "babylonjs/types";
  6919. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6920. import { Plane } from "babylonjs/Maths/math.plane";
  6921. /**
  6922. * Class used to store bounding sphere information
  6923. */
  6924. export class BoundingSphere {
  6925. /**
  6926. * Gets the center of the bounding sphere in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Radius of the bounding sphere in local space
  6931. */
  6932. radius: number;
  6933. /**
  6934. * Gets the center of the bounding sphere in world space
  6935. */
  6936. readonly centerWorld: Vector3;
  6937. /**
  6938. * Radius of the bounding sphere in world space
  6939. */
  6940. radiusWorld: number;
  6941. /**
  6942. * Gets the minimum vector in local space
  6943. */
  6944. readonly minimum: Vector3;
  6945. /**
  6946. * Gets the maximum vector in local space
  6947. */
  6948. readonly maximum: Vector3;
  6949. private _worldMatrix;
  6950. private static readonly TmpVector3;
  6951. /**
  6952. * Creates a new bounding sphere
  6953. * @param min defines the minimum vector (in local space)
  6954. * @param max defines the maximum vector (in local space)
  6955. * @param worldMatrix defines the new world matrix
  6956. */
  6957. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6958. /**
  6959. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6960. * @param min defines the new minimum vector (in local space)
  6961. * @param max defines the new maximum vector (in local space)
  6962. * @param worldMatrix defines the new world matrix
  6963. */
  6964. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6965. /**
  6966. * Scale the current bounding sphere by applying a scale factor
  6967. * @param factor defines the scale factor to apply
  6968. * @returns the current bounding box
  6969. */
  6970. scale(factor: number): BoundingSphere;
  6971. /**
  6972. * Gets the world matrix of the bounding box
  6973. * @returns a matrix
  6974. */
  6975. getWorldMatrix(): DeepImmutable<Matrix>;
  6976. /** @hidden */
  6977. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6978. /**
  6979. * Tests if the bounding sphere is intersecting the frustum planes
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @returns true if there is an intersection
  6982. */
  6983. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if the bounding sphere center is in between the frustum planes.
  6986. * Used for optimistic fast inclusion.
  6987. * @param frustumPlanes defines the frustum planes to test
  6988. * @returns true if the sphere center is in between the frustum planes
  6989. */
  6990. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6991. /**
  6992. * Tests if a point is inside the bounding sphere
  6993. * @param point defines the point to test
  6994. * @returns true if the point is inside the bounding sphere
  6995. */
  6996. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6997. /**
  6998. * Checks if two sphere intersct
  6999. * @param sphere0 sphere 0
  7000. * @param sphere1 sphere 1
  7001. * @returns true if the speres intersect
  7002. */
  7003. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7004. }
  7005. }
  7006. declare module "babylonjs/Culling/boundingBox" {
  7007. import { DeepImmutable } from "babylonjs/types";
  7008. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7009. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7010. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7011. import { Plane } from "babylonjs/Maths/math.plane";
  7012. /**
  7013. * Class used to store bounding box information
  7014. */
  7015. export class BoundingBox implements ICullable {
  7016. /**
  7017. * Gets the 8 vectors representing the bounding box in local space
  7018. */
  7019. readonly vectors: Vector3[];
  7020. /**
  7021. * Gets the center of the bounding box in local space
  7022. */
  7023. readonly center: Vector3;
  7024. /**
  7025. * Gets the center of the bounding box in world space
  7026. */
  7027. readonly centerWorld: Vector3;
  7028. /**
  7029. * Gets the extend size in local space
  7030. */
  7031. readonly extendSize: Vector3;
  7032. /**
  7033. * Gets the extend size in world space
  7034. */
  7035. readonly extendSizeWorld: Vector3;
  7036. /**
  7037. * Gets the OBB (object bounding box) directions
  7038. */
  7039. readonly directions: Vector3[];
  7040. /**
  7041. * Gets the 8 vectors representing the bounding box in world space
  7042. */
  7043. readonly vectorsWorld: Vector3[];
  7044. /**
  7045. * Gets the minimum vector in world space
  7046. */
  7047. readonly minimumWorld: Vector3;
  7048. /**
  7049. * Gets the maximum vector in world space
  7050. */
  7051. readonly maximumWorld: Vector3;
  7052. /**
  7053. * Gets the minimum vector in local space
  7054. */
  7055. readonly minimum: Vector3;
  7056. /**
  7057. * Gets the maximum vector in local space
  7058. */
  7059. readonly maximum: Vector3;
  7060. private _worldMatrix;
  7061. private static readonly TmpVector3;
  7062. /**
  7063. * @hidden
  7064. */
  7065. _tag: number;
  7066. /**
  7067. * Creates a new bounding box
  7068. * @param min defines the minimum vector (in local space)
  7069. * @param max defines the maximum vector (in local space)
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7073. /**
  7074. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7075. * @param min defines the new minimum vector (in local space)
  7076. * @param max defines the new maximum vector (in local space)
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Scale the current bounding box by applying a scale factor
  7082. * @param factor defines the scale factor to apply
  7083. * @returns the current bounding box
  7084. */
  7085. scale(factor: number): BoundingBox;
  7086. /**
  7087. * Gets the world matrix of the bounding box
  7088. * @returns a matrix
  7089. */
  7090. getWorldMatrix(): DeepImmutable<Matrix>;
  7091. /** @hidden */
  7092. _update(world: DeepImmutable<Matrix>): void;
  7093. /**
  7094. * Tests if the bounding box is intersecting the frustum planes
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @returns true if there is an intersection
  7097. */
  7098. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. /**
  7100. * Tests if the bounding box is entirely inside the frustum planes
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @returns true if there is an inclusion
  7103. */
  7104. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a point is inside the bounding box
  7107. * @param point defines the point to test
  7108. * @returns true if the point is inside the bounding box
  7109. */
  7110. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7111. /**
  7112. * Tests if the bounding box intersects with a bounding sphere
  7113. * @param sphere defines the sphere to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7117. /**
  7118. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7119. * @param min defines the min vector to use
  7120. * @param max defines the max vector to use
  7121. * @returns true if there is an intersection
  7122. */
  7123. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7124. /**
  7125. * Tests if two bounding boxes are intersections
  7126. * @param box0 defines the first box to test
  7127. * @param box1 defines the second box to test
  7128. * @returns true if there is an intersection
  7129. */
  7130. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7131. /**
  7132. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7133. * @param minPoint defines the minimum vector of the bounding box
  7134. * @param maxPoint defines the maximum vector of the bounding box
  7135. * @param sphereCenter defines the sphere center
  7136. * @param sphereRadius defines the sphere radius
  7137. * @returns true if there is an intersection
  7138. */
  7139. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7140. /**
  7141. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7142. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7143. * @param frustumPlanes defines the frustum planes to test
  7144. * @return true if there is an inclusion
  7145. */
  7146. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /**
  7148. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7149. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7150. * @param frustumPlanes defines the frustum planes to test
  7151. * @return true if there is an intersection
  7152. */
  7153. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7154. }
  7155. }
  7156. declare module "babylonjs/Collisions/collider" {
  7157. import { Nullable, IndicesArray } from "babylonjs/types";
  7158. import { Vector3 } from "babylonjs/Maths/math.vector";
  7159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7160. import { Plane } from "babylonjs/Maths/math.plane";
  7161. /** @hidden */
  7162. export class Collider {
  7163. /** Define if a collision was found */
  7164. collisionFound: boolean;
  7165. /**
  7166. * Define last intersection point in local space
  7167. */
  7168. intersectionPoint: Vector3;
  7169. /**
  7170. * Define last collided mesh
  7171. */
  7172. collidedMesh: Nullable<AbstractMesh>;
  7173. private _collisionPoint;
  7174. private _planeIntersectionPoint;
  7175. private _tempVector;
  7176. private _tempVector2;
  7177. private _tempVector3;
  7178. private _tempVector4;
  7179. private _edge;
  7180. private _baseToVertex;
  7181. private _destinationPoint;
  7182. private _slidePlaneNormal;
  7183. private _displacementVector;
  7184. /** @hidden */
  7185. _radius: Vector3;
  7186. /** @hidden */
  7187. _retry: number;
  7188. private _velocity;
  7189. private _basePoint;
  7190. private _epsilon;
  7191. /** @hidden */
  7192. _velocityWorldLength: number;
  7193. /** @hidden */
  7194. _basePointWorld: Vector3;
  7195. private _velocityWorld;
  7196. private _normalizedVelocity;
  7197. /** @hidden */
  7198. _initialVelocity: Vector3;
  7199. /** @hidden */
  7200. _initialPosition: Vector3;
  7201. private _nearestDistance;
  7202. private _collisionMask;
  7203. get collisionMask(): number;
  7204. set collisionMask(mask: number);
  7205. /**
  7206. * Gets the plane normal used to compute the sliding response (in local space)
  7207. */
  7208. get slidePlaneNormal(): Vector3;
  7209. /** @hidden */
  7210. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7211. /** @hidden */
  7212. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7213. /** @hidden */
  7214. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7215. /** @hidden */
  7216. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7217. /** @hidden */
  7218. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7219. /** @hidden */
  7220. _getResponse(pos: Vector3, vel: Vector3): void;
  7221. }
  7222. }
  7223. declare module "babylonjs/Culling/boundingInfo" {
  7224. import { DeepImmutable } from "babylonjs/types";
  7225. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7226. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7227. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7228. import { Plane } from "babylonjs/Maths/math.plane";
  7229. import { Collider } from "babylonjs/Collisions/collider";
  7230. /**
  7231. * Interface for cullable objects
  7232. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7233. */
  7234. export interface ICullable {
  7235. /**
  7236. * Checks if the object or part of the object is in the frustum
  7237. * @param frustumPlanes Camera near/planes
  7238. * @returns true if the object is in frustum otherwise false
  7239. */
  7240. isInFrustum(frustumPlanes: Plane[]): boolean;
  7241. /**
  7242. * Checks if a cullable object (mesh...) is in the camera frustum
  7243. * Unlike isInFrustum this cheks the full bounding box
  7244. * @param frustumPlanes Camera near/planes
  7245. * @returns true if the object is in frustum otherwise false
  7246. */
  7247. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7248. }
  7249. /**
  7250. * Info for a bounding data of a mesh
  7251. */
  7252. export class BoundingInfo implements ICullable {
  7253. /**
  7254. * Bounding box for the mesh
  7255. */
  7256. readonly boundingBox: BoundingBox;
  7257. /**
  7258. * Bounding sphere for the mesh
  7259. */
  7260. readonly boundingSphere: BoundingSphere;
  7261. private _isLocked;
  7262. private static readonly TmpVector3;
  7263. /**
  7264. * Constructs bounding info
  7265. * @param minimum min vector of the bounding box/sphere
  7266. * @param maximum max vector of the bounding box/sphere
  7267. * @param worldMatrix defines the new world matrix
  7268. */
  7269. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7270. /**
  7271. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7272. * @param min defines the new minimum vector (in local space)
  7273. * @param max defines the new maximum vector (in local space)
  7274. * @param worldMatrix defines the new world matrix
  7275. */
  7276. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7277. /**
  7278. * min vector of the bounding box/sphere
  7279. */
  7280. get minimum(): Vector3;
  7281. /**
  7282. * max vector of the bounding box/sphere
  7283. */
  7284. get maximum(): Vector3;
  7285. /**
  7286. * If the info is locked and won't be updated to avoid perf overhead
  7287. */
  7288. get isLocked(): boolean;
  7289. set isLocked(value: boolean);
  7290. /**
  7291. * Updates the bounding sphere and box
  7292. * @param world world matrix to be used to update
  7293. */
  7294. update(world: DeepImmutable<Matrix>): void;
  7295. /**
  7296. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7297. * @param center New center of the bounding info
  7298. * @param extend New extend of the bounding info
  7299. * @returns the current bounding info
  7300. */
  7301. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7302. /**
  7303. * Scale the current bounding info by applying a scale factor
  7304. * @param factor defines the scale factor to apply
  7305. * @returns the current bounding info
  7306. */
  7307. scale(factor: number): BoundingInfo;
  7308. /**
  7309. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7310. * @param frustumPlanes defines the frustum to test
  7311. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7312. * @returns true if the bounding info is in the frustum planes
  7313. */
  7314. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7315. /**
  7316. * Gets the world distance between the min and max points of the bounding box
  7317. */
  7318. get diagonalLength(): number;
  7319. /**
  7320. * Checks if a cullable object (mesh...) is in the camera frustum
  7321. * Unlike isInFrustum this cheks the full bounding box
  7322. * @param frustumPlanes Camera near/planes
  7323. * @returns true if the object is in frustum otherwise false
  7324. */
  7325. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /** @hidden */
  7327. _checkCollision(collider: Collider): boolean;
  7328. /**
  7329. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7330. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7331. * @param point the point to check intersection with
  7332. * @returns if the point intersects
  7333. */
  7334. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7335. /**
  7336. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7337. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7338. * @param boundingInfo the bounding info to check intersection with
  7339. * @param precise if the intersection should be done using OBB
  7340. * @returns if the bounding info intersects
  7341. */
  7342. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7343. }
  7344. }
  7345. declare module "babylonjs/Maths/math.functions" {
  7346. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7347. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7348. /**
  7349. * Extracts minimum and maximum values from a list of indexed positions
  7350. * @param positions defines the positions to use
  7351. * @param indices defines the indices to the positions
  7352. * @param indexStart defines the start index
  7353. * @param indexCount defines the end index
  7354. * @param bias defines bias value to add to the result
  7355. * @return minimum and maximum values
  7356. */
  7357. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7358. minimum: Vector3;
  7359. maximum: Vector3;
  7360. };
  7361. /**
  7362. * Extracts minimum and maximum values from a list of positions
  7363. * @param positions defines the positions to use
  7364. * @param start defines the start index in the positions array
  7365. * @param count defines the number of positions to handle
  7366. * @param bias defines bias value to add to the result
  7367. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7368. * @return minimum and maximum values
  7369. */
  7370. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7371. minimum: Vector3;
  7372. maximum: Vector3;
  7373. };
  7374. }
  7375. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7376. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7377. /** @hidden */
  7378. export class WebGLDataBuffer extends DataBuffer {
  7379. private _buffer;
  7380. constructor(resource: WebGLBuffer);
  7381. get underlyingResource(): any;
  7382. }
  7383. }
  7384. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7385. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7386. import { Nullable } from "babylonjs/types";
  7387. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7388. /** @hidden */
  7389. export class WebGLPipelineContext implements IPipelineContext {
  7390. engine: ThinEngine;
  7391. program: Nullable<WebGLProgram>;
  7392. context?: WebGLRenderingContext;
  7393. vertexShader?: WebGLShader;
  7394. fragmentShader?: WebGLShader;
  7395. isParallelCompiled: boolean;
  7396. onCompiled?: () => void;
  7397. transformFeedback?: WebGLTransformFeedback | null;
  7398. vertexCompilationError: Nullable<string>;
  7399. fragmentCompilationError: Nullable<string>;
  7400. programLinkError: Nullable<string>;
  7401. programValidationError: Nullable<string>;
  7402. get isAsync(): boolean;
  7403. get isReady(): boolean;
  7404. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7405. _getVertexShaderCode(): string | null;
  7406. _getFragmentShaderCode(): string | null;
  7407. }
  7408. }
  7409. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7410. import { FloatArray, Nullable } from "babylonjs/types";
  7411. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7412. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7413. module "babylonjs/Engines/thinEngine" {
  7414. interface ThinEngine {
  7415. /**
  7416. * Create an uniform buffer
  7417. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7418. * @param elements defines the content of the uniform buffer
  7419. * @returns the webGL uniform buffer
  7420. */
  7421. createUniformBuffer(elements: FloatArray): DataBuffer;
  7422. /**
  7423. * Create a dynamic uniform buffer
  7424. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7425. * @param elements defines the content of the uniform buffer
  7426. * @returns the webGL uniform buffer
  7427. */
  7428. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7429. /**
  7430. * Update an existing uniform buffer
  7431. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7432. * @param uniformBuffer defines the target uniform buffer
  7433. * @param elements defines the content to update
  7434. * @param offset defines the offset in the uniform buffer where update should start
  7435. * @param count defines the size of the data to update
  7436. */
  7437. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7438. /**
  7439. * Bind an uniform buffer to the current webGL context
  7440. * @param buffer defines the buffer to bind
  7441. */
  7442. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7443. /**
  7444. * Bind a buffer to the current webGL context at a given location
  7445. * @param buffer defines the buffer to bind
  7446. * @param location defines the index where to bind the buffer
  7447. */
  7448. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7449. /**
  7450. * Bind a specific block at a given index in a specific shader program
  7451. * @param pipelineContext defines the pipeline context to use
  7452. * @param blockName defines the block name
  7453. * @param index defines the index where to bind the block
  7454. */
  7455. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7456. }
  7457. }
  7458. }
  7459. declare module "babylonjs/Materials/uniformBuffer" {
  7460. import { Nullable, FloatArray } from "babylonjs/types";
  7461. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7462. import { Engine } from "babylonjs/Engines/engine";
  7463. import { Effect } from "babylonjs/Materials/effect";
  7464. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7465. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7466. import { Color3 } from "babylonjs/Maths/math.color";
  7467. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7468. /**
  7469. * Uniform buffer objects.
  7470. *
  7471. * Handles blocks of uniform on the GPU.
  7472. *
  7473. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7474. *
  7475. * For more information, please refer to :
  7476. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7477. */
  7478. export class UniformBuffer {
  7479. private _engine;
  7480. private _buffer;
  7481. private _data;
  7482. private _bufferData;
  7483. private _dynamic?;
  7484. private _uniformLocations;
  7485. private _uniformSizes;
  7486. private _uniformLocationPointer;
  7487. private _needSync;
  7488. private _noUBO;
  7489. private _currentEffect;
  7490. /** @hidden */
  7491. _alreadyBound: boolean;
  7492. private static _MAX_UNIFORM_SIZE;
  7493. private static _tempBuffer;
  7494. /**
  7495. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7500. /**
  7501. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7506. /**
  7507. * Lambda to Update a single float in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateFloat: (name: string, x: number) => void;
  7512. /**
  7513. * Lambda to Update a vec2 of float in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7518. /**
  7519. * Lambda to Update a vec3 of float in a uniform buffer.
  7520. * This is dynamic to allow compat with webgl 1 and 2.
  7521. * You will need to pass the name of the uniform as well as the value.
  7522. */
  7523. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7524. /**
  7525. * Lambda to Update a vec4 of float in a uniform buffer.
  7526. * This is dynamic to allow compat with webgl 1 and 2.
  7527. * You will need to pass the name of the uniform as well as the value.
  7528. */
  7529. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7530. /**
  7531. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7532. * This is dynamic to allow compat with webgl 1 and 2.
  7533. * You will need to pass the name of the uniform as well as the value.
  7534. */
  7535. updateMatrix: (name: string, mat: Matrix) => void;
  7536. /**
  7537. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7538. * This is dynamic to allow compat with webgl 1 and 2.
  7539. * You will need to pass the name of the uniform as well as the value.
  7540. */
  7541. updateVector3: (name: string, vector: Vector3) => void;
  7542. /**
  7543. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7544. * This is dynamic to allow compat with webgl 1 and 2.
  7545. * You will need to pass the name of the uniform as well as the value.
  7546. */
  7547. updateVector4: (name: string, vector: Vector4) => void;
  7548. /**
  7549. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7550. * This is dynamic to allow compat with webgl 1 and 2.
  7551. * You will need to pass the name of the uniform as well as the value.
  7552. */
  7553. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7554. /**
  7555. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7556. * This is dynamic to allow compat with webgl 1 and 2.
  7557. * You will need to pass the name of the uniform as well as the value.
  7558. */
  7559. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7560. /**
  7561. * Instantiates a new Uniform buffer objects.
  7562. *
  7563. * Handles blocks of uniform on the GPU.
  7564. *
  7565. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7566. *
  7567. * For more information, please refer to :
  7568. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7569. * @param engine Define the engine the buffer is associated with
  7570. * @param data Define the data contained in the buffer
  7571. * @param dynamic Define if the buffer is updatable
  7572. */
  7573. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7574. /**
  7575. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7576. * or just falling back on setUniformXXX calls.
  7577. */
  7578. get useUbo(): boolean;
  7579. /**
  7580. * Indicates if the WebGL underlying uniform buffer is in sync
  7581. * with the javascript cache data.
  7582. */
  7583. get isSync(): boolean;
  7584. /**
  7585. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7586. * Also, a dynamic UniformBuffer will disable cache verification and always
  7587. * update the underlying WebGL uniform buffer to the GPU.
  7588. * @returns if Dynamic, otherwise false
  7589. */
  7590. isDynamic(): boolean;
  7591. /**
  7592. * The data cache on JS side.
  7593. * @returns the underlying data as a float array
  7594. */
  7595. getData(): Float32Array;
  7596. /**
  7597. * The underlying WebGL Uniform buffer.
  7598. * @returns the webgl buffer
  7599. */
  7600. getBuffer(): Nullable<DataBuffer>;
  7601. /**
  7602. * std140 layout specifies how to align data within an UBO structure.
  7603. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7604. * for specs.
  7605. */
  7606. private _fillAlignment;
  7607. /**
  7608. * Adds an uniform in the buffer.
  7609. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7610. * for the layout to be correct !
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. * @param size Data size, or data directly.
  7613. */
  7614. addUniform(name: string, size: number | number[]): void;
  7615. /**
  7616. * Adds a Matrix 4x4 to the uniform buffer.
  7617. * @param name Name of the uniform, as used in the uniform block in the shader.
  7618. * @param mat A 4x4 matrix.
  7619. */
  7620. addMatrix(name: string, mat: Matrix): void;
  7621. /**
  7622. * Adds a vec2 to the uniform buffer.
  7623. * @param name Name of the uniform, as used in the uniform block in the shader.
  7624. * @param x Define the x component value of the vec2
  7625. * @param y Define the y component value of the vec2
  7626. */
  7627. addFloat2(name: string, x: number, y: number): void;
  7628. /**
  7629. * Adds a vec3 to the uniform buffer.
  7630. * @param name Name of the uniform, as used in the uniform block in the shader.
  7631. * @param x Define the x component value of the vec3
  7632. * @param y Define the y component value of the vec3
  7633. * @param z Define the z component value of the vec3
  7634. */
  7635. addFloat3(name: string, x: number, y: number, z: number): void;
  7636. /**
  7637. * Adds a vec3 to the uniform buffer.
  7638. * @param name Name of the uniform, as used in the uniform block in the shader.
  7639. * @param color Define the vec3 from a Color
  7640. */
  7641. addColor3(name: string, color: Color3): void;
  7642. /**
  7643. * Adds a vec4 to the uniform buffer.
  7644. * @param name Name of the uniform, as used in the uniform block in the shader.
  7645. * @param color Define the rgb components from a Color
  7646. * @param alpha Define the a component of the vec4
  7647. */
  7648. addColor4(name: string, color: Color3, alpha: number): void;
  7649. /**
  7650. * Adds a vec3 to the uniform buffer.
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param vector Define the vec3 components from a Vector
  7653. */
  7654. addVector3(name: string, vector: Vector3): void;
  7655. /**
  7656. * Adds a Matrix 3x3 to the uniform buffer.
  7657. * @param name Name of the uniform, as used in the uniform block in the shader.
  7658. */
  7659. addMatrix3x3(name: string): void;
  7660. /**
  7661. * Adds a Matrix 2x2 to the uniform buffer.
  7662. * @param name Name of the uniform, as used in the uniform block in the shader.
  7663. */
  7664. addMatrix2x2(name: string): void;
  7665. /**
  7666. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7667. */
  7668. create(): void;
  7669. /** @hidden */
  7670. _rebuild(): void;
  7671. /**
  7672. * Updates the WebGL Uniform Buffer on the GPU.
  7673. * If the `dynamic` flag is set to true, no cache comparison is done.
  7674. * Otherwise, the buffer will be updated only if the cache differs.
  7675. */
  7676. update(): void;
  7677. /**
  7678. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7679. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7680. * @param data Define the flattened data
  7681. * @param size Define the size of the data.
  7682. */
  7683. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7684. private _valueCache;
  7685. private _cacheMatrix;
  7686. private _updateMatrix3x3ForUniform;
  7687. private _updateMatrix3x3ForEffect;
  7688. private _updateMatrix2x2ForEffect;
  7689. private _updateMatrix2x2ForUniform;
  7690. private _updateFloatForEffect;
  7691. private _updateFloatForUniform;
  7692. private _updateFloat2ForEffect;
  7693. private _updateFloat2ForUniform;
  7694. private _updateFloat3ForEffect;
  7695. private _updateFloat3ForUniform;
  7696. private _updateFloat4ForEffect;
  7697. private _updateFloat4ForUniform;
  7698. private _updateMatrixForEffect;
  7699. private _updateMatrixForUniform;
  7700. private _updateVector3ForEffect;
  7701. private _updateVector3ForUniform;
  7702. private _updateVector4ForEffect;
  7703. private _updateVector4ForUniform;
  7704. private _updateColor3ForEffect;
  7705. private _updateColor3ForUniform;
  7706. private _updateColor4ForEffect;
  7707. private _updateColor4ForUniform;
  7708. /**
  7709. * Sets a sampler uniform on the effect.
  7710. * @param name Define the name of the sampler.
  7711. * @param texture Define the texture to set in the sampler
  7712. */
  7713. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7714. /**
  7715. * Directly updates the value of the uniform in the cache AND on the GPU.
  7716. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7717. * @param data Define the flattened data
  7718. */
  7719. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7720. /**
  7721. * Binds this uniform buffer to an effect.
  7722. * @param effect Define the effect to bind the buffer to
  7723. * @param name Name of the uniform block in the shader.
  7724. */
  7725. bindToEffect(effect: Effect, name: string): void;
  7726. /**
  7727. * Disposes the uniform buffer.
  7728. */
  7729. dispose(): void;
  7730. }
  7731. }
  7732. declare module "babylonjs/Misc/iInspectable" {
  7733. /**
  7734. * Enum that determines the text-wrapping mode to use.
  7735. */
  7736. export enum InspectableType {
  7737. /**
  7738. * Checkbox for booleans
  7739. */
  7740. Checkbox = 0,
  7741. /**
  7742. * Sliders for numbers
  7743. */
  7744. Slider = 1,
  7745. /**
  7746. * Vector3
  7747. */
  7748. Vector3 = 2,
  7749. /**
  7750. * Quaternions
  7751. */
  7752. Quaternion = 3,
  7753. /**
  7754. * Color3
  7755. */
  7756. Color3 = 4,
  7757. /**
  7758. * String
  7759. */
  7760. String = 5
  7761. }
  7762. /**
  7763. * Interface used to define custom inspectable properties.
  7764. * This interface is used by the inspector to display custom property grids
  7765. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7766. */
  7767. export interface IInspectable {
  7768. /**
  7769. * Gets the label to display
  7770. */
  7771. label: string;
  7772. /**
  7773. * Gets the name of the property to edit
  7774. */
  7775. propertyName: string;
  7776. /**
  7777. * Gets the type of the editor to use
  7778. */
  7779. type: InspectableType;
  7780. /**
  7781. * Gets the minimum value of the property when using in "slider" mode
  7782. */
  7783. min?: number;
  7784. /**
  7785. * Gets the maximum value of the property when using in "slider" mode
  7786. */
  7787. max?: number;
  7788. /**
  7789. * Gets the setp to use when using in "slider" mode
  7790. */
  7791. step?: number;
  7792. }
  7793. }
  7794. declare module "babylonjs/Misc/timingTools" {
  7795. /**
  7796. * Class used to provide helper for timing
  7797. */
  7798. export class TimingTools {
  7799. /**
  7800. * Polyfill for setImmediate
  7801. * @param action defines the action to execute after the current execution block
  7802. */
  7803. static SetImmediate(action: () => void): void;
  7804. }
  7805. }
  7806. declare module "babylonjs/Misc/instantiationTools" {
  7807. /**
  7808. * Class used to enable instatition of objects by class name
  7809. */
  7810. export class InstantiationTools {
  7811. /**
  7812. * Use this object to register external classes like custom textures or material
  7813. * to allow the laoders to instantiate them
  7814. */
  7815. static RegisteredExternalClasses: {
  7816. [key: string]: Object;
  7817. };
  7818. /**
  7819. * Tries to instantiate a new object from a given class name
  7820. * @param className defines the class name to instantiate
  7821. * @returns the new object or null if the system was not able to do the instantiation
  7822. */
  7823. static Instantiate(className: string): any;
  7824. }
  7825. }
  7826. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7827. /**
  7828. * Define options used to create a depth texture
  7829. */
  7830. export class DepthTextureCreationOptions {
  7831. /** Specifies whether or not a stencil should be allocated in the texture */
  7832. generateStencil?: boolean;
  7833. /** Specifies whether or not bilinear filtering is enable on the texture */
  7834. bilinearFiltering?: boolean;
  7835. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7836. comparisonFunction?: number;
  7837. /** Specifies if the created texture is a cube texture */
  7838. isCube?: boolean;
  7839. }
  7840. }
  7841. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7843. import { Nullable } from "babylonjs/types";
  7844. import { Scene } from "babylonjs/scene";
  7845. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7846. module "babylonjs/Engines/thinEngine" {
  7847. interface ThinEngine {
  7848. /**
  7849. * Creates a depth stencil cube texture.
  7850. * This is only available in WebGL 2.
  7851. * @param size The size of face edge in the cube texture.
  7852. * @param options The options defining the cube texture.
  7853. * @returns The cube texture
  7854. */
  7855. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7856. /**
  7857. * Creates a cube texture
  7858. * @param rootUrl defines the url where the files to load is located
  7859. * @param scene defines the current scene
  7860. * @param files defines the list of files to load (1 per face)
  7861. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7862. * @param onLoad defines an optional callback raised when the texture is loaded
  7863. * @param onError defines an optional callback raised if there is an issue to load the texture
  7864. * @param format defines the format of the data
  7865. * @param forcedExtension defines the extension to use to pick the right loader
  7866. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7867. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7868. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7869. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7870. * @returns the cube texture as an InternalTexture
  7871. */
  7872. 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;
  7873. /**
  7874. * Creates a cube texture
  7875. * @param rootUrl defines the url where the files to load is located
  7876. * @param scene defines the current scene
  7877. * @param files defines the list of files to load (1 per face)
  7878. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7879. * @param onLoad defines an optional callback raised when the texture is loaded
  7880. * @param onError defines an optional callback raised if there is an issue to load the texture
  7881. * @param format defines the format of the data
  7882. * @param forcedExtension defines the extension to use to pick the right loader
  7883. * @returns the cube texture as an InternalTexture
  7884. */
  7885. 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;
  7886. /**
  7887. * Creates a cube texture
  7888. * @param rootUrl defines the url where the files to load is located
  7889. * @param scene defines the current scene
  7890. * @param files defines the list of files to load (1 per face)
  7891. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7892. * @param onLoad defines an optional callback raised when the texture is loaded
  7893. * @param onError defines an optional callback raised if there is an issue to load the texture
  7894. * @param format defines the format of the data
  7895. * @param forcedExtension defines the extension to use to pick the right loader
  7896. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7897. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7898. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7899. * @returns the cube texture as an InternalTexture
  7900. */
  7901. 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;
  7902. /** @hidden */
  7903. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7904. /** @hidden */
  7905. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7906. /** @hidden */
  7907. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7908. /** @hidden */
  7909. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7910. /**
  7911. * @hidden
  7912. */
  7913. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7914. }
  7915. }
  7916. }
  7917. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7918. import { Nullable } from "babylonjs/types";
  7919. import { Scene } from "babylonjs/scene";
  7920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7922. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7923. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7924. import { Observable } from "babylonjs/Misc/observable";
  7925. /**
  7926. * Class for creating a cube texture
  7927. */
  7928. export class CubeTexture extends BaseTexture {
  7929. private _delayedOnLoad;
  7930. /**
  7931. * Observable triggered once the texture has been loaded.
  7932. */
  7933. onLoadObservable: Observable<CubeTexture>;
  7934. /**
  7935. * The url of the texture
  7936. */
  7937. url: string;
  7938. /**
  7939. * Gets or sets the center of the bounding box associated with the cube texture.
  7940. * It must define where the camera used to render the texture was set
  7941. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7942. */
  7943. boundingBoxPosition: Vector3;
  7944. private _boundingBoxSize;
  7945. /**
  7946. * Gets or sets the size of the bounding box associated with the cube texture
  7947. * When defined, the cubemap will switch to local mode
  7948. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7949. * @example https://www.babylonjs-playground.com/#RNASML
  7950. */
  7951. set boundingBoxSize(value: Vector3);
  7952. /**
  7953. * Returns the bounding box size
  7954. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7955. */
  7956. get boundingBoxSize(): Vector3;
  7957. protected _rotationY: number;
  7958. /**
  7959. * Sets texture matrix rotation angle around Y axis in radians.
  7960. */
  7961. set rotationY(value: number);
  7962. /**
  7963. * Gets texture matrix rotation angle around Y axis radians.
  7964. */
  7965. get rotationY(): number;
  7966. /**
  7967. * Are mip maps generated for this texture or not.
  7968. */
  7969. get noMipmap(): boolean;
  7970. private _noMipmap;
  7971. private _files;
  7972. protected _forcedExtension: Nullable<string>;
  7973. private _extensions;
  7974. private _textureMatrix;
  7975. private _format;
  7976. private _createPolynomials;
  7977. /**
  7978. * Creates a cube texture from an array of image urls
  7979. * @param files defines an array of image urls
  7980. * @param scene defines the hosting scene
  7981. * @param noMipmap specifies if mip maps are not used
  7982. * @returns a cube texture
  7983. */
  7984. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7985. /**
  7986. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7987. * @param url defines the url of the prefiltered texture
  7988. * @param scene defines the scene the texture is attached to
  7989. * @param forcedExtension defines the extension of the file if different from the url
  7990. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7991. * @return the prefiltered texture
  7992. */
  7993. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7994. /**
  7995. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7996. * as prefiltered data.
  7997. * @param rootUrl defines the url of the texture or the root name of the six images
  7998. * @param null defines the scene or engine the texture is attached to
  7999. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8000. * @param noMipmap defines if mipmaps should be created or not
  8001. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8002. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8003. * @param onError defines a callback triggered in case of error during load
  8004. * @param format defines the internal format to use for the texture once loaded
  8005. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8006. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8007. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8008. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8009. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8010. * @return the cube texture
  8011. */
  8012. 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);
  8013. /**
  8014. * Get the current class name of the texture useful for serialization or dynamic coding.
  8015. * @returns "CubeTexture"
  8016. */
  8017. getClassName(): string;
  8018. /**
  8019. * Update the url (and optional buffer) of this texture if url was null during construction.
  8020. * @param url the url of the texture
  8021. * @param forcedExtension defines the extension to use
  8022. * @param onLoad callback called when the texture is loaded (defaults to null)
  8023. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8024. */
  8025. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8026. /**
  8027. * Delays loading of the cube texture
  8028. * @param forcedExtension defines the extension to use
  8029. */
  8030. delayLoad(forcedExtension?: string): void;
  8031. /**
  8032. * Returns the reflection texture matrix
  8033. * @returns the reflection texture matrix
  8034. */
  8035. getReflectionTextureMatrix(): Matrix;
  8036. /**
  8037. * Sets the reflection texture matrix
  8038. * @param value Reflection texture matrix
  8039. */
  8040. setReflectionTextureMatrix(value: Matrix): void;
  8041. /**
  8042. * Parses text to create a cube texture
  8043. * @param parsedTexture define the serialized text to read from
  8044. * @param scene defines the hosting scene
  8045. * @param rootUrl defines the root url of the cube texture
  8046. * @returns a cube texture
  8047. */
  8048. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8049. /**
  8050. * Makes a clone, or deep copy, of the cube texture
  8051. * @returns a new cube texture
  8052. */
  8053. clone(): CubeTexture;
  8054. }
  8055. }
  8056. declare module "babylonjs/Materials/materialDefines" {
  8057. /**
  8058. * Manages the defines for the Material
  8059. */
  8060. export class MaterialDefines {
  8061. /** @hidden */
  8062. protected _keys: string[];
  8063. private _isDirty;
  8064. /** @hidden */
  8065. _renderId: number;
  8066. /** @hidden */
  8067. _areLightsDirty: boolean;
  8068. /** @hidden */
  8069. _areLightsDisposed: boolean;
  8070. /** @hidden */
  8071. _areAttributesDirty: boolean;
  8072. /** @hidden */
  8073. _areTexturesDirty: boolean;
  8074. /** @hidden */
  8075. _areFresnelDirty: boolean;
  8076. /** @hidden */
  8077. _areMiscDirty: boolean;
  8078. /** @hidden */
  8079. _areImageProcessingDirty: boolean;
  8080. /** @hidden */
  8081. _normals: boolean;
  8082. /** @hidden */
  8083. _uvs: boolean;
  8084. /** @hidden */
  8085. _needNormals: boolean;
  8086. /** @hidden */
  8087. _needUVs: boolean;
  8088. [id: string]: any;
  8089. /**
  8090. * Specifies if the material needs to be re-calculated
  8091. */
  8092. get isDirty(): boolean;
  8093. /**
  8094. * Marks the material to indicate that it has been re-calculated
  8095. */
  8096. markAsProcessed(): void;
  8097. /**
  8098. * Marks the material to indicate that it needs to be re-calculated
  8099. */
  8100. markAsUnprocessed(): void;
  8101. /**
  8102. * Marks the material to indicate all of its defines need to be re-calculated
  8103. */
  8104. markAllAsDirty(): void;
  8105. /**
  8106. * Marks the material to indicate that image processing needs to be re-calculated
  8107. */
  8108. markAsImageProcessingDirty(): void;
  8109. /**
  8110. * Marks the material to indicate the lights need to be re-calculated
  8111. * @param disposed Defines whether the light is dirty due to dispose or not
  8112. */
  8113. markAsLightDirty(disposed?: boolean): void;
  8114. /**
  8115. * Marks the attribute state as changed
  8116. */
  8117. markAsAttributesDirty(): void;
  8118. /**
  8119. * Marks the texture state as changed
  8120. */
  8121. markAsTexturesDirty(): void;
  8122. /**
  8123. * Marks the fresnel state as changed
  8124. */
  8125. markAsFresnelDirty(): void;
  8126. /**
  8127. * Marks the misc state as changed
  8128. */
  8129. markAsMiscDirty(): void;
  8130. /**
  8131. * Rebuilds the material defines
  8132. */
  8133. rebuild(): void;
  8134. /**
  8135. * Specifies if two material defines are equal
  8136. * @param other - A material define instance to compare to
  8137. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8138. */
  8139. isEqual(other: MaterialDefines): boolean;
  8140. /**
  8141. * Clones this instance's defines to another instance
  8142. * @param other - material defines to clone values to
  8143. */
  8144. cloneTo(other: MaterialDefines): void;
  8145. /**
  8146. * Resets the material define values
  8147. */
  8148. reset(): void;
  8149. /**
  8150. * Converts the material define values to a string
  8151. * @returns - String of material define information
  8152. */
  8153. toString(): string;
  8154. }
  8155. }
  8156. declare module "babylonjs/Materials/colorCurves" {
  8157. import { Effect } from "babylonjs/Materials/effect";
  8158. /**
  8159. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8160. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8161. * 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;
  8162. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8163. */
  8164. export class ColorCurves {
  8165. private _dirty;
  8166. private _tempColor;
  8167. private _globalCurve;
  8168. private _highlightsCurve;
  8169. private _midtonesCurve;
  8170. private _shadowsCurve;
  8171. private _positiveCurve;
  8172. private _negativeCurve;
  8173. private _globalHue;
  8174. private _globalDensity;
  8175. private _globalSaturation;
  8176. private _globalExposure;
  8177. /**
  8178. * Gets the global Hue value.
  8179. * 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).
  8180. */
  8181. get globalHue(): number;
  8182. /**
  8183. * Sets the global Hue value.
  8184. * 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).
  8185. */
  8186. set globalHue(value: number);
  8187. /**
  8188. * Gets the global Density value.
  8189. * 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.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get globalDensity(): number;
  8193. /**
  8194. * Sets the global Density value.
  8195. * 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.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set globalDensity(value: number);
  8199. /**
  8200. * Gets the global Saturation value.
  8201. * 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.
  8202. */
  8203. get globalSaturation(): number;
  8204. /**
  8205. * Sets the global Saturation value.
  8206. * 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.
  8207. */
  8208. set globalSaturation(value: number);
  8209. /**
  8210. * Gets the global Exposure value.
  8211. * 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.
  8212. */
  8213. get globalExposure(): number;
  8214. /**
  8215. * Sets the global Exposure value.
  8216. * 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.
  8217. */
  8218. set globalExposure(value: number);
  8219. private _highlightsHue;
  8220. private _highlightsDensity;
  8221. private _highlightsSaturation;
  8222. private _highlightsExposure;
  8223. /**
  8224. * Gets the highlights Hue value.
  8225. * 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).
  8226. */
  8227. get highlightsHue(): number;
  8228. /**
  8229. * Sets the highlights Hue value.
  8230. * 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).
  8231. */
  8232. set highlightsHue(value: number);
  8233. /**
  8234. * Gets the highlights Density value.
  8235. * 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.
  8236. * Values less than zero provide a filter of opposite hue.
  8237. */
  8238. get highlightsDensity(): number;
  8239. /**
  8240. * Sets the highlights Density value.
  8241. * 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.
  8242. * Values less than zero provide a filter of opposite hue.
  8243. */
  8244. set highlightsDensity(value: number);
  8245. /**
  8246. * Gets the highlights Saturation value.
  8247. * 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.
  8248. */
  8249. get highlightsSaturation(): number;
  8250. /**
  8251. * Sets the highlights Saturation value.
  8252. * 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.
  8253. */
  8254. set highlightsSaturation(value: number);
  8255. /**
  8256. * Gets the highlights Exposure value.
  8257. * 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.
  8258. */
  8259. get highlightsExposure(): number;
  8260. /**
  8261. * Sets the highlights Exposure value.
  8262. * 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.
  8263. */
  8264. set highlightsExposure(value: number);
  8265. private _midtonesHue;
  8266. private _midtonesDensity;
  8267. private _midtonesSaturation;
  8268. private _midtonesExposure;
  8269. /**
  8270. * Gets the midtones Hue value.
  8271. * 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).
  8272. */
  8273. get midtonesHue(): number;
  8274. /**
  8275. * Sets the midtones Hue value.
  8276. * 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).
  8277. */
  8278. set midtonesHue(value: number);
  8279. /**
  8280. * Gets the midtones Density value.
  8281. * 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.
  8282. * Values less than zero provide a filter of opposite hue.
  8283. */
  8284. get midtonesDensity(): number;
  8285. /**
  8286. * Sets the midtones Density value.
  8287. * 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.
  8288. * Values less than zero provide a filter of opposite hue.
  8289. */
  8290. set midtonesDensity(value: number);
  8291. /**
  8292. * Gets the midtones Saturation value.
  8293. * 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.
  8294. */
  8295. get midtonesSaturation(): number;
  8296. /**
  8297. * Sets the midtones Saturation value.
  8298. * 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.
  8299. */
  8300. set midtonesSaturation(value: number);
  8301. /**
  8302. * Gets the midtones Exposure value.
  8303. * 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.
  8304. */
  8305. get midtonesExposure(): number;
  8306. /**
  8307. * Sets the midtones Exposure value.
  8308. * 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.
  8309. */
  8310. set midtonesExposure(value: number);
  8311. private _shadowsHue;
  8312. private _shadowsDensity;
  8313. private _shadowsSaturation;
  8314. private _shadowsExposure;
  8315. /**
  8316. * Gets the shadows Hue value.
  8317. * 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).
  8318. */
  8319. get shadowsHue(): number;
  8320. /**
  8321. * Sets the shadows Hue value.
  8322. * 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).
  8323. */
  8324. set shadowsHue(value: number);
  8325. /**
  8326. * Gets the shadows Density value.
  8327. * 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.
  8328. * Values less than zero provide a filter of opposite hue.
  8329. */
  8330. get shadowsDensity(): number;
  8331. /**
  8332. * Sets the shadows Density value.
  8333. * 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.
  8334. * Values less than zero provide a filter of opposite hue.
  8335. */
  8336. set shadowsDensity(value: number);
  8337. /**
  8338. * Gets the shadows Saturation value.
  8339. * 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.
  8340. */
  8341. get shadowsSaturation(): number;
  8342. /**
  8343. * Sets the shadows Saturation value.
  8344. * 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.
  8345. */
  8346. set shadowsSaturation(value: number);
  8347. /**
  8348. * Gets the shadows Exposure value.
  8349. * 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.
  8350. */
  8351. get shadowsExposure(): number;
  8352. /**
  8353. * Sets the shadows Exposure value.
  8354. * 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.
  8355. */
  8356. set shadowsExposure(value: number);
  8357. /**
  8358. * Returns the class name
  8359. * @returns The class name
  8360. */
  8361. getClassName(): string;
  8362. /**
  8363. * Binds the color curves to the shader.
  8364. * @param colorCurves The color curve to bind
  8365. * @param effect The effect to bind to
  8366. * @param positiveUniform The positive uniform shader parameter
  8367. * @param neutralUniform The neutral uniform shader parameter
  8368. * @param negativeUniform The negative uniform shader parameter
  8369. */
  8370. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8371. /**
  8372. * Prepare the list of uniforms associated with the ColorCurves effects.
  8373. * @param uniformsList The list of uniforms used in the effect
  8374. */
  8375. static PrepareUniforms(uniformsList: string[]): void;
  8376. /**
  8377. * Returns color grading data based on a hue, density, saturation and exposure value.
  8378. * @param filterHue The hue of the color filter.
  8379. * @param filterDensity The density of the color filter.
  8380. * @param saturation The saturation.
  8381. * @param exposure The exposure.
  8382. * @param result The result data container.
  8383. */
  8384. private getColorGradingDataToRef;
  8385. /**
  8386. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8387. * @param value The input slider value in range [-100,100].
  8388. * @returns Adjusted value.
  8389. */
  8390. private static applyColorGradingSliderNonlinear;
  8391. /**
  8392. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8393. * @param hue The hue (H) input.
  8394. * @param saturation The saturation (S) input.
  8395. * @param brightness The brightness (B) input.
  8396. * @result An RGBA color represented as Vector4.
  8397. */
  8398. private static fromHSBToRef;
  8399. /**
  8400. * Returns a value clamped between min and max
  8401. * @param value The value to clamp
  8402. * @param min The minimum of value
  8403. * @param max The maximum of value
  8404. * @returns The clamped value.
  8405. */
  8406. private static clamp;
  8407. /**
  8408. * Clones the current color curve instance.
  8409. * @return The cloned curves
  8410. */
  8411. clone(): ColorCurves;
  8412. /**
  8413. * Serializes the current color curve instance to a json representation.
  8414. * @return a JSON representation
  8415. */
  8416. serialize(): any;
  8417. /**
  8418. * Parses the color curve from a json representation.
  8419. * @param source the JSON source to parse
  8420. * @return The parsed curves
  8421. */
  8422. static Parse(source: any): ColorCurves;
  8423. }
  8424. }
  8425. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8426. import { Observable } from "babylonjs/Misc/observable";
  8427. import { Nullable } from "babylonjs/types";
  8428. import { Color4 } from "babylonjs/Maths/math.color";
  8429. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8430. import { Effect } from "babylonjs/Materials/effect";
  8431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8432. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8433. /**
  8434. * Interface to follow in your material defines to integrate easily the
  8435. * Image proccessing functions.
  8436. * @hidden
  8437. */
  8438. export interface IImageProcessingConfigurationDefines {
  8439. IMAGEPROCESSING: boolean;
  8440. VIGNETTE: boolean;
  8441. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8442. VIGNETTEBLENDMODEOPAQUE: boolean;
  8443. TONEMAPPING: boolean;
  8444. TONEMAPPING_ACES: boolean;
  8445. CONTRAST: boolean;
  8446. EXPOSURE: boolean;
  8447. COLORCURVES: boolean;
  8448. COLORGRADING: boolean;
  8449. COLORGRADING3D: boolean;
  8450. SAMPLER3DGREENDEPTH: boolean;
  8451. SAMPLER3DBGRMAP: boolean;
  8452. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8453. }
  8454. /**
  8455. * @hidden
  8456. */
  8457. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8458. IMAGEPROCESSING: boolean;
  8459. VIGNETTE: boolean;
  8460. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8461. VIGNETTEBLENDMODEOPAQUE: boolean;
  8462. TONEMAPPING: boolean;
  8463. TONEMAPPING_ACES: boolean;
  8464. CONTRAST: boolean;
  8465. COLORCURVES: boolean;
  8466. COLORGRADING: boolean;
  8467. COLORGRADING3D: boolean;
  8468. SAMPLER3DGREENDEPTH: boolean;
  8469. SAMPLER3DBGRMAP: boolean;
  8470. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8471. EXPOSURE: boolean;
  8472. constructor();
  8473. }
  8474. /**
  8475. * This groups together the common properties used for image processing either in direct forward pass
  8476. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8477. * or not.
  8478. */
  8479. export class ImageProcessingConfiguration {
  8480. /**
  8481. * Default tone mapping applied in BabylonJS.
  8482. */
  8483. static readonly TONEMAPPING_STANDARD: number;
  8484. /**
  8485. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8486. * to other engines rendering to increase portability.
  8487. */
  8488. static readonly TONEMAPPING_ACES: number;
  8489. /**
  8490. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8491. */
  8492. colorCurves: Nullable<ColorCurves>;
  8493. private _colorCurvesEnabled;
  8494. /**
  8495. * Gets wether the color curves effect is enabled.
  8496. */
  8497. get colorCurvesEnabled(): boolean;
  8498. /**
  8499. * Sets wether the color curves effect is enabled.
  8500. */
  8501. set colorCurvesEnabled(value: boolean);
  8502. private _colorGradingTexture;
  8503. /**
  8504. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8505. */
  8506. get colorGradingTexture(): Nullable<BaseTexture>;
  8507. /**
  8508. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8509. */
  8510. set colorGradingTexture(value: Nullable<BaseTexture>);
  8511. private _colorGradingEnabled;
  8512. /**
  8513. * Gets wether the color grading effect is enabled.
  8514. */
  8515. get colorGradingEnabled(): boolean;
  8516. /**
  8517. * Sets wether the color grading effect is enabled.
  8518. */
  8519. set colorGradingEnabled(value: boolean);
  8520. private _colorGradingWithGreenDepth;
  8521. /**
  8522. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8523. */
  8524. get colorGradingWithGreenDepth(): boolean;
  8525. /**
  8526. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8527. */
  8528. set colorGradingWithGreenDepth(value: boolean);
  8529. private _colorGradingBGR;
  8530. /**
  8531. * Gets wether the color grading texture contains BGR values.
  8532. */
  8533. get colorGradingBGR(): boolean;
  8534. /**
  8535. * Sets wether the color grading texture contains BGR values.
  8536. */
  8537. set colorGradingBGR(value: boolean);
  8538. /** @hidden */
  8539. _exposure: number;
  8540. /**
  8541. * Gets the Exposure used in the effect.
  8542. */
  8543. get exposure(): number;
  8544. /**
  8545. * Sets the Exposure used in the effect.
  8546. */
  8547. set exposure(value: number);
  8548. private _toneMappingEnabled;
  8549. /**
  8550. * Gets wether the tone mapping effect is enabled.
  8551. */
  8552. get toneMappingEnabled(): boolean;
  8553. /**
  8554. * Sets wether the tone mapping effect is enabled.
  8555. */
  8556. set toneMappingEnabled(value: boolean);
  8557. private _toneMappingType;
  8558. /**
  8559. * Gets the type of tone mapping effect.
  8560. */
  8561. get toneMappingType(): number;
  8562. /**
  8563. * Sets the type of tone mapping effect used in BabylonJS.
  8564. */
  8565. set toneMappingType(value: number);
  8566. protected _contrast: number;
  8567. /**
  8568. * Gets the contrast used in the effect.
  8569. */
  8570. get contrast(): number;
  8571. /**
  8572. * Sets the contrast used in the effect.
  8573. */
  8574. set contrast(value: number);
  8575. /**
  8576. * Vignette stretch size.
  8577. */
  8578. vignetteStretch: number;
  8579. /**
  8580. * Vignette centre X Offset.
  8581. */
  8582. vignetteCentreX: number;
  8583. /**
  8584. * Vignette centre Y Offset.
  8585. */
  8586. vignetteCentreY: number;
  8587. /**
  8588. * Vignette weight or intensity of the vignette effect.
  8589. */
  8590. vignetteWeight: number;
  8591. /**
  8592. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8593. * if vignetteEnabled is set to true.
  8594. */
  8595. vignetteColor: Color4;
  8596. /**
  8597. * Camera field of view used by the Vignette effect.
  8598. */
  8599. vignetteCameraFov: number;
  8600. private _vignetteBlendMode;
  8601. /**
  8602. * Gets the vignette blend mode allowing different kind of effect.
  8603. */
  8604. get vignetteBlendMode(): number;
  8605. /**
  8606. * Sets the vignette blend mode allowing different kind of effect.
  8607. */
  8608. set vignetteBlendMode(value: number);
  8609. private _vignetteEnabled;
  8610. /**
  8611. * Gets wether the vignette effect is enabled.
  8612. */
  8613. get vignetteEnabled(): boolean;
  8614. /**
  8615. * Sets wether the vignette effect is enabled.
  8616. */
  8617. set vignetteEnabled(value: boolean);
  8618. private _applyByPostProcess;
  8619. /**
  8620. * Gets wether the image processing is applied through a post process or not.
  8621. */
  8622. get applyByPostProcess(): boolean;
  8623. /**
  8624. * Sets wether the image processing is applied through a post process or not.
  8625. */
  8626. set applyByPostProcess(value: boolean);
  8627. private _isEnabled;
  8628. /**
  8629. * Gets wether the image processing is enabled or not.
  8630. */
  8631. get isEnabled(): boolean;
  8632. /**
  8633. * Sets wether the image processing is enabled or not.
  8634. */
  8635. set isEnabled(value: boolean);
  8636. /**
  8637. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8638. */
  8639. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8640. /**
  8641. * Method called each time the image processing information changes requires to recompile the effect.
  8642. */
  8643. protected _updateParameters(): void;
  8644. /**
  8645. * Gets the current class name.
  8646. * @return "ImageProcessingConfiguration"
  8647. */
  8648. getClassName(): string;
  8649. /**
  8650. * Prepare the list of uniforms associated with the Image Processing effects.
  8651. * @param uniforms The list of uniforms used in the effect
  8652. * @param defines the list of defines currently in use
  8653. */
  8654. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8655. /**
  8656. * Prepare the list of samplers associated with the Image Processing effects.
  8657. * @param samplersList The list of uniforms used in the effect
  8658. * @param defines the list of defines currently in use
  8659. */
  8660. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8661. /**
  8662. * Prepare the list of defines associated to the shader.
  8663. * @param defines the list of defines to complete
  8664. * @param forPostProcess Define if we are currently in post process mode or not
  8665. */
  8666. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8667. /**
  8668. * Returns true if all the image processing information are ready.
  8669. * @returns True if ready, otherwise, false
  8670. */
  8671. isReady(): boolean;
  8672. /**
  8673. * Binds the image processing to the shader.
  8674. * @param effect The effect to bind to
  8675. * @param overrideAspectRatio Override the aspect ratio of the effect
  8676. */
  8677. bind(effect: Effect, overrideAspectRatio?: number): void;
  8678. /**
  8679. * Clones the current image processing instance.
  8680. * @return The cloned image processing
  8681. */
  8682. clone(): ImageProcessingConfiguration;
  8683. /**
  8684. * Serializes the current image processing instance to a json representation.
  8685. * @return a JSON representation
  8686. */
  8687. serialize(): any;
  8688. /**
  8689. * Parses the image processing from a json representation.
  8690. * @param source the JSON source to parse
  8691. * @return The parsed image processing
  8692. */
  8693. static Parse(source: any): ImageProcessingConfiguration;
  8694. private static _VIGNETTEMODE_MULTIPLY;
  8695. private static _VIGNETTEMODE_OPAQUE;
  8696. /**
  8697. * Used to apply the vignette as a mix with the pixel color.
  8698. */
  8699. static get VIGNETTEMODE_MULTIPLY(): number;
  8700. /**
  8701. * Used to apply the vignette as a replacement of the pixel color.
  8702. */
  8703. static get VIGNETTEMODE_OPAQUE(): number;
  8704. }
  8705. }
  8706. declare module "babylonjs/Shaders/postprocess.vertex" {
  8707. /** @hidden */
  8708. export var postprocessVertexShader: {
  8709. name: string;
  8710. shader: string;
  8711. };
  8712. }
  8713. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8714. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8715. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8716. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8717. /**
  8718. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8719. */
  8720. export type RenderTargetTextureSize = number | {
  8721. width: number;
  8722. height: number;
  8723. layers?: number;
  8724. };
  8725. module "babylonjs/Engines/thinEngine" {
  8726. interface ThinEngine {
  8727. /**
  8728. * Creates a new render target texture
  8729. * @param size defines the size of the texture
  8730. * @param options defines the options used to create the texture
  8731. * @returns a new render target texture stored in an InternalTexture
  8732. */
  8733. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8734. /**
  8735. * Creates a depth stencil texture.
  8736. * This is only available in WebGL 2 or with the depth texture extension available.
  8737. * @param size The size of face edge in the texture.
  8738. * @param options The options defining the texture.
  8739. * @returns The texture
  8740. */
  8741. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8742. /** @hidden */
  8743. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8744. }
  8745. }
  8746. }
  8747. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8748. /**
  8749. * Defines the kind of connection point for node based material
  8750. */
  8751. export enum NodeMaterialBlockConnectionPointTypes {
  8752. /** Float */
  8753. Float = 1,
  8754. /** Int */
  8755. Int = 2,
  8756. /** Vector2 */
  8757. Vector2 = 4,
  8758. /** Vector3 */
  8759. Vector3 = 8,
  8760. /** Vector4 */
  8761. Vector4 = 16,
  8762. /** Color3 */
  8763. Color3 = 32,
  8764. /** Color4 */
  8765. Color4 = 64,
  8766. /** Matrix */
  8767. Matrix = 128,
  8768. /** Custom object */
  8769. Object = 256,
  8770. /** Detect type based on connection */
  8771. AutoDetect = 1024,
  8772. /** Output type that will be defined by input type */
  8773. BasedOnInput = 2048
  8774. }
  8775. }
  8776. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8777. /**
  8778. * Enum used to define the target of a block
  8779. */
  8780. export enum NodeMaterialBlockTargets {
  8781. /** Vertex shader */
  8782. Vertex = 1,
  8783. /** Fragment shader */
  8784. Fragment = 2,
  8785. /** Neutral */
  8786. Neutral = 4,
  8787. /** Vertex and Fragment */
  8788. VertexAndFragment = 3
  8789. }
  8790. }
  8791. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8792. /**
  8793. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8794. */
  8795. export enum NodeMaterialBlockConnectionPointMode {
  8796. /** Value is an uniform */
  8797. Uniform = 0,
  8798. /** Value is a mesh attribute */
  8799. Attribute = 1,
  8800. /** Value is a varying between vertex and fragment shaders */
  8801. Varying = 2,
  8802. /** Mode is undefined */
  8803. Undefined = 3
  8804. }
  8805. }
  8806. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8807. /**
  8808. * Enum used to define system values e.g. values automatically provided by the system
  8809. */
  8810. export enum NodeMaterialSystemValues {
  8811. /** World */
  8812. World = 1,
  8813. /** View */
  8814. View = 2,
  8815. /** Projection */
  8816. Projection = 3,
  8817. /** ViewProjection */
  8818. ViewProjection = 4,
  8819. /** WorldView */
  8820. WorldView = 5,
  8821. /** WorldViewProjection */
  8822. WorldViewProjection = 6,
  8823. /** CameraPosition */
  8824. CameraPosition = 7,
  8825. /** Fog Color */
  8826. FogColor = 8,
  8827. /** Delta time */
  8828. DeltaTime = 9
  8829. }
  8830. }
  8831. declare module "babylonjs/Maths/math.axis" {
  8832. import { Vector3 } from "babylonjs/Maths/math.vector";
  8833. /** Defines supported spaces */
  8834. export enum Space {
  8835. /** Local (object) space */
  8836. LOCAL = 0,
  8837. /** World space */
  8838. WORLD = 1,
  8839. /** Bone space */
  8840. BONE = 2
  8841. }
  8842. /** Defines the 3 main axes */
  8843. export class Axis {
  8844. /** X axis */
  8845. static X: Vector3;
  8846. /** Y axis */
  8847. static Y: Vector3;
  8848. /** Z axis */
  8849. static Z: Vector3;
  8850. }
  8851. }
  8852. declare module "babylonjs/Maths/math.frustum" {
  8853. import { Matrix } from "babylonjs/Maths/math.vector";
  8854. import { DeepImmutable } from "babylonjs/types";
  8855. import { Plane } from "babylonjs/Maths/math.plane";
  8856. /**
  8857. * Represents a camera frustum
  8858. */
  8859. export class Frustum {
  8860. /**
  8861. * Gets the planes representing the frustum
  8862. * @param transform matrix to be applied to the returned planes
  8863. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8864. */
  8865. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8866. /**
  8867. * Gets the near frustum plane transformed by the transform matrix
  8868. * @param transform transformation matrix to be applied to the resulting frustum plane
  8869. * @param frustumPlane the resuling frustum plane
  8870. */
  8871. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8872. /**
  8873. * Gets the far frustum plane transformed by the transform matrix
  8874. * @param transform transformation matrix to be applied to the resulting frustum plane
  8875. * @param frustumPlane the resuling frustum plane
  8876. */
  8877. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8878. /**
  8879. * Gets the left frustum plane transformed by the transform matrix
  8880. * @param transform transformation matrix to be applied to the resulting frustum plane
  8881. * @param frustumPlane the resuling frustum plane
  8882. */
  8883. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8884. /**
  8885. * Gets the right frustum plane transformed by the transform matrix
  8886. * @param transform transformation matrix to be applied to the resulting frustum plane
  8887. * @param frustumPlane the resuling frustum plane
  8888. */
  8889. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8890. /**
  8891. * Gets the top frustum plane transformed by the transform matrix
  8892. * @param transform transformation matrix to be applied to the resulting frustum plane
  8893. * @param frustumPlane the resuling frustum plane
  8894. */
  8895. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8896. /**
  8897. * Gets the bottom frustum plane transformed by the transform matrix
  8898. * @param transform transformation matrix to be applied to the resulting frustum plane
  8899. * @param frustumPlane the resuling frustum plane
  8900. */
  8901. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8902. /**
  8903. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8904. * @param transform transformation matrix to be applied to the resulting frustum planes
  8905. * @param frustumPlanes the resuling frustum planes
  8906. */
  8907. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8908. }
  8909. }
  8910. declare module "babylonjs/Maths/math.size" {
  8911. /**
  8912. * Interface for the size containing width and height
  8913. */
  8914. export interface ISize {
  8915. /**
  8916. * Width
  8917. */
  8918. width: number;
  8919. /**
  8920. * Heighht
  8921. */
  8922. height: number;
  8923. }
  8924. /**
  8925. * Size containing widht and height
  8926. */
  8927. export class Size implements ISize {
  8928. /**
  8929. * Width
  8930. */
  8931. width: number;
  8932. /**
  8933. * Height
  8934. */
  8935. height: number;
  8936. /**
  8937. * Creates a Size object from the given width and height (floats).
  8938. * @param width width of the new size
  8939. * @param height height of the new size
  8940. */
  8941. constructor(width: number, height: number);
  8942. /**
  8943. * Returns a string with the Size width and height
  8944. * @returns a string with the Size width and height
  8945. */
  8946. toString(): string;
  8947. /**
  8948. * "Size"
  8949. * @returns the string "Size"
  8950. */
  8951. getClassName(): string;
  8952. /**
  8953. * Returns the Size hash code.
  8954. * @returns a hash code for a unique width and height
  8955. */
  8956. getHashCode(): number;
  8957. /**
  8958. * Updates the current size from the given one.
  8959. * @param src the given size
  8960. */
  8961. copyFrom(src: Size): void;
  8962. /**
  8963. * Updates in place the current Size from the given floats.
  8964. * @param width width of the new size
  8965. * @param height height of the new size
  8966. * @returns the updated Size.
  8967. */
  8968. copyFromFloats(width: number, height: number): Size;
  8969. /**
  8970. * Updates in place the current Size from the given floats.
  8971. * @param width width to set
  8972. * @param height height to set
  8973. * @returns the updated Size.
  8974. */
  8975. set(width: number, height: number): Size;
  8976. /**
  8977. * Multiplies the width and height by numbers
  8978. * @param w factor to multiple the width by
  8979. * @param h factor to multiple the height by
  8980. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8981. */
  8982. multiplyByFloats(w: number, h: number): Size;
  8983. /**
  8984. * Clones the size
  8985. * @returns a new Size copied from the given one.
  8986. */
  8987. clone(): Size;
  8988. /**
  8989. * True if the current Size and the given one width and height are strictly equal.
  8990. * @param other the other size to compare against
  8991. * @returns True if the current Size and the given one width and height are strictly equal.
  8992. */
  8993. equals(other: Size): boolean;
  8994. /**
  8995. * The surface of the Size : width * height (float).
  8996. */
  8997. get surface(): number;
  8998. /**
  8999. * Create a new size of zero
  9000. * @returns a new Size set to (0.0, 0.0)
  9001. */
  9002. static Zero(): Size;
  9003. /**
  9004. * Sums the width and height of two sizes
  9005. * @param otherSize size to add to this size
  9006. * @returns a new Size set as the addition result of the current Size and the given one.
  9007. */
  9008. add(otherSize: Size): Size;
  9009. /**
  9010. * Subtracts the width and height of two
  9011. * @param otherSize size to subtract to this size
  9012. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9013. */
  9014. subtract(otherSize: Size): Size;
  9015. /**
  9016. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9017. * @param start starting size to lerp between
  9018. * @param end end size to lerp between
  9019. * @param amount amount to lerp between the start and end values
  9020. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9021. */
  9022. static Lerp(start: Size, end: Size, amount: number): Size;
  9023. }
  9024. }
  9025. declare module "babylonjs/Maths/math.vertexFormat" {
  9026. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9027. /**
  9028. * Contains position and normal vectors for a vertex
  9029. */
  9030. export class PositionNormalVertex {
  9031. /** the position of the vertex (defaut: 0,0,0) */
  9032. position: Vector3;
  9033. /** the normal of the vertex (defaut: 0,1,0) */
  9034. normal: Vector3;
  9035. /**
  9036. * Creates a PositionNormalVertex
  9037. * @param position the position of the vertex (defaut: 0,0,0)
  9038. * @param normal the normal of the vertex (defaut: 0,1,0)
  9039. */
  9040. constructor(
  9041. /** the position of the vertex (defaut: 0,0,0) */
  9042. position?: Vector3,
  9043. /** the normal of the vertex (defaut: 0,1,0) */
  9044. normal?: Vector3);
  9045. /**
  9046. * Clones the PositionNormalVertex
  9047. * @returns the cloned PositionNormalVertex
  9048. */
  9049. clone(): PositionNormalVertex;
  9050. }
  9051. /**
  9052. * Contains position, normal and uv vectors for a vertex
  9053. */
  9054. export class PositionNormalTextureVertex {
  9055. /** the position of the vertex (defaut: 0,0,0) */
  9056. position: Vector3;
  9057. /** the normal of the vertex (defaut: 0,1,0) */
  9058. normal: Vector3;
  9059. /** the uv of the vertex (default: 0,0) */
  9060. uv: Vector2;
  9061. /**
  9062. * Creates a PositionNormalTextureVertex
  9063. * @param position the position of the vertex (defaut: 0,0,0)
  9064. * @param normal the normal of the vertex (defaut: 0,1,0)
  9065. * @param uv the uv of the vertex (default: 0,0)
  9066. */
  9067. constructor(
  9068. /** the position of the vertex (defaut: 0,0,0) */
  9069. position?: Vector3,
  9070. /** the normal of the vertex (defaut: 0,1,0) */
  9071. normal?: Vector3,
  9072. /** the uv of the vertex (default: 0,0) */
  9073. uv?: Vector2);
  9074. /**
  9075. * Clones the PositionNormalTextureVertex
  9076. * @returns the cloned PositionNormalTextureVertex
  9077. */
  9078. clone(): PositionNormalTextureVertex;
  9079. }
  9080. }
  9081. declare module "babylonjs/Maths/math" {
  9082. export * from "babylonjs/Maths/math.axis";
  9083. export * from "babylonjs/Maths/math.color";
  9084. export * from "babylonjs/Maths/math.constants";
  9085. export * from "babylonjs/Maths/math.frustum";
  9086. export * from "babylonjs/Maths/math.path";
  9087. export * from "babylonjs/Maths/math.plane";
  9088. export * from "babylonjs/Maths/math.size";
  9089. export * from "babylonjs/Maths/math.vector";
  9090. export * from "babylonjs/Maths/math.vertexFormat";
  9091. export * from "babylonjs/Maths/math.viewport";
  9092. }
  9093. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9094. /**
  9095. * Enum defining the type of animations supported by InputBlock
  9096. */
  9097. export enum AnimatedInputBlockTypes {
  9098. /** No animation */
  9099. None = 0,
  9100. /** Time based animation. Will only work for floats */
  9101. Time = 1
  9102. }
  9103. }
  9104. declare module "babylonjs/Lights/shadowLight" {
  9105. import { Camera } from "babylonjs/Cameras/camera";
  9106. import { Scene } from "babylonjs/scene";
  9107. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9109. import { Light } from "babylonjs/Lights/light";
  9110. /**
  9111. * Interface describing all the common properties and methods a shadow light needs to implement.
  9112. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9113. * as well as binding the different shadow properties to the effects.
  9114. */
  9115. export interface IShadowLight extends Light {
  9116. /**
  9117. * The light id in the scene (used in scene.findLighById for instance)
  9118. */
  9119. id: string;
  9120. /**
  9121. * The position the shdow will be casted from.
  9122. */
  9123. position: Vector3;
  9124. /**
  9125. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9126. */
  9127. direction: Vector3;
  9128. /**
  9129. * The transformed position. Position of the light in world space taking parenting in account.
  9130. */
  9131. transformedPosition: Vector3;
  9132. /**
  9133. * The transformed direction. Direction of the light in world space taking parenting in account.
  9134. */
  9135. transformedDirection: Vector3;
  9136. /**
  9137. * The friendly name of the light in the scene.
  9138. */
  9139. name: string;
  9140. /**
  9141. * Defines the shadow projection clipping minimum z value.
  9142. */
  9143. shadowMinZ: number;
  9144. /**
  9145. * Defines the shadow projection clipping maximum z value.
  9146. */
  9147. shadowMaxZ: number;
  9148. /**
  9149. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9150. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9151. */
  9152. computeTransformedInformation(): boolean;
  9153. /**
  9154. * Gets the scene the light belongs to.
  9155. * @returns The scene
  9156. */
  9157. getScene(): Scene;
  9158. /**
  9159. * Callback defining a custom Projection Matrix Builder.
  9160. * This can be used to override the default projection matrix computation.
  9161. */
  9162. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9163. /**
  9164. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9165. * @param matrix The materix to updated with the projection information
  9166. * @param viewMatrix The transform matrix of the light
  9167. * @param renderList The list of mesh to render in the map
  9168. * @returns The current light
  9169. */
  9170. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9171. /**
  9172. * Gets the current depth scale used in ESM.
  9173. * @returns The scale
  9174. */
  9175. getDepthScale(): number;
  9176. /**
  9177. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9178. * @returns true if a cube texture needs to be use
  9179. */
  9180. needCube(): boolean;
  9181. /**
  9182. * Detects if the projection matrix requires to be recomputed this frame.
  9183. * @returns true if it requires to be recomputed otherwise, false.
  9184. */
  9185. needProjectionMatrixCompute(): boolean;
  9186. /**
  9187. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9188. */
  9189. forceProjectionMatrixCompute(): void;
  9190. /**
  9191. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9192. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9193. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9194. */
  9195. getShadowDirection(faceIndex?: number): Vector3;
  9196. /**
  9197. * Gets the minZ used for shadow according to both the scene and the light.
  9198. * @param activeCamera The camera we are returning the min for
  9199. * @returns the depth min z
  9200. */
  9201. getDepthMinZ(activeCamera: Camera): number;
  9202. /**
  9203. * Gets the maxZ used for shadow according to both the scene and the light.
  9204. * @param activeCamera The camera we are returning the max for
  9205. * @returns the depth max z
  9206. */
  9207. getDepthMaxZ(activeCamera: Camera): number;
  9208. }
  9209. /**
  9210. * Base implementation IShadowLight
  9211. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9212. */
  9213. export abstract class ShadowLight extends Light implements IShadowLight {
  9214. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9215. protected _position: Vector3;
  9216. protected _setPosition(value: Vector3): void;
  9217. /**
  9218. * Sets the position the shadow will be casted from. Also use as the light position for both
  9219. * point and spot lights.
  9220. */
  9221. get position(): Vector3;
  9222. /**
  9223. * Sets the position the shadow will be casted from. Also use as the light position for both
  9224. * point and spot lights.
  9225. */
  9226. set position(value: Vector3);
  9227. protected _direction: Vector3;
  9228. protected _setDirection(value: Vector3): void;
  9229. /**
  9230. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9231. * Also use as the light direction on spot and directional lights.
  9232. */
  9233. get direction(): Vector3;
  9234. /**
  9235. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9236. * Also use as the light direction on spot and directional lights.
  9237. */
  9238. set direction(value: Vector3);
  9239. protected _shadowMinZ: number;
  9240. /**
  9241. * Gets the shadow projection clipping minimum z value.
  9242. */
  9243. get shadowMinZ(): number;
  9244. /**
  9245. * Sets the shadow projection clipping minimum z value.
  9246. */
  9247. set shadowMinZ(value: number);
  9248. protected _shadowMaxZ: number;
  9249. /**
  9250. * Sets the shadow projection clipping maximum z value.
  9251. */
  9252. get shadowMaxZ(): number;
  9253. /**
  9254. * Gets the shadow projection clipping maximum z value.
  9255. */
  9256. set shadowMaxZ(value: number);
  9257. /**
  9258. * Callback defining a custom Projection Matrix Builder.
  9259. * This can be used to override the default projection matrix computation.
  9260. */
  9261. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9262. /**
  9263. * The transformed position. Position of the light in world space taking parenting in account.
  9264. */
  9265. transformedPosition: Vector3;
  9266. /**
  9267. * The transformed direction. Direction of the light in world space taking parenting in account.
  9268. */
  9269. transformedDirection: Vector3;
  9270. private _needProjectionMatrixCompute;
  9271. /**
  9272. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9273. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9274. */
  9275. computeTransformedInformation(): boolean;
  9276. /**
  9277. * Return the depth scale used for the shadow map.
  9278. * @returns the depth scale.
  9279. */
  9280. getDepthScale(): number;
  9281. /**
  9282. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9283. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9284. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9285. */
  9286. getShadowDirection(faceIndex?: number): Vector3;
  9287. /**
  9288. * Returns the ShadowLight absolute position in the World.
  9289. * @returns the position vector in world space
  9290. */
  9291. getAbsolutePosition(): Vector3;
  9292. /**
  9293. * Sets the ShadowLight direction toward the passed target.
  9294. * @param target The point to target in local space
  9295. * @returns the updated ShadowLight direction
  9296. */
  9297. setDirectionToTarget(target: Vector3): Vector3;
  9298. /**
  9299. * Returns the light rotation in euler definition.
  9300. * @returns the x y z rotation in local space.
  9301. */
  9302. getRotation(): Vector3;
  9303. /**
  9304. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9305. * @returns true if a cube texture needs to be use
  9306. */
  9307. needCube(): boolean;
  9308. /**
  9309. * Detects if the projection matrix requires to be recomputed this frame.
  9310. * @returns true if it requires to be recomputed otherwise, false.
  9311. */
  9312. needProjectionMatrixCompute(): boolean;
  9313. /**
  9314. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9315. */
  9316. forceProjectionMatrixCompute(): void;
  9317. /** @hidden */
  9318. _initCache(): void;
  9319. /** @hidden */
  9320. _isSynchronized(): boolean;
  9321. /**
  9322. * Computes the world matrix of the node
  9323. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9324. * @returns the world matrix
  9325. */
  9326. computeWorldMatrix(force?: boolean): Matrix;
  9327. /**
  9328. * Gets the minZ used for shadow according to both the scene and the light.
  9329. * @param activeCamera The camera we are returning the min for
  9330. * @returns the depth min z
  9331. */
  9332. getDepthMinZ(activeCamera: Camera): number;
  9333. /**
  9334. * Gets the maxZ used for shadow according to both the scene and the light.
  9335. * @param activeCamera The camera we are returning the max for
  9336. * @returns the depth max z
  9337. */
  9338. getDepthMaxZ(activeCamera: Camera): number;
  9339. /**
  9340. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9341. * @param matrix The materix to updated with the projection information
  9342. * @param viewMatrix The transform matrix of the light
  9343. * @param renderList The list of mesh to render in the map
  9344. * @returns The current light
  9345. */
  9346. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9347. }
  9348. }
  9349. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9350. /** @hidden */
  9351. export var packingFunctions: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9357. /** @hidden */
  9358. export var bayerDitherFunctions: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9364. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9365. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9366. /** @hidden */
  9367. export var shadowMapFragmentDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9373. /** @hidden */
  9374. export var clipPlaneFragmentDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9380. /** @hidden */
  9381. export var clipPlaneFragment: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9387. /** @hidden */
  9388. export var shadowMapFragment: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9394. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9395. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9396. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9397. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9398. /** @hidden */
  9399. export var shadowMapPixelShader: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9405. /** @hidden */
  9406. export var bonesDeclaration: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9412. /** @hidden */
  9413. export var morphTargetsVertexGlobalDeclaration: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9419. /** @hidden */
  9420. export var morphTargetsVertexDeclaration: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9426. /** @hidden */
  9427. export var instancesDeclaration: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9433. /** @hidden */
  9434. export var helperFunctions: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9440. /** @hidden */
  9441. export var shadowMapVertexDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9447. /** @hidden */
  9448. export var clipPlaneVertexDeclaration: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9454. /** @hidden */
  9455. export var morphTargetsVertex: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9461. /** @hidden */
  9462. export var instancesVertex: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9468. /** @hidden */
  9469. export var bonesVertex: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9475. /** @hidden */
  9476. export var shadowMapVertexNormalBias: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9482. /** @hidden */
  9483. export var shadowMapVertexMetric: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9489. /** @hidden */
  9490. export var clipPlaneVertex: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9496. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9497. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9498. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9499. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9500. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9501. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9502. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9504. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9505. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9506. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9507. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9508. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9509. /** @hidden */
  9510. export var shadowMapVertexShader: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9516. /** @hidden */
  9517. export var depthBoxBlurPixelShader: {
  9518. name: string;
  9519. shader: string;
  9520. };
  9521. }
  9522. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9523. /** @hidden */
  9524. export var shadowMapFragmentSoftTransparentShadow: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Materials/effectFallbacks" {
  9530. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9531. import { Effect } from "babylonjs/Materials/effect";
  9532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9533. /**
  9534. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9535. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9536. */
  9537. export class EffectFallbacks implements IEffectFallbacks {
  9538. private _defines;
  9539. private _currentRank;
  9540. private _maxRank;
  9541. private _mesh;
  9542. /**
  9543. * Removes the fallback from the bound mesh.
  9544. */
  9545. unBindMesh(): void;
  9546. /**
  9547. * Adds a fallback on the specified property.
  9548. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9549. * @param define The name of the define in the shader
  9550. */
  9551. addFallback(rank: number, define: string): void;
  9552. /**
  9553. * Sets the mesh to use CPU skinning when needing to fallback.
  9554. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9555. * @param mesh The mesh to use the fallbacks.
  9556. */
  9557. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9558. /**
  9559. * Checks to see if more fallbacks are still availible.
  9560. */
  9561. get hasMoreFallbacks(): boolean;
  9562. /**
  9563. * Removes the defines that should be removed when falling back.
  9564. * @param currentDefines defines the current define statements for the shader.
  9565. * @param effect defines the current effect we try to compile
  9566. * @returns The resulting defines with defines of the current rank removed.
  9567. */
  9568. reduce(currentDefines: string, effect: Effect): string;
  9569. }
  9570. }
  9571. declare module "babylonjs/Actions/action" {
  9572. import { Observable } from "babylonjs/Misc/observable";
  9573. import { Condition } from "babylonjs/Actions/condition";
  9574. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9575. import { Nullable } from "babylonjs/types";
  9576. import { Scene } from "babylonjs/scene";
  9577. import { ActionManager } from "babylonjs/Actions/actionManager";
  9578. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9579. import { Node } from "babylonjs/node";
  9580. /**
  9581. * Interface used to define Action
  9582. */
  9583. export interface IAction {
  9584. /**
  9585. * Trigger for the action
  9586. */
  9587. trigger: number;
  9588. /** Options of the trigger */
  9589. triggerOptions: any;
  9590. /**
  9591. * Gets the trigger parameters
  9592. * @returns the trigger parameters
  9593. */
  9594. getTriggerParameter(): any;
  9595. /**
  9596. * Internal only - executes current action event
  9597. * @hidden
  9598. */
  9599. _executeCurrent(evt?: ActionEvent): void;
  9600. /**
  9601. * Serialize placeholder for child classes
  9602. * @param parent of child
  9603. * @returns the serialized object
  9604. */
  9605. serialize(parent: any): any;
  9606. /**
  9607. * Internal only
  9608. * @hidden
  9609. */
  9610. _prepare(): void;
  9611. /**
  9612. * Internal only - manager for action
  9613. * @hidden
  9614. */
  9615. _actionManager: Nullable<AbstractActionManager>;
  9616. /**
  9617. * Adds action to chain of actions, may be a DoNothingAction
  9618. * @param action defines the next action to execute
  9619. * @returns The action passed in
  9620. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9621. */
  9622. then(action: IAction): IAction;
  9623. }
  9624. /**
  9625. * The action to be carried out following a trigger
  9626. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9627. */
  9628. export class Action implements IAction {
  9629. /** the trigger, with or without parameters, for the action */
  9630. triggerOptions: any;
  9631. /**
  9632. * Trigger for the action
  9633. */
  9634. trigger: number;
  9635. /**
  9636. * Internal only - manager for action
  9637. * @hidden
  9638. */
  9639. _actionManager: ActionManager;
  9640. private _nextActiveAction;
  9641. private _child;
  9642. private _condition?;
  9643. private _triggerParameter;
  9644. /**
  9645. * An event triggered prior to action being executed.
  9646. */
  9647. onBeforeExecuteObservable: Observable<Action>;
  9648. /**
  9649. * Creates a new Action
  9650. * @param triggerOptions the trigger, with or without parameters, for the action
  9651. * @param condition an optional determinant of action
  9652. */
  9653. constructor(
  9654. /** the trigger, with or without parameters, for the action */
  9655. triggerOptions: any, condition?: Condition);
  9656. /**
  9657. * Internal only
  9658. * @hidden
  9659. */
  9660. _prepare(): void;
  9661. /**
  9662. * Gets the trigger parameters
  9663. * @returns the trigger parameters
  9664. */
  9665. getTriggerParameter(): any;
  9666. /**
  9667. * Internal only - executes current action event
  9668. * @hidden
  9669. */
  9670. _executeCurrent(evt?: ActionEvent): void;
  9671. /**
  9672. * Execute placeholder for child classes
  9673. * @param evt optional action event
  9674. */
  9675. execute(evt?: ActionEvent): void;
  9676. /**
  9677. * Skips to next active action
  9678. */
  9679. skipToNextActiveAction(): void;
  9680. /**
  9681. * Adds action to chain of actions, may be a DoNothingAction
  9682. * @param action defines the next action to execute
  9683. * @returns The action passed in
  9684. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9685. */
  9686. then(action: Action): Action;
  9687. /**
  9688. * Internal only
  9689. * @hidden
  9690. */
  9691. _getProperty(propertyPath: string): string;
  9692. /**
  9693. * Internal only
  9694. * @hidden
  9695. */
  9696. _getEffectiveTarget(target: any, propertyPath: string): any;
  9697. /**
  9698. * Serialize placeholder for child classes
  9699. * @param parent of child
  9700. * @returns the serialized object
  9701. */
  9702. serialize(parent: any): any;
  9703. /**
  9704. * Internal only called by serialize
  9705. * @hidden
  9706. */
  9707. protected _serialize(serializedAction: any, parent?: any): any;
  9708. /**
  9709. * Internal only
  9710. * @hidden
  9711. */
  9712. static _SerializeValueAsString: (value: any) => string;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. static _GetTargetProperty: (target: Scene | Node) => {
  9718. name: string;
  9719. targetType: string;
  9720. value: string;
  9721. };
  9722. }
  9723. }
  9724. declare module "babylonjs/Actions/condition" {
  9725. import { ActionManager } from "babylonjs/Actions/actionManager";
  9726. /**
  9727. * A Condition applied to an Action
  9728. */
  9729. export class Condition {
  9730. /**
  9731. * Internal only - manager for action
  9732. * @hidden
  9733. */
  9734. _actionManager: ActionManager;
  9735. /**
  9736. * Internal only
  9737. * @hidden
  9738. */
  9739. _evaluationId: number;
  9740. /**
  9741. * Internal only
  9742. * @hidden
  9743. */
  9744. _currentResult: boolean;
  9745. /**
  9746. * Creates a new Condition
  9747. * @param actionManager the manager of the action the condition is applied to
  9748. */
  9749. constructor(actionManager: ActionManager);
  9750. /**
  9751. * Check if the current condition is valid
  9752. * @returns a boolean
  9753. */
  9754. isValid(): boolean;
  9755. /**
  9756. * Internal only
  9757. * @hidden
  9758. */
  9759. _getProperty(propertyPath: string): string;
  9760. /**
  9761. * Internal only
  9762. * @hidden
  9763. */
  9764. _getEffectiveTarget(target: any, propertyPath: string): any;
  9765. /**
  9766. * Serialize placeholder for child classes
  9767. * @returns the serialized object
  9768. */
  9769. serialize(): any;
  9770. /**
  9771. * Internal only
  9772. * @hidden
  9773. */
  9774. protected _serialize(serializedCondition: any): any;
  9775. }
  9776. /**
  9777. * Defines specific conditional operators as extensions of Condition
  9778. */
  9779. export class ValueCondition extends Condition {
  9780. /** path to specify the property of the target the conditional operator uses */
  9781. propertyPath: string;
  9782. /** the value compared by the conditional operator against the current value of the property */
  9783. value: any;
  9784. /** the conditional operator, default ValueCondition.IsEqual */
  9785. operator: number;
  9786. /**
  9787. * Internal only
  9788. * @hidden
  9789. */
  9790. private static _IsEqual;
  9791. /**
  9792. * Internal only
  9793. * @hidden
  9794. */
  9795. private static _IsDifferent;
  9796. /**
  9797. * Internal only
  9798. * @hidden
  9799. */
  9800. private static _IsGreater;
  9801. /**
  9802. * Internal only
  9803. * @hidden
  9804. */
  9805. private static _IsLesser;
  9806. /**
  9807. * returns the number for IsEqual
  9808. */
  9809. static get IsEqual(): number;
  9810. /**
  9811. * Returns the number for IsDifferent
  9812. */
  9813. static get IsDifferent(): number;
  9814. /**
  9815. * Returns the number for IsGreater
  9816. */
  9817. static get IsGreater(): number;
  9818. /**
  9819. * Returns the number for IsLesser
  9820. */
  9821. static get IsLesser(): number;
  9822. /**
  9823. * Internal only The action manager for the condition
  9824. * @hidden
  9825. */
  9826. _actionManager: ActionManager;
  9827. /**
  9828. * Internal only
  9829. * @hidden
  9830. */
  9831. private _target;
  9832. /**
  9833. * Internal only
  9834. * @hidden
  9835. */
  9836. private _effectiveTarget;
  9837. /**
  9838. * Internal only
  9839. * @hidden
  9840. */
  9841. private _property;
  9842. /**
  9843. * Creates a new ValueCondition
  9844. * @param actionManager manager for the action the condition applies to
  9845. * @param target for the action
  9846. * @param propertyPath path to specify the property of the target the conditional operator uses
  9847. * @param value the value compared by the conditional operator against the current value of the property
  9848. * @param operator the conditional operator, default ValueCondition.IsEqual
  9849. */
  9850. constructor(actionManager: ActionManager, target: any,
  9851. /** path to specify the property of the target the conditional operator uses */
  9852. propertyPath: string,
  9853. /** the value compared by the conditional operator against the current value of the property */
  9854. value: any,
  9855. /** the conditional operator, default ValueCondition.IsEqual */
  9856. operator?: number);
  9857. /**
  9858. * Compares the given value with the property value for the specified conditional operator
  9859. * @returns the result of the comparison
  9860. */
  9861. isValid(): boolean;
  9862. /**
  9863. * Serialize the ValueCondition into a JSON compatible object
  9864. * @returns serialization object
  9865. */
  9866. serialize(): any;
  9867. /**
  9868. * Gets the name of the conditional operator for the ValueCondition
  9869. * @param operator the conditional operator
  9870. * @returns the name
  9871. */
  9872. static GetOperatorName(operator: number): string;
  9873. }
  9874. /**
  9875. * Defines a predicate condition as an extension of Condition
  9876. */
  9877. export class PredicateCondition extends Condition {
  9878. /** defines the predicate function used to validate the condition */
  9879. predicate: () => boolean;
  9880. /**
  9881. * Internal only - manager for action
  9882. * @hidden
  9883. */
  9884. _actionManager: ActionManager;
  9885. /**
  9886. * Creates a new PredicateCondition
  9887. * @param actionManager manager for the action the condition applies to
  9888. * @param predicate defines the predicate function used to validate the condition
  9889. */
  9890. constructor(actionManager: ActionManager,
  9891. /** defines the predicate function used to validate the condition */
  9892. predicate: () => boolean);
  9893. /**
  9894. * @returns the validity of the predicate condition
  9895. */
  9896. isValid(): boolean;
  9897. }
  9898. /**
  9899. * Defines a state condition as an extension of Condition
  9900. */
  9901. export class StateCondition extends Condition {
  9902. /** Value to compare with target state */
  9903. value: string;
  9904. /**
  9905. * Internal only - manager for action
  9906. * @hidden
  9907. */
  9908. _actionManager: ActionManager;
  9909. /**
  9910. * Internal only
  9911. * @hidden
  9912. */
  9913. private _target;
  9914. /**
  9915. * Creates a new StateCondition
  9916. * @param actionManager manager for the action the condition applies to
  9917. * @param target of the condition
  9918. * @param value to compare with target state
  9919. */
  9920. constructor(actionManager: ActionManager, target: any,
  9921. /** Value to compare with target state */
  9922. value: string);
  9923. /**
  9924. * Gets a boolean indicating if the current condition is met
  9925. * @returns the validity of the state
  9926. */
  9927. isValid(): boolean;
  9928. /**
  9929. * Serialize the StateCondition into a JSON compatible object
  9930. * @returns serialization object
  9931. */
  9932. serialize(): any;
  9933. }
  9934. }
  9935. declare module "babylonjs/Actions/directActions" {
  9936. import { Action } from "babylonjs/Actions/action";
  9937. import { Condition } from "babylonjs/Actions/condition";
  9938. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9939. /**
  9940. * This defines an action responsible to toggle a boolean once triggered.
  9941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9942. */
  9943. export class SwitchBooleanAction extends Action {
  9944. /**
  9945. * The path to the boolean property in the target object
  9946. */
  9947. propertyPath: string;
  9948. private _target;
  9949. private _effectiveTarget;
  9950. private _property;
  9951. /**
  9952. * Instantiate the action
  9953. * @param triggerOptions defines the trigger options
  9954. * @param target defines the object containing the boolean
  9955. * @param propertyPath defines the path to the boolean property in the target object
  9956. * @param condition defines the trigger related conditions
  9957. */
  9958. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9959. /** @hidden */
  9960. _prepare(): void;
  9961. /**
  9962. * Execute the action toggle the boolean value.
  9963. */
  9964. execute(): void;
  9965. /**
  9966. * Serializes the actions and its related information.
  9967. * @param parent defines the object to serialize in
  9968. * @returns the serialized object
  9969. */
  9970. serialize(parent: any): any;
  9971. }
  9972. /**
  9973. * This defines an action responsible to set a the state field of the target
  9974. * to a desired value once triggered.
  9975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9976. */
  9977. export class SetStateAction extends Action {
  9978. /**
  9979. * The value to store in the state field.
  9980. */
  9981. value: string;
  9982. private _target;
  9983. /**
  9984. * Instantiate the action
  9985. * @param triggerOptions defines the trigger options
  9986. * @param target defines the object containing the state property
  9987. * @param value defines the value to store in the state field
  9988. * @param condition defines the trigger related conditions
  9989. */
  9990. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9991. /**
  9992. * Execute the action and store the value on the target state property.
  9993. */
  9994. execute(): void;
  9995. /**
  9996. * Serializes the actions and its related information.
  9997. * @param parent defines the object to serialize in
  9998. * @returns the serialized object
  9999. */
  10000. serialize(parent: any): any;
  10001. }
  10002. /**
  10003. * This defines an action responsible to set a property of the target
  10004. * to a desired value once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class SetValueAction extends Action {
  10008. /**
  10009. * The path of the property to set in the target.
  10010. */
  10011. propertyPath: string;
  10012. /**
  10013. * The value to set in the property
  10014. */
  10015. value: any;
  10016. private _target;
  10017. private _effectiveTarget;
  10018. private _property;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the object containing the property
  10023. * @param propertyPath defines the path of the property to set in the target
  10024. * @param value defines the value to set in the property
  10025. * @param condition defines the trigger related conditions
  10026. */
  10027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10028. /** @hidden */
  10029. _prepare(): void;
  10030. /**
  10031. * Execute the action and set the targetted property to the desired value.
  10032. */
  10033. execute(): void;
  10034. /**
  10035. * Serializes the actions and its related information.
  10036. * @param parent defines the object to serialize in
  10037. * @returns the serialized object
  10038. */
  10039. serialize(parent: any): any;
  10040. }
  10041. /**
  10042. * This defines an action responsible to increment the target value
  10043. * to a desired value once triggered.
  10044. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10045. */
  10046. export class IncrementValueAction extends Action {
  10047. /**
  10048. * The path of the property to increment in the target.
  10049. */
  10050. propertyPath: string;
  10051. /**
  10052. * The value we should increment the property by.
  10053. */
  10054. value: any;
  10055. private _target;
  10056. private _effectiveTarget;
  10057. private _property;
  10058. /**
  10059. * Instantiate the action
  10060. * @param triggerOptions defines the trigger options
  10061. * @param target defines the object containing the property
  10062. * @param propertyPath defines the path of the property to increment in the target
  10063. * @param value defines the value value we should increment the property by
  10064. * @param condition defines the trigger related conditions
  10065. */
  10066. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10067. /** @hidden */
  10068. _prepare(): void;
  10069. /**
  10070. * Execute the action and increment the target of the value amount.
  10071. */
  10072. execute(): void;
  10073. /**
  10074. * Serializes the actions and its related information.
  10075. * @param parent defines the object to serialize in
  10076. * @returns the serialized object
  10077. */
  10078. serialize(parent: any): any;
  10079. }
  10080. /**
  10081. * This defines an action responsible to start an animation once triggered.
  10082. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10083. */
  10084. export class PlayAnimationAction extends Action {
  10085. /**
  10086. * Where the animation should start (animation frame)
  10087. */
  10088. from: number;
  10089. /**
  10090. * Where the animation should stop (animation frame)
  10091. */
  10092. to: number;
  10093. /**
  10094. * Define if the animation should loop or stop after the first play.
  10095. */
  10096. loop?: boolean;
  10097. private _target;
  10098. /**
  10099. * Instantiate the action
  10100. * @param triggerOptions defines the trigger options
  10101. * @param target defines the target animation or animation name
  10102. * @param from defines from where the animation should start (animation frame)
  10103. * @param end defines where the animation should stop (animation frame)
  10104. * @param loop defines if the animation should loop or stop after the first play
  10105. * @param condition defines the trigger related conditions
  10106. */
  10107. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10108. /** @hidden */
  10109. _prepare(): void;
  10110. /**
  10111. * Execute the action and play the animation.
  10112. */
  10113. execute(): void;
  10114. /**
  10115. * Serializes the actions and its related information.
  10116. * @param parent defines the object to serialize in
  10117. * @returns the serialized object
  10118. */
  10119. serialize(parent: any): any;
  10120. }
  10121. /**
  10122. * This defines an action responsible to stop an animation once triggered.
  10123. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10124. */
  10125. export class StopAnimationAction extends Action {
  10126. private _target;
  10127. /**
  10128. * Instantiate the action
  10129. * @param triggerOptions defines the trigger options
  10130. * @param target defines the target animation or animation name
  10131. * @param condition defines the trigger related conditions
  10132. */
  10133. constructor(triggerOptions: any, target: any, condition?: Condition);
  10134. /** @hidden */
  10135. _prepare(): void;
  10136. /**
  10137. * Execute the action and stop the animation.
  10138. */
  10139. execute(): void;
  10140. /**
  10141. * Serializes the actions and its related information.
  10142. * @param parent defines the object to serialize in
  10143. * @returns the serialized object
  10144. */
  10145. serialize(parent: any): any;
  10146. }
  10147. /**
  10148. * This defines an action responsible that does nothing once triggered.
  10149. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10150. */
  10151. export class DoNothingAction extends Action {
  10152. /**
  10153. * Instantiate the action
  10154. * @param triggerOptions defines the trigger options
  10155. * @param condition defines the trigger related conditions
  10156. */
  10157. constructor(triggerOptions?: any, condition?: Condition);
  10158. /**
  10159. * Execute the action and do nothing.
  10160. */
  10161. execute(): void;
  10162. /**
  10163. * Serializes the actions and its related information.
  10164. * @param parent defines the object to serialize in
  10165. * @returns the serialized object
  10166. */
  10167. serialize(parent: any): any;
  10168. }
  10169. /**
  10170. * This defines an action responsible to trigger several actions once triggered.
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10172. */
  10173. export class CombineAction extends Action {
  10174. /**
  10175. * The list of aggregated animations to run.
  10176. */
  10177. children: Action[];
  10178. /**
  10179. * Instantiate the action
  10180. * @param triggerOptions defines the trigger options
  10181. * @param children defines the list of aggregated animations to run
  10182. * @param condition defines the trigger related conditions
  10183. */
  10184. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10185. /** @hidden */
  10186. _prepare(): void;
  10187. /**
  10188. * Execute the action and executes all the aggregated actions.
  10189. */
  10190. execute(evt: ActionEvent): void;
  10191. /**
  10192. * Serializes the actions and its related information.
  10193. * @param parent defines the object to serialize in
  10194. * @returns the serialized object
  10195. */
  10196. serialize(parent: any): any;
  10197. }
  10198. /**
  10199. * This defines an action responsible to run code (external event) once triggered.
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10201. */
  10202. export class ExecuteCodeAction extends Action {
  10203. /**
  10204. * The callback function to run.
  10205. */
  10206. func: (evt: ActionEvent) => void;
  10207. /**
  10208. * Instantiate the action
  10209. * @param triggerOptions defines the trigger options
  10210. * @param func defines the callback function to run
  10211. * @param condition defines the trigger related conditions
  10212. */
  10213. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10214. /**
  10215. * Execute the action and run the attached code.
  10216. */
  10217. execute(evt: ActionEvent): void;
  10218. }
  10219. /**
  10220. * This defines an action responsible to set the parent property of the target once triggered.
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10222. */
  10223. export class SetParentAction extends Action {
  10224. private _parent;
  10225. private _target;
  10226. /**
  10227. * Instantiate the action
  10228. * @param triggerOptions defines the trigger options
  10229. * @param target defines the target containing the parent property
  10230. * @param parent defines from where the animation should start (animation frame)
  10231. * @param condition defines the trigger related conditions
  10232. */
  10233. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10234. /** @hidden */
  10235. _prepare(): void;
  10236. /**
  10237. * Execute the action and set the parent property.
  10238. */
  10239. execute(): void;
  10240. /**
  10241. * Serializes the actions and its related information.
  10242. * @param parent defines the object to serialize in
  10243. * @returns the serialized object
  10244. */
  10245. serialize(parent: any): any;
  10246. }
  10247. }
  10248. declare module "babylonjs/Actions/actionManager" {
  10249. import { Nullable } from "babylonjs/types";
  10250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10251. import { Scene } from "babylonjs/scene";
  10252. import { IAction } from "babylonjs/Actions/action";
  10253. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10254. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10255. /**
  10256. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10257. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10258. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10259. */
  10260. export class ActionManager extends AbstractActionManager {
  10261. /**
  10262. * Nothing
  10263. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10264. */
  10265. static readonly NothingTrigger: number;
  10266. /**
  10267. * On pick
  10268. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10269. */
  10270. static readonly OnPickTrigger: number;
  10271. /**
  10272. * On left pick
  10273. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10274. */
  10275. static readonly OnLeftPickTrigger: number;
  10276. /**
  10277. * On right pick
  10278. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10279. */
  10280. static readonly OnRightPickTrigger: number;
  10281. /**
  10282. * On center pick
  10283. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10284. */
  10285. static readonly OnCenterPickTrigger: number;
  10286. /**
  10287. * On pick down
  10288. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10289. */
  10290. static readonly OnPickDownTrigger: number;
  10291. /**
  10292. * On double pick
  10293. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10294. */
  10295. static readonly OnDoublePickTrigger: number;
  10296. /**
  10297. * On pick up
  10298. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10299. */
  10300. static readonly OnPickUpTrigger: number;
  10301. /**
  10302. * On pick out.
  10303. * This trigger will only be raised if you also declared a OnPickDown
  10304. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10305. */
  10306. static readonly OnPickOutTrigger: number;
  10307. /**
  10308. * On long press
  10309. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10310. */
  10311. static readonly OnLongPressTrigger: number;
  10312. /**
  10313. * On pointer over
  10314. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10315. */
  10316. static readonly OnPointerOverTrigger: number;
  10317. /**
  10318. * On pointer out
  10319. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10320. */
  10321. static readonly OnPointerOutTrigger: number;
  10322. /**
  10323. * On every frame
  10324. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10325. */
  10326. static readonly OnEveryFrameTrigger: number;
  10327. /**
  10328. * On intersection enter
  10329. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10330. */
  10331. static readonly OnIntersectionEnterTrigger: number;
  10332. /**
  10333. * On intersection exit
  10334. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10335. */
  10336. static readonly OnIntersectionExitTrigger: number;
  10337. /**
  10338. * On key down
  10339. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10340. */
  10341. static readonly OnKeyDownTrigger: number;
  10342. /**
  10343. * On key up
  10344. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10345. */
  10346. static readonly OnKeyUpTrigger: number;
  10347. private _scene;
  10348. /**
  10349. * Creates a new action manager
  10350. * @param scene defines the hosting scene
  10351. */
  10352. constructor(scene: Scene);
  10353. /**
  10354. * Releases all associated resources
  10355. */
  10356. dispose(): void;
  10357. /**
  10358. * Gets hosting scene
  10359. * @returns the hosting scene
  10360. */
  10361. getScene(): Scene;
  10362. /**
  10363. * Does this action manager handles actions of any of the given triggers
  10364. * @param triggers defines the triggers to be tested
  10365. * @return a boolean indicating whether one (or more) of the triggers is handled
  10366. */
  10367. hasSpecificTriggers(triggers: number[]): boolean;
  10368. /**
  10369. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10370. * speed.
  10371. * @param triggerA defines the trigger to be tested
  10372. * @param triggerB defines the trigger to be tested
  10373. * @return a boolean indicating whether one (or more) of the triggers is handled
  10374. */
  10375. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10376. /**
  10377. * Does this action manager handles actions of a given trigger
  10378. * @param trigger defines the trigger to be tested
  10379. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10380. * @return whether the trigger is handled
  10381. */
  10382. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10383. /**
  10384. * Does this action manager has pointer triggers
  10385. */
  10386. get hasPointerTriggers(): boolean;
  10387. /**
  10388. * Does this action manager has pick triggers
  10389. */
  10390. get hasPickTriggers(): boolean;
  10391. /**
  10392. * Registers an action to this action manager
  10393. * @param action defines the action to be registered
  10394. * @return the action amended (prepared) after registration
  10395. */
  10396. registerAction(action: IAction): Nullable<IAction>;
  10397. /**
  10398. * Unregisters an action to this action manager
  10399. * @param action defines the action to be unregistered
  10400. * @return a boolean indicating whether the action has been unregistered
  10401. */
  10402. unregisterAction(action: IAction): Boolean;
  10403. /**
  10404. * Process a specific trigger
  10405. * @param trigger defines the trigger to process
  10406. * @param evt defines the event details to be processed
  10407. */
  10408. processTrigger(trigger: number, evt?: IActionEvent): void;
  10409. /** @hidden */
  10410. _getEffectiveTarget(target: any, propertyPath: string): any;
  10411. /** @hidden */
  10412. _getProperty(propertyPath: string): string;
  10413. /**
  10414. * Serialize this manager to a JSON object
  10415. * @param name defines the property name to store this manager
  10416. * @returns a JSON representation of this manager
  10417. */
  10418. serialize(name: string): any;
  10419. /**
  10420. * Creates a new ActionManager from a JSON data
  10421. * @param parsedActions defines the JSON data to read from
  10422. * @param object defines the hosting mesh
  10423. * @param scene defines the hosting scene
  10424. */
  10425. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10426. /**
  10427. * Get a trigger name by index
  10428. * @param trigger defines the trigger index
  10429. * @returns a trigger name
  10430. */
  10431. static GetTriggerName(trigger: number): string;
  10432. }
  10433. }
  10434. declare module "babylonjs/Sprites/sprite" {
  10435. import { Vector3 } from "babylonjs/Maths/math.vector";
  10436. import { Nullable } from "babylonjs/types";
  10437. import { ActionManager } from "babylonjs/Actions/actionManager";
  10438. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10439. import { Color4 } from "babylonjs/Maths/math.color";
  10440. import { Observable } from "babylonjs/Misc/observable";
  10441. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10442. import { Animation } from "babylonjs/Animations/animation";
  10443. /**
  10444. * Class used to represent a sprite
  10445. * @see https://doc.babylonjs.com/babylon101/sprites
  10446. */
  10447. export class Sprite implements IAnimatable {
  10448. /** defines the name */
  10449. name: string;
  10450. /** Gets or sets the current world position */
  10451. position: Vector3;
  10452. /** Gets or sets the main color */
  10453. color: Color4;
  10454. /** Gets or sets the width */
  10455. width: number;
  10456. /** Gets or sets the height */
  10457. height: number;
  10458. /** Gets or sets rotation angle */
  10459. angle: number;
  10460. /** Gets or sets the cell index in the sprite sheet */
  10461. cellIndex: number;
  10462. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10463. cellRef: string;
  10464. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10465. invertU: boolean;
  10466. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10467. invertV: boolean;
  10468. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10469. disposeWhenFinishedAnimating: boolean;
  10470. /** Gets the list of attached animations */
  10471. animations: Nullable<Array<Animation>>;
  10472. /** Gets or sets a boolean indicating if the sprite can be picked */
  10473. isPickable: boolean;
  10474. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10475. useAlphaForPicking: boolean;
  10476. /** @hidden */
  10477. _xOffset: number;
  10478. /** @hidden */
  10479. _yOffset: number;
  10480. /** @hidden */
  10481. _xSize: number;
  10482. /** @hidden */
  10483. _ySize: number;
  10484. /**
  10485. * Gets or sets the associated action manager
  10486. */
  10487. actionManager: Nullable<ActionManager>;
  10488. /**
  10489. * An event triggered when the control has been disposed
  10490. */
  10491. onDisposeObservable: Observable<Sprite>;
  10492. private _animationStarted;
  10493. private _loopAnimation;
  10494. private _fromIndex;
  10495. private _toIndex;
  10496. private _delay;
  10497. private _direction;
  10498. private _manager;
  10499. private _time;
  10500. private _onAnimationEnd;
  10501. /**
  10502. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10503. */
  10504. isVisible: boolean;
  10505. /**
  10506. * Gets or sets the sprite size
  10507. */
  10508. get size(): number;
  10509. set size(value: number);
  10510. /**
  10511. * Returns a boolean indicating if the animation is started
  10512. */
  10513. get animationStarted(): boolean;
  10514. /**
  10515. * Gets or sets the unique id of the sprite
  10516. */
  10517. uniqueId: number;
  10518. /**
  10519. * Gets the manager of this sprite
  10520. */
  10521. get manager(): ISpriteManager;
  10522. /**
  10523. * Creates a new Sprite
  10524. * @param name defines the name
  10525. * @param manager defines the manager
  10526. */
  10527. constructor(
  10528. /** defines the name */
  10529. name: string, manager: ISpriteManager);
  10530. /**
  10531. * Returns the string "Sprite"
  10532. * @returns "Sprite"
  10533. */
  10534. getClassName(): string;
  10535. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10536. get fromIndex(): number;
  10537. set fromIndex(value: number);
  10538. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10539. get toIndex(): number;
  10540. set toIndex(value: number);
  10541. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10542. get loopAnimation(): boolean;
  10543. set loopAnimation(value: boolean);
  10544. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10545. get delay(): number;
  10546. set delay(value: number);
  10547. /**
  10548. * Starts an animation
  10549. * @param from defines the initial key
  10550. * @param to defines the end key
  10551. * @param loop defines if the animation must loop
  10552. * @param delay defines the start delay (in ms)
  10553. * @param onAnimationEnd defines a callback to call when animation ends
  10554. */
  10555. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10556. /** Stops current animation (if any) */
  10557. stopAnimation(): void;
  10558. /** @hidden */
  10559. _animate(deltaTime: number): void;
  10560. /** Release associated resources */
  10561. dispose(): void;
  10562. /**
  10563. * Serializes the sprite to a JSON object
  10564. * @returns the JSON object
  10565. */
  10566. serialize(): any;
  10567. /**
  10568. * Parses a JSON object to create a new sprite
  10569. * @param parsedSprite The JSON object to parse
  10570. * @param manager defines the hosting manager
  10571. * @returns the new sprite
  10572. */
  10573. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10574. }
  10575. }
  10576. declare module "babylonjs/Collisions/pickingInfo" {
  10577. import { Nullable } from "babylonjs/types";
  10578. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10580. import { Sprite } from "babylonjs/Sprites/sprite";
  10581. import { Ray } from "babylonjs/Culling/ray";
  10582. /**
  10583. * Information about the result of picking within a scene
  10584. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10585. */
  10586. export class PickingInfo {
  10587. /** @hidden */
  10588. _pickingUnavailable: boolean;
  10589. /**
  10590. * If the pick collided with an object
  10591. */
  10592. hit: boolean;
  10593. /**
  10594. * Distance away where the pick collided
  10595. */
  10596. distance: number;
  10597. /**
  10598. * The location of pick collision
  10599. */
  10600. pickedPoint: Nullable<Vector3>;
  10601. /**
  10602. * The mesh corresponding the the pick collision
  10603. */
  10604. pickedMesh: Nullable<AbstractMesh>;
  10605. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10606. bu: number;
  10607. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10608. bv: number;
  10609. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10610. faceId: number;
  10611. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10612. subMeshFaceId: number;
  10613. /** Id of the the submesh that was picked */
  10614. subMeshId: number;
  10615. /** If a sprite was picked, this will be the sprite the pick collided with */
  10616. pickedSprite: Nullable<Sprite>;
  10617. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10618. thinInstanceIndex: number;
  10619. /**
  10620. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10621. */
  10622. originMesh: Nullable<AbstractMesh>;
  10623. /**
  10624. * The ray that was used to perform the picking.
  10625. */
  10626. ray: Nullable<Ray>;
  10627. /**
  10628. * Gets the normal correspodning to the face the pick collided with
  10629. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10630. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10631. * @returns The normal correspodning to the face the pick collided with
  10632. */
  10633. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10634. /**
  10635. * Gets the texture coordinates of where the pick occured
  10636. * @returns the vector containing the coordnates of the texture
  10637. */
  10638. getTextureCoordinates(): Nullable<Vector2>;
  10639. }
  10640. }
  10641. declare module "babylonjs/Culling/ray" {
  10642. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10643. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10645. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10646. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10647. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10648. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10649. import { Plane } from "babylonjs/Maths/math.plane";
  10650. /**
  10651. * Class representing a ray with position and direction
  10652. */
  10653. export class Ray {
  10654. /** origin point */
  10655. origin: Vector3;
  10656. /** direction */
  10657. direction: Vector3;
  10658. /** length of the ray */
  10659. length: number;
  10660. private static readonly _TmpVector3;
  10661. private _tmpRay;
  10662. /**
  10663. * Creates a new ray
  10664. * @param origin origin point
  10665. * @param direction direction
  10666. * @param length length of the ray
  10667. */
  10668. constructor(
  10669. /** origin point */
  10670. origin: Vector3,
  10671. /** direction */
  10672. direction: Vector3,
  10673. /** length of the ray */
  10674. length?: number);
  10675. /**
  10676. * Checks if the ray intersects a box
  10677. * This does not account for the ray lenght by design to improve perfs.
  10678. * @param minimum bound of the box
  10679. * @param maximum bound of the box
  10680. * @param intersectionTreshold extra extend to be added to the box in all direction
  10681. * @returns if the box was hit
  10682. */
  10683. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10684. /**
  10685. * Checks if the ray intersects a box
  10686. * This does not account for the ray lenght by design to improve perfs.
  10687. * @param box the bounding box to check
  10688. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10689. * @returns if the box was hit
  10690. */
  10691. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10692. /**
  10693. * If the ray hits a sphere
  10694. * @param sphere the bounding sphere to check
  10695. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10696. * @returns true if it hits the sphere
  10697. */
  10698. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10699. /**
  10700. * If the ray hits a triange
  10701. * @param vertex0 triangle vertex
  10702. * @param vertex1 triangle vertex
  10703. * @param vertex2 triangle vertex
  10704. * @returns intersection information if hit
  10705. */
  10706. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10707. /**
  10708. * Checks if ray intersects a plane
  10709. * @param plane the plane to check
  10710. * @returns the distance away it was hit
  10711. */
  10712. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10713. /**
  10714. * Calculate the intercept of a ray on a given axis
  10715. * @param axis to check 'x' | 'y' | 'z'
  10716. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10717. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10718. */
  10719. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10720. /**
  10721. * Checks if ray intersects a mesh
  10722. * @param mesh the mesh to check
  10723. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10724. * @returns picking info of the intersecton
  10725. */
  10726. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10727. /**
  10728. * Checks if ray intersects a mesh
  10729. * @param meshes the meshes to check
  10730. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10731. * @param results array to store result in
  10732. * @returns Array of picking infos
  10733. */
  10734. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10735. private _comparePickingInfo;
  10736. private static smallnum;
  10737. private static rayl;
  10738. /**
  10739. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10740. * @param sega the first point of the segment to test the intersection against
  10741. * @param segb the second point of the segment to test the intersection against
  10742. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10743. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10744. */
  10745. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10746. /**
  10747. * Update the ray from viewport position
  10748. * @param x position
  10749. * @param y y position
  10750. * @param viewportWidth viewport width
  10751. * @param viewportHeight viewport height
  10752. * @param world world matrix
  10753. * @param view view matrix
  10754. * @param projection projection matrix
  10755. * @returns this ray updated
  10756. */
  10757. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10758. /**
  10759. * Creates a ray with origin and direction of 0,0,0
  10760. * @returns the new ray
  10761. */
  10762. static Zero(): Ray;
  10763. /**
  10764. * Creates a new ray from screen space and viewport
  10765. * @param x position
  10766. * @param y y position
  10767. * @param viewportWidth viewport width
  10768. * @param viewportHeight viewport height
  10769. * @param world world matrix
  10770. * @param view view matrix
  10771. * @param projection projection matrix
  10772. * @returns new ray
  10773. */
  10774. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10775. /**
  10776. * 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
  10777. * transformed to the given world matrix.
  10778. * @param origin The origin point
  10779. * @param end The end point
  10780. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10781. * @returns the new ray
  10782. */
  10783. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10784. /**
  10785. * Transforms a ray by a matrix
  10786. * @param ray ray to transform
  10787. * @param matrix matrix to apply
  10788. * @returns the resulting new ray
  10789. */
  10790. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10791. /**
  10792. * Transforms a ray by a matrix
  10793. * @param ray ray to transform
  10794. * @param matrix matrix to apply
  10795. * @param result ray to store result in
  10796. */
  10797. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10798. /**
  10799. * Unproject a ray from screen space to object space
  10800. * @param sourceX defines the screen space x coordinate to use
  10801. * @param sourceY defines the screen space y coordinate to use
  10802. * @param viewportWidth defines the current width of the viewport
  10803. * @param viewportHeight defines the current height of the viewport
  10804. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10805. * @param view defines the view matrix to use
  10806. * @param projection defines the projection matrix to use
  10807. */
  10808. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10809. }
  10810. /**
  10811. * Type used to define predicate used to select faces when a mesh intersection is detected
  10812. */
  10813. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10814. module "babylonjs/scene" {
  10815. interface Scene {
  10816. /** @hidden */
  10817. _tempPickingRay: Nullable<Ray>;
  10818. /** @hidden */
  10819. _cachedRayForTransform: Ray;
  10820. /** @hidden */
  10821. _pickWithRayInverseMatrix: Matrix;
  10822. /** @hidden */
  10823. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10824. /** @hidden */
  10825. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10826. /** @hidden */
  10827. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10828. }
  10829. }
  10830. }
  10831. declare module "babylonjs/sceneComponent" {
  10832. import { Scene } from "babylonjs/scene";
  10833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10835. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10836. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10837. import { Nullable } from "babylonjs/types";
  10838. import { Camera } from "babylonjs/Cameras/camera";
  10839. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10840. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10841. import { AbstractScene } from "babylonjs/abstractScene";
  10842. import { Mesh } from "babylonjs/Meshes/mesh";
  10843. /**
  10844. * Groups all the scene component constants in one place to ease maintenance.
  10845. * @hidden
  10846. */
  10847. export class SceneComponentConstants {
  10848. static readonly NAME_EFFECTLAYER: string;
  10849. static readonly NAME_LAYER: string;
  10850. static readonly NAME_LENSFLARESYSTEM: string;
  10851. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10852. static readonly NAME_PARTICLESYSTEM: string;
  10853. static readonly NAME_GAMEPAD: string;
  10854. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10855. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10856. static readonly NAME_PREPASSRENDERER: string;
  10857. static readonly NAME_DEPTHRENDERER: string;
  10858. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10859. static readonly NAME_SPRITE: string;
  10860. static readonly NAME_OUTLINERENDERER: string;
  10861. static readonly NAME_PROCEDURALTEXTURE: string;
  10862. static readonly NAME_SHADOWGENERATOR: string;
  10863. static readonly NAME_OCTREE: string;
  10864. static readonly NAME_PHYSICSENGINE: string;
  10865. static readonly NAME_AUDIO: string;
  10866. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10867. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10868. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10869. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10870. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10871. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10872. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10873. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10874. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10875. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10876. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10877. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10878. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10879. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10880. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10881. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10882. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10883. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10884. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10885. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10886. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10887. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10888. static readonly STEP_AFTERRENDER_AUDIO: number;
  10889. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10890. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10891. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10892. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10893. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10894. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10895. static readonly STEP_POINTERMOVE_SPRITE: number;
  10896. static readonly STEP_POINTERDOWN_SPRITE: number;
  10897. static readonly STEP_POINTERUP_SPRITE: number;
  10898. }
  10899. /**
  10900. * This represents a scene component.
  10901. *
  10902. * This is used to decouple the dependency the scene is having on the different workloads like
  10903. * layers, post processes...
  10904. */
  10905. export interface ISceneComponent {
  10906. /**
  10907. * The name of the component. Each component must have a unique name.
  10908. */
  10909. name: string;
  10910. /**
  10911. * The scene the component belongs to.
  10912. */
  10913. scene: Scene;
  10914. /**
  10915. * Register the component to one instance of a scene.
  10916. */
  10917. register(): void;
  10918. /**
  10919. * Rebuilds the elements related to this component in case of
  10920. * context lost for instance.
  10921. */
  10922. rebuild(): void;
  10923. /**
  10924. * Disposes the component and the associated ressources.
  10925. */
  10926. dispose(): void;
  10927. }
  10928. /**
  10929. * This represents a SERIALIZABLE scene component.
  10930. *
  10931. * This extends Scene Component to add Serialization methods on top.
  10932. */
  10933. export interface ISceneSerializableComponent extends ISceneComponent {
  10934. /**
  10935. * Adds all the elements from the container to the scene
  10936. * @param container the container holding the elements
  10937. */
  10938. addFromContainer(container: AbstractScene): void;
  10939. /**
  10940. * Removes all the elements in the container from the scene
  10941. * @param container contains the elements to remove
  10942. * @param dispose if the removed element should be disposed (default: false)
  10943. */
  10944. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10945. /**
  10946. * Serializes the component data to the specified json object
  10947. * @param serializationObject The object to serialize to
  10948. */
  10949. serialize(serializationObject: any): void;
  10950. }
  10951. /**
  10952. * Strong typing of a Mesh related stage step action
  10953. */
  10954. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10955. /**
  10956. * Strong typing of a Evaluate Sub Mesh related stage step action
  10957. */
  10958. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10959. /**
  10960. * Strong typing of a Active Mesh related stage step action
  10961. */
  10962. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10963. /**
  10964. * Strong typing of a Camera related stage step action
  10965. */
  10966. export type CameraStageAction = (camera: Camera) => void;
  10967. /**
  10968. * Strong typing of a Camera Frame buffer related stage step action
  10969. */
  10970. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10971. /**
  10972. * Strong typing of a Render Target related stage step action
  10973. */
  10974. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10975. /**
  10976. * Strong typing of a RenderingGroup related stage step action
  10977. */
  10978. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10979. /**
  10980. * Strong typing of a Mesh Render related stage step action
  10981. */
  10982. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10983. /**
  10984. * Strong typing of a simple stage step action
  10985. */
  10986. export type SimpleStageAction = () => void;
  10987. /**
  10988. * Strong typing of a render target action.
  10989. */
  10990. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10991. /**
  10992. * Strong typing of a pointer move action.
  10993. */
  10994. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10995. /**
  10996. * Strong typing of a pointer up/down action.
  10997. */
  10998. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10999. /**
  11000. * Representation of a stage in the scene (Basically a list of ordered steps)
  11001. * @hidden
  11002. */
  11003. export class Stage<T extends Function> extends Array<{
  11004. index: number;
  11005. component: ISceneComponent;
  11006. action: T;
  11007. }> {
  11008. /**
  11009. * Hide ctor from the rest of the world.
  11010. * @param items The items to add.
  11011. */
  11012. private constructor();
  11013. /**
  11014. * Creates a new Stage.
  11015. * @returns A new instance of a Stage
  11016. */
  11017. static Create<T extends Function>(): Stage<T>;
  11018. /**
  11019. * Registers a step in an ordered way in the targeted stage.
  11020. * @param index Defines the position to register the step in
  11021. * @param component Defines the component attached to the step
  11022. * @param action Defines the action to launch during the step
  11023. */
  11024. registerStep(index: number, component: ISceneComponent, action: T): void;
  11025. /**
  11026. * Clears all the steps from the stage.
  11027. */
  11028. clear(): void;
  11029. }
  11030. }
  11031. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11032. import { Nullable } from "babylonjs/types";
  11033. import { Observable } from "babylonjs/Misc/observable";
  11034. import { Scene } from "babylonjs/scene";
  11035. import { Sprite } from "babylonjs/Sprites/sprite";
  11036. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11037. import { Ray } from "babylonjs/Culling/ray";
  11038. import { Camera } from "babylonjs/Cameras/camera";
  11039. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11040. import { ISceneComponent } from "babylonjs/sceneComponent";
  11041. module "babylonjs/scene" {
  11042. interface Scene {
  11043. /** @hidden */
  11044. _pointerOverSprite: Nullable<Sprite>;
  11045. /** @hidden */
  11046. _pickedDownSprite: Nullable<Sprite>;
  11047. /** @hidden */
  11048. _tempSpritePickingRay: Nullable<Ray>;
  11049. /**
  11050. * All of the sprite managers added to this scene
  11051. * @see https://doc.babylonjs.com/babylon101/sprites
  11052. */
  11053. spriteManagers: Array<ISpriteManager>;
  11054. /**
  11055. * An event triggered when sprites rendering is about to start
  11056. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11057. */
  11058. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11059. /**
  11060. * An event triggered when sprites rendering is done
  11061. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11062. */
  11063. onAfterSpritesRenderingObservable: Observable<Scene>;
  11064. /** @hidden */
  11065. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11066. /** Launch a ray to try to pick a sprite in the scene
  11067. * @param x position on screen
  11068. * @param y position on screen
  11069. * @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
  11070. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11071. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11072. * @returns a PickingInfo
  11073. */
  11074. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11075. /** Use the given ray to pick a sprite in the scene
  11076. * @param ray The ray (in world space) to use to pick meshes
  11077. * @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
  11078. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11079. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11080. * @returns a PickingInfo
  11081. */
  11082. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11083. /** @hidden */
  11084. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11085. /** Launch a ray to try to pick sprites in the scene
  11086. * @param x position on screen
  11087. * @param y position on screen
  11088. * @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
  11089. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11090. * @returns a PickingInfo array
  11091. */
  11092. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11093. /** Use the given ray to pick sprites in the scene
  11094. * @param ray The ray (in world space) to use to pick meshes
  11095. * @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
  11096. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11097. * @returns a PickingInfo array
  11098. */
  11099. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11100. /**
  11101. * Force the sprite under the pointer
  11102. * @param sprite defines the sprite to use
  11103. */
  11104. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11105. /**
  11106. * Gets the sprite under the pointer
  11107. * @returns a Sprite or null if no sprite is under the pointer
  11108. */
  11109. getPointerOverSprite(): Nullable<Sprite>;
  11110. }
  11111. }
  11112. /**
  11113. * Defines the sprite scene component responsible to manage sprites
  11114. * in a given scene.
  11115. */
  11116. export class SpriteSceneComponent implements ISceneComponent {
  11117. /**
  11118. * The component name helpfull to identify the component in the list of scene components.
  11119. */
  11120. readonly name: string;
  11121. /**
  11122. * The scene the component belongs to.
  11123. */
  11124. scene: Scene;
  11125. /** @hidden */
  11126. private _spritePredicate;
  11127. /**
  11128. * Creates a new instance of the component for the given scene
  11129. * @param scene Defines the scene to register the component in
  11130. */
  11131. constructor(scene: Scene);
  11132. /**
  11133. * Registers the component in a given scene
  11134. */
  11135. register(): void;
  11136. /**
  11137. * Rebuilds the elements related to this component in case of
  11138. * context lost for instance.
  11139. */
  11140. rebuild(): void;
  11141. /**
  11142. * Disposes the component and the associated ressources.
  11143. */
  11144. dispose(): void;
  11145. private _pickSpriteButKeepRay;
  11146. private _pointerMove;
  11147. private _pointerDown;
  11148. private _pointerUp;
  11149. }
  11150. }
  11151. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11152. /** @hidden */
  11153. export var fogFragmentDeclaration: {
  11154. name: string;
  11155. shader: string;
  11156. };
  11157. }
  11158. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11159. /** @hidden */
  11160. export var fogFragment: {
  11161. name: string;
  11162. shader: string;
  11163. };
  11164. }
  11165. declare module "babylonjs/Shaders/sprites.fragment" {
  11166. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11167. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11168. /** @hidden */
  11169. export var spritesPixelShader: {
  11170. name: string;
  11171. shader: string;
  11172. };
  11173. }
  11174. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11175. /** @hidden */
  11176. export var fogVertexDeclaration: {
  11177. name: string;
  11178. shader: string;
  11179. };
  11180. }
  11181. declare module "babylonjs/Shaders/sprites.vertex" {
  11182. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11183. /** @hidden */
  11184. export var spritesVertexShader: {
  11185. name: string;
  11186. shader: string;
  11187. };
  11188. }
  11189. declare module "babylonjs/Sprites/spriteManager" {
  11190. import { IDisposable, Scene } from "babylonjs/scene";
  11191. import { Nullable } from "babylonjs/types";
  11192. import { Observable } from "babylonjs/Misc/observable";
  11193. import { Sprite } from "babylonjs/Sprites/sprite";
  11194. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11195. import { Camera } from "babylonjs/Cameras/camera";
  11196. import { Texture } from "babylonjs/Materials/Textures/texture";
  11197. import "babylonjs/Shaders/sprites.fragment";
  11198. import "babylonjs/Shaders/sprites.vertex";
  11199. import { Ray } from "babylonjs/Culling/ray";
  11200. /**
  11201. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11202. */
  11203. export interface ISpriteManager extends IDisposable {
  11204. /**
  11205. * Gets manager's name
  11206. */
  11207. name: string;
  11208. /**
  11209. * Restricts the camera to viewing objects with the same layerMask.
  11210. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11211. */
  11212. layerMask: number;
  11213. /**
  11214. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11215. */
  11216. isPickable: boolean;
  11217. /**
  11218. * Gets the hosting scene
  11219. */
  11220. scene: Scene;
  11221. /**
  11222. * Specifies the rendering group id for this mesh (0 by default)
  11223. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11224. */
  11225. renderingGroupId: number;
  11226. /**
  11227. * Defines the list of sprites managed by the manager.
  11228. */
  11229. sprites: Array<Sprite>;
  11230. /**
  11231. * Gets or sets the spritesheet texture
  11232. */
  11233. texture: Texture;
  11234. /** Defines the default width of a cell in the spritesheet */
  11235. cellWidth: number;
  11236. /** Defines the default height of a cell in the spritesheet */
  11237. cellHeight: number;
  11238. /**
  11239. * Tests the intersection of a sprite with a specific ray.
  11240. * @param ray The ray we are sending to test the collision
  11241. * @param camera The camera space we are sending rays in
  11242. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11243. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11244. * @returns picking info or null.
  11245. */
  11246. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11247. /**
  11248. * Intersects the sprites with a ray
  11249. * @param ray defines the ray to intersect with
  11250. * @param camera defines the current active camera
  11251. * @param predicate defines a predicate used to select candidate sprites
  11252. * @returns null if no hit or a PickingInfo array
  11253. */
  11254. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11255. /**
  11256. * Renders the list of sprites on screen.
  11257. */
  11258. render(): void;
  11259. }
  11260. /**
  11261. * Class used to manage multiple sprites on the same spritesheet
  11262. * @see https://doc.babylonjs.com/babylon101/sprites
  11263. */
  11264. export class SpriteManager implements ISpriteManager {
  11265. /** defines the manager's name */
  11266. name: string;
  11267. /** Define the Url to load snippets */
  11268. static SnippetUrl: string;
  11269. /** Snippet ID if the manager was created from the snippet server */
  11270. snippetId: string;
  11271. /** Gets the list of sprites */
  11272. sprites: Sprite[];
  11273. /** Gets or sets the rendering group id (0 by default) */
  11274. renderingGroupId: number;
  11275. /** Gets or sets camera layer mask */
  11276. layerMask: number;
  11277. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11278. fogEnabled: boolean;
  11279. /** Gets or sets a boolean indicating if the sprites are pickable */
  11280. isPickable: boolean;
  11281. /** Defines the default width of a cell in the spritesheet */
  11282. cellWidth: number;
  11283. /** Defines the default height of a cell in the spritesheet */
  11284. cellHeight: number;
  11285. /** Associative array from JSON sprite data file */
  11286. private _cellData;
  11287. /** Array of sprite names from JSON sprite data file */
  11288. private _spriteMap;
  11289. /** True when packed cell data from JSON file is ready*/
  11290. private _packedAndReady;
  11291. private _textureContent;
  11292. private _useInstancing;
  11293. /**
  11294. * An event triggered when the manager is disposed.
  11295. */
  11296. onDisposeObservable: Observable<SpriteManager>;
  11297. private _onDisposeObserver;
  11298. /**
  11299. * Callback called when the manager is disposed
  11300. */
  11301. set onDispose(callback: () => void);
  11302. private _capacity;
  11303. private _fromPacked;
  11304. private _spriteTexture;
  11305. private _epsilon;
  11306. private _scene;
  11307. private _vertexData;
  11308. private _buffer;
  11309. private _vertexBuffers;
  11310. private _spriteBuffer;
  11311. private _indexBuffer;
  11312. private _effectBase;
  11313. private _effectFog;
  11314. private _vertexBufferSize;
  11315. /**
  11316. * Gets or sets the unique id of the sprite
  11317. */
  11318. uniqueId: number;
  11319. /**
  11320. * Gets the array of sprites
  11321. */
  11322. get children(): Sprite[];
  11323. /**
  11324. * Gets the hosting scene
  11325. */
  11326. get scene(): Scene;
  11327. /**
  11328. * Gets the capacity of the manager
  11329. */
  11330. get capacity(): number;
  11331. /**
  11332. * Gets or sets the spritesheet texture
  11333. */
  11334. get texture(): Texture;
  11335. set texture(value: Texture);
  11336. private _blendMode;
  11337. /**
  11338. * Blend mode use to render the particle, it can be any of
  11339. * the static Constants.ALPHA_x properties provided in this class.
  11340. * Default value is Constants.ALPHA_COMBINE
  11341. */
  11342. get blendMode(): number;
  11343. set blendMode(blendMode: number);
  11344. /** Disables writing to the depth buffer when rendering the sprites.
  11345. * It can be handy to disable depth writing when using textures without alpha channel
  11346. * and setting some specific blend modes.
  11347. */
  11348. disableDepthWrite: boolean;
  11349. /**
  11350. * Creates a new sprite manager
  11351. * @param name defines the manager's name
  11352. * @param imgUrl defines the sprite sheet url
  11353. * @param capacity defines the maximum allowed number of sprites
  11354. * @param cellSize defines the size of a sprite cell
  11355. * @param scene defines the hosting scene
  11356. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11357. * @param samplingMode defines the smapling mode to use with spritesheet
  11358. * @param fromPacked set to false; do not alter
  11359. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11360. */
  11361. constructor(
  11362. /** defines the manager's name */
  11363. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11364. /**
  11365. * Returns the string "SpriteManager"
  11366. * @returns "SpriteManager"
  11367. */
  11368. getClassName(): string;
  11369. private _makePacked;
  11370. private _appendSpriteVertex;
  11371. private _checkTextureAlpha;
  11372. /**
  11373. * Intersects the sprites with a ray
  11374. * @param ray defines the ray to intersect with
  11375. * @param camera defines the current active camera
  11376. * @param predicate defines a predicate used to select candidate sprites
  11377. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11378. * @returns null if no hit or a PickingInfo
  11379. */
  11380. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11381. /**
  11382. * Intersects the sprites with a ray
  11383. * @param ray defines the ray to intersect with
  11384. * @param camera defines the current active camera
  11385. * @param predicate defines a predicate used to select candidate sprites
  11386. * @returns null if no hit or a PickingInfo array
  11387. */
  11388. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11389. /**
  11390. * Render all child sprites
  11391. */
  11392. render(): void;
  11393. /**
  11394. * Release associated resources
  11395. */
  11396. dispose(): void;
  11397. /**
  11398. * Serializes the sprite manager to a JSON object
  11399. * @param serializeTexture defines if the texture must be serialized as well
  11400. * @returns the JSON object
  11401. */
  11402. serialize(serializeTexture?: boolean): any;
  11403. /**
  11404. * Parses a JSON object to create a new sprite manager.
  11405. * @param parsedManager The JSON object to parse
  11406. * @param scene The scene to create the sprite managerin
  11407. * @param rootUrl The root url to use to load external dependencies like texture
  11408. * @returns the new sprite manager
  11409. */
  11410. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11411. /**
  11412. * Creates a sprite manager from a snippet saved in a remote file
  11413. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11414. * @param url defines the url to load from
  11415. * @param scene defines the hosting scene
  11416. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11417. * @returns a promise that will resolve to the new sprite manager
  11418. */
  11419. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11420. /**
  11421. * Creates a sprite manager from a snippet saved by the sprite editor
  11422. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11423. * @param scene defines the hosting scene
  11424. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11425. * @returns a promise that will resolve to the new sprite manager
  11426. */
  11427. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11428. }
  11429. }
  11430. declare module "babylonjs/Misc/gradients" {
  11431. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11432. /** Interface used by value gradients (color, factor, ...) */
  11433. export interface IValueGradient {
  11434. /**
  11435. * Gets or sets the gradient value (between 0 and 1)
  11436. */
  11437. gradient: number;
  11438. }
  11439. /** Class used to store color4 gradient */
  11440. export class ColorGradient implements IValueGradient {
  11441. /**
  11442. * Gets or sets the gradient value (between 0 and 1)
  11443. */
  11444. gradient: number;
  11445. /**
  11446. * Gets or sets first associated color
  11447. */
  11448. color1: Color4;
  11449. /**
  11450. * Gets or sets second associated color
  11451. */
  11452. color2?: Color4 | undefined;
  11453. /**
  11454. * Creates a new color4 gradient
  11455. * @param gradient gets or sets the gradient value (between 0 and 1)
  11456. * @param color1 gets or sets first associated color
  11457. * @param color2 gets or sets first second color
  11458. */
  11459. constructor(
  11460. /**
  11461. * Gets or sets the gradient value (between 0 and 1)
  11462. */
  11463. gradient: number,
  11464. /**
  11465. * Gets or sets first associated color
  11466. */
  11467. color1: Color4,
  11468. /**
  11469. * Gets or sets second associated color
  11470. */
  11471. color2?: Color4 | undefined);
  11472. /**
  11473. * Will get a color picked randomly between color1 and color2.
  11474. * If color2 is undefined then color1 will be used
  11475. * @param result defines the target Color4 to store the result in
  11476. */
  11477. getColorToRef(result: Color4): void;
  11478. }
  11479. /** Class used to store color 3 gradient */
  11480. export class Color3Gradient implements IValueGradient {
  11481. /**
  11482. * Gets or sets the gradient value (between 0 and 1)
  11483. */
  11484. gradient: number;
  11485. /**
  11486. * Gets or sets the associated color
  11487. */
  11488. color: Color3;
  11489. /**
  11490. * Creates a new color3 gradient
  11491. * @param gradient gets or sets the gradient value (between 0 and 1)
  11492. * @param color gets or sets associated color
  11493. */
  11494. constructor(
  11495. /**
  11496. * Gets or sets the gradient value (between 0 and 1)
  11497. */
  11498. gradient: number,
  11499. /**
  11500. * Gets or sets the associated color
  11501. */
  11502. color: Color3);
  11503. }
  11504. /** Class used to store factor gradient */
  11505. export class FactorGradient implements IValueGradient {
  11506. /**
  11507. * Gets or sets the gradient value (between 0 and 1)
  11508. */
  11509. gradient: number;
  11510. /**
  11511. * Gets or sets first associated factor
  11512. */
  11513. factor1: number;
  11514. /**
  11515. * Gets or sets second associated factor
  11516. */
  11517. factor2?: number | undefined;
  11518. /**
  11519. * Creates a new factor gradient
  11520. * @param gradient gets or sets the gradient value (between 0 and 1)
  11521. * @param factor1 gets or sets first associated factor
  11522. * @param factor2 gets or sets second associated factor
  11523. */
  11524. constructor(
  11525. /**
  11526. * Gets or sets the gradient value (between 0 and 1)
  11527. */
  11528. gradient: number,
  11529. /**
  11530. * Gets or sets first associated factor
  11531. */
  11532. factor1: number,
  11533. /**
  11534. * Gets or sets second associated factor
  11535. */
  11536. factor2?: number | undefined);
  11537. /**
  11538. * Will get a number picked randomly between factor1 and factor2.
  11539. * If factor2 is undefined then factor1 will be used
  11540. * @returns the picked number
  11541. */
  11542. getFactor(): number;
  11543. }
  11544. /**
  11545. * Helper used to simplify some generic gradient tasks
  11546. */
  11547. export class GradientHelper {
  11548. /**
  11549. * Gets the current gradient from an array of IValueGradient
  11550. * @param ratio defines the current ratio to get
  11551. * @param gradients defines the array of IValueGradient
  11552. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11553. */
  11554. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11555. }
  11556. }
  11557. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11558. import { Nullable } from "babylonjs/types";
  11559. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11560. import { Scene } from "babylonjs/scene";
  11561. module "babylonjs/Engines/thinEngine" {
  11562. interface ThinEngine {
  11563. /**
  11564. * Creates a raw texture
  11565. * @param data defines the data to store in the texture
  11566. * @param width defines the width of the texture
  11567. * @param height defines the height of the texture
  11568. * @param format defines the format of the data
  11569. * @param generateMipMaps defines if the engine should generate the mip levels
  11570. * @param invertY defines if data must be stored with Y axis inverted
  11571. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11572. * @param compression defines the compression used (null by default)
  11573. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11574. * @returns the raw texture inside an InternalTexture
  11575. */
  11576. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11577. /**
  11578. * Update a raw texture
  11579. * @param texture defines the texture to update
  11580. * @param data defines the data to store in the texture
  11581. * @param format defines the format of the data
  11582. * @param invertY defines if data must be stored with Y axis inverted
  11583. */
  11584. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11585. /**
  11586. * Update a raw texture
  11587. * @param texture defines the texture to update
  11588. * @param data defines the data to store in the texture
  11589. * @param format defines the format of the data
  11590. * @param invertY defines if data must be stored with Y axis inverted
  11591. * @param compression defines the compression used (null by default)
  11592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11593. */
  11594. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11595. /**
  11596. * Creates a new raw cube texture
  11597. * @param data defines the array of data to use to create each face
  11598. * @param size defines the size of the textures
  11599. * @param format defines the format of the data
  11600. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11601. * @param generateMipMaps defines if the engine should generate the mip levels
  11602. * @param invertY defines if data must be stored with Y axis inverted
  11603. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11604. * @param compression defines the compression used (null by default)
  11605. * @returns the cube texture as an InternalTexture
  11606. */
  11607. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11608. /**
  11609. * Update a raw cube texture
  11610. * @param texture defines the texture to udpdate
  11611. * @param data defines the data to store
  11612. * @param format defines the data format
  11613. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11614. * @param invertY defines if data must be stored with Y axis inverted
  11615. */
  11616. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11617. /**
  11618. * Update a raw cube texture
  11619. * @param texture defines the texture to udpdate
  11620. * @param data defines the data to store
  11621. * @param format defines the data format
  11622. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11623. * @param invertY defines if data must be stored with Y axis inverted
  11624. * @param compression defines the compression used (null by default)
  11625. */
  11626. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11627. /**
  11628. * Update a raw cube texture
  11629. * @param texture defines the texture to udpdate
  11630. * @param data defines the data to store
  11631. * @param format defines the data format
  11632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  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 level defines which level of the texture to update
  11636. */
  11637. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11638. /**
  11639. * Creates a new raw cube texture from a specified url
  11640. * @param url defines the url where the data is located
  11641. * @param scene defines the current scene
  11642. * @param size defines the size of the textures
  11643. * @param format defines the format of the data
  11644. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11645. * @param noMipmap defines if the engine should avoid generating the mip levels
  11646. * @param callback defines a callback used to extract texture data from loaded data
  11647. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11648. * @param onLoad defines a callback called when texture is loaded
  11649. * @param onError defines a callback called if there is an error
  11650. * @returns the cube texture as an InternalTexture
  11651. */
  11652. 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;
  11653. /**
  11654. * Creates a new raw cube texture from a specified url
  11655. * @param url defines the url where the data is located
  11656. * @param scene defines the current scene
  11657. * @param size defines the size of the textures
  11658. * @param format defines the format of the data
  11659. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11660. * @param noMipmap defines if the engine should avoid generating the mip levels
  11661. * @param callback defines a callback used to extract texture data from loaded data
  11662. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11663. * @param onLoad defines a callback called when texture is loaded
  11664. * @param onError defines a callback called if there is an error
  11665. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11666. * @param invertY defines if data must be stored with Y axis inverted
  11667. * @returns the cube texture as an InternalTexture
  11668. */
  11669. 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;
  11670. /**
  11671. * Creates a new raw 3D texture
  11672. * @param data defines the data used to create the texture
  11673. * @param width defines the width of the texture
  11674. * @param height defines the height of the texture
  11675. * @param depth defines the depth of the texture
  11676. * @param format defines the format of the texture
  11677. * @param generateMipMaps defines if the engine must generate mip levels
  11678. * @param invertY defines if data must be stored with Y axis inverted
  11679. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11680. * @param compression defines the compressed used (can be null)
  11681. * @param textureType defines the compressed used (can be null)
  11682. * @returns a new raw 3D texture (stored in an InternalTexture)
  11683. */
  11684. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11685. /**
  11686. * Update a raw 3D texture
  11687. * @param texture defines the texture to update
  11688. * @param data defines the data to store
  11689. * @param format defines the data format
  11690. * @param invertY defines if data must be stored with Y axis inverted
  11691. */
  11692. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11693. /**
  11694. * Update a raw 3D texture
  11695. * @param texture defines the texture to update
  11696. * @param data defines the data to store
  11697. * @param format defines the data format
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @param compression defines the used compression (can be null)
  11700. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11701. */
  11702. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11703. /**
  11704. * Creates a new raw 2D array texture
  11705. * @param data defines the data used to create the texture
  11706. * @param width defines the width of the texture
  11707. * @param height defines the height of the texture
  11708. * @param depth defines the number of layers of the texture
  11709. * @param format defines the format of the texture
  11710. * @param generateMipMaps defines if the engine must generate mip levels
  11711. * @param invertY defines if data must be stored with Y axis inverted
  11712. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11713. * @param compression defines the compressed used (can be null)
  11714. * @param textureType defines the compressed used (can be null)
  11715. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11716. */
  11717. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11718. /**
  11719. * Update a raw 2D array texture
  11720. * @param texture defines the texture to update
  11721. * @param data defines the data to store
  11722. * @param format defines the data format
  11723. * @param invertY defines if data must be stored with Y axis inverted
  11724. */
  11725. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11726. /**
  11727. * Update a raw 2D array texture
  11728. * @param texture defines the texture to update
  11729. * @param data defines the data to store
  11730. * @param format defines the data format
  11731. * @param invertY defines if data must be stored with Y axis inverted
  11732. * @param compression defines the used compression (can be null)
  11733. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11734. */
  11735. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11736. }
  11737. }
  11738. }
  11739. declare module "babylonjs/Materials/Textures/rawTexture" {
  11740. import { Texture } from "babylonjs/Materials/Textures/texture";
  11741. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11742. import { Nullable } from "babylonjs/types";
  11743. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11744. import { Scene } from "babylonjs/scene";
  11745. /**
  11746. * Raw texture can help creating a texture directly from an array of data.
  11747. * This can be super useful if you either get the data from an uncompressed source or
  11748. * if you wish to create your texture pixel by pixel.
  11749. */
  11750. export class RawTexture extends Texture {
  11751. /**
  11752. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11753. */
  11754. format: number;
  11755. /**
  11756. * Instantiates a new RawTexture.
  11757. * Raw texture can help creating a texture directly from an array of data.
  11758. * This can be super useful if you either get the data from an uncompressed source or
  11759. * if you wish to create your texture pixel by pixel.
  11760. * @param data define the array of data to use to create the texture
  11761. * @param width define the width of the texture
  11762. * @param height define the height of the texture
  11763. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11764. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11765. * @param generateMipMaps define whether mip maps should be generated or not
  11766. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11767. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11768. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11769. */
  11770. constructor(data: ArrayBufferView, width: number, height: number,
  11771. /**
  11772. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11773. */
  11774. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11775. /**
  11776. * Updates the texture underlying data.
  11777. * @param data Define the new data of the texture
  11778. */
  11779. update(data: ArrayBufferView): void;
  11780. /**
  11781. * Creates a luminance texture from some data.
  11782. * @param data Define the texture data
  11783. * @param width Define the width of the texture
  11784. * @param height Define the height of the texture
  11785. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11786. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11787. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11788. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11789. * @returns the luminance texture
  11790. */
  11791. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11792. /**
  11793. * Creates a luminance alpha texture from some data.
  11794. * @param data Define the texture data
  11795. * @param width Define the width of the texture
  11796. * @param height Define the height of the texture
  11797. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11798. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11799. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11800. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11801. * @returns the luminance alpha texture
  11802. */
  11803. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11804. /**
  11805. * Creates an alpha texture from some data.
  11806. * @param data Define the texture data
  11807. * @param width Define the width of the texture
  11808. * @param height Define the height of the texture
  11809. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11810. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11811. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11812. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11813. * @returns the alpha texture
  11814. */
  11815. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11816. /**
  11817. * Creates a RGB texture from some data.
  11818. * @param data Define the texture data
  11819. * @param width Define the width of the texture
  11820. * @param height Define the height of the texture
  11821. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11822. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11823. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11824. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11825. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11826. * @returns the RGB alpha texture
  11827. */
  11828. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11829. /**
  11830. * Creates a RGBA texture from some data.
  11831. * @param data Define the texture data
  11832. * @param width Define the width of the texture
  11833. * @param height Define the height of the texture
  11834. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11838. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11839. * @returns the RGBA texture
  11840. */
  11841. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11842. /**
  11843. * Creates a R texture from some data.
  11844. * @param data Define the texture data
  11845. * @param width Define the width of the texture
  11846. * @param height Define the height of the texture
  11847. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11848. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11849. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11850. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11851. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11852. * @returns the R texture
  11853. */
  11854. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11855. }
  11856. }
  11857. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11858. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11859. import { IndicesArray, DataArray } from "babylonjs/types";
  11860. module "babylonjs/Engines/thinEngine" {
  11861. interface ThinEngine {
  11862. /**
  11863. * Update a dynamic index buffer
  11864. * @param indexBuffer defines the target index buffer
  11865. * @param indices defines the data to update
  11866. * @param offset defines the offset in the target index buffer where update should start
  11867. */
  11868. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11869. /**
  11870. * Updates a dynamic vertex buffer.
  11871. * @param vertexBuffer the vertex buffer to update
  11872. * @param data the data used to update the vertex buffer
  11873. * @param byteOffset the byte offset of the data
  11874. * @param byteLength the byte length of the data
  11875. */
  11876. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11877. }
  11878. }
  11879. }
  11880. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11881. import { Scene } from "babylonjs/scene";
  11882. import { ISceneComponent } from "babylonjs/sceneComponent";
  11883. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11884. module "babylonjs/abstractScene" {
  11885. interface AbstractScene {
  11886. /**
  11887. * The list of procedural textures added to the scene
  11888. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11889. */
  11890. proceduralTextures: Array<ProceduralTexture>;
  11891. }
  11892. }
  11893. /**
  11894. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11895. * in a given scene.
  11896. */
  11897. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11898. /**
  11899. * The component name helpfull to identify the component in the list of scene components.
  11900. */
  11901. readonly name: string;
  11902. /**
  11903. * The scene the component belongs to.
  11904. */
  11905. scene: Scene;
  11906. /**
  11907. * Creates a new instance of the component for the given scene
  11908. * @param scene Defines the scene to register the component in
  11909. */
  11910. constructor(scene: Scene);
  11911. /**
  11912. * Registers the component in a given scene
  11913. */
  11914. register(): void;
  11915. /**
  11916. * Rebuilds the elements related to this component in case of
  11917. * context lost for instance.
  11918. */
  11919. rebuild(): void;
  11920. /**
  11921. * Disposes the component and the associated ressources.
  11922. */
  11923. dispose(): void;
  11924. private _beforeClear;
  11925. }
  11926. }
  11927. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11929. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11930. module "babylonjs/Engines/thinEngine" {
  11931. interface ThinEngine {
  11932. /**
  11933. * Creates a new render target cube texture
  11934. * @param size defines the size of the texture
  11935. * @param options defines the options used to create the texture
  11936. * @returns a new render target cube texture stored in an InternalTexture
  11937. */
  11938. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11939. }
  11940. }
  11941. }
  11942. declare module "babylonjs/Shaders/procedural.vertex" {
  11943. /** @hidden */
  11944. export var proceduralVertexShader: {
  11945. name: string;
  11946. shader: string;
  11947. };
  11948. }
  11949. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11950. import { Observable } from "babylonjs/Misc/observable";
  11951. import { Nullable } from "babylonjs/types";
  11952. import { Scene } from "babylonjs/scene";
  11953. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11954. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11955. import { Effect } from "babylonjs/Materials/effect";
  11956. import { Texture } from "babylonjs/Materials/Textures/texture";
  11957. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11958. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11959. import "babylonjs/Shaders/procedural.vertex";
  11960. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11961. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11962. /**
  11963. * 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.
  11964. * This is the base class of any Procedural texture and contains most of the shareable code.
  11965. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11966. */
  11967. export class ProceduralTexture extends Texture {
  11968. /**
  11969. * Define if the texture is enabled or not (disabled texture will not render)
  11970. */
  11971. isEnabled: boolean;
  11972. /**
  11973. * Define if the texture must be cleared before rendering (default is true)
  11974. */
  11975. autoClear: boolean;
  11976. /**
  11977. * Callback called when the texture is generated
  11978. */
  11979. onGenerated: () => void;
  11980. /**
  11981. * Event raised when the texture is generated
  11982. */
  11983. onGeneratedObservable: Observable<ProceduralTexture>;
  11984. /**
  11985. * Event raised before the texture is generated
  11986. */
  11987. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11988. /**
  11989. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11990. */
  11991. nodeMaterialSource: Nullable<NodeMaterial>;
  11992. /** @hidden */
  11993. _generateMipMaps: boolean;
  11994. /** @hidden **/
  11995. _effect: Effect;
  11996. /** @hidden */
  11997. _textures: {
  11998. [key: string]: Texture;
  11999. };
  12000. /** @hidden */
  12001. protected _fallbackTexture: Nullable<Texture>;
  12002. private _size;
  12003. private _currentRefreshId;
  12004. private _frameId;
  12005. private _refreshRate;
  12006. private _vertexBuffers;
  12007. private _indexBuffer;
  12008. private _uniforms;
  12009. private _samplers;
  12010. private _fragment;
  12011. private _floats;
  12012. private _ints;
  12013. private _floatsArrays;
  12014. private _colors3;
  12015. private _colors4;
  12016. private _vectors2;
  12017. private _vectors3;
  12018. private _matrices;
  12019. private _fallbackTextureUsed;
  12020. private _fullEngine;
  12021. private _cachedDefines;
  12022. private _contentUpdateId;
  12023. private _contentData;
  12024. /**
  12025. * Instantiates a new procedural texture.
  12026. * 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.
  12027. * This is the base class of any Procedural texture and contains most of the shareable code.
  12028. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12029. * @param name Define the name of the texture
  12030. * @param size Define the size of the texture to create
  12031. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12032. * @param scene Define the scene the texture belongs to
  12033. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12034. * @param generateMipMaps Define if the texture should creates mip maps or not
  12035. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12036. */
  12037. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12038. /**
  12039. * The effect that is created when initializing the post process.
  12040. * @returns The created effect corresponding the the postprocess.
  12041. */
  12042. getEffect(): Effect;
  12043. /**
  12044. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12045. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12046. */
  12047. getContent(): Nullable<ArrayBufferView>;
  12048. private _createIndexBuffer;
  12049. /** @hidden */
  12050. _rebuild(): void;
  12051. /**
  12052. * Resets the texture in order to recreate its associated resources.
  12053. * This can be called in case of context loss
  12054. */
  12055. reset(): void;
  12056. protected _getDefines(): string;
  12057. /**
  12058. * Is the texture ready to be used ? (rendered at least once)
  12059. * @returns true if ready, otherwise, false.
  12060. */
  12061. isReady(): boolean;
  12062. /**
  12063. * Resets the refresh counter of the texture and start bak from scratch.
  12064. * Could be useful to regenerate the texture if it is setup to render only once.
  12065. */
  12066. resetRefreshCounter(): void;
  12067. /**
  12068. * Set the fragment shader to use in order to render the texture.
  12069. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12070. */
  12071. setFragment(fragment: any): void;
  12072. /**
  12073. * Define the refresh rate of the texture or the rendering frequency.
  12074. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12075. */
  12076. get refreshRate(): number;
  12077. set refreshRate(value: number);
  12078. /** @hidden */
  12079. _shouldRender(): boolean;
  12080. /**
  12081. * Get the size the texture is rendering at.
  12082. * @returns the size (on cube texture it is always squared)
  12083. */
  12084. getRenderSize(): RenderTargetTextureSize;
  12085. /**
  12086. * Resize the texture to new value.
  12087. * @param size Define the new size the texture should have
  12088. * @param generateMipMaps Define whether the new texture should create mip maps
  12089. */
  12090. resize(size: number, generateMipMaps: boolean): void;
  12091. private _checkUniform;
  12092. /**
  12093. * Set a texture in the shader program used to render.
  12094. * @param name Define the name of the uniform samplers as defined in the shader
  12095. * @param texture Define the texture to bind to this sampler
  12096. * @return the texture itself allowing "fluent" like uniform updates
  12097. */
  12098. setTexture(name: string, texture: Texture): ProceduralTexture;
  12099. /**
  12100. * Set a float in the shader.
  12101. * @param name Define the name of the uniform as defined in the shader
  12102. * @param value Define the value to give to the uniform
  12103. * @return the texture itself allowing "fluent" like uniform updates
  12104. */
  12105. setFloat(name: string, value: number): ProceduralTexture;
  12106. /**
  12107. * Set a int in the shader.
  12108. * @param name Define the name of the uniform as defined in the shader
  12109. * @param value Define the value to give to the uniform
  12110. * @return the texture itself allowing "fluent" like uniform updates
  12111. */
  12112. setInt(name: string, value: number): ProceduralTexture;
  12113. /**
  12114. * Set an array of floats in the shader.
  12115. * @param name Define the name of the uniform as defined in the shader
  12116. * @param value Define the value to give to the uniform
  12117. * @return the texture itself allowing "fluent" like uniform updates
  12118. */
  12119. setFloats(name: string, value: number[]): ProceduralTexture;
  12120. /**
  12121. * Set a vec3 in the shader from a Color3.
  12122. * @param name Define the name of the uniform as defined in the shader
  12123. * @param value Define the value to give to the uniform
  12124. * @return the texture itself allowing "fluent" like uniform updates
  12125. */
  12126. setColor3(name: string, value: Color3): ProceduralTexture;
  12127. /**
  12128. * Set a vec4 in the shader from a Color4.
  12129. * @param name Define the name of the uniform as defined in the shader
  12130. * @param value Define the value to give to the uniform
  12131. * @return the texture itself allowing "fluent" like uniform updates
  12132. */
  12133. setColor4(name: string, value: Color4): ProceduralTexture;
  12134. /**
  12135. * Set a vec2 in the shader from a Vector2.
  12136. * @param name Define the name of the uniform as defined in the shader
  12137. * @param value Define the value to give to the uniform
  12138. * @return the texture itself allowing "fluent" like uniform updates
  12139. */
  12140. setVector2(name: string, value: Vector2): ProceduralTexture;
  12141. /**
  12142. * Set a vec3 in the shader from a Vector3.
  12143. * @param name Define the name of the uniform as defined in the shader
  12144. * @param value Define the value to give to the uniform
  12145. * @return the texture itself allowing "fluent" like uniform updates
  12146. */
  12147. setVector3(name: string, value: Vector3): ProceduralTexture;
  12148. /**
  12149. * Set a mat4 in the shader from a MAtrix.
  12150. * @param name Define the name of the uniform as defined in the shader
  12151. * @param value Define the value to give to the uniform
  12152. * @return the texture itself allowing "fluent" like uniform updates
  12153. */
  12154. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12155. /**
  12156. * Render the texture to its associated render target.
  12157. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12158. */
  12159. render(useCameraPostProcess?: boolean): void;
  12160. /**
  12161. * Clone the texture.
  12162. * @returns the cloned texture
  12163. */
  12164. clone(): ProceduralTexture;
  12165. /**
  12166. * Dispose the texture and release its asoociated resources.
  12167. */
  12168. dispose(): void;
  12169. }
  12170. }
  12171. declare module "babylonjs/Particles/baseParticleSystem" {
  12172. import { Nullable } from "babylonjs/types";
  12173. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12175. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12176. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12177. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12179. import { Color4 } from "babylonjs/Maths/math.color";
  12180. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12181. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12182. import { Animation } from "babylonjs/Animations/animation";
  12183. import { Scene } from "babylonjs/scene";
  12184. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12185. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12186. /**
  12187. * This represents the base class for particle system in Babylon.
  12188. * 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.
  12189. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12190. * @example https://doc.babylonjs.com/babylon101/particles
  12191. */
  12192. export class BaseParticleSystem {
  12193. /**
  12194. * Source color is added to the destination color without alpha affecting the result
  12195. */
  12196. static BLENDMODE_ONEONE: number;
  12197. /**
  12198. * Blend current color and particle color using particle’s alpha
  12199. */
  12200. static BLENDMODE_STANDARD: number;
  12201. /**
  12202. * Add current color and particle color multiplied by particle’s alpha
  12203. */
  12204. static BLENDMODE_ADD: number;
  12205. /**
  12206. * Multiply current color with particle color
  12207. */
  12208. static BLENDMODE_MULTIPLY: number;
  12209. /**
  12210. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12211. */
  12212. static BLENDMODE_MULTIPLYADD: number;
  12213. /**
  12214. * List of animations used by the particle system.
  12215. */
  12216. animations: Animation[];
  12217. /**
  12218. * Gets or sets the unique id of the particle system
  12219. */
  12220. uniqueId: number;
  12221. /**
  12222. * The id of the Particle system.
  12223. */
  12224. id: string;
  12225. /**
  12226. * The friendly name of the Particle system.
  12227. */
  12228. name: string;
  12229. /**
  12230. * Snippet ID if the particle system was created from the snippet server
  12231. */
  12232. snippetId: string;
  12233. /**
  12234. * The rendering group used by the Particle system to chose when to render.
  12235. */
  12236. renderingGroupId: number;
  12237. /**
  12238. * The emitter represents the Mesh or position we are attaching the particle system to.
  12239. */
  12240. emitter: Nullable<AbstractMesh | Vector3>;
  12241. /**
  12242. * The maximum number of particles to emit per frame
  12243. */
  12244. emitRate: number;
  12245. /**
  12246. * If you want to launch only a few particles at once, that can be done, as well.
  12247. */
  12248. manualEmitCount: number;
  12249. /**
  12250. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12251. */
  12252. updateSpeed: number;
  12253. /**
  12254. * The amount of time the particle system is running (depends of the overall update speed).
  12255. */
  12256. targetStopDuration: number;
  12257. /**
  12258. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12259. */
  12260. disposeOnStop: boolean;
  12261. /**
  12262. * Minimum power of emitting particles.
  12263. */
  12264. minEmitPower: number;
  12265. /**
  12266. * Maximum power of emitting particles.
  12267. */
  12268. maxEmitPower: number;
  12269. /**
  12270. * Minimum life time of emitting particles.
  12271. */
  12272. minLifeTime: number;
  12273. /**
  12274. * Maximum life time of emitting particles.
  12275. */
  12276. maxLifeTime: number;
  12277. /**
  12278. * Minimum Size of emitting particles.
  12279. */
  12280. minSize: number;
  12281. /**
  12282. * Maximum Size of emitting particles.
  12283. */
  12284. maxSize: number;
  12285. /**
  12286. * Minimum scale of emitting particles on X axis.
  12287. */
  12288. minScaleX: number;
  12289. /**
  12290. * Maximum scale of emitting particles on X axis.
  12291. */
  12292. maxScaleX: number;
  12293. /**
  12294. * Minimum scale of emitting particles on Y axis.
  12295. */
  12296. minScaleY: number;
  12297. /**
  12298. * Maximum scale of emitting particles on Y axis.
  12299. */
  12300. maxScaleY: number;
  12301. /**
  12302. * Gets or sets the minimal initial rotation in radians.
  12303. */
  12304. minInitialRotation: number;
  12305. /**
  12306. * Gets or sets the maximal initial rotation in radians.
  12307. */
  12308. maxInitialRotation: number;
  12309. /**
  12310. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12311. */
  12312. minAngularSpeed: number;
  12313. /**
  12314. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12315. */
  12316. maxAngularSpeed: number;
  12317. /**
  12318. * The texture used to render each particle. (this can be a spritesheet)
  12319. */
  12320. particleTexture: Nullable<BaseTexture>;
  12321. /**
  12322. * The layer mask we are rendering the particles through.
  12323. */
  12324. layerMask: number;
  12325. /**
  12326. * This can help using your own shader to render the particle system.
  12327. * The according effect will be created
  12328. */
  12329. customShader: any;
  12330. /**
  12331. * By default particle system starts as soon as they are created. This prevents the
  12332. * automatic start to happen and let you decide when to start emitting particles.
  12333. */
  12334. preventAutoStart: boolean;
  12335. private _noiseTexture;
  12336. /**
  12337. * Gets or sets a texture used to add random noise to particle positions
  12338. */
  12339. get noiseTexture(): Nullable<ProceduralTexture>;
  12340. set noiseTexture(value: Nullable<ProceduralTexture>);
  12341. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12342. noiseStrength: Vector3;
  12343. /**
  12344. * Callback triggered when the particle animation is ending.
  12345. */
  12346. onAnimationEnd: Nullable<() => void>;
  12347. /**
  12348. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12349. */
  12350. blendMode: number;
  12351. /**
  12352. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12353. * to override the particles.
  12354. */
  12355. forceDepthWrite: boolean;
  12356. /** 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 */
  12357. preWarmCycles: number;
  12358. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12359. preWarmStepOffset: number;
  12360. /**
  12361. * 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)
  12362. */
  12363. spriteCellChangeSpeed: number;
  12364. /**
  12365. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12366. */
  12367. startSpriteCellID: number;
  12368. /**
  12369. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12370. */
  12371. endSpriteCellID: number;
  12372. /**
  12373. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12374. */
  12375. spriteCellWidth: number;
  12376. /**
  12377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12378. */
  12379. spriteCellHeight: number;
  12380. /**
  12381. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12382. */
  12383. spriteRandomStartCell: boolean;
  12384. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12385. translationPivot: Vector2;
  12386. /** @hidden */
  12387. protected _isAnimationSheetEnabled: boolean;
  12388. /**
  12389. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12390. */
  12391. beginAnimationOnStart: boolean;
  12392. /**
  12393. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12394. */
  12395. beginAnimationFrom: number;
  12396. /**
  12397. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12398. */
  12399. beginAnimationTo: number;
  12400. /**
  12401. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12402. */
  12403. beginAnimationLoop: boolean;
  12404. /**
  12405. * Gets or sets a world offset applied to all particles
  12406. */
  12407. worldOffset: Vector3;
  12408. /**
  12409. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12410. */
  12411. get isAnimationSheetEnabled(): boolean;
  12412. set isAnimationSheetEnabled(value: boolean);
  12413. /**
  12414. * Get hosting scene
  12415. * @returns the scene
  12416. */
  12417. getScene(): Nullable<Scene>;
  12418. /**
  12419. * You can use gravity if you want to give an orientation to your particles.
  12420. */
  12421. gravity: Vector3;
  12422. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12423. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12424. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12425. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12426. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12427. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12428. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12429. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12430. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12431. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12432. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12433. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12434. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12435. /**
  12436. * Defines the delay in milliseconds before starting the system (0 by default)
  12437. */
  12438. startDelay: number;
  12439. /**
  12440. * Gets the current list of drag gradients.
  12441. * You must use addDragGradient and removeDragGradient to udpate this list
  12442. * @returns the list of drag gradients
  12443. */
  12444. getDragGradients(): Nullable<Array<FactorGradient>>;
  12445. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12446. limitVelocityDamping: number;
  12447. /**
  12448. * Gets the current list of limit velocity gradients.
  12449. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12450. * @returns the list of limit velocity gradients
  12451. */
  12452. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12453. /**
  12454. * Gets the current list of color gradients.
  12455. * You must use addColorGradient and removeColorGradient to udpate this list
  12456. * @returns the list of color gradients
  12457. */
  12458. getColorGradients(): Nullable<Array<ColorGradient>>;
  12459. /**
  12460. * Gets the current list of size gradients.
  12461. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12462. * @returns the list of size gradients
  12463. */
  12464. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12465. /**
  12466. * Gets the current list of color remap gradients.
  12467. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12468. * @returns the list of color remap gradients
  12469. */
  12470. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12471. /**
  12472. * Gets the current list of alpha remap gradients.
  12473. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12474. * @returns the list of alpha remap gradients
  12475. */
  12476. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12477. /**
  12478. * Gets the current list of life time gradients.
  12479. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12480. * @returns the list of life time gradients
  12481. */
  12482. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12483. /**
  12484. * Gets the current list of angular speed gradients.
  12485. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12486. * @returns the list of angular speed gradients
  12487. */
  12488. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12489. /**
  12490. * Gets the current list of velocity gradients.
  12491. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12492. * @returns the list of velocity gradients
  12493. */
  12494. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12495. /**
  12496. * Gets the current list of start size gradients.
  12497. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12498. * @returns the list of start size gradients
  12499. */
  12500. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12501. /**
  12502. * Gets the current list of emit rate gradients.
  12503. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12504. * @returns the list of emit rate gradients
  12505. */
  12506. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12507. /**
  12508. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12509. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12510. */
  12511. get direction1(): Vector3;
  12512. set direction1(value: Vector3);
  12513. /**
  12514. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12515. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12516. */
  12517. get direction2(): Vector3;
  12518. set direction2(value: Vector3);
  12519. /**
  12520. * 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.
  12521. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12522. */
  12523. get minEmitBox(): Vector3;
  12524. set minEmitBox(value: Vector3);
  12525. /**
  12526. * 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.
  12527. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12528. */
  12529. get maxEmitBox(): Vector3;
  12530. set maxEmitBox(value: Vector3);
  12531. /**
  12532. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12533. */
  12534. color1: Color4;
  12535. /**
  12536. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12537. */
  12538. color2: Color4;
  12539. /**
  12540. * Color the particle will have at the end of its lifetime
  12541. */
  12542. colorDead: Color4;
  12543. /**
  12544. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12545. */
  12546. textureMask: Color4;
  12547. /**
  12548. * The particle emitter type defines the emitter used by the particle system.
  12549. * It can be for example box, sphere, or cone...
  12550. */
  12551. particleEmitterType: IParticleEmitterType;
  12552. /** @hidden */
  12553. _isSubEmitter: boolean;
  12554. /**
  12555. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12556. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12557. */
  12558. billboardMode: number;
  12559. protected _isBillboardBased: boolean;
  12560. /**
  12561. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12562. */
  12563. get isBillboardBased(): boolean;
  12564. set isBillboardBased(value: boolean);
  12565. /**
  12566. * The scene the particle system belongs to.
  12567. */
  12568. protected _scene: Nullable<Scene>;
  12569. /**
  12570. * The engine the particle system belongs to.
  12571. */
  12572. protected _engine: ThinEngine;
  12573. /**
  12574. * Local cache of defines for image processing.
  12575. */
  12576. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12577. /**
  12578. * Default configuration related to image processing available in the standard Material.
  12579. */
  12580. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12581. /**
  12582. * Gets the image processing configuration used either in this material.
  12583. */
  12584. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12585. /**
  12586. * Sets the Default image processing configuration used either in the this material.
  12587. *
  12588. * If sets to null, the scene one is in use.
  12589. */
  12590. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12591. /**
  12592. * Attaches a new image processing configuration to the Standard Material.
  12593. * @param configuration
  12594. */
  12595. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12596. /** @hidden */
  12597. protected _reset(): void;
  12598. /** @hidden */
  12599. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12600. /**
  12601. * Instantiates a particle system.
  12602. * 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.
  12603. * @param name The name of the particle system
  12604. */
  12605. constructor(name: string);
  12606. /**
  12607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12610. * @returns the emitter
  12611. */
  12612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12613. /**
  12614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12615. * @param radius The radius of the hemisphere to emit from
  12616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12617. * @returns the emitter
  12618. */
  12619. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12620. /**
  12621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12622. * @param radius The radius of the sphere to emit from
  12623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12624. * @returns the emitter
  12625. */
  12626. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12627. /**
  12628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12629. * @param radius The radius of the sphere to emit from
  12630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12632. * @returns the emitter
  12633. */
  12634. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12635. /**
  12636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12637. * @param radius The radius of the emission cylinder
  12638. * @param height The height of the emission cylinder
  12639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12641. * @returns the emitter
  12642. */
  12643. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12644. /**
  12645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12646. * @param radius The radius of the cylinder to emit from
  12647. * @param height The height of the emission cylinder
  12648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12651. * @returns the emitter
  12652. */
  12653. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12654. /**
  12655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12656. * @param radius The radius of the cone to emit from
  12657. * @param angle The base angle of the cone
  12658. * @returns the emitter
  12659. */
  12660. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12661. /**
  12662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12667. * @returns the emitter
  12668. */
  12669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12670. }
  12671. }
  12672. declare module "babylonjs/Particles/subEmitter" {
  12673. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12674. import { Scene } from "babylonjs/scene";
  12675. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12676. /**
  12677. * Type of sub emitter
  12678. */
  12679. export enum SubEmitterType {
  12680. /**
  12681. * Attached to the particle over it's lifetime
  12682. */
  12683. ATTACHED = 0,
  12684. /**
  12685. * Created when the particle dies
  12686. */
  12687. END = 1
  12688. }
  12689. /**
  12690. * Sub emitter class used to emit particles from an existing particle
  12691. */
  12692. export class SubEmitter {
  12693. /**
  12694. * the particle system to be used by the sub emitter
  12695. */
  12696. particleSystem: ParticleSystem;
  12697. /**
  12698. * Type of the submitter (Default: END)
  12699. */
  12700. type: SubEmitterType;
  12701. /**
  12702. * 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)
  12703. * Note: This only is supported when using an emitter of type Mesh
  12704. */
  12705. inheritDirection: boolean;
  12706. /**
  12707. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12708. */
  12709. inheritedVelocityAmount: number;
  12710. /**
  12711. * Creates a sub emitter
  12712. * @param particleSystem the particle system to be used by the sub emitter
  12713. */
  12714. constructor(
  12715. /**
  12716. * the particle system to be used by the sub emitter
  12717. */
  12718. particleSystem: ParticleSystem);
  12719. /**
  12720. * Clones the sub emitter
  12721. * @returns the cloned sub emitter
  12722. */
  12723. clone(): SubEmitter;
  12724. /**
  12725. * Serialize current object to a JSON object
  12726. * @returns the serialized object
  12727. */
  12728. serialize(): any;
  12729. /** @hidden */
  12730. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12731. /**
  12732. * Creates a new SubEmitter from a serialized JSON version
  12733. * @param serializationObject defines the JSON object to read from
  12734. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12735. * @param rootUrl defines the rootUrl for data loading
  12736. * @returns a new SubEmitter
  12737. */
  12738. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12739. /** Release associated resources */
  12740. dispose(): void;
  12741. }
  12742. }
  12743. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12744. /** @hidden */
  12745. export var imageProcessingDeclaration: {
  12746. name: string;
  12747. shader: string;
  12748. };
  12749. }
  12750. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12751. /** @hidden */
  12752. export var imageProcessingFunctions: {
  12753. name: string;
  12754. shader: string;
  12755. };
  12756. }
  12757. declare module "babylonjs/Shaders/particles.fragment" {
  12758. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12759. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12760. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12761. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12762. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12763. /** @hidden */
  12764. export var particlesPixelShader: {
  12765. name: string;
  12766. shader: string;
  12767. };
  12768. }
  12769. declare module "babylonjs/Shaders/particles.vertex" {
  12770. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12771. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12772. /** @hidden */
  12773. export var particlesVertexShader: {
  12774. name: string;
  12775. shader: string;
  12776. };
  12777. }
  12778. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12779. import { Nullable } from "babylonjs/types";
  12780. import { Plane } from "babylonjs/Maths/math";
  12781. /**
  12782. * Interface used to define entities containing multiple clip planes
  12783. */
  12784. export interface IClipPlanesHolder {
  12785. /**
  12786. * Gets or sets the active clipplane 1
  12787. */
  12788. clipPlane: Nullable<Plane>;
  12789. /**
  12790. * Gets or sets the active clipplane 2
  12791. */
  12792. clipPlane2: Nullable<Plane>;
  12793. /**
  12794. * Gets or sets the active clipplane 3
  12795. */
  12796. clipPlane3: Nullable<Plane>;
  12797. /**
  12798. * Gets or sets the active clipplane 4
  12799. */
  12800. clipPlane4: Nullable<Plane>;
  12801. /**
  12802. * Gets or sets the active clipplane 5
  12803. */
  12804. clipPlane5: Nullable<Plane>;
  12805. /**
  12806. * Gets or sets the active clipplane 6
  12807. */
  12808. clipPlane6: Nullable<Plane>;
  12809. }
  12810. }
  12811. declare module "babylonjs/Materials/thinMaterialHelper" {
  12812. import { Effect } from "babylonjs/Materials/effect";
  12813. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12814. /**
  12815. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12816. *
  12817. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12818. *
  12819. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12820. */
  12821. export class ThinMaterialHelper {
  12822. /**
  12823. * Binds the clip plane information from the holder to the effect.
  12824. * @param effect The effect we are binding the data to
  12825. * @param holder The entity containing the clip plane information
  12826. */
  12827. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12828. }
  12829. }
  12830. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12831. module "babylonjs/Engines/thinEngine" {
  12832. interface ThinEngine {
  12833. /**
  12834. * Sets alpha constants used by some alpha blending modes
  12835. * @param r defines the red component
  12836. * @param g defines the green component
  12837. * @param b defines the blue component
  12838. * @param a defines the alpha component
  12839. */
  12840. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12841. /**
  12842. * Sets the current alpha mode
  12843. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12844. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12845. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12846. */
  12847. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12848. /**
  12849. * Gets the current alpha mode
  12850. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12851. * @returns the current alpha mode
  12852. */
  12853. getAlphaMode(): number;
  12854. /**
  12855. * Sets the current alpha equation
  12856. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12857. */
  12858. setAlphaEquation(equation: number): void;
  12859. /**
  12860. * Gets the current alpha equation.
  12861. * @returns the current alpha equation
  12862. */
  12863. getAlphaEquation(): number;
  12864. }
  12865. }
  12866. }
  12867. declare module "babylonjs/Particles/particleSystem" {
  12868. import { Nullable } from "babylonjs/types";
  12869. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12870. import { Observable } from "babylonjs/Misc/observable";
  12871. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12872. import { Effect } from "babylonjs/Materials/effect";
  12873. import { IDisposable } from "babylonjs/scene";
  12874. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12875. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12876. import { Particle } from "babylonjs/Particles/particle";
  12877. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12878. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12879. import "babylonjs/Shaders/particles.fragment";
  12880. import "babylonjs/Shaders/particles.vertex";
  12881. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12882. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12883. import "babylonjs/Engines/Extensions/engine.alpha";
  12884. import { Scene } from "babylonjs/scene";
  12885. /**
  12886. * This represents a particle system in Babylon.
  12887. * 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.
  12888. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12889. * @example https://doc.babylonjs.com/babylon101/particles
  12890. */
  12891. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12892. /**
  12893. * Billboard mode will only apply to Y axis
  12894. */
  12895. static readonly BILLBOARDMODE_Y: number;
  12896. /**
  12897. * Billboard mode will apply to all axes
  12898. */
  12899. static readonly BILLBOARDMODE_ALL: number;
  12900. /**
  12901. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12902. */
  12903. static readonly BILLBOARDMODE_STRETCHED: number;
  12904. /**
  12905. * This function can be defined to provide custom update for active particles.
  12906. * This function will be called instead of regular update (age, position, color, etc.).
  12907. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12908. */
  12909. updateFunction: (particles: Particle[]) => void;
  12910. private _emitterWorldMatrix;
  12911. /**
  12912. * This function can be defined to specify initial direction for every new particle.
  12913. * It by default use the emitterType defined function
  12914. */
  12915. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12916. /**
  12917. * This function can be defined to specify initial position for every new particle.
  12918. * It by default use the emitterType defined function
  12919. */
  12920. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12921. /**
  12922. * @hidden
  12923. */
  12924. _inheritedVelocityOffset: Vector3;
  12925. /**
  12926. * An event triggered when the system is disposed
  12927. */
  12928. onDisposeObservable: Observable<IParticleSystem>;
  12929. private _onDisposeObserver;
  12930. /**
  12931. * Sets a callback that will be triggered when the system is disposed
  12932. */
  12933. set onDispose(callback: () => void);
  12934. private _particles;
  12935. private _epsilon;
  12936. private _capacity;
  12937. private _stockParticles;
  12938. private _newPartsExcess;
  12939. private _vertexData;
  12940. private _vertexBuffer;
  12941. private _vertexBuffers;
  12942. private _spriteBuffer;
  12943. private _indexBuffer;
  12944. private _effect;
  12945. private _customEffect;
  12946. private _cachedDefines;
  12947. private _scaledColorStep;
  12948. private _colorDiff;
  12949. private _scaledDirection;
  12950. private _scaledGravity;
  12951. private _currentRenderId;
  12952. private _alive;
  12953. private _useInstancing;
  12954. private _started;
  12955. private _stopped;
  12956. private _actualFrame;
  12957. private _scaledUpdateSpeed;
  12958. private _vertexBufferSize;
  12959. /** @hidden */
  12960. _currentEmitRateGradient: Nullable<FactorGradient>;
  12961. /** @hidden */
  12962. _currentEmitRate1: number;
  12963. /** @hidden */
  12964. _currentEmitRate2: number;
  12965. /** @hidden */
  12966. _currentStartSizeGradient: Nullable<FactorGradient>;
  12967. /** @hidden */
  12968. _currentStartSize1: number;
  12969. /** @hidden */
  12970. _currentStartSize2: number;
  12971. private readonly _rawTextureWidth;
  12972. private _rampGradientsTexture;
  12973. private _useRampGradients;
  12974. /** Gets or sets a matrix to use to compute projection */
  12975. defaultProjectionMatrix: Matrix;
  12976. /** Gets or sets a matrix to use to compute view */
  12977. defaultViewMatrix: Matrix;
  12978. /** Gets or sets a boolean indicating that ramp gradients must be used
  12979. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12980. */
  12981. get useRampGradients(): boolean;
  12982. set useRampGradients(value: boolean);
  12983. /**
  12984. * 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.
  12985. * 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: [])
  12986. */
  12987. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12988. private _subEmitters;
  12989. /**
  12990. * @hidden
  12991. * If the particle systems emitter should be disposed when the particle system is disposed
  12992. */
  12993. _disposeEmitterOnDispose: boolean;
  12994. /**
  12995. * The current active Sub-systems, this property is used by the root particle system only.
  12996. */
  12997. activeSubSystems: Array<ParticleSystem>;
  12998. /**
  12999. * Specifies if the particles are updated in emitter local space or world space
  13000. */
  13001. isLocal: boolean;
  13002. private _rootParticleSystem;
  13003. /**
  13004. * Gets the current list of active particles
  13005. */
  13006. get particles(): Particle[];
  13007. /**
  13008. * Gets the number of particles active at the same time.
  13009. * @returns The number of active particles.
  13010. */
  13011. getActiveCount(): number;
  13012. /**
  13013. * Returns the string "ParticleSystem"
  13014. * @returns a string containing the class name
  13015. */
  13016. getClassName(): string;
  13017. /**
  13018. * Gets a boolean indicating that the system is stopping
  13019. * @returns true if the system is currently stopping
  13020. */
  13021. isStopping(): boolean;
  13022. /**
  13023. * Gets the custom effect used to render the particles
  13024. * @param blendMode Blend mode for which the effect should be retrieved
  13025. * @returns The effect
  13026. */
  13027. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13028. /**
  13029. * Sets the custom effect used to render the particles
  13030. * @param effect The effect to set
  13031. * @param blendMode Blend mode for which the effect should be set
  13032. */
  13033. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13034. /** @hidden */
  13035. private _onBeforeDrawParticlesObservable;
  13036. /**
  13037. * Observable that will be called just before the particles are drawn
  13038. */
  13039. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13040. /**
  13041. * Gets the name of the particle vertex shader
  13042. */
  13043. get vertexShaderName(): string;
  13044. /**
  13045. * Instantiates a particle system.
  13046. * 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.
  13047. * @param name The name of the particle system
  13048. * @param capacity The max number of particles alive at the same time
  13049. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13050. * @param customEffect a custom effect used to change the way particles are rendered by default
  13051. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13052. * @param epsilon Offset used to render the particles
  13053. */
  13054. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13055. private _addFactorGradient;
  13056. private _removeFactorGradient;
  13057. /**
  13058. * Adds a new life time gradient
  13059. * @param gradient defines the gradient to use (between 0 and 1)
  13060. * @param factor defines the life time factor to affect to the specified gradient
  13061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13062. * @returns the current particle system
  13063. */
  13064. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13065. /**
  13066. * Remove a specific life time gradient
  13067. * @param gradient defines the gradient to remove
  13068. * @returns the current particle system
  13069. */
  13070. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13071. /**
  13072. * Adds a new size gradient
  13073. * @param gradient defines the gradient to use (between 0 and 1)
  13074. * @param factor defines the size factor to affect to the specified gradient
  13075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13076. * @returns the current particle system
  13077. */
  13078. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13079. /**
  13080. * Remove a specific size gradient
  13081. * @param gradient defines the gradient to remove
  13082. * @returns the current particle system
  13083. */
  13084. removeSizeGradient(gradient: number): IParticleSystem;
  13085. /**
  13086. * Adds a new color remap gradient
  13087. * @param gradient defines the gradient to use (between 0 and 1)
  13088. * @param min defines the color remap minimal range
  13089. * @param max defines the color remap maximal range
  13090. * @returns the current particle system
  13091. */
  13092. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13093. /**
  13094. * Remove a specific color remap gradient
  13095. * @param gradient defines the gradient to remove
  13096. * @returns the current particle system
  13097. */
  13098. removeColorRemapGradient(gradient: number): IParticleSystem;
  13099. /**
  13100. * Adds a new alpha remap gradient
  13101. * @param gradient defines the gradient to use (between 0 and 1)
  13102. * @param min defines the alpha remap minimal range
  13103. * @param max defines the alpha remap maximal range
  13104. * @returns the current particle system
  13105. */
  13106. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13107. /**
  13108. * Remove a specific alpha remap gradient
  13109. * @param gradient defines the gradient to remove
  13110. * @returns the current particle system
  13111. */
  13112. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13113. /**
  13114. * Adds a new angular speed gradient
  13115. * @param gradient defines the gradient to use (between 0 and 1)
  13116. * @param factor defines the angular speed to affect to the specified gradient
  13117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13118. * @returns the current particle system
  13119. */
  13120. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13121. /**
  13122. * Remove a specific angular speed gradient
  13123. * @param gradient defines the gradient to remove
  13124. * @returns the current particle system
  13125. */
  13126. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13127. /**
  13128. * Adds a new velocity gradient
  13129. * @param gradient defines the gradient to use (between 0 and 1)
  13130. * @param factor defines the velocity to affect to the specified gradient
  13131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13132. * @returns the current particle system
  13133. */
  13134. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13135. /**
  13136. * Remove a specific velocity gradient
  13137. * @param gradient defines the gradient to remove
  13138. * @returns the current particle system
  13139. */
  13140. removeVelocityGradient(gradient: number): IParticleSystem;
  13141. /**
  13142. * Adds a new limit velocity gradient
  13143. * @param gradient defines the gradient to use (between 0 and 1)
  13144. * @param factor defines the limit velocity value to affect to the specified gradient
  13145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13146. * @returns the current particle system
  13147. */
  13148. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13149. /**
  13150. * Remove a specific limit velocity gradient
  13151. * @param gradient defines the gradient to remove
  13152. * @returns the current particle system
  13153. */
  13154. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13155. /**
  13156. * Adds a new drag gradient
  13157. * @param gradient defines the gradient to use (between 0 and 1)
  13158. * @param factor defines the drag value to affect to the specified gradient
  13159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13160. * @returns the current particle system
  13161. */
  13162. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13163. /**
  13164. * Remove a specific drag gradient
  13165. * @param gradient defines the gradient to remove
  13166. * @returns the current particle system
  13167. */
  13168. removeDragGradient(gradient: number): IParticleSystem;
  13169. /**
  13170. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13171. * @param gradient defines the gradient to use (between 0 and 1)
  13172. * @param factor defines the emit rate value to affect to the specified gradient
  13173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13174. * @returns the current particle system
  13175. */
  13176. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13177. /**
  13178. * Remove a specific emit rate gradient
  13179. * @param gradient defines the gradient to remove
  13180. * @returns the current particle system
  13181. */
  13182. removeEmitRateGradient(gradient: number): IParticleSystem;
  13183. /**
  13184. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13185. * @param gradient defines the gradient to use (between 0 and 1)
  13186. * @param factor defines the start size value to affect to the specified gradient
  13187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13188. * @returns the current particle system
  13189. */
  13190. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13191. /**
  13192. * Remove a specific start size gradient
  13193. * @param gradient defines the gradient to remove
  13194. * @returns the current particle system
  13195. */
  13196. removeStartSizeGradient(gradient: number): IParticleSystem;
  13197. private _createRampGradientTexture;
  13198. /**
  13199. * Gets the current list of ramp gradients.
  13200. * You must use addRampGradient and removeRampGradient to udpate this list
  13201. * @returns the list of ramp gradients
  13202. */
  13203. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13204. /** Force the system to rebuild all gradients that need to be resync */
  13205. forceRefreshGradients(): void;
  13206. private _syncRampGradientTexture;
  13207. /**
  13208. * Adds a new ramp gradient used to remap particle colors
  13209. * @param gradient defines the gradient to use (between 0 and 1)
  13210. * @param color defines the color to affect to the specified gradient
  13211. * @returns the current particle system
  13212. */
  13213. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13214. /**
  13215. * Remove a specific ramp gradient
  13216. * @param gradient defines the gradient to remove
  13217. * @returns the current particle system
  13218. */
  13219. removeRampGradient(gradient: number): ParticleSystem;
  13220. /**
  13221. * Adds a new color gradient
  13222. * @param gradient defines the gradient to use (between 0 and 1)
  13223. * @param color1 defines the color to affect to the specified gradient
  13224. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13225. * @returns this particle system
  13226. */
  13227. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13228. /**
  13229. * Remove a specific color gradient
  13230. * @param gradient defines the gradient to remove
  13231. * @returns this particle system
  13232. */
  13233. removeColorGradient(gradient: number): IParticleSystem;
  13234. private _fetchR;
  13235. protected _reset(): void;
  13236. private _resetEffect;
  13237. private _createVertexBuffers;
  13238. private _createIndexBuffer;
  13239. /**
  13240. * Gets the maximum number of particles active at the same time.
  13241. * @returns The max number of active particles.
  13242. */
  13243. getCapacity(): number;
  13244. /**
  13245. * Gets whether there are still active particles in the system.
  13246. * @returns True if it is alive, otherwise false.
  13247. */
  13248. isAlive(): boolean;
  13249. /**
  13250. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13251. * @returns True if it has been started, otherwise false.
  13252. */
  13253. isStarted(): boolean;
  13254. private _prepareSubEmitterInternalArray;
  13255. /**
  13256. * Starts the particle system and begins to emit
  13257. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13258. */
  13259. start(delay?: number): void;
  13260. /**
  13261. * Stops the particle system.
  13262. * @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.
  13263. */
  13264. stop(stopSubEmitters?: boolean): void;
  13265. /**
  13266. * Remove all active particles
  13267. */
  13268. reset(): void;
  13269. /**
  13270. * @hidden (for internal use only)
  13271. */
  13272. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13273. /**
  13274. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13275. * Its lifetime will start back at 0.
  13276. */
  13277. recycleParticle: (particle: Particle) => void;
  13278. private _stopSubEmitters;
  13279. private _createParticle;
  13280. private _removeFromRoot;
  13281. private _emitFromParticle;
  13282. private _update;
  13283. /** @hidden */
  13284. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13285. /** @hidden */
  13286. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13287. /**
  13288. * Fill the defines array according to the current settings of the particle system
  13289. * @param defines Array to be updated
  13290. * @param blendMode blend mode to take into account when updating the array
  13291. */
  13292. fillDefines(defines: Array<string>, blendMode: number): void;
  13293. /**
  13294. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13295. * @param uniforms Uniforms array to fill
  13296. * @param attributes Attributes array to fill
  13297. * @param samplers Samplers array to fill
  13298. */
  13299. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13300. /** @hidden */
  13301. private _getEffect;
  13302. /**
  13303. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13304. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13305. */
  13306. animate(preWarmOnly?: boolean): void;
  13307. private _appendParticleVertices;
  13308. /**
  13309. * Rebuilds the particle system.
  13310. */
  13311. rebuild(): void;
  13312. /**
  13313. * Is this system ready to be used/rendered
  13314. * @return true if the system is ready
  13315. */
  13316. isReady(): boolean;
  13317. private _render;
  13318. /**
  13319. * Renders the particle system in its current state.
  13320. * @returns the current number of particles
  13321. */
  13322. render(): number;
  13323. /**
  13324. * Disposes the particle system and free the associated resources
  13325. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13326. */
  13327. dispose(disposeTexture?: boolean): void;
  13328. /**
  13329. * Clones the particle system.
  13330. * @param name The name of the cloned object
  13331. * @param newEmitter The new emitter to use
  13332. * @returns the cloned particle system
  13333. */
  13334. clone(name: string, newEmitter: any): ParticleSystem;
  13335. /**
  13336. * Serializes the particle system to a JSON object
  13337. * @param serializeTexture defines if the texture must be serialized as well
  13338. * @returns the JSON object
  13339. */
  13340. serialize(serializeTexture?: boolean): any;
  13341. /** @hidden */
  13342. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13343. /** @hidden */
  13344. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13345. /**
  13346. * Parses a JSON object to create a particle system.
  13347. * @param parsedParticleSystem The JSON object to parse
  13348. * @param sceneOrEngine The scene or the engine to create the particle system in
  13349. * @param rootUrl The root url to use to load external dependencies like texture
  13350. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13351. * @returns the Parsed particle system
  13352. */
  13353. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13354. }
  13355. }
  13356. declare module "babylonjs/Particles/particle" {
  13357. import { Nullable } from "babylonjs/types";
  13358. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13359. import { Color4 } from "babylonjs/Maths/math.color";
  13360. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13361. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13362. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13363. /**
  13364. * A particle represents one of the element emitted by a particle system.
  13365. * This is mainly define by its coordinates, direction, velocity and age.
  13366. */
  13367. export class Particle {
  13368. /**
  13369. * The particle system the particle belongs to.
  13370. */
  13371. particleSystem: ParticleSystem;
  13372. private static _Count;
  13373. /**
  13374. * Unique ID of the particle
  13375. */
  13376. id: number;
  13377. /**
  13378. * The world position of the particle in the scene.
  13379. */
  13380. position: Vector3;
  13381. /**
  13382. * The world direction of the particle in the scene.
  13383. */
  13384. direction: Vector3;
  13385. /**
  13386. * The color of the particle.
  13387. */
  13388. color: Color4;
  13389. /**
  13390. * The color change of the particle per step.
  13391. */
  13392. colorStep: Color4;
  13393. /**
  13394. * Defines how long will the life of the particle be.
  13395. */
  13396. lifeTime: number;
  13397. /**
  13398. * The current age of the particle.
  13399. */
  13400. age: number;
  13401. /**
  13402. * The current size of the particle.
  13403. */
  13404. size: number;
  13405. /**
  13406. * The current scale of the particle.
  13407. */
  13408. scale: Vector2;
  13409. /**
  13410. * The current angle of the particle.
  13411. */
  13412. angle: number;
  13413. /**
  13414. * Defines how fast is the angle changing.
  13415. */
  13416. angularSpeed: number;
  13417. /**
  13418. * Defines the cell index used by the particle to be rendered from a sprite.
  13419. */
  13420. cellIndex: number;
  13421. /**
  13422. * The information required to support color remapping
  13423. */
  13424. remapData: Vector4;
  13425. /** @hidden */
  13426. _randomCellOffset?: number;
  13427. /** @hidden */
  13428. _initialDirection: Nullable<Vector3>;
  13429. /** @hidden */
  13430. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13431. /** @hidden */
  13432. _initialStartSpriteCellID: number;
  13433. /** @hidden */
  13434. _initialEndSpriteCellID: number;
  13435. /** @hidden */
  13436. _currentColorGradient: Nullable<ColorGradient>;
  13437. /** @hidden */
  13438. _currentColor1: Color4;
  13439. /** @hidden */
  13440. _currentColor2: Color4;
  13441. /** @hidden */
  13442. _currentSizeGradient: Nullable<FactorGradient>;
  13443. /** @hidden */
  13444. _currentSize1: number;
  13445. /** @hidden */
  13446. _currentSize2: number;
  13447. /** @hidden */
  13448. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13449. /** @hidden */
  13450. _currentAngularSpeed1: number;
  13451. /** @hidden */
  13452. _currentAngularSpeed2: number;
  13453. /** @hidden */
  13454. _currentVelocityGradient: Nullable<FactorGradient>;
  13455. /** @hidden */
  13456. _currentVelocity1: number;
  13457. /** @hidden */
  13458. _currentVelocity2: number;
  13459. /** @hidden */
  13460. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13461. /** @hidden */
  13462. _currentLimitVelocity1: number;
  13463. /** @hidden */
  13464. _currentLimitVelocity2: number;
  13465. /** @hidden */
  13466. _currentDragGradient: Nullable<FactorGradient>;
  13467. /** @hidden */
  13468. _currentDrag1: number;
  13469. /** @hidden */
  13470. _currentDrag2: number;
  13471. /** @hidden */
  13472. _randomNoiseCoordinates1: Vector3;
  13473. /** @hidden */
  13474. _randomNoiseCoordinates2: Vector3;
  13475. /** @hidden */
  13476. _localPosition?: Vector3;
  13477. /**
  13478. * Creates a new instance Particle
  13479. * @param particleSystem the particle system the particle belongs to
  13480. */
  13481. constructor(
  13482. /**
  13483. * The particle system the particle belongs to.
  13484. */
  13485. particleSystem: ParticleSystem);
  13486. private updateCellInfoFromSystem;
  13487. /**
  13488. * Defines how the sprite cell index is updated for the particle
  13489. */
  13490. updateCellIndex(): void;
  13491. /** @hidden */
  13492. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13493. /** @hidden */
  13494. _inheritParticleInfoToSubEmitters(): void;
  13495. /** @hidden */
  13496. _reset(): void;
  13497. /**
  13498. * Copy the properties of particle to another one.
  13499. * @param other the particle to copy the information to.
  13500. */
  13501. copyTo(other: Particle): void;
  13502. }
  13503. }
  13504. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13505. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13506. import { Effect } from "babylonjs/Materials/effect";
  13507. import { Particle } from "babylonjs/Particles/particle";
  13508. import { Nullable } from "babylonjs/types";
  13509. import { Scene } from "babylonjs/scene";
  13510. /**
  13511. * Particle emitter represents a volume emitting particles.
  13512. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13513. */
  13514. export interface IParticleEmitterType {
  13515. /**
  13516. * Called by the particle System when the direction is computed for the created particle.
  13517. * @param worldMatrix is the world matrix of the particle system
  13518. * @param directionToUpdate is the direction vector to update with the result
  13519. * @param particle is the particle we are computed the direction for
  13520. * @param isLocal defines if the direction should be set in local space
  13521. */
  13522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13523. /**
  13524. * Called by the particle System when the position is computed for the created particle.
  13525. * @param worldMatrix is the world matrix of the particle system
  13526. * @param positionToUpdate is the position vector to update with the result
  13527. * @param particle is the particle we are computed the position for
  13528. * @param isLocal defines if the position should be set in local space
  13529. */
  13530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13531. /**
  13532. * Clones the current emitter and returns a copy of it
  13533. * @returns the new emitter
  13534. */
  13535. clone(): IParticleEmitterType;
  13536. /**
  13537. * Called by the GPUParticleSystem to setup the update shader
  13538. * @param effect defines the update shader
  13539. */
  13540. applyToShader(effect: Effect): void;
  13541. /**
  13542. * Returns a string to use to update the GPU particles update shader
  13543. * @returns the effect defines string
  13544. */
  13545. getEffectDefines(): string;
  13546. /**
  13547. * Returns a string representing the class name
  13548. * @returns a string containing the class name
  13549. */
  13550. getClassName(): string;
  13551. /**
  13552. * Serializes the particle system to a JSON object.
  13553. * @returns the JSON object
  13554. */
  13555. serialize(): any;
  13556. /**
  13557. * Parse properties from a JSON object
  13558. * @param serializationObject defines the JSON object
  13559. * @param scene defines the hosting scene
  13560. */
  13561. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13562. }
  13563. }
  13564. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13565. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13566. import { Effect } from "babylonjs/Materials/effect";
  13567. import { Particle } from "babylonjs/Particles/particle";
  13568. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13569. /**
  13570. * Particle emitter emitting particles from the inside of a box.
  13571. * It emits the particles randomly between 2 given directions.
  13572. */
  13573. export class BoxParticleEmitter implements IParticleEmitterType {
  13574. /**
  13575. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13576. */
  13577. direction1: Vector3;
  13578. /**
  13579. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13580. */
  13581. direction2: Vector3;
  13582. /**
  13583. * 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.
  13584. */
  13585. minEmitBox: Vector3;
  13586. /**
  13587. * 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.
  13588. */
  13589. maxEmitBox: Vector3;
  13590. /**
  13591. * Creates a new instance BoxParticleEmitter
  13592. */
  13593. constructor();
  13594. /**
  13595. * Called by the particle System when the direction is computed for the created particle.
  13596. * @param worldMatrix is the world matrix of the particle system
  13597. * @param directionToUpdate is the direction vector to update with the result
  13598. * @param particle is the particle we are computed the direction for
  13599. * @param isLocal defines if the direction should be set in local space
  13600. */
  13601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13602. /**
  13603. * Called by the particle System when the position is computed for the created particle.
  13604. * @param worldMatrix is the world matrix of the particle system
  13605. * @param positionToUpdate is the position vector to update with the result
  13606. * @param particle is the particle we are computed the position for
  13607. * @param isLocal defines if the position should be set in local space
  13608. */
  13609. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13610. /**
  13611. * Clones the current emitter and returns a copy of it
  13612. * @returns the new emitter
  13613. */
  13614. clone(): BoxParticleEmitter;
  13615. /**
  13616. * Called by the GPUParticleSystem to setup the update shader
  13617. * @param effect defines the update shader
  13618. */
  13619. applyToShader(effect: Effect): void;
  13620. /**
  13621. * Returns a string to use to update the GPU particles update shader
  13622. * @returns a string containng the defines string
  13623. */
  13624. getEffectDefines(): string;
  13625. /**
  13626. * Returns the string "BoxParticleEmitter"
  13627. * @returns a string containing the class name
  13628. */
  13629. getClassName(): string;
  13630. /**
  13631. * Serializes the particle system to a JSON object.
  13632. * @returns the JSON object
  13633. */
  13634. serialize(): any;
  13635. /**
  13636. * Parse properties from a JSON object
  13637. * @param serializationObject defines the JSON object
  13638. */
  13639. parse(serializationObject: any): void;
  13640. }
  13641. }
  13642. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13643. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13644. import { Effect } from "babylonjs/Materials/effect";
  13645. import { Particle } from "babylonjs/Particles/particle";
  13646. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13647. /**
  13648. * Particle emitter emitting particles from the inside of a cone.
  13649. * It emits the particles alongside the cone volume from the base to the particle.
  13650. * The emission direction might be randomized.
  13651. */
  13652. export class ConeParticleEmitter implements IParticleEmitterType {
  13653. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13654. directionRandomizer: number;
  13655. private _radius;
  13656. private _angle;
  13657. private _height;
  13658. /**
  13659. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13660. */
  13661. radiusRange: number;
  13662. /**
  13663. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13664. */
  13665. heightRange: number;
  13666. /**
  13667. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13668. */
  13669. emitFromSpawnPointOnly: boolean;
  13670. /**
  13671. * Gets or sets the radius of the emission cone
  13672. */
  13673. get radius(): number;
  13674. set radius(value: number);
  13675. /**
  13676. * Gets or sets the angle of the emission cone
  13677. */
  13678. get angle(): number;
  13679. set angle(value: number);
  13680. private _buildHeight;
  13681. /**
  13682. * Creates a new instance ConeParticleEmitter
  13683. * @param radius the radius of the emission cone (1 by default)
  13684. * @param angle the cone base angle (PI by default)
  13685. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13686. */
  13687. constructor(radius?: number, angle?: number,
  13688. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13689. directionRandomizer?: number);
  13690. /**
  13691. * Called by the particle System when the direction is computed for the created particle.
  13692. * @param worldMatrix is the world matrix of the particle system
  13693. * @param directionToUpdate is the direction vector to update with the result
  13694. * @param particle is the particle we are computed the direction for
  13695. * @param isLocal defines if the direction should be set in local space
  13696. */
  13697. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13698. /**
  13699. * Called by the particle System when the position is computed for the created particle.
  13700. * @param worldMatrix is the world matrix of the particle system
  13701. * @param positionToUpdate is the position vector to update with the result
  13702. * @param particle is the particle we are computed the position for
  13703. * @param isLocal defines if the position should be set in local space
  13704. */
  13705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13706. /**
  13707. * Clones the current emitter and returns a copy of it
  13708. * @returns the new emitter
  13709. */
  13710. clone(): ConeParticleEmitter;
  13711. /**
  13712. * Called by the GPUParticleSystem to setup the update shader
  13713. * @param effect defines the update shader
  13714. */
  13715. applyToShader(effect: Effect): void;
  13716. /**
  13717. * Returns a string to use to update the GPU particles update shader
  13718. * @returns a string containng the defines string
  13719. */
  13720. getEffectDefines(): string;
  13721. /**
  13722. * Returns the string "ConeParticleEmitter"
  13723. * @returns a string containing the class name
  13724. */
  13725. getClassName(): string;
  13726. /**
  13727. * Serializes the particle system to a JSON object.
  13728. * @returns the JSON object
  13729. */
  13730. serialize(): any;
  13731. /**
  13732. * Parse properties from a JSON object
  13733. * @param serializationObject defines the JSON object
  13734. */
  13735. parse(serializationObject: any): void;
  13736. }
  13737. }
  13738. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13740. import { Effect } from "babylonjs/Materials/effect";
  13741. import { Particle } from "babylonjs/Particles/particle";
  13742. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13743. /**
  13744. * Particle emitter emitting particles from the inside of a cylinder.
  13745. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13746. */
  13747. export class CylinderParticleEmitter implements IParticleEmitterType {
  13748. /**
  13749. * The radius of the emission cylinder.
  13750. */
  13751. radius: number;
  13752. /**
  13753. * The height of the emission cylinder.
  13754. */
  13755. height: number;
  13756. /**
  13757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13758. */
  13759. radiusRange: number;
  13760. /**
  13761. * How much to randomize the particle direction [0-1].
  13762. */
  13763. directionRandomizer: number;
  13764. /**
  13765. * Creates a new instance CylinderParticleEmitter
  13766. * @param radius the radius of the emission cylinder (1 by default)
  13767. * @param height the height of the emission cylinder (1 by default)
  13768. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13769. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13770. */
  13771. constructor(
  13772. /**
  13773. * The radius of the emission cylinder.
  13774. */
  13775. radius?: number,
  13776. /**
  13777. * The height of the emission cylinder.
  13778. */
  13779. height?: number,
  13780. /**
  13781. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13782. */
  13783. radiusRange?: number,
  13784. /**
  13785. * How much to randomize the particle direction [0-1].
  13786. */
  13787. directionRandomizer?: number);
  13788. /**
  13789. * Called by the particle System when the direction is computed for the created particle.
  13790. * @param worldMatrix is the world matrix of the particle system
  13791. * @param directionToUpdate is the direction vector to update with the result
  13792. * @param particle is the particle we are computed the direction for
  13793. * @param isLocal defines if the direction should be set in local space
  13794. */
  13795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13796. /**
  13797. * Called by the particle System when the position is computed for the created particle.
  13798. * @param worldMatrix is the world matrix of the particle system
  13799. * @param positionToUpdate is the position vector to update with the result
  13800. * @param particle is the particle we are computed the position for
  13801. * @param isLocal defines if the position should be set in local space
  13802. */
  13803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13804. /**
  13805. * Clones the current emitter and returns a copy of it
  13806. * @returns the new emitter
  13807. */
  13808. clone(): CylinderParticleEmitter;
  13809. /**
  13810. * Called by the GPUParticleSystem to setup the update shader
  13811. * @param effect defines the update shader
  13812. */
  13813. applyToShader(effect: Effect): void;
  13814. /**
  13815. * Returns a string to use to update the GPU particles update shader
  13816. * @returns a string containng the defines string
  13817. */
  13818. getEffectDefines(): string;
  13819. /**
  13820. * Returns the string "CylinderParticleEmitter"
  13821. * @returns a string containing the class name
  13822. */
  13823. getClassName(): string;
  13824. /**
  13825. * Serializes the particle system to a JSON object.
  13826. * @returns the JSON object
  13827. */
  13828. serialize(): any;
  13829. /**
  13830. * Parse properties from a JSON object
  13831. * @param serializationObject defines the JSON object
  13832. */
  13833. parse(serializationObject: any): void;
  13834. }
  13835. /**
  13836. * Particle emitter emitting particles from the inside of a cylinder.
  13837. * It emits the particles randomly between two vectors.
  13838. */
  13839. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13840. /**
  13841. * The min limit of the emission direction.
  13842. */
  13843. direction1: Vector3;
  13844. /**
  13845. * The max limit of the emission direction.
  13846. */
  13847. direction2: Vector3;
  13848. /**
  13849. * Creates a new instance CylinderDirectedParticleEmitter
  13850. * @param radius the radius of the emission cylinder (1 by default)
  13851. * @param height the height of the emission cylinder (1 by default)
  13852. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13853. * @param direction1 the min limit of the emission direction (up vector by default)
  13854. * @param direction2 the max limit of the emission direction (up vector by default)
  13855. */
  13856. constructor(radius?: number, height?: number, radiusRange?: number,
  13857. /**
  13858. * The min limit of the emission direction.
  13859. */
  13860. direction1?: Vector3,
  13861. /**
  13862. * The max limit of the emission direction.
  13863. */
  13864. direction2?: Vector3);
  13865. /**
  13866. * Called by the particle System when the direction is computed for the created particle.
  13867. * @param worldMatrix is the world matrix of the particle system
  13868. * @param directionToUpdate is the direction vector to update with the result
  13869. * @param particle is the particle we are computed the direction for
  13870. */
  13871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13872. /**
  13873. * Clones the current emitter and returns a copy of it
  13874. * @returns the new emitter
  13875. */
  13876. clone(): CylinderDirectedParticleEmitter;
  13877. /**
  13878. * Called by the GPUParticleSystem to setup the update shader
  13879. * @param effect defines the update shader
  13880. */
  13881. applyToShader(effect: Effect): void;
  13882. /**
  13883. * Returns a string to use to update the GPU particles update shader
  13884. * @returns a string containng the defines string
  13885. */
  13886. getEffectDefines(): string;
  13887. /**
  13888. * Returns the string "CylinderDirectedParticleEmitter"
  13889. * @returns a string containing the class name
  13890. */
  13891. getClassName(): string;
  13892. /**
  13893. * Serializes the particle system to a JSON object.
  13894. * @returns the JSON object
  13895. */
  13896. serialize(): any;
  13897. /**
  13898. * Parse properties from a JSON object
  13899. * @param serializationObject defines the JSON object
  13900. */
  13901. parse(serializationObject: any): void;
  13902. }
  13903. }
  13904. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13905. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13906. import { Effect } from "babylonjs/Materials/effect";
  13907. import { Particle } from "babylonjs/Particles/particle";
  13908. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13909. /**
  13910. * Particle emitter emitting particles from the inside of a hemisphere.
  13911. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13912. */
  13913. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13914. /**
  13915. * The radius of the emission hemisphere.
  13916. */
  13917. radius: number;
  13918. /**
  13919. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13920. */
  13921. radiusRange: number;
  13922. /**
  13923. * How much to randomize the particle direction [0-1].
  13924. */
  13925. directionRandomizer: number;
  13926. /**
  13927. * Creates a new instance HemisphericParticleEmitter
  13928. * @param radius the radius of the emission hemisphere (1 by default)
  13929. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13930. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13931. */
  13932. constructor(
  13933. /**
  13934. * The radius of the emission hemisphere.
  13935. */
  13936. radius?: number,
  13937. /**
  13938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13939. */
  13940. radiusRange?: number,
  13941. /**
  13942. * How much to randomize the particle direction [0-1].
  13943. */
  13944. directionRandomizer?: number);
  13945. /**
  13946. * Called by the particle System when the direction is computed for the created particle.
  13947. * @param worldMatrix is the world matrix of the particle system
  13948. * @param directionToUpdate is the direction vector to update with the result
  13949. * @param particle is the particle we are computed the direction for
  13950. * @param isLocal defines if the direction should be set in local space
  13951. */
  13952. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13953. /**
  13954. * Called by the particle System when the position is computed for the created particle.
  13955. * @param worldMatrix is the world matrix of the particle system
  13956. * @param positionToUpdate is the position vector to update with the result
  13957. * @param particle is the particle we are computed the position for
  13958. * @param isLocal defines if the position should be set in local space
  13959. */
  13960. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13961. /**
  13962. * Clones the current emitter and returns a copy of it
  13963. * @returns the new emitter
  13964. */
  13965. clone(): HemisphericParticleEmitter;
  13966. /**
  13967. * Called by the GPUParticleSystem to setup the update shader
  13968. * @param effect defines the update shader
  13969. */
  13970. applyToShader(effect: Effect): void;
  13971. /**
  13972. * Returns a string to use to update the GPU particles update shader
  13973. * @returns a string containng the defines string
  13974. */
  13975. getEffectDefines(): string;
  13976. /**
  13977. * Returns the string "HemisphericParticleEmitter"
  13978. * @returns a string containing the class name
  13979. */
  13980. getClassName(): string;
  13981. /**
  13982. * Serializes the particle system to a JSON object.
  13983. * @returns the JSON object
  13984. */
  13985. serialize(): any;
  13986. /**
  13987. * Parse properties from a JSON object
  13988. * @param serializationObject defines the JSON object
  13989. */
  13990. parse(serializationObject: any): void;
  13991. }
  13992. }
  13993. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13994. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13995. import { Effect } from "babylonjs/Materials/effect";
  13996. import { Particle } from "babylonjs/Particles/particle";
  13997. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13998. /**
  13999. * Particle emitter emitting particles from a point.
  14000. * It emits the particles randomly between 2 given directions.
  14001. */
  14002. export class PointParticleEmitter implements IParticleEmitterType {
  14003. /**
  14004. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14005. */
  14006. direction1: Vector3;
  14007. /**
  14008. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14009. */
  14010. direction2: Vector3;
  14011. /**
  14012. * Creates a new instance PointParticleEmitter
  14013. */
  14014. constructor();
  14015. /**
  14016. * Called by the particle System when the direction is computed for the created particle.
  14017. * @param worldMatrix is the world matrix of the particle system
  14018. * @param directionToUpdate is the direction vector to update with the result
  14019. * @param particle is the particle we are computed the direction for
  14020. * @param isLocal defines if the direction should be set in local space
  14021. */
  14022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14023. /**
  14024. * Called by the particle System when the position is computed for the created particle.
  14025. * @param worldMatrix is the world matrix of the particle system
  14026. * @param positionToUpdate is the position vector to update with the result
  14027. * @param particle is the particle we are computed the position for
  14028. * @param isLocal defines if the position should be set in local space
  14029. */
  14030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14031. /**
  14032. * Clones the current emitter and returns a copy of it
  14033. * @returns the new emitter
  14034. */
  14035. clone(): PointParticleEmitter;
  14036. /**
  14037. * Called by the GPUParticleSystem to setup the update shader
  14038. * @param effect defines the update shader
  14039. */
  14040. applyToShader(effect: Effect): void;
  14041. /**
  14042. * Returns a string to use to update the GPU particles update shader
  14043. * @returns a string containng the defines string
  14044. */
  14045. getEffectDefines(): string;
  14046. /**
  14047. * Returns the string "PointParticleEmitter"
  14048. * @returns a string containing the class name
  14049. */
  14050. getClassName(): string;
  14051. /**
  14052. * Serializes the particle system to a JSON object.
  14053. * @returns the JSON object
  14054. */
  14055. serialize(): any;
  14056. /**
  14057. * Parse properties from a JSON object
  14058. * @param serializationObject defines the JSON object
  14059. */
  14060. parse(serializationObject: any): void;
  14061. }
  14062. }
  14063. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14064. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14065. import { Effect } from "babylonjs/Materials/effect";
  14066. import { Particle } from "babylonjs/Particles/particle";
  14067. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14068. /**
  14069. * Particle emitter emitting particles from the inside of a sphere.
  14070. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14071. */
  14072. export class SphereParticleEmitter implements IParticleEmitterType {
  14073. /**
  14074. * The radius of the emission sphere.
  14075. */
  14076. radius: number;
  14077. /**
  14078. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14079. */
  14080. radiusRange: number;
  14081. /**
  14082. * How much to randomize the particle direction [0-1].
  14083. */
  14084. directionRandomizer: number;
  14085. /**
  14086. * Creates a new instance SphereParticleEmitter
  14087. * @param radius the radius of the emission sphere (1 by default)
  14088. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14089. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14090. */
  14091. constructor(
  14092. /**
  14093. * The radius of the emission sphere.
  14094. */
  14095. radius?: number,
  14096. /**
  14097. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14098. */
  14099. radiusRange?: number,
  14100. /**
  14101. * How much to randomize the particle direction [0-1].
  14102. */
  14103. directionRandomizer?: number);
  14104. /**
  14105. * Called by the particle System when the direction is computed for the created particle.
  14106. * @param worldMatrix is the world matrix of the particle system
  14107. * @param directionToUpdate is the direction vector to update with the result
  14108. * @param particle is the particle we are computed the direction for
  14109. * @param isLocal defines if the direction should be set in local space
  14110. */
  14111. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14112. /**
  14113. * Called by the particle System when the position is computed for the created particle.
  14114. * @param worldMatrix is the world matrix of the particle system
  14115. * @param positionToUpdate is the position vector to update with the result
  14116. * @param particle is the particle we are computed the position for
  14117. * @param isLocal defines if the position should be set in local space
  14118. */
  14119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14120. /**
  14121. * Clones the current emitter and returns a copy of it
  14122. * @returns the new emitter
  14123. */
  14124. clone(): SphereParticleEmitter;
  14125. /**
  14126. * Called by the GPUParticleSystem to setup the update shader
  14127. * @param effect defines the update shader
  14128. */
  14129. applyToShader(effect: Effect): void;
  14130. /**
  14131. * Returns a string to use to update the GPU particles update shader
  14132. * @returns a string containng the defines string
  14133. */
  14134. getEffectDefines(): string;
  14135. /**
  14136. * Returns the string "SphereParticleEmitter"
  14137. * @returns a string containing the class name
  14138. */
  14139. getClassName(): string;
  14140. /**
  14141. * Serializes the particle system to a JSON object.
  14142. * @returns the JSON object
  14143. */
  14144. serialize(): any;
  14145. /**
  14146. * Parse properties from a JSON object
  14147. * @param serializationObject defines the JSON object
  14148. */
  14149. parse(serializationObject: any): void;
  14150. }
  14151. /**
  14152. * Particle emitter emitting particles from the inside of a sphere.
  14153. * It emits the particles randomly between two vectors.
  14154. */
  14155. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14156. /**
  14157. * The min limit of the emission direction.
  14158. */
  14159. direction1: Vector3;
  14160. /**
  14161. * The max limit of the emission direction.
  14162. */
  14163. direction2: Vector3;
  14164. /**
  14165. * Creates a new instance SphereDirectedParticleEmitter
  14166. * @param radius the radius of the emission sphere (1 by default)
  14167. * @param direction1 the min limit of the emission direction (up vector by default)
  14168. * @param direction2 the max limit of the emission direction (up vector by default)
  14169. */
  14170. constructor(radius?: number,
  14171. /**
  14172. * The min limit of the emission direction.
  14173. */
  14174. direction1?: Vector3,
  14175. /**
  14176. * The max limit of the emission direction.
  14177. */
  14178. direction2?: Vector3);
  14179. /**
  14180. * Called by the particle System when the direction is computed for the created particle.
  14181. * @param worldMatrix is the world matrix of the particle system
  14182. * @param directionToUpdate is the direction vector to update with the result
  14183. * @param particle is the particle we are computed the direction for
  14184. */
  14185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14186. /**
  14187. * Clones the current emitter and returns a copy of it
  14188. * @returns the new emitter
  14189. */
  14190. clone(): SphereDirectedParticleEmitter;
  14191. /**
  14192. * Called by the GPUParticleSystem to setup the update shader
  14193. * @param effect defines the update shader
  14194. */
  14195. applyToShader(effect: Effect): void;
  14196. /**
  14197. * Returns a string to use to update the GPU particles update shader
  14198. * @returns a string containng the defines string
  14199. */
  14200. getEffectDefines(): string;
  14201. /**
  14202. * Returns the string "SphereDirectedParticleEmitter"
  14203. * @returns a string containing the class name
  14204. */
  14205. getClassName(): string;
  14206. /**
  14207. * Serializes the particle system to a JSON object.
  14208. * @returns the JSON object
  14209. */
  14210. serialize(): any;
  14211. /**
  14212. * Parse properties from a JSON object
  14213. * @param serializationObject defines the JSON object
  14214. */
  14215. parse(serializationObject: any): void;
  14216. }
  14217. }
  14218. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14220. import { Effect } from "babylonjs/Materials/effect";
  14221. import { Particle } from "babylonjs/Particles/particle";
  14222. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14223. import { Nullable } from "babylonjs/types";
  14224. /**
  14225. * Particle emitter emitting particles from a custom list of positions.
  14226. */
  14227. export class CustomParticleEmitter implements IParticleEmitterType {
  14228. /**
  14229. * Gets or sets the position generator that will create the inital position of each particle.
  14230. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14231. */
  14232. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14233. /**
  14234. * Gets or sets the destination generator that will create the final destination of each particle.
  14235. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14236. */
  14237. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14238. /**
  14239. * Creates a new instance CustomParticleEmitter
  14240. */
  14241. constructor();
  14242. /**
  14243. * Called by the particle System when the direction is computed for the created particle.
  14244. * @param worldMatrix is the world matrix of the particle system
  14245. * @param directionToUpdate is the direction vector to update with the result
  14246. * @param particle is the particle we are computed the direction for
  14247. * @param isLocal defines if the direction should be set in local space
  14248. */
  14249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14250. /**
  14251. * Called by the particle System when the position is computed for the created particle.
  14252. * @param worldMatrix is the world matrix of the particle system
  14253. * @param positionToUpdate is the position vector to update with the result
  14254. * @param particle is the particle we are computed the position for
  14255. * @param isLocal defines if the position should be set in local space
  14256. */
  14257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14258. /**
  14259. * Clones the current emitter and returns a copy of it
  14260. * @returns the new emitter
  14261. */
  14262. clone(): CustomParticleEmitter;
  14263. /**
  14264. * Called by the GPUParticleSystem to setup the update shader
  14265. * @param effect defines the update shader
  14266. */
  14267. applyToShader(effect: Effect): void;
  14268. /**
  14269. * Returns a string to use to update the GPU particles update shader
  14270. * @returns a string containng the defines string
  14271. */
  14272. getEffectDefines(): string;
  14273. /**
  14274. * Returns the string "PointParticleEmitter"
  14275. * @returns a string containing the class name
  14276. */
  14277. getClassName(): string;
  14278. /**
  14279. * Serializes the particle system to a JSON object.
  14280. * @returns the JSON object
  14281. */
  14282. serialize(): any;
  14283. /**
  14284. * Parse properties from a JSON object
  14285. * @param serializationObject defines the JSON object
  14286. */
  14287. parse(serializationObject: any): void;
  14288. }
  14289. }
  14290. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14291. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14292. import { Effect } from "babylonjs/Materials/effect";
  14293. import { Particle } from "babylonjs/Particles/particle";
  14294. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14295. import { Nullable } from "babylonjs/types";
  14296. import { Scene } from "babylonjs/scene";
  14297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14298. /**
  14299. * Particle emitter emitting particles from the inside of a box.
  14300. * It emits the particles randomly between 2 given directions.
  14301. */
  14302. export class MeshParticleEmitter implements IParticleEmitterType {
  14303. private _indices;
  14304. private _positions;
  14305. private _normals;
  14306. private _storedNormal;
  14307. private _mesh;
  14308. /**
  14309. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14310. */
  14311. direction1: Vector3;
  14312. /**
  14313. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14314. */
  14315. direction2: Vector3;
  14316. /**
  14317. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14318. */
  14319. useMeshNormalsForDirection: boolean;
  14320. /** Defines the mesh to use as source */
  14321. get mesh(): Nullable<AbstractMesh>;
  14322. set mesh(value: Nullable<AbstractMesh>);
  14323. /**
  14324. * Creates a new instance MeshParticleEmitter
  14325. * @param mesh defines the mesh to use as source
  14326. */
  14327. constructor(mesh?: Nullable<AbstractMesh>);
  14328. /**
  14329. * Called by the particle System when the direction is computed for the created particle.
  14330. * @param worldMatrix is the world matrix of the particle system
  14331. * @param directionToUpdate is the direction vector to update with the result
  14332. * @param particle is the particle we are computed the direction for
  14333. * @param isLocal defines if the direction should be set in local space
  14334. */
  14335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14336. /**
  14337. * Called by the particle System when the position is computed for the created particle.
  14338. * @param worldMatrix is the world matrix of the particle system
  14339. * @param positionToUpdate is the position vector to update with the result
  14340. * @param particle is the particle we are computed the position for
  14341. * @param isLocal defines if the position should be set in local space
  14342. */
  14343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14344. /**
  14345. * Clones the current emitter and returns a copy of it
  14346. * @returns the new emitter
  14347. */
  14348. clone(): MeshParticleEmitter;
  14349. /**
  14350. * Called by the GPUParticleSystem to setup the update shader
  14351. * @param effect defines the update shader
  14352. */
  14353. applyToShader(effect: Effect): void;
  14354. /**
  14355. * Returns a string to use to update the GPU particles update shader
  14356. * @returns a string containng the defines string
  14357. */
  14358. getEffectDefines(): string;
  14359. /**
  14360. * Returns the string "BoxParticleEmitter"
  14361. * @returns a string containing the class name
  14362. */
  14363. getClassName(): string;
  14364. /**
  14365. * Serializes the particle system to a JSON object.
  14366. * @returns the JSON object
  14367. */
  14368. serialize(): any;
  14369. /**
  14370. * Parse properties from a JSON object
  14371. * @param serializationObject defines the JSON object
  14372. * @param scene defines the hosting scene
  14373. */
  14374. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14375. }
  14376. }
  14377. declare module "babylonjs/Particles/EmitterTypes/index" {
  14378. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14379. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14380. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14381. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14382. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14383. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14384. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14385. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14386. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14387. }
  14388. declare module "babylonjs/Particles/IParticleSystem" {
  14389. import { Nullable } from "babylonjs/types";
  14390. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14391. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14393. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14394. import { Scene } from "babylonjs/scene";
  14395. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14396. import { Effect } from "babylonjs/Materials/effect";
  14397. import { Observable } from "babylonjs/Misc/observable";
  14398. import { Animation } from "babylonjs/Animations/animation";
  14399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14400. /**
  14401. * Interface representing a particle system in Babylon.js.
  14402. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14403. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14404. */
  14405. export interface IParticleSystem {
  14406. /**
  14407. * List of animations used by the particle system.
  14408. */
  14409. animations: Animation[];
  14410. /**
  14411. * The id of the Particle system.
  14412. */
  14413. id: string;
  14414. /**
  14415. * The name of the Particle system.
  14416. */
  14417. name: string;
  14418. /**
  14419. * The emitter represents the Mesh or position we are attaching the particle system to.
  14420. */
  14421. emitter: Nullable<AbstractMesh | Vector3>;
  14422. /**
  14423. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14424. */
  14425. isBillboardBased: boolean;
  14426. /**
  14427. * The rendering group used by the Particle system to chose when to render.
  14428. */
  14429. renderingGroupId: number;
  14430. /**
  14431. * The layer mask we are rendering the particles through.
  14432. */
  14433. layerMask: number;
  14434. /**
  14435. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14436. */
  14437. updateSpeed: number;
  14438. /**
  14439. * The amount of time the particle system is running (depends of the overall update speed).
  14440. */
  14441. targetStopDuration: number;
  14442. /**
  14443. * The texture used to render each particle. (this can be a spritesheet)
  14444. */
  14445. particleTexture: Nullable<BaseTexture>;
  14446. /**
  14447. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14448. */
  14449. blendMode: number;
  14450. /**
  14451. * Minimum life time of emitting particles.
  14452. */
  14453. minLifeTime: number;
  14454. /**
  14455. * Maximum life time of emitting particles.
  14456. */
  14457. maxLifeTime: number;
  14458. /**
  14459. * Minimum Size of emitting particles.
  14460. */
  14461. minSize: number;
  14462. /**
  14463. * Maximum Size of emitting particles.
  14464. */
  14465. maxSize: number;
  14466. /**
  14467. * Minimum scale of emitting particles on X axis.
  14468. */
  14469. minScaleX: number;
  14470. /**
  14471. * Maximum scale of emitting particles on X axis.
  14472. */
  14473. maxScaleX: number;
  14474. /**
  14475. * Minimum scale of emitting particles on Y axis.
  14476. */
  14477. minScaleY: number;
  14478. /**
  14479. * Maximum scale of emitting particles on Y axis.
  14480. */
  14481. maxScaleY: number;
  14482. /**
  14483. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14484. */
  14485. color1: Color4;
  14486. /**
  14487. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14488. */
  14489. color2: Color4;
  14490. /**
  14491. * Color the particle will have at the end of its lifetime.
  14492. */
  14493. colorDead: Color4;
  14494. /**
  14495. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14496. */
  14497. emitRate: number;
  14498. /**
  14499. * You can use gravity if you want to give an orientation to your particles.
  14500. */
  14501. gravity: Vector3;
  14502. /**
  14503. * Minimum power of emitting particles.
  14504. */
  14505. minEmitPower: number;
  14506. /**
  14507. * Maximum power of emitting particles.
  14508. */
  14509. maxEmitPower: number;
  14510. /**
  14511. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14512. */
  14513. minAngularSpeed: number;
  14514. /**
  14515. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14516. */
  14517. maxAngularSpeed: number;
  14518. /**
  14519. * Gets or sets the minimal initial rotation in radians.
  14520. */
  14521. minInitialRotation: number;
  14522. /**
  14523. * Gets or sets the maximal initial rotation in radians.
  14524. */
  14525. maxInitialRotation: number;
  14526. /**
  14527. * The particle emitter type defines the emitter used by the particle system.
  14528. * It can be for example box, sphere, or cone...
  14529. */
  14530. particleEmitterType: Nullable<IParticleEmitterType>;
  14531. /**
  14532. * Defines the delay in milliseconds before starting the system (0 by default)
  14533. */
  14534. startDelay: number;
  14535. /**
  14536. * 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
  14537. */
  14538. preWarmCycles: number;
  14539. /**
  14540. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14541. */
  14542. preWarmStepOffset: number;
  14543. /**
  14544. * 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)
  14545. */
  14546. spriteCellChangeSpeed: number;
  14547. /**
  14548. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14549. */
  14550. startSpriteCellID: number;
  14551. /**
  14552. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14553. */
  14554. endSpriteCellID: number;
  14555. /**
  14556. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14557. */
  14558. spriteCellWidth: number;
  14559. /**
  14560. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14561. */
  14562. spriteCellHeight: number;
  14563. /**
  14564. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14565. */
  14566. spriteRandomStartCell: boolean;
  14567. /**
  14568. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14569. */
  14570. isAnimationSheetEnabled: boolean;
  14571. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14572. translationPivot: Vector2;
  14573. /**
  14574. * Gets or sets a texture used to add random noise to particle positions
  14575. */
  14576. noiseTexture: Nullable<BaseTexture>;
  14577. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14578. noiseStrength: Vector3;
  14579. /**
  14580. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14581. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14582. */
  14583. billboardMode: number;
  14584. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14585. limitVelocityDamping: number;
  14586. /**
  14587. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14588. */
  14589. beginAnimationOnStart: boolean;
  14590. /**
  14591. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14592. */
  14593. beginAnimationFrom: number;
  14594. /**
  14595. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14596. */
  14597. beginAnimationTo: number;
  14598. /**
  14599. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14600. */
  14601. beginAnimationLoop: boolean;
  14602. /**
  14603. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14604. */
  14605. disposeOnStop: boolean;
  14606. /**
  14607. * Specifies if the particles are updated in emitter local space or world space
  14608. */
  14609. isLocal: boolean;
  14610. /** Snippet ID if the particle system was created from the snippet server */
  14611. snippetId: string;
  14612. /** Gets or sets a matrix to use to compute projection */
  14613. defaultProjectionMatrix: Matrix;
  14614. /**
  14615. * Gets the maximum number of particles active at the same time.
  14616. * @returns The max number of active particles.
  14617. */
  14618. getCapacity(): number;
  14619. /**
  14620. * Gets the number of particles active at the same time.
  14621. * @returns The number of active particles.
  14622. */
  14623. getActiveCount(): number;
  14624. /**
  14625. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14626. * @returns True if it has been started, otherwise false.
  14627. */
  14628. isStarted(): boolean;
  14629. /**
  14630. * Animates the particle system for this frame.
  14631. */
  14632. animate(): void;
  14633. /**
  14634. * Renders the particle system in its current state.
  14635. * @returns the current number of particles
  14636. */
  14637. render(): number;
  14638. /**
  14639. * Dispose the particle system and frees its associated resources.
  14640. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14641. */
  14642. dispose(disposeTexture?: boolean): void;
  14643. /**
  14644. * An event triggered when the system is disposed
  14645. */
  14646. onDisposeObservable: Observable<IParticleSystem>;
  14647. /**
  14648. * Clones the particle system.
  14649. * @param name The name of the cloned object
  14650. * @param newEmitter The new emitter to use
  14651. * @returns the cloned particle system
  14652. */
  14653. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14654. /**
  14655. * Serializes the particle system to a JSON object
  14656. * @param serializeTexture defines if the texture must be serialized as well
  14657. * @returns the JSON object
  14658. */
  14659. serialize(serializeTexture: boolean): any;
  14660. /**
  14661. * Rebuild the particle system
  14662. */
  14663. rebuild(): void;
  14664. /** Force the system to rebuild all gradients that need to be resync */
  14665. forceRefreshGradients(): void;
  14666. /**
  14667. * Starts the particle system and begins to emit
  14668. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14669. */
  14670. start(delay?: number): void;
  14671. /**
  14672. * Stops the particle system.
  14673. */
  14674. stop(): void;
  14675. /**
  14676. * Remove all active particles
  14677. */
  14678. reset(): void;
  14679. /**
  14680. * Gets a boolean indicating that the system is stopping
  14681. * @returns true if the system is currently stopping
  14682. */
  14683. isStopping(): boolean;
  14684. /**
  14685. * Is this system ready to be used/rendered
  14686. * @return true if the system is ready
  14687. */
  14688. isReady(): boolean;
  14689. /**
  14690. * Returns the string "ParticleSystem"
  14691. * @returns a string containing the class name
  14692. */
  14693. getClassName(): string;
  14694. /**
  14695. * Gets the custom effect used to render the particles
  14696. * @param blendMode Blend mode for which the effect should be retrieved
  14697. * @returns The effect
  14698. */
  14699. getCustomEffect(blendMode: number): Nullable<Effect>;
  14700. /**
  14701. * Sets the custom effect used to render the particles
  14702. * @param effect The effect to set
  14703. * @param blendMode Blend mode for which the effect should be set
  14704. */
  14705. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14706. /**
  14707. * Fill the defines array according to the current settings of the particle system
  14708. * @param defines Array to be updated
  14709. * @param blendMode blend mode to take into account when updating the array
  14710. */
  14711. fillDefines(defines: Array<string>, blendMode: number): void;
  14712. /**
  14713. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14714. * @param uniforms Uniforms array to fill
  14715. * @param attributes Attributes array to fill
  14716. * @param samplers Samplers array to fill
  14717. */
  14718. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14719. /**
  14720. * Observable that will be called just before the particles are drawn
  14721. */
  14722. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14723. /**
  14724. * Gets the name of the particle vertex shader
  14725. */
  14726. vertexShaderName: string;
  14727. /**
  14728. * Adds a new color gradient
  14729. * @param gradient defines the gradient to use (between 0 and 1)
  14730. * @param color1 defines the color to affect to the specified gradient
  14731. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14732. * @returns the current particle system
  14733. */
  14734. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14735. /**
  14736. * Remove a specific color gradient
  14737. * @param gradient defines the gradient to remove
  14738. * @returns the current particle system
  14739. */
  14740. removeColorGradient(gradient: number): IParticleSystem;
  14741. /**
  14742. * Adds a new size gradient
  14743. * @param gradient defines the gradient to use (between 0 and 1)
  14744. * @param factor defines the size factor to affect to the specified gradient
  14745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14746. * @returns the current particle system
  14747. */
  14748. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14749. /**
  14750. * Remove a specific size gradient
  14751. * @param gradient defines the gradient to remove
  14752. * @returns the current particle system
  14753. */
  14754. removeSizeGradient(gradient: number): IParticleSystem;
  14755. /**
  14756. * Gets the current list of color gradients.
  14757. * You must use addColorGradient and removeColorGradient to udpate this list
  14758. * @returns the list of color gradients
  14759. */
  14760. getColorGradients(): Nullable<Array<ColorGradient>>;
  14761. /**
  14762. * Gets the current list of size gradients.
  14763. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14764. * @returns the list of size gradients
  14765. */
  14766. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14767. /**
  14768. * Gets the current list of angular speed gradients.
  14769. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14770. * @returns the list of angular speed gradients
  14771. */
  14772. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14773. /**
  14774. * Adds a new angular speed gradient
  14775. * @param gradient defines the gradient to use (between 0 and 1)
  14776. * @param factor defines the angular speed to affect to the specified gradient
  14777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14778. * @returns the current particle system
  14779. */
  14780. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14781. /**
  14782. * Remove a specific angular speed gradient
  14783. * @param gradient defines the gradient to remove
  14784. * @returns the current particle system
  14785. */
  14786. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14787. /**
  14788. * Gets the current list of velocity gradients.
  14789. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14790. * @returns the list of velocity gradients
  14791. */
  14792. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14793. /**
  14794. * Adds a new velocity gradient
  14795. * @param gradient defines the gradient to use (between 0 and 1)
  14796. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14801. /**
  14802. * Remove a specific velocity gradient
  14803. * @param gradient defines the gradient to remove
  14804. * @returns the current particle system
  14805. */
  14806. removeVelocityGradient(gradient: number): IParticleSystem;
  14807. /**
  14808. * Gets the current list of limit velocity gradients.
  14809. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14810. * @returns the list of limit velocity gradients
  14811. */
  14812. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14813. /**
  14814. * Adds a new limit velocity gradient
  14815. * @param gradient defines the gradient to use (between 0 and 1)
  14816. * @param factor defines the limit velocity to affect to the specified gradient
  14817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14818. * @returns the current particle system
  14819. */
  14820. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14821. /**
  14822. * Remove a specific limit velocity gradient
  14823. * @param gradient defines the gradient to remove
  14824. * @returns the current particle system
  14825. */
  14826. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14827. /**
  14828. * Adds a new drag gradient
  14829. * @param gradient defines the gradient to use (between 0 and 1)
  14830. * @param factor defines the drag to affect to the specified gradient
  14831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14832. * @returns the current particle system
  14833. */
  14834. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14835. /**
  14836. * Remove a specific drag gradient
  14837. * @param gradient defines the gradient to remove
  14838. * @returns the current particle system
  14839. */
  14840. removeDragGradient(gradient: number): IParticleSystem;
  14841. /**
  14842. * Gets the current list of drag gradients.
  14843. * You must use addDragGradient and removeDragGradient to udpate this list
  14844. * @returns the list of drag gradients
  14845. */
  14846. getDragGradients(): Nullable<Array<FactorGradient>>;
  14847. /**
  14848. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14849. * @param gradient defines the gradient to use (between 0 and 1)
  14850. * @param factor defines the emit rate to affect to the specified gradient
  14851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14852. * @returns the current particle system
  14853. */
  14854. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14855. /**
  14856. * Remove a specific emit rate gradient
  14857. * @param gradient defines the gradient to remove
  14858. * @returns the current particle system
  14859. */
  14860. removeEmitRateGradient(gradient: number): IParticleSystem;
  14861. /**
  14862. * Gets the current list of emit rate gradients.
  14863. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14864. * @returns the list of emit rate gradients
  14865. */
  14866. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14867. /**
  14868. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14869. * @param gradient defines the gradient to use (between 0 and 1)
  14870. * @param factor defines the start size to affect to the specified gradient
  14871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14872. * @returns the current particle system
  14873. */
  14874. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14875. /**
  14876. * Remove a specific start size gradient
  14877. * @param gradient defines the gradient to remove
  14878. * @returns the current particle system
  14879. */
  14880. removeStartSizeGradient(gradient: number): IParticleSystem;
  14881. /**
  14882. * Gets the current list of start size gradients.
  14883. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14884. * @returns the list of start size gradients
  14885. */
  14886. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14887. /**
  14888. * Adds a new life time gradient
  14889. * @param gradient defines the gradient to use (between 0 and 1)
  14890. * @param factor defines the life time factor to affect to the specified gradient
  14891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14892. * @returns the current particle system
  14893. */
  14894. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14895. /**
  14896. * Remove a specific life time gradient
  14897. * @param gradient defines the gradient to remove
  14898. * @returns the current particle system
  14899. */
  14900. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14901. /**
  14902. * Gets the current list of life time gradients.
  14903. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14904. * @returns the list of life time gradients
  14905. */
  14906. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14907. /**
  14908. * Gets the current list of color gradients.
  14909. * You must use addColorGradient and removeColorGradient to udpate this list
  14910. * @returns the list of color gradients
  14911. */
  14912. getColorGradients(): Nullable<Array<ColorGradient>>;
  14913. /**
  14914. * Adds a new ramp gradient used to remap particle colors
  14915. * @param gradient defines the gradient to use (between 0 and 1)
  14916. * @param color defines the color to affect to the specified gradient
  14917. * @returns the current particle system
  14918. */
  14919. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14920. /**
  14921. * Gets the current list of ramp gradients.
  14922. * You must use addRampGradient and removeRampGradient to udpate this list
  14923. * @returns the list of ramp gradients
  14924. */
  14925. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14926. /** Gets or sets a boolean indicating that ramp gradients must be used
  14927. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14928. */
  14929. useRampGradients: boolean;
  14930. /**
  14931. * Adds a new color remap gradient
  14932. * @param gradient defines the gradient to use (between 0 and 1)
  14933. * @param min defines the color remap minimal range
  14934. * @param max defines the color remap maximal range
  14935. * @returns the current particle system
  14936. */
  14937. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14938. /**
  14939. * Gets the current list of color remap gradients.
  14940. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14941. * @returns the list of color remap gradients
  14942. */
  14943. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14944. /**
  14945. * Adds a new alpha remap gradient
  14946. * @param gradient defines the gradient to use (between 0 and 1)
  14947. * @param min defines the alpha remap minimal range
  14948. * @param max defines the alpha remap maximal range
  14949. * @returns the current particle system
  14950. */
  14951. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14952. /**
  14953. * Gets the current list of alpha remap gradients.
  14954. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14955. * @returns the list of alpha remap gradients
  14956. */
  14957. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14958. /**
  14959. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14960. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14961. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14962. * @returns the emitter
  14963. */
  14964. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14965. /**
  14966. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14967. * @param radius The radius of the hemisphere to emit from
  14968. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14969. * @returns the emitter
  14970. */
  14971. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14972. /**
  14973. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14974. * @param radius The radius of the sphere to emit from
  14975. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14976. * @returns the emitter
  14977. */
  14978. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14979. /**
  14980. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14981. * @param radius The radius of the sphere to emit from
  14982. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14983. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14984. * @returns the emitter
  14985. */
  14986. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14987. /**
  14988. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14989. * @param radius The radius of the emission cylinder
  14990. * @param height The height of the emission cylinder
  14991. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14992. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14993. * @returns the emitter
  14994. */
  14995. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14996. /**
  14997. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14998. * @param radius The radius of the cylinder to emit from
  14999. * @param height The height of the emission cylinder
  15000. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15003. * @returns the emitter
  15004. */
  15005. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15006. /**
  15007. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15008. * @param radius The radius of the cone to emit from
  15009. * @param angle The base angle of the cone
  15010. * @returns the emitter
  15011. */
  15012. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15013. /**
  15014. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15015. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15016. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15017. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15018. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15019. * @returns the emitter
  15020. */
  15021. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15022. /**
  15023. * Get hosting scene
  15024. * @returns the scene
  15025. */
  15026. getScene(): Nullable<Scene>;
  15027. }
  15028. }
  15029. declare module "babylonjs/Meshes/transformNode" {
  15030. import { DeepImmutable } from "babylonjs/types";
  15031. import { Observable } from "babylonjs/Misc/observable";
  15032. import { Nullable } from "babylonjs/types";
  15033. import { Camera } from "babylonjs/Cameras/camera";
  15034. import { Scene } from "babylonjs/scene";
  15035. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15036. import { Node } from "babylonjs/node";
  15037. import { Bone } from "babylonjs/Bones/bone";
  15038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15039. import { Space } from "babylonjs/Maths/math.axis";
  15040. /**
  15041. * 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.
  15042. * @see https://doc.babylonjs.com/how_to/transformnode
  15043. */
  15044. export class TransformNode extends Node {
  15045. /**
  15046. * Object will not rotate to face the camera
  15047. */
  15048. static BILLBOARDMODE_NONE: number;
  15049. /**
  15050. * Object will rotate to face the camera but only on the x axis
  15051. */
  15052. static BILLBOARDMODE_X: number;
  15053. /**
  15054. * Object will rotate to face the camera but only on the y axis
  15055. */
  15056. static BILLBOARDMODE_Y: number;
  15057. /**
  15058. * Object will rotate to face the camera but only on the z axis
  15059. */
  15060. static BILLBOARDMODE_Z: number;
  15061. /**
  15062. * Object will rotate to face the camera
  15063. */
  15064. static BILLBOARDMODE_ALL: number;
  15065. /**
  15066. * Object will rotate to face the camera's position instead of orientation
  15067. */
  15068. static BILLBOARDMODE_USE_POSITION: number;
  15069. private static _TmpRotation;
  15070. private static _TmpScaling;
  15071. private static _TmpTranslation;
  15072. private _forward;
  15073. private _forwardInverted;
  15074. private _up;
  15075. private _right;
  15076. private _rightInverted;
  15077. private _position;
  15078. private _rotation;
  15079. private _rotationQuaternion;
  15080. protected _scaling: Vector3;
  15081. protected _isDirty: boolean;
  15082. private _transformToBoneReferal;
  15083. private _isAbsoluteSynced;
  15084. private _billboardMode;
  15085. /**
  15086. * Gets or sets the billboard mode. Default is 0.
  15087. *
  15088. * | Value | Type | Description |
  15089. * | --- | --- | --- |
  15090. * | 0 | BILLBOARDMODE_NONE | |
  15091. * | 1 | BILLBOARDMODE_X | |
  15092. * | 2 | BILLBOARDMODE_Y | |
  15093. * | 4 | BILLBOARDMODE_Z | |
  15094. * | 7 | BILLBOARDMODE_ALL | |
  15095. *
  15096. */
  15097. get billboardMode(): number;
  15098. set billboardMode(value: number);
  15099. private _preserveParentRotationForBillboard;
  15100. /**
  15101. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15102. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15103. */
  15104. get preserveParentRotationForBillboard(): boolean;
  15105. set preserveParentRotationForBillboard(value: boolean);
  15106. /**
  15107. * 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
  15108. */
  15109. scalingDeterminant: number;
  15110. private _infiniteDistance;
  15111. /**
  15112. * Gets or sets the distance of the object to max, often used by skybox
  15113. */
  15114. get infiniteDistance(): boolean;
  15115. set infiniteDistance(value: boolean);
  15116. /**
  15117. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15118. * By default the system will update normals to compensate
  15119. */
  15120. ignoreNonUniformScaling: boolean;
  15121. /**
  15122. * 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
  15123. */
  15124. reIntegrateRotationIntoRotationQuaternion: boolean;
  15125. /** @hidden */
  15126. _poseMatrix: Nullable<Matrix>;
  15127. /** @hidden */
  15128. _localMatrix: Matrix;
  15129. private _usePivotMatrix;
  15130. private _absolutePosition;
  15131. private _absoluteScaling;
  15132. private _absoluteRotationQuaternion;
  15133. private _pivotMatrix;
  15134. private _pivotMatrixInverse;
  15135. /** @hidden */
  15136. _postMultiplyPivotMatrix: boolean;
  15137. protected _isWorldMatrixFrozen: boolean;
  15138. /** @hidden */
  15139. _indexInSceneTransformNodesArray: number;
  15140. /**
  15141. * An event triggered after the world matrix is updated
  15142. */
  15143. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15144. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15145. /**
  15146. * Gets a string identifying the name of the class
  15147. * @returns "TransformNode" string
  15148. */
  15149. getClassName(): string;
  15150. /**
  15151. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15152. */
  15153. get position(): Vector3;
  15154. set position(newPosition: Vector3);
  15155. /**
  15156. * 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)).
  15157. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15158. */
  15159. get rotation(): Vector3;
  15160. set rotation(newRotation: Vector3);
  15161. /**
  15162. * 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)).
  15163. */
  15164. get scaling(): Vector3;
  15165. set scaling(newScaling: Vector3);
  15166. /**
  15167. * 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).
  15168. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15169. */
  15170. get rotationQuaternion(): Nullable<Quaternion>;
  15171. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15172. /**
  15173. * The forward direction of that transform in world space.
  15174. */
  15175. get forward(): Vector3;
  15176. /**
  15177. * The up direction of that transform in world space.
  15178. */
  15179. get up(): Vector3;
  15180. /**
  15181. * The right direction of that transform in world space.
  15182. */
  15183. get right(): Vector3;
  15184. /**
  15185. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15186. * @param matrix the matrix to copy the pose from
  15187. * @returns this TransformNode.
  15188. */
  15189. updatePoseMatrix(matrix: Matrix): TransformNode;
  15190. /**
  15191. * Returns the mesh Pose matrix.
  15192. * @returns the pose matrix
  15193. */
  15194. getPoseMatrix(): Matrix;
  15195. /** @hidden */
  15196. _isSynchronized(): boolean;
  15197. /** @hidden */
  15198. _initCache(): void;
  15199. /**
  15200. * Flag the transform node as dirty (Forcing it to update everything)
  15201. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15202. * @returns this transform node
  15203. */
  15204. markAsDirty(property: string): TransformNode;
  15205. /**
  15206. * Returns the current mesh absolute position.
  15207. * Returns a Vector3.
  15208. */
  15209. get absolutePosition(): Vector3;
  15210. /**
  15211. * Returns the current mesh absolute scaling.
  15212. * Returns a Vector3.
  15213. */
  15214. get absoluteScaling(): Vector3;
  15215. /**
  15216. * Returns the current mesh absolute rotation.
  15217. * Returns a Quaternion.
  15218. */
  15219. get absoluteRotationQuaternion(): Quaternion;
  15220. /**
  15221. * Sets a new matrix to apply before all other transformation
  15222. * @param matrix defines the transform matrix
  15223. * @returns the current TransformNode
  15224. */
  15225. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15226. /**
  15227. * Sets a new pivot matrix to the current node
  15228. * @param matrix defines the new pivot matrix to use
  15229. * @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
  15230. * @returns the current TransformNode
  15231. */
  15232. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15233. /**
  15234. * Returns the mesh pivot matrix.
  15235. * Default : Identity.
  15236. * @returns the matrix
  15237. */
  15238. getPivotMatrix(): Matrix;
  15239. /**
  15240. * Instantiate (when possible) or clone that node with its hierarchy
  15241. * @param newParent defines the new parent to use for the instance (or clone)
  15242. * @param options defines options to configure how copy is done
  15243. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15244. * @returns an instance (or a clone) of the current node with its hiearchy
  15245. */
  15246. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15247. doNotInstantiate: boolean;
  15248. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15249. /**
  15250. * Prevents the World matrix to be computed any longer
  15251. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15252. * @returns the TransformNode.
  15253. */
  15254. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15255. /**
  15256. * Allows back the World matrix computation.
  15257. * @returns the TransformNode.
  15258. */
  15259. unfreezeWorldMatrix(): this;
  15260. /**
  15261. * True if the World matrix has been frozen.
  15262. */
  15263. get isWorldMatrixFrozen(): boolean;
  15264. /**
  15265. * Retuns the mesh absolute position in the World.
  15266. * @returns a Vector3.
  15267. */
  15268. getAbsolutePosition(): Vector3;
  15269. /**
  15270. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15271. * @param absolutePosition the absolute position to set
  15272. * @returns the TransformNode.
  15273. */
  15274. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15275. /**
  15276. * Sets the mesh position in its local space.
  15277. * @param vector3 the position to set in localspace
  15278. * @returns the TransformNode.
  15279. */
  15280. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15281. /**
  15282. * Returns the mesh position in the local space from the current World matrix values.
  15283. * @returns a new Vector3.
  15284. */
  15285. getPositionExpressedInLocalSpace(): Vector3;
  15286. /**
  15287. * Translates the mesh along the passed Vector3 in its local space.
  15288. * @param vector3 the distance to translate in localspace
  15289. * @returns the TransformNode.
  15290. */
  15291. locallyTranslate(vector3: Vector3): TransformNode;
  15292. private static _lookAtVectorCache;
  15293. /**
  15294. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15295. * @param targetPoint the position (must be in same space as current mesh) to look at
  15296. * @param yawCor optional yaw (y-axis) correction in radians
  15297. * @param pitchCor optional pitch (x-axis) correction in radians
  15298. * @param rollCor optional roll (z-axis) correction in radians
  15299. * @param space the choosen space of the target
  15300. * @returns the TransformNode.
  15301. */
  15302. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15303. /**
  15304. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15305. * This Vector3 is expressed in the World space.
  15306. * @param localAxis axis to rotate
  15307. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15308. */
  15309. getDirection(localAxis: Vector3): Vector3;
  15310. /**
  15311. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15312. * localAxis is expressed in the mesh local space.
  15313. * result is computed in the Wordl space from the mesh World matrix.
  15314. * @param localAxis axis to rotate
  15315. * @param result the resulting transformnode
  15316. * @returns this TransformNode.
  15317. */
  15318. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15319. /**
  15320. * Sets this transform node rotation to the given local axis.
  15321. * @param localAxis the axis in local space
  15322. * @param yawCor optional yaw (y-axis) correction in radians
  15323. * @param pitchCor optional pitch (x-axis) correction in radians
  15324. * @param rollCor optional roll (z-axis) correction in radians
  15325. * @returns this TransformNode
  15326. */
  15327. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15328. /**
  15329. * Sets a new pivot point to the current node
  15330. * @param point defines the new pivot point to use
  15331. * @param space defines if the point is in world or local space (local by default)
  15332. * @returns the current TransformNode
  15333. */
  15334. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15335. /**
  15336. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15337. * @returns the pivot point
  15338. */
  15339. getPivotPoint(): Vector3;
  15340. /**
  15341. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15342. * @param result the vector3 to store the result
  15343. * @returns this TransformNode.
  15344. */
  15345. getPivotPointToRef(result: Vector3): TransformNode;
  15346. /**
  15347. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15348. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15349. */
  15350. getAbsolutePivotPoint(): Vector3;
  15351. /**
  15352. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15353. * @param result vector3 to store the result
  15354. * @returns this TransformNode.
  15355. */
  15356. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15357. /**
  15358. * Defines the passed node as the parent of the current node.
  15359. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15360. * @see https://doc.babylonjs.com/how_to/parenting
  15361. * @param node the node ot set as the parent
  15362. * @returns this TransformNode.
  15363. */
  15364. setParent(node: Nullable<Node>): TransformNode;
  15365. private _nonUniformScaling;
  15366. /**
  15367. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15368. */
  15369. get nonUniformScaling(): boolean;
  15370. /** @hidden */
  15371. _updateNonUniformScalingState(value: boolean): boolean;
  15372. /**
  15373. * Attach the current TransformNode to another TransformNode associated with a bone
  15374. * @param bone Bone affecting the TransformNode
  15375. * @param affectedTransformNode TransformNode associated with the bone
  15376. * @returns this object
  15377. */
  15378. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15379. /**
  15380. * Detach the transform node if its associated with a bone
  15381. * @returns this object
  15382. */
  15383. detachFromBone(): TransformNode;
  15384. private static _rotationAxisCache;
  15385. /**
  15386. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15387. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15388. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15389. * The passed axis is also normalized.
  15390. * @param axis the axis to rotate around
  15391. * @param amount the amount to rotate in radians
  15392. * @param space Space to rotate in (Default: local)
  15393. * @returns the TransformNode.
  15394. */
  15395. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15396. /**
  15397. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15398. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15399. * The passed axis is also normalized. .
  15400. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15401. * @param point the point to rotate around
  15402. * @param axis the axis to rotate around
  15403. * @param amount the amount to rotate in radians
  15404. * @returns the TransformNode
  15405. */
  15406. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15407. /**
  15408. * Translates the mesh along the axis vector for the passed distance in the given space.
  15409. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15410. * @param axis the axis to translate in
  15411. * @param distance the distance to translate
  15412. * @param space Space to rotate in (Default: local)
  15413. * @returns the TransformNode.
  15414. */
  15415. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15416. /**
  15417. * Adds a rotation step to the mesh current rotation.
  15418. * x, y, z are Euler angles expressed in radians.
  15419. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15420. * This means this rotation is made in the mesh local space only.
  15421. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15422. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15423. * ```javascript
  15424. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15425. * ```
  15426. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15427. * 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.
  15428. * @param x Rotation to add
  15429. * @param y Rotation to add
  15430. * @param z Rotation to add
  15431. * @returns the TransformNode.
  15432. */
  15433. addRotation(x: number, y: number, z: number): TransformNode;
  15434. /**
  15435. * @hidden
  15436. */
  15437. protected _getEffectiveParent(): Nullable<Node>;
  15438. /**
  15439. * Computes the world matrix of the node
  15440. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15441. * @returns the world matrix
  15442. */
  15443. computeWorldMatrix(force?: boolean): Matrix;
  15444. /**
  15445. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15446. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15447. */
  15448. resetLocalMatrix(independentOfChildren?: boolean): void;
  15449. protected _afterComputeWorldMatrix(): void;
  15450. /**
  15451. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15452. * @param func callback function to add
  15453. *
  15454. * @returns the TransformNode.
  15455. */
  15456. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15457. /**
  15458. * Removes a registered callback function.
  15459. * @param func callback function to remove
  15460. * @returns the TransformNode.
  15461. */
  15462. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15463. /**
  15464. * Gets the position of the current mesh in camera space
  15465. * @param camera defines the camera to use
  15466. * @returns a position
  15467. */
  15468. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15469. /**
  15470. * Returns the distance from the mesh to the active camera
  15471. * @param camera defines the camera to use
  15472. * @returns the distance
  15473. */
  15474. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15475. /**
  15476. * Clone the current transform node
  15477. * @param name Name of the new clone
  15478. * @param newParent New parent for the clone
  15479. * @param doNotCloneChildren Do not clone children hierarchy
  15480. * @returns the new transform node
  15481. */
  15482. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15483. /**
  15484. * Serializes the objects information.
  15485. * @param currentSerializationObject defines the object to serialize in
  15486. * @returns the serialized object
  15487. */
  15488. serialize(currentSerializationObject?: any): any;
  15489. /**
  15490. * Returns a new TransformNode object parsed from the source provided.
  15491. * @param parsedTransformNode is the source.
  15492. * @param scene the scne the object belongs to
  15493. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15494. * @returns a new TransformNode object parsed from the source provided.
  15495. */
  15496. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15497. /**
  15498. * Get all child-transformNodes of this node
  15499. * @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
  15500. * @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
  15501. * @returns an array of TransformNode
  15502. */
  15503. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15504. /**
  15505. * Releases resources associated with this transform node.
  15506. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15507. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15508. */
  15509. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15510. /**
  15511. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15512. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15513. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15514. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15515. * @returns the current mesh
  15516. */
  15517. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15518. private _syncAbsoluteScalingAndRotation;
  15519. }
  15520. }
  15521. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15522. /**
  15523. * Class used to override all child animations of a given target
  15524. */
  15525. export class AnimationPropertiesOverride {
  15526. /**
  15527. * Gets or sets a value indicating if animation blending must be used
  15528. */
  15529. enableBlending: boolean;
  15530. /**
  15531. * Gets or sets the blending speed to use when enableBlending is true
  15532. */
  15533. blendingSpeed: number;
  15534. /**
  15535. * Gets or sets the default loop mode to use
  15536. */
  15537. loopMode: number;
  15538. }
  15539. }
  15540. declare module "babylonjs/Bones/bone" {
  15541. import { Skeleton } from "babylonjs/Bones/skeleton";
  15542. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15543. import { Nullable } from "babylonjs/types";
  15544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15545. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15546. import { Node } from "babylonjs/node";
  15547. import { Space } from "babylonjs/Maths/math.axis";
  15548. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15549. /**
  15550. * Class used to store bone information
  15551. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15552. */
  15553. export class Bone extends Node {
  15554. /**
  15555. * defines the bone name
  15556. */
  15557. name: string;
  15558. private static _tmpVecs;
  15559. private static _tmpQuat;
  15560. private static _tmpMats;
  15561. /**
  15562. * Gets the list of child bones
  15563. */
  15564. children: Bone[];
  15565. /** Gets the animations associated with this bone */
  15566. animations: import("babylonjs/Animations/animation").Animation[];
  15567. /**
  15568. * Gets or sets bone length
  15569. */
  15570. length: number;
  15571. /**
  15572. * @hidden Internal only
  15573. * Set this value to map this bone to a different index in the transform matrices
  15574. * Set this value to -1 to exclude the bone from the transform matrices
  15575. */
  15576. _index: Nullable<number>;
  15577. private _skeleton;
  15578. private _localMatrix;
  15579. private _restPose;
  15580. private _bindPose;
  15581. private _baseMatrix;
  15582. private _absoluteTransform;
  15583. private _invertedAbsoluteTransform;
  15584. private _parent;
  15585. private _scalingDeterminant;
  15586. private _worldTransform;
  15587. private _localScaling;
  15588. private _localRotation;
  15589. private _localPosition;
  15590. private _needToDecompose;
  15591. private _needToCompose;
  15592. /** @hidden */
  15593. _linkedTransformNode: Nullable<TransformNode>;
  15594. /** @hidden */
  15595. _waitingTransformNodeId: Nullable<string>;
  15596. /** @hidden */
  15597. get _matrix(): Matrix;
  15598. /** @hidden */
  15599. set _matrix(value: Matrix);
  15600. /**
  15601. * Create a new bone
  15602. * @param name defines the bone name
  15603. * @param skeleton defines the parent skeleton
  15604. * @param parentBone defines the parent (can be null if the bone is the root)
  15605. * @param localMatrix defines the local matrix
  15606. * @param restPose defines the rest pose matrix
  15607. * @param baseMatrix defines the base matrix
  15608. * @param index defines index of the bone in the hiearchy
  15609. */
  15610. constructor(
  15611. /**
  15612. * defines the bone name
  15613. */
  15614. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15615. /**
  15616. * Gets the current object class name.
  15617. * @return the class name
  15618. */
  15619. getClassName(): string;
  15620. /**
  15621. * Gets the parent skeleton
  15622. * @returns a skeleton
  15623. */
  15624. getSkeleton(): Skeleton;
  15625. /**
  15626. * Gets parent bone
  15627. * @returns a bone or null if the bone is the root of the bone hierarchy
  15628. */
  15629. getParent(): Nullable<Bone>;
  15630. /**
  15631. * Returns an array containing the root bones
  15632. * @returns an array containing the root bones
  15633. */
  15634. getChildren(): Array<Bone>;
  15635. /**
  15636. * Gets the node index in matrix array generated for rendering
  15637. * @returns the node index
  15638. */
  15639. getIndex(): number;
  15640. /**
  15641. * Sets the parent bone
  15642. * @param parent defines the parent (can be null if the bone is the root)
  15643. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15644. */
  15645. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15646. /**
  15647. * Gets the local matrix
  15648. * @returns a matrix
  15649. */
  15650. getLocalMatrix(): Matrix;
  15651. /**
  15652. * Gets the base matrix (initial matrix which remains unchanged)
  15653. * @returns a matrix
  15654. */
  15655. getBaseMatrix(): Matrix;
  15656. /**
  15657. * Gets the rest pose matrix
  15658. * @returns a matrix
  15659. */
  15660. getRestPose(): Matrix;
  15661. /**
  15662. * Sets the rest pose matrix
  15663. * @param matrix the local-space rest pose to set for this bone
  15664. */
  15665. setRestPose(matrix: Matrix): void;
  15666. /**
  15667. * Gets the bind pose matrix
  15668. * @returns the bind pose matrix
  15669. */
  15670. getBindPose(): Matrix;
  15671. /**
  15672. * Sets the bind pose matrix
  15673. * @param matrix the local-space bind pose to set for this bone
  15674. */
  15675. setBindPose(matrix: Matrix): void;
  15676. /**
  15677. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15678. */
  15679. getWorldMatrix(): Matrix;
  15680. /**
  15681. * Sets the local matrix to rest pose matrix
  15682. */
  15683. returnToRest(): void;
  15684. /**
  15685. * Gets the inverse of the absolute transform matrix.
  15686. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15687. * @returns a matrix
  15688. */
  15689. getInvertedAbsoluteTransform(): Matrix;
  15690. /**
  15691. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15692. * @returns a matrix
  15693. */
  15694. getAbsoluteTransform(): Matrix;
  15695. /**
  15696. * Links with the given transform node.
  15697. * The local matrix of this bone is copied from the transform node every frame.
  15698. * @param transformNode defines the transform node to link to
  15699. */
  15700. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15701. /**
  15702. * Gets the node used to drive the bone's transformation
  15703. * @returns a transform node or null
  15704. */
  15705. getTransformNode(): Nullable<TransformNode>;
  15706. /** Gets or sets current position (in local space) */
  15707. get position(): Vector3;
  15708. set position(newPosition: Vector3);
  15709. /** Gets or sets current rotation (in local space) */
  15710. get rotation(): Vector3;
  15711. set rotation(newRotation: Vector3);
  15712. /** Gets or sets current rotation quaternion (in local space) */
  15713. get rotationQuaternion(): Quaternion;
  15714. set rotationQuaternion(newRotation: Quaternion);
  15715. /** Gets or sets current scaling (in local space) */
  15716. get scaling(): Vector3;
  15717. set scaling(newScaling: Vector3);
  15718. /**
  15719. * Gets the animation properties override
  15720. */
  15721. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15722. private _decompose;
  15723. private _compose;
  15724. /**
  15725. * Update the base and local matrices
  15726. * @param matrix defines the new base or local matrix
  15727. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15728. * @param updateLocalMatrix defines if the local matrix should be updated
  15729. */
  15730. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15731. /** @hidden */
  15732. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15733. /**
  15734. * Flag the bone as dirty (Forcing it to update everything)
  15735. */
  15736. markAsDirty(): void;
  15737. /** @hidden */
  15738. _markAsDirtyAndCompose(): void;
  15739. private _markAsDirtyAndDecompose;
  15740. /**
  15741. * Translate the bone in local or world space
  15742. * @param vec The amount to translate the bone
  15743. * @param space The space that the translation is in
  15744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15745. */
  15746. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15747. /**
  15748. * Set the postion of the bone in local or world space
  15749. * @param position The position to set the bone
  15750. * @param space The space that the position is in
  15751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15752. */
  15753. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15754. /**
  15755. * Set the absolute position of the bone (world space)
  15756. * @param position The position to set the bone
  15757. * @param mesh The mesh that this bone is attached to
  15758. */
  15759. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15760. /**
  15761. * Scale the bone on the x, y and z axes (in local space)
  15762. * @param x The amount to scale the bone on the x axis
  15763. * @param y The amount to scale the bone on the y axis
  15764. * @param z The amount to scale the bone on the z axis
  15765. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15766. */
  15767. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15768. /**
  15769. * Set the bone scaling in local space
  15770. * @param scale defines the scaling vector
  15771. */
  15772. setScale(scale: Vector3): void;
  15773. /**
  15774. * Gets the current scaling in local space
  15775. * @returns the current scaling vector
  15776. */
  15777. getScale(): Vector3;
  15778. /**
  15779. * Gets the current scaling in local space and stores it in a target vector
  15780. * @param result defines the target vector
  15781. */
  15782. getScaleToRef(result: Vector3): void;
  15783. /**
  15784. * Set the yaw, pitch, and roll of the bone in local or world space
  15785. * @param yaw The rotation of the bone on the y axis
  15786. * @param pitch The rotation of the bone on the x axis
  15787. * @param roll The rotation of the bone on the z axis
  15788. * @param space The space that the axes of rotation are in
  15789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15790. */
  15791. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15792. /**
  15793. * Add a rotation to the bone on an axis in local or world space
  15794. * @param axis The axis to rotate the bone on
  15795. * @param amount The amount to rotate the bone
  15796. * @param space The space that the axis is in
  15797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15798. */
  15799. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15800. /**
  15801. * Set the rotation of the bone to a particular axis angle in local or world space
  15802. * @param axis The axis to rotate the bone on
  15803. * @param angle The angle that the bone should be rotated to
  15804. * @param space The space that the axis is in
  15805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15806. */
  15807. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15808. /**
  15809. * Set the euler rotation of the bone in local or world space
  15810. * @param rotation The euler rotation that the bone should be set to
  15811. * @param space The space that the rotation is in
  15812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15813. */
  15814. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15815. /**
  15816. * Set the quaternion rotation of the bone in local or world space
  15817. * @param quat The quaternion rotation that the bone should be set to
  15818. * @param space The space that the rotation is in
  15819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15820. */
  15821. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15822. /**
  15823. * Set the rotation matrix of the bone in local or world space
  15824. * @param rotMat The rotation matrix that the bone should be set to
  15825. * @param space The space that the rotation is in
  15826. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15827. */
  15828. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15829. private _rotateWithMatrix;
  15830. private _getNegativeRotationToRef;
  15831. /**
  15832. * Get the position of the bone in local or world space
  15833. * @param space The space that the returned position is in
  15834. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15835. * @returns The position of the bone
  15836. */
  15837. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15838. /**
  15839. * Copy the position of the bone to a vector3 in local or world space
  15840. * @param space The space that the returned position is in
  15841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15842. * @param result The vector3 to copy the position to
  15843. */
  15844. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15845. /**
  15846. * Get the absolute position of the bone (world space)
  15847. * @param mesh The mesh that this bone is attached to
  15848. * @returns The absolute position of the bone
  15849. */
  15850. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15851. /**
  15852. * Copy the absolute position of the bone (world space) to the result param
  15853. * @param mesh The mesh that this bone is attached to
  15854. * @param result The vector3 to copy the absolute position to
  15855. */
  15856. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15857. /**
  15858. * Compute the absolute transforms of this bone and its children
  15859. */
  15860. computeAbsoluteTransforms(): void;
  15861. /**
  15862. * Get the world direction from an axis that is in the local space of the bone
  15863. * @param localAxis The local direction that is used to compute the world direction
  15864. * @param mesh The mesh that this bone is attached to
  15865. * @returns The world direction
  15866. */
  15867. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15868. /**
  15869. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15870. * @param localAxis The local direction that is used to compute the world direction
  15871. * @param mesh The mesh that this bone is attached to
  15872. * @param result The vector3 that the world direction will be copied to
  15873. */
  15874. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15875. /**
  15876. * Get the euler rotation of the bone in local or world space
  15877. * @param space The space that the rotation should be in
  15878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15879. * @returns The euler rotation
  15880. */
  15881. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15882. /**
  15883. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15884. * @param space The space that the rotation should be in
  15885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15886. * @param result The vector3 that the rotation should be copied to
  15887. */
  15888. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15889. /**
  15890. * Get the quaternion rotation of the bone in either local or world space
  15891. * @param space The space that the rotation should be in
  15892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15893. * @returns The quaternion rotation
  15894. */
  15895. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15896. /**
  15897. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15898. * @param space The space that the rotation should be in
  15899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15900. * @param result The quaternion that the rotation should be copied to
  15901. */
  15902. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15903. /**
  15904. * Get the rotation matrix of the bone in local or world space
  15905. * @param space The space that the rotation should be in
  15906. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15907. * @returns The rotation matrix
  15908. */
  15909. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15910. /**
  15911. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15912. * @param space The space that the rotation should be in
  15913. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15914. * @param result The quaternion that the rotation should be copied to
  15915. */
  15916. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15917. /**
  15918. * Get the world position of a point that is in the local space of the bone
  15919. * @param position The local position
  15920. * @param mesh The mesh that this bone is attached to
  15921. * @returns The world position
  15922. */
  15923. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15924. /**
  15925. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15926. * @param position The local position
  15927. * @param mesh The mesh that this bone is attached to
  15928. * @param result The vector3 that the world position should be copied to
  15929. */
  15930. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15931. /**
  15932. * Get the local position of a point that is in world space
  15933. * @param position The world position
  15934. * @param mesh The mesh that this bone is attached to
  15935. * @returns The local position
  15936. */
  15937. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15938. /**
  15939. * Get the local position of a point that is in world space and copy it to the result param
  15940. * @param position The world position
  15941. * @param mesh The mesh that this bone is attached to
  15942. * @param result The vector3 that the local position should be copied to
  15943. */
  15944. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15945. /**
  15946. * Set the current local matrix as the restPose for this bone.
  15947. */
  15948. setCurrentPoseAsRest(): void;
  15949. }
  15950. }
  15951. declare module "babylonjs/Animations/runtimeAnimation" {
  15952. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15953. import { Animatable } from "babylonjs/Animations/animatable";
  15954. import { Scene } from "babylonjs/scene";
  15955. /**
  15956. * Defines a runtime animation
  15957. */
  15958. export class RuntimeAnimation {
  15959. private _events;
  15960. /**
  15961. * The current frame of the runtime animation
  15962. */
  15963. private _currentFrame;
  15964. /**
  15965. * The animation used by the runtime animation
  15966. */
  15967. private _animation;
  15968. /**
  15969. * The target of the runtime animation
  15970. */
  15971. private _target;
  15972. /**
  15973. * The initiating animatable
  15974. */
  15975. private _host;
  15976. /**
  15977. * The original value of the runtime animation
  15978. */
  15979. private _originalValue;
  15980. /**
  15981. * The original blend value of the runtime animation
  15982. */
  15983. private _originalBlendValue;
  15984. /**
  15985. * The offsets cache of the runtime animation
  15986. */
  15987. private _offsetsCache;
  15988. /**
  15989. * The high limits cache of the runtime animation
  15990. */
  15991. private _highLimitsCache;
  15992. /**
  15993. * Specifies if the runtime animation has been stopped
  15994. */
  15995. private _stopped;
  15996. /**
  15997. * The blending factor of the runtime animation
  15998. */
  15999. private _blendingFactor;
  16000. /**
  16001. * The BabylonJS scene
  16002. */
  16003. private _scene;
  16004. /**
  16005. * The current value of the runtime animation
  16006. */
  16007. private _currentValue;
  16008. /** @hidden */
  16009. _animationState: _IAnimationState;
  16010. /**
  16011. * The active target of the runtime animation
  16012. */
  16013. private _activeTargets;
  16014. private _currentActiveTarget;
  16015. private _directTarget;
  16016. /**
  16017. * The target path of the runtime animation
  16018. */
  16019. private _targetPath;
  16020. /**
  16021. * The weight of the runtime animation
  16022. */
  16023. private _weight;
  16024. /**
  16025. * The ratio offset of the runtime animation
  16026. */
  16027. private _ratioOffset;
  16028. /**
  16029. * The previous delay of the runtime animation
  16030. */
  16031. private _previousDelay;
  16032. /**
  16033. * The previous ratio of the runtime animation
  16034. */
  16035. private _previousRatio;
  16036. private _enableBlending;
  16037. private _keys;
  16038. private _minFrame;
  16039. private _maxFrame;
  16040. private _minValue;
  16041. private _maxValue;
  16042. private _targetIsArray;
  16043. /**
  16044. * Gets the current frame of the runtime animation
  16045. */
  16046. get currentFrame(): number;
  16047. /**
  16048. * Gets the weight of the runtime animation
  16049. */
  16050. get weight(): number;
  16051. /**
  16052. * Gets the current value of the runtime animation
  16053. */
  16054. get currentValue(): any;
  16055. /**
  16056. * Gets the target path of the runtime animation
  16057. */
  16058. get targetPath(): string;
  16059. /**
  16060. * Gets the actual target of the runtime animation
  16061. */
  16062. get target(): any;
  16063. /**
  16064. * Gets the additive state of the runtime animation
  16065. */
  16066. get isAdditive(): boolean;
  16067. /** @hidden */
  16068. _onLoop: () => void;
  16069. /**
  16070. * Create a new RuntimeAnimation object
  16071. * @param target defines the target of the animation
  16072. * @param animation defines the source animation object
  16073. * @param scene defines the hosting scene
  16074. * @param host defines the initiating Animatable
  16075. */
  16076. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16077. private _preparePath;
  16078. /**
  16079. * Gets the animation from the runtime animation
  16080. */
  16081. get animation(): Animation;
  16082. /**
  16083. * Resets the runtime animation to the beginning
  16084. * @param restoreOriginal defines whether to restore the target property to the original value
  16085. */
  16086. reset(restoreOriginal?: boolean): void;
  16087. /**
  16088. * Specifies if the runtime animation is stopped
  16089. * @returns Boolean specifying if the runtime animation is stopped
  16090. */
  16091. isStopped(): boolean;
  16092. /**
  16093. * Disposes of the runtime animation
  16094. */
  16095. dispose(): void;
  16096. /**
  16097. * Apply the interpolated value to the target
  16098. * @param currentValue defines the value computed by the animation
  16099. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16100. */
  16101. setValue(currentValue: any, weight: number): void;
  16102. private _getOriginalValues;
  16103. private _setValue;
  16104. /**
  16105. * Gets the loop pmode of the runtime animation
  16106. * @returns Loop Mode
  16107. */
  16108. private _getCorrectLoopMode;
  16109. /**
  16110. * Move the current animation to a given frame
  16111. * @param frame defines the frame to move to
  16112. */
  16113. goToFrame(frame: number): void;
  16114. /**
  16115. * @hidden Internal use only
  16116. */
  16117. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16118. /**
  16119. * Execute the current animation
  16120. * @param delay defines the delay to add to the current frame
  16121. * @param from defines the lower bound of the animation range
  16122. * @param to defines the upper bound of the animation range
  16123. * @param loop defines if the current animation must loop
  16124. * @param speedRatio defines the current speed ratio
  16125. * @param weight defines the weight of the animation (default is -1 so no weight)
  16126. * @param onLoop optional callback called when animation loops
  16127. * @returns a boolean indicating if the animation is running
  16128. */
  16129. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16130. }
  16131. }
  16132. declare module "babylonjs/Animations/animatable" {
  16133. import { Animation } from "babylonjs/Animations/animation";
  16134. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16135. import { Nullable } from "babylonjs/types";
  16136. import { Observable } from "babylonjs/Misc/observable";
  16137. import { Scene } from "babylonjs/scene";
  16138. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16139. import { Node } from "babylonjs/node";
  16140. /**
  16141. * Class used to store an actual running animation
  16142. */
  16143. export class Animatable {
  16144. /** defines the target object */
  16145. target: any;
  16146. /** defines the starting frame number (default is 0) */
  16147. fromFrame: number;
  16148. /** defines the ending frame number (default is 100) */
  16149. toFrame: number;
  16150. /** defines if the animation must loop (default is false) */
  16151. loopAnimation: boolean;
  16152. /** defines a callback to call when animation ends if it is not looping */
  16153. onAnimationEnd?: (() => void) | null | undefined;
  16154. /** defines a callback to call when animation loops */
  16155. onAnimationLoop?: (() => void) | null | undefined;
  16156. /** defines whether the animation should be evaluated additively */
  16157. isAdditive: boolean;
  16158. private _localDelayOffset;
  16159. private _pausedDelay;
  16160. private _runtimeAnimations;
  16161. private _paused;
  16162. private _scene;
  16163. private _speedRatio;
  16164. private _weight;
  16165. private _syncRoot;
  16166. /**
  16167. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16168. * This will only apply for non looping animation (default is true)
  16169. */
  16170. disposeOnEnd: boolean;
  16171. /**
  16172. * Gets a boolean indicating if the animation has started
  16173. */
  16174. animationStarted: boolean;
  16175. /**
  16176. * Observer raised when the animation ends
  16177. */
  16178. onAnimationEndObservable: Observable<Animatable>;
  16179. /**
  16180. * Observer raised when the animation loops
  16181. */
  16182. onAnimationLoopObservable: Observable<Animatable>;
  16183. /**
  16184. * Gets the root Animatable used to synchronize and normalize animations
  16185. */
  16186. get syncRoot(): Nullable<Animatable>;
  16187. /**
  16188. * Gets the current frame of the first RuntimeAnimation
  16189. * Used to synchronize Animatables
  16190. */
  16191. get masterFrame(): number;
  16192. /**
  16193. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16194. */
  16195. get weight(): number;
  16196. set weight(value: number);
  16197. /**
  16198. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16199. */
  16200. get speedRatio(): number;
  16201. set speedRatio(value: number);
  16202. /**
  16203. * Creates a new Animatable
  16204. * @param scene defines the hosting scene
  16205. * @param target defines the target object
  16206. * @param fromFrame defines the starting frame number (default is 0)
  16207. * @param toFrame defines the ending frame number (default is 100)
  16208. * @param loopAnimation defines if the animation must loop (default is false)
  16209. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16210. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16211. * @param animations defines a group of animation to add to the new Animatable
  16212. * @param onAnimationLoop defines a callback to call when animation loops
  16213. * @param isAdditive defines whether the animation should be evaluated additively
  16214. */
  16215. constructor(scene: Scene,
  16216. /** defines the target object */
  16217. target: any,
  16218. /** defines the starting frame number (default is 0) */
  16219. fromFrame?: number,
  16220. /** defines the ending frame number (default is 100) */
  16221. toFrame?: number,
  16222. /** defines if the animation must loop (default is false) */
  16223. loopAnimation?: boolean, speedRatio?: number,
  16224. /** defines a callback to call when animation ends if it is not looping */
  16225. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16226. /** defines a callback to call when animation loops */
  16227. onAnimationLoop?: (() => void) | null | undefined,
  16228. /** defines whether the animation should be evaluated additively */
  16229. isAdditive?: boolean);
  16230. /**
  16231. * Synchronize and normalize current Animatable with a source Animatable
  16232. * This is useful when using animation weights and when animations are not of the same length
  16233. * @param root defines the root Animatable to synchronize with
  16234. * @returns the current Animatable
  16235. */
  16236. syncWith(root: Animatable): Animatable;
  16237. /**
  16238. * Gets the list of runtime animations
  16239. * @returns an array of RuntimeAnimation
  16240. */
  16241. getAnimations(): RuntimeAnimation[];
  16242. /**
  16243. * Adds more animations to the current animatable
  16244. * @param target defines the target of the animations
  16245. * @param animations defines the new animations to add
  16246. */
  16247. appendAnimations(target: any, animations: Animation[]): void;
  16248. /**
  16249. * Gets the source animation for a specific property
  16250. * @param property defines the propertyu to look for
  16251. * @returns null or the source animation for the given property
  16252. */
  16253. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16254. /**
  16255. * Gets the runtime animation for a specific property
  16256. * @param property defines the propertyu to look for
  16257. * @returns null or the runtime animation for the given property
  16258. */
  16259. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16260. /**
  16261. * Resets the animatable to its original state
  16262. */
  16263. reset(): void;
  16264. /**
  16265. * Allows the animatable to blend with current running animations
  16266. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16267. * @param blendingSpeed defines the blending speed to use
  16268. */
  16269. enableBlending(blendingSpeed: number): void;
  16270. /**
  16271. * Disable animation blending
  16272. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16273. */
  16274. disableBlending(): void;
  16275. /**
  16276. * Jump directly to a given frame
  16277. * @param frame defines the frame to jump to
  16278. */
  16279. goToFrame(frame: number): void;
  16280. /**
  16281. * Pause the animation
  16282. */
  16283. pause(): void;
  16284. /**
  16285. * Restart the animation
  16286. */
  16287. restart(): void;
  16288. private _raiseOnAnimationEnd;
  16289. /**
  16290. * Stop and delete the current animation
  16291. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16292. * @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)
  16293. */
  16294. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16295. /**
  16296. * Wait asynchronously for the animation to end
  16297. * @returns a promise which will be fullfilled when the animation ends
  16298. */
  16299. waitAsync(): Promise<Animatable>;
  16300. /** @hidden */
  16301. _animate(delay: number): boolean;
  16302. }
  16303. module "babylonjs/scene" {
  16304. interface Scene {
  16305. /** @hidden */
  16306. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16307. /** @hidden */
  16308. _processLateAnimationBindingsForMatrices(holder: {
  16309. totalWeight: number;
  16310. totalAdditiveWeight: number;
  16311. animations: RuntimeAnimation[];
  16312. additiveAnimations: RuntimeAnimation[];
  16313. originalValue: Matrix;
  16314. }): any;
  16315. /** @hidden */
  16316. _processLateAnimationBindingsForQuaternions(holder: {
  16317. totalWeight: number;
  16318. totalAdditiveWeight: number;
  16319. animations: RuntimeAnimation[];
  16320. additiveAnimations: RuntimeAnimation[];
  16321. originalValue: Quaternion;
  16322. }, refQuaternion: Quaternion): Quaternion;
  16323. /** @hidden */
  16324. _processLateAnimationBindings(): void;
  16325. /**
  16326. * Will start the animation sequence of a given target
  16327. * @param target defines the target
  16328. * @param from defines from which frame should animation start
  16329. * @param to defines until which frame should animation run.
  16330. * @param weight defines the weight to apply to the animation (1.0 by default)
  16331. * @param loop defines if the animation loops
  16332. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16333. * @param onAnimationEnd defines the function to be executed when the animation ends
  16334. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16335. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16336. * @param onAnimationLoop defines the callback to call when an animation loops
  16337. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16338. * @returns the animatable object created for this animation
  16339. */
  16340. 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;
  16341. /**
  16342. * Will start the animation sequence of a given target
  16343. * @param target defines the target
  16344. * @param from defines from which frame should animation start
  16345. * @param to defines until which frame should animation run.
  16346. * @param loop defines if the animation loops
  16347. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16348. * @param onAnimationEnd defines the function to be executed when the animation ends
  16349. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16350. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16351. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16352. * @param onAnimationLoop defines the callback to call when an animation loops
  16353. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16354. * @returns the animatable object created for this animation
  16355. */
  16356. 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;
  16357. /**
  16358. * Will start the animation sequence of a given target and its hierarchy
  16359. * @param target defines the target
  16360. * @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.
  16361. * @param from defines from which frame should animation start
  16362. * @param to defines until which frame should animation run.
  16363. * @param loop defines if the animation loops
  16364. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16365. * @param onAnimationEnd defines the function to be executed when the animation ends
  16366. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16367. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16368. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16369. * @param onAnimationLoop defines the callback to call when an animation loops
  16370. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16371. * @returns the list of created animatables
  16372. */
  16373. 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[];
  16374. /**
  16375. * Begin a new animation on a given node
  16376. * @param target defines the target where the animation will take place
  16377. * @param animations defines the list of animations to start
  16378. * @param from defines the initial value
  16379. * @param to defines the final value
  16380. * @param loop defines if you want animation to loop (off by default)
  16381. * @param speedRatio defines the speed ratio to apply to all animations
  16382. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16383. * @param onAnimationLoop defines the callback to call when an animation loops
  16384. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16385. * @returns the list of created animatables
  16386. */
  16387. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16388. /**
  16389. * Begin a new animation on a given node and its hierarchy
  16390. * @param target defines the root node where the animation will take place
  16391. * @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.
  16392. * @param animations defines the list of animations to start
  16393. * @param from defines the initial value
  16394. * @param to defines the final value
  16395. * @param loop defines if you want animation to loop (off by default)
  16396. * @param speedRatio defines the speed ratio to apply to all animations
  16397. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16398. * @param onAnimationLoop defines the callback to call when an animation loops
  16399. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16400. * @returns the list of animatables created for all nodes
  16401. */
  16402. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16403. /**
  16404. * Gets the animatable associated with a specific target
  16405. * @param target defines the target of the animatable
  16406. * @returns the required animatable if found
  16407. */
  16408. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16409. /**
  16410. * Gets all animatables associated with a given target
  16411. * @param target defines the target to look animatables for
  16412. * @returns an array of Animatables
  16413. */
  16414. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16415. /**
  16416. * Stops and removes all animations that have been applied to the scene
  16417. */
  16418. stopAllAnimations(): void;
  16419. /**
  16420. * Gets the current delta time used by animation engine
  16421. */
  16422. deltaTime: number;
  16423. }
  16424. }
  16425. module "babylonjs/Bones/bone" {
  16426. interface Bone {
  16427. /**
  16428. * Copy an animation range from another bone
  16429. * @param source defines the source bone
  16430. * @param rangeName defines the range name to copy
  16431. * @param frameOffset defines the frame offset
  16432. * @param rescaleAsRequired defines if rescaling must be applied if required
  16433. * @param skelDimensionsRatio defines the scaling ratio
  16434. * @returns true if operation was successful
  16435. */
  16436. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16437. }
  16438. }
  16439. }
  16440. declare module "babylonjs/Bones/skeleton" {
  16441. import { Bone } from "babylonjs/Bones/bone";
  16442. import { Observable } from "babylonjs/Misc/observable";
  16443. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16444. import { Scene } from "babylonjs/scene";
  16445. import { Nullable } from "babylonjs/types";
  16446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16447. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16448. import { Animatable } from "babylonjs/Animations/animatable";
  16449. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16450. import { Animation } from "babylonjs/Animations/animation";
  16451. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16452. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16453. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16454. /**
  16455. * Class used to handle skinning animations
  16456. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16457. */
  16458. export class Skeleton implements IAnimatable {
  16459. /** defines the skeleton name */
  16460. name: string;
  16461. /** defines the skeleton Id */
  16462. id: string;
  16463. /**
  16464. * Defines the list of child bones
  16465. */
  16466. bones: Bone[];
  16467. /**
  16468. * Defines an estimate of the dimension of the skeleton at rest
  16469. */
  16470. dimensionsAtRest: Vector3;
  16471. /**
  16472. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16473. */
  16474. needInitialSkinMatrix: boolean;
  16475. /**
  16476. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16477. */
  16478. overrideMesh: Nullable<AbstractMesh>;
  16479. /**
  16480. * Gets the list of animations attached to this skeleton
  16481. */
  16482. animations: Array<Animation>;
  16483. private _scene;
  16484. private _isDirty;
  16485. private _transformMatrices;
  16486. private _transformMatrixTexture;
  16487. private _meshesWithPoseMatrix;
  16488. private _animatables;
  16489. private _identity;
  16490. private _synchronizedWithMesh;
  16491. private _ranges;
  16492. private _lastAbsoluteTransformsUpdateId;
  16493. private _canUseTextureForBones;
  16494. private _uniqueId;
  16495. /** @hidden */
  16496. _numBonesWithLinkedTransformNode: number;
  16497. /** @hidden */
  16498. _hasWaitingData: Nullable<boolean>;
  16499. /** @hidden */
  16500. _waitingOverrideMeshId: Nullable<string>;
  16501. /**
  16502. * Specifies if the skeleton should be serialized
  16503. */
  16504. doNotSerialize: boolean;
  16505. private _useTextureToStoreBoneMatrices;
  16506. /**
  16507. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16508. * Please note that this option is not available if the hardware does not support it
  16509. */
  16510. get useTextureToStoreBoneMatrices(): boolean;
  16511. set useTextureToStoreBoneMatrices(value: boolean);
  16512. private _animationPropertiesOverride;
  16513. /**
  16514. * Gets or sets the animation properties override
  16515. */
  16516. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16517. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16518. /**
  16519. * List of inspectable custom properties (used by the Inspector)
  16520. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16521. */
  16522. inspectableCustomProperties: IInspectable[];
  16523. /**
  16524. * An observable triggered before computing the skeleton's matrices
  16525. */
  16526. onBeforeComputeObservable: Observable<Skeleton>;
  16527. /**
  16528. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16529. */
  16530. get isUsingTextureForMatrices(): boolean;
  16531. /**
  16532. * Gets the unique ID of this skeleton
  16533. */
  16534. get uniqueId(): number;
  16535. /**
  16536. * Creates a new skeleton
  16537. * @param name defines the skeleton name
  16538. * @param id defines the skeleton Id
  16539. * @param scene defines the hosting scene
  16540. */
  16541. constructor(
  16542. /** defines the skeleton name */
  16543. name: string,
  16544. /** defines the skeleton Id */
  16545. id: string, scene: Scene);
  16546. /**
  16547. * Gets the current object class name.
  16548. * @return the class name
  16549. */
  16550. getClassName(): string;
  16551. /**
  16552. * Returns an array containing the root bones
  16553. * @returns an array containing the root bones
  16554. */
  16555. getChildren(): Array<Bone>;
  16556. /**
  16557. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16558. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16559. * @returns a Float32Array containing matrices data
  16560. */
  16561. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16562. /**
  16563. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16564. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16565. * @returns a raw texture containing the data
  16566. */
  16567. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16568. /**
  16569. * Gets the current hosting scene
  16570. * @returns a scene object
  16571. */
  16572. getScene(): Scene;
  16573. /**
  16574. * Gets a string representing the current skeleton data
  16575. * @param fullDetails defines a boolean indicating if we want a verbose version
  16576. * @returns a string representing the current skeleton data
  16577. */
  16578. toString(fullDetails?: boolean): string;
  16579. /**
  16580. * Get bone's index searching by name
  16581. * @param name defines bone's name to search for
  16582. * @return the indice of the bone. Returns -1 if not found
  16583. */
  16584. getBoneIndexByName(name: string): number;
  16585. /**
  16586. * Creater a new animation range
  16587. * @param name defines the name of the range
  16588. * @param from defines the start key
  16589. * @param to defines the end key
  16590. */
  16591. createAnimationRange(name: string, from: number, to: number): void;
  16592. /**
  16593. * Delete a specific animation range
  16594. * @param name defines the name of the range
  16595. * @param deleteFrames defines if frames must be removed as well
  16596. */
  16597. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16598. /**
  16599. * Gets a specific animation range
  16600. * @param name defines the name of the range to look for
  16601. * @returns the requested animation range or null if not found
  16602. */
  16603. getAnimationRange(name: string): Nullable<AnimationRange>;
  16604. /**
  16605. * Gets the list of all animation ranges defined on this skeleton
  16606. * @returns an array
  16607. */
  16608. getAnimationRanges(): Nullable<AnimationRange>[];
  16609. /**
  16610. * Copy animation range from a source skeleton.
  16611. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16612. * @param source defines the source skeleton
  16613. * @param name defines the name of the range to copy
  16614. * @param rescaleAsRequired defines if rescaling must be applied if required
  16615. * @returns true if operation was successful
  16616. */
  16617. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16618. /**
  16619. * Forces the skeleton to go to rest pose
  16620. */
  16621. returnToRest(): void;
  16622. private _getHighestAnimationFrame;
  16623. /**
  16624. * Begin a specific animation range
  16625. * @param name defines the name of the range to start
  16626. * @param loop defines if looping must be turned on (false by default)
  16627. * @param speedRatio defines the speed ratio to apply (1 by default)
  16628. * @param onAnimationEnd defines a callback which will be called when animation will end
  16629. * @returns a new animatable
  16630. */
  16631. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16632. /**
  16633. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16634. * @param skeleton defines the Skeleton containing the animation range to convert
  16635. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16636. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16637. * @returns the original skeleton
  16638. */
  16639. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16640. /** @hidden */
  16641. _markAsDirty(): void;
  16642. /** @hidden */
  16643. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16644. /** @hidden */
  16645. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16646. private _computeTransformMatrices;
  16647. /**
  16648. * Build all resources required to render a skeleton
  16649. */
  16650. prepare(): void;
  16651. /**
  16652. * Gets the list of animatables currently running for this skeleton
  16653. * @returns an array of animatables
  16654. */
  16655. getAnimatables(): IAnimatable[];
  16656. /**
  16657. * Clone the current skeleton
  16658. * @param name defines the name of the new skeleton
  16659. * @param id defines the id of the new skeleton
  16660. * @returns the new skeleton
  16661. */
  16662. clone(name: string, id?: string): Skeleton;
  16663. /**
  16664. * Enable animation blending for this skeleton
  16665. * @param blendingSpeed defines the blending speed to apply
  16666. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16667. */
  16668. enableBlending(blendingSpeed?: number): void;
  16669. /**
  16670. * Releases all resources associated with the current skeleton
  16671. */
  16672. dispose(): void;
  16673. /**
  16674. * Serialize the skeleton in a JSON object
  16675. * @returns a JSON object
  16676. */
  16677. serialize(): any;
  16678. /**
  16679. * Creates a new skeleton from serialized data
  16680. * @param parsedSkeleton defines the serialized data
  16681. * @param scene defines the hosting scene
  16682. * @returns a new skeleton
  16683. */
  16684. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16685. /**
  16686. * Compute all node absolute transforms
  16687. * @param forceUpdate defines if computation must be done even if cache is up to date
  16688. */
  16689. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16690. /**
  16691. * Gets the root pose matrix
  16692. * @returns a matrix
  16693. */
  16694. getPoseMatrix(): Nullable<Matrix>;
  16695. /**
  16696. * Sorts bones per internal index
  16697. */
  16698. sortBones(): void;
  16699. private _sortBones;
  16700. /**
  16701. * Set the current local matrix as the restPose for all bones in the skeleton.
  16702. */
  16703. setCurrentPoseAsRest(): void;
  16704. }
  16705. }
  16706. declare module "babylonjs/Meshes/instancedMesh" {
  16707. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16708. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16709. import { Camera } from "babylonjs/Cameras/camera";
  16710. import { Node } from "babylonjs/node";
  16711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16712. import { Mesh } from "babylonjs/Meshes/mesh";
  16713. import { Material } from "babylonjs/Materials/material";
  16714. import { Skeleton } from "babylonjs/Bones/skeleton";
  16715. import { Light } from "babylonjs/Lights/light";
  16716. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16717. /**
  16718. * Creates an instance based on a source mesh.
  16719. */
  16720. export class InstancedMesh extends AbstractMesh {
  16721. private _sourceMesh;
  16722. private _currentLOD;
  16723. /** @hidden */
  16724. _indexInSourceMeshInstanceArray: number;
  16725. constructor(name: string, source: Mesh);
  16726. /**
  16727. * Returns the string "InstancedMesh".
  16728. */
  16729. getClassName(): string;
  16730. /** Gets the list of lights affecting that mesh */
  16731. get lightSources(): Light[];
  16732. _resyncLightSources(): void;
  16733. _resyncLightSource(light: Light): void;
  16734. _removeLightSource(light: Light, dispose: boolean): void;
  16735. /**
  16736. * If the source mesh receives shadows
  16737. */
  16738. get receiveShadows(): boolean;
  16739. /**
  16740. * The material of the source mesh
  16741. */
  16742. get material(): Nullable<Material>;
  16743. /**
  16744. * Visibility of the source mesh
  16745. */
  16746. get visibility(): number;
  16747. /**
  16748. * Skeleton of the source mesh
  16749. */
  16750. get skeleton(): Nullable<Skeleton>;
  16751. /**
  16752. * Rendering ground id of the source mesh
  16753. */
  16754. get renderingGroupId(): number;
  16755. set renderingGroupId(value: number);
  16756. /**
  16757. * Returns the total number of vertices (integer).
  16758. */
  16759. getTotalVertices(): number;
  16760. /**
  16761. * Returns a positive integer : the total number of indices in this mesh geometry.
  16762. * @returns the numner of indices or zero if the mesh has no geometry.
  16763. */
  16764. getTotalIndices(): number;
  16765. /**
  16766. * The source mesh of the instance
  16767. */
  16768. get sourceMesh(): Mesh;
  16769. /**
  16770. * Creates a new InstancedMesh object from the mesh model.
  16771. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16772. * @param name defines the name of the new instance
  16773. * @returns a new InstancedMesh
  16774. */
  16775. createInstance(name: string): InstancedMesh;
  16776. /**
  16777. * Is this node ready to be used/rendered
  16778. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16779. * @return {boolean} is it ready
  16780. */
  16781. isReady(completeCheck?: boolean): boolean;
  16782. /**
  16783. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16784. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16785. * @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.
  16786. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16787. */
  16788. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16789. /**
  16790. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16791. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16792. * The `data` are either a numeric array either a Float32Array.
  16793. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16794. * 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).
  16795. * Note that a new underlying VertexBuffer object is created each call.
  16796. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16797. *
  16798. * Possible `kind` values :
  16799. * - VertexBuffer.PositionKind
  16800. * - VertexBuffer.UVKind
  16801. * - VertexBuffer.UV2Kind
  16802. * - VertexBuffer.UV3Kind
  16803. * - VertexBuffer.UV4Kind
  16804. * - VertexBuffer.UV5Kind
  16805. * - VertexBuffer.UV6Kind
  16806. * - VertexBuffer.ColorKind
  16807. * - VertexBuffer.MatricesIndicesKind
  16808. * - VertexBuffer.MatricesIndicesExtraKind
  16809. * - VertexBuffer.MatricesWeightsKind
  16810. * - VertexBuffer.MatricesWeightsExtraKind
  16811. *
  16812. * Returns the Mesh.
  16813. */
  16814. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16815. /**
  16816. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16817. * If the mesh has no geometry, it is simply returned as it is.
  16818. * The `data` are either a numeric array either a Float32Array.
  16819. * No new underlying VertexBuffer object is created.
  16820. * 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.
  16821. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16822. *
  16823. * Possible `kind` values :
  16824. * - VertexBuffer.PositionKind
  16825. * - VertexBuffer.UVKind
  16826. * - VertexBuffer.UV2Kind
  16827. * - VertexBuffer.UV3Kind
  16828. * - VertexBuffer.UV4Kind
  16829. * - VertexBuffer.UV5Kind
  16830. * - VertexBuffer.UV6Kind
  16831. * - VertexBuffer.ColorKind
  16832. * - VertexBuffer.MatricesIndicesKind
  16833. * - VertexBuffer.MatricesIndicesExtraKind
  16834. * - VertexBuffer.MatricesWeightsKind
  16835. * - VertexBuffer.MatricesWeightsExtraKind
  16836. *
  16837. * Returns the Mesh.
  16838. */
  16839. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16840. /**
  16841. * Sets the mesh indices.
  16842. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16843. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16844. * This method creates a new index buffer each call.
  16845. * Returns the Mesh.
  16846. */
  16847. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16848. /**
  16849. * Boolean : True if the mesh owns the requested kind of data.
  16850. */
  16851. isVerticesDataPresent(kind: string): boolean;
  16852. /**
  16853. * Returns an array of indices (IndicesArray).
  16854. */
  16855. getIndices(): Nullable<IndicesArray>;
  16856. get _positions(): Nullable<Vector3[]>;
  16857. /**
  16858. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16859. * This means the mesh underlying bounding box and sphere are recomputed.
  16860. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16861. * @returns the current mesh
  16862. */
  16863. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16864. /** @hidden */
  16865. _preActivate(): InstancedMesh;
  16866. /** @hidden */
  16867. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16868. /** @hidden */
  16869. _postActivate(): void;
  16870. getWorldMatrix(): Matrix;
  16871. get isAnInstance(): boolean;
  16872. /**
  16873. * Returns the current associated LOD AbstractMesh.
  16874. */
  16875. getLOD(camera: Camera): AbstractMesh;
  16876. /** @hidden */
  16877. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16878. /** @hidden */
  16879. _syncSubMeshes(): InstancedMesh;
  16880. /** @hidden */
  16881. _generatePointsArray(): boolean;
  16882. /** @hidden */
  16883. _updateBoundingInfo(): AbstractMesh;
  16884. /**
  16885. * Creates a new InstancedMesh from the current mesh.
  16886. * - name (string) : the cloned mesh name
  16887. * - newParent (optional Node) : the optional Node to parent the clone to.
  16888. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16889. *
  16890. * Returns the clone.
  16891. */
  16892. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16893. /**
  16894. * Disposes the InstancedMesh.
  16895. * Returns nothing.
  16896. */
  16897. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16898. }
  16899. module "babylonjs/Meshes/mesh" {
  16900. interface Mesh {
  16901. /**
  16902. * Register a custom buffer that will be instanced
  16903. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16904. * @param kind defines the buffer kind
  16905. * @param stride defines the stride in floats
  16906. */
  16907. registerInstancedBuffer(kind: string, stride: number): void;
  16908. /**
  16909. * true to use the edge renderer for all instances of this mesh
  16910. */
  16911. edgesShareWithInstances: boolean;
  16912. /** @hidden */
  16913. _userInstancedBuffersStorage: {
  16914. data: {
  16915. [key: string]: Float32Array;
  16916. };
  16917. sizes: {
  16918. [key: string]: number;
  16919. };
  16920. vertexBuffers: {
  16921. [key: string]: Nullable<VertexBuffer>;
  16922. };
  16923. strides: {
  16924. [key: string]: number;
  16925. };
  16926. };
  16927. }
  16928. }
  16929. module "babylonjs/Meshes/abstractMesh" {
  16930. interface AbstractMesh {
  16931. /**
  16932. * Object used to store instanced buffers defined by user
  16933. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16934. */
  16935. instancedBuffers: {
  16936. [key: string]: any;
  16937. };
  16938. }
  16939. }
  16940. }
  16941. declare module "babylonjs/Materials/shaderMaterial" {
  16942. import { Nullable } from "babylonjs/types";
  16943. import { Scene } from "babylonjs/scene";
  16944. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16946. import { Mesh } from "babylonjs/Meshes/mesh";
  16947. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16948. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16949. import { Effect } from "babylonjs/Materials/effect";
  16950. import { Material } from "babylonjs/Materials/material";
  16951. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16952. /**
  16953. * Defines the options associated with the creation of a shader material.
  16954. */
  16955. export interface IShaderMaterialOptions {
  16956. /**
  16957. * Does the material work in alpha blend mode
  16958. */
  16959. needAlphaBlending: boolean;
  16960. /**
  16961. * Does the material work in alpha test mode
  16962. */
  16963. needAlphaTesting: boolean;
  16964. /**
  16965. * The list of attribute names used in the shader
  16966. */
  16967. attributes: string[];
  16968. /**
  16969. * The list of unifrom names used in the shader
  16970. */
  16971. uniforms: string[];
  16972. /**
  16973. * The list of UBO names used in the shader
  16974. */
  16975. uniformBuffers: string[];
  16976. /**
  16977. * The list of sampler names used in the shader
  16978. */
  16979. samplers: string[];
  16980. /**
  16981. * The list of defines used in the shader
  16982. */
  16983. defines: string[];
  16984. }
  16985. /**
  16986. * 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.
  16987. *
  16988. * This returned material effects how the mesh will look based on the code in the shaders.
  16989. *
  16990. * @see https://doc.babylonjs.com/how_to/shader_material
  16991. */
  16992. export class ShaderMaterial extends Material {
  16993. private _shaderPath;
  16994. private _options;
  16995. private _textures;
  16996. private _textureArrays;
  16997. private _floats;
  16998. private _ints;
  16999. private _floatsArrays;
  17000. private _colors3;
  17001. private _colors3Arrays;
  17002. private _colors4;
  17003. private _colors4Arrays;
  17004. private _vectors2;
  17005. private _vectors3;
  17006. private _vectors4;
  17007. private _matrices;
  17008. private _matrixArrays;
  17009. private _matrices3x3;
  17010. private _matrices2x2;
  17011. private _vectors2Arrays;
  17012. private _vectors3Arrays;
  17013. private _vectors4Arrays;
  17014. private _cachedWorldViewMatrix;
  17015. private _cachedWorldViewProjectionMatrix;
  17016. private _renderId;
  17017. private _multiview;
  17018. private _cachedDefines;
  17019. /** Define the Url to load snippets */
  17020. static SnippetUrl: string;
  17021. /** Snippet ID if the material was created from the snippet server */
  17022. snippetId: string;
  17023. /**
  17024. * Instantiate a new shader material.
  17025. * 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.
  17026. * This returned material effects how the mesh will look based on the code in the shaders.
  17027. * @see https://doc.babylonjs.com/how_to/shader_material
  17028. * @param name Define the name of the material in the scene
  17029. * @param scene Define the scene the material belongs to
  17030. * @param shaderPath Defines the route to the shader code in one of three ways:
  17031. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17032. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17033. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17034. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17035. * @param options Define the options used to create the shader
  17036. */
  17037. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17038. /**
  17039. * Gets the shader path used to define the shader code
  17040. * It can be modified to trigger a new compilation
  17041. */
  17042. get shaderPath(): any;
  17043. /**
  17044. * Sets the shader path used to define the shader code
  17045. * It can be modified to trigger a new compilation
  17046. */
  17047. set shaderPath(shaderPath: any);
  17048. /**
  17049. * Gets the options used to compile the shader.
  17050. * They can be modified to trigger a new compilation
  17051. */
  17052. get options(): IShaderMaterialOptions;
  17053. /**
  17054. * Gets the current class name of the material e.g. "ShaderMaterial"
  17055. * Mainly use in serialization.
  17056. * @returns the class name
  17057. */
  17058. getClassName(): string;
  17059. /**
  17060. * Specifies if the material will require alpha blending
  17061. * @returns a boolean specifying if alpha blending is needed
  17062. */
  17063. needAlphaBlending(): boolean;
  17064. /**
  17065. * Specifies if this material should be rendered in alpha test mode
  17066. * @returns a boolean specifying if an alpha test is needed.
  17067. */
  17068. needAlphaTesting(): boolean;
  17069. private _checkUniform;
  17070. /**
  17071. * Set a texture in the shader.
  17072. * @param name Define the name of the uniform samplers as defined in the shader
  17073. * @param texture Define the texture to bind to this sampler
  17074. * @return the material itself allowing "fluent" like uniform updates
  17075. */
  17076. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17077. /**
  17078. * Set a texture array in the shader.
  17079. * @param name Define the name of the uniform sampler array as defined in the shader
  17080. * @param textures Define the list of textures to bind to this sampler
  17081. * @return the material itself allowing "fluent" like uniform updates
  17082. */
  17083. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17084. /**
  17085. * Set a float in the shader.
  17086. * @param name Define the name of the uniform as defined in the shader
  17087. * @param value Define the value to give to the uniform
  17088. * @return the material itself allowing "fluent" like uniform updates
  17089. */
  17090. setFloat(name: string, value: number): ShaderMaterial;
  17091. /**
  17092. * Set a int in the shader.
  17093. * @param name Define the name of the uniform as defined in the shader
  17094. * @param value Define the value to give to the uniform
  17095. * @return the material itself allowing "fluent" like uniform updates
  17096. */
  17097. setInt(name: string, value: number): ShaderMaterial;
  17098. /**
  17099. * Set an array of floats in the shader.
  17100. * @param name Define the name of the uniform as defined in the shader
  17101. * @param value Define the value to give to the uniform
  17102. * @return the material itself allowing "fluent" like uniform updates
  17103. */
  17104. setFloats(name: string, value: number[]): ShaderMaterial;
  17105. /**
  17106. * Set a vec3 in the shader from a Color3.
  17107. * @param name Define the name of the uniform as defined in the shader
  17108. * @param value Define the value to give to the uniform
  17109. * @return the material itself allowing "fluent" like uniform updates
  17110. */
  17111. setColor3(name: string, value: Color3): ShaderMaterial;
  17112. /**
  17113. * Set a vec3 array in the shader from a Color3 array.
  17114. * @param name Define the name of the uniform as defined in the shader
  17115. * @param value Define the value to give to the uniform
  17116. * @return the material itself allowing "fluent" like uniform updates
  17117. */
  17118. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17119. /**
  17120. * Set a vec4 in the shader from a Color4.
  17121. * @param name Define the name of the uniform as defined in the shader
  17122. * @param value Define the value to give to the uniform
  17123. * @return the material itself allowing "fluent" like uniform updates
  17124. */
  17125. setColor4(name: string, value: Color4): ShaderMaterial;
  17126. /**
  17127. * Set a vec4 array in the shader from a Color4 array.
  17128. * @param name Define the name of the uniform as defined in the shader
  17129. * @param value Define the value to give to the uniform
  17130. * @return the material itself allowing "fluent" like uniform updates
  17131. */
  17132. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17133. /**
  17134. * Set a vec2 in the shader from a Vector2.
  17135. * @param name Define the name of the uniform as defined in the shader
  17136. * @param value Define the value to give to the uniform
  17137. * @return the material itself allowing "fluent" like uniform updates
  17138. */
  17139. setVector2(name: string, value: Vector2): ShaderMaterial;
  17140. /**
  17141. * Set a vec3 in the shader from a Vector3.
  17142. * @param name Define the name of the uniform as defined in the shader
  17143. * @param value Define the value to give to the uniform
  17144. * @return the material itself allowing "fluent" like uniform updates
  17145. */
  17146. setVector3(name: string, value: Vector3): ShaderMaterial;
  17147. /**
  17148. * Set a vec4 in the shader from a Vector4.
  17149. * @param name Define the name of the uniform as defined in the shader
  17150. * @param value Define the value to give to the uniform
  17151. * @return the material itself allowing "fluent" like uniform updates
  17152. */
  17153. setVector4(name: string, value: Vector4): ShaderMaterial;
  17154. /**
  17155. * Set a mat4 in the shader from a Matrix.
  17156. * @param name Define the name of the uniform as defined in the shader
  17157. * @param value Define the value to give to the uniform
  17158. * @return the material itself allowing "fluent" like uniform updates
  17159. */
  17160. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17161. /**
  17162. * Set a float32Array in the shader from a matrix array.
  17163. * @param name Define the name of the uniform as defined in the shader
  17164. * @param value Define the value to give to the uniform
  17165. * @return the material itself allowing "fluent" like uniform updates
  17166. */
  17167. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17168. /**
  17169. * Set a mat3 in the shader from a Float32Array.
  17170. * @param name Define the name of the uniform as defined in the shader
  17171. * @param value Define the value to give to the uniform
  17172. * @return the material itself allowing "fluent" like uniform updates
  17173. */
  17174. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17175. /**
  17176. * Set a mat2 in the shader from a Float32Array.
  17177. * @param name Define the name of the uniform as defined in the shader
  17178. * @param value Define the value to give to the uniform
  17179. * @return the material itself allowing "fluent" like uniform updates
  17180. */
  17181. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17182. /**
  17183. * Set a vec2 array in the shader from a number array.
  17184. * @param name Define the name of the uniform as defined in the shader
  17185. * @param value Define the value to give to the uniform
  17186. * @return the material itself allowing "fluent" like uniform updates
  17187. */
  17188. setArray2(name: string, value: number[]): ShaderMaterial;
  17189. /**
  17190. * Set a vec3 array in the shader from a number array.
  17191. * @param name Define the name of the uniform as defined in the shader
  17192. * @param value Define the value to give to the uniform
  17193. * @return the material itself allowing "fluent" like uniform updates
  17194. */
  17195. setArray3(name: string, value: number[]): ShaderMaterial;
  17196. /**
  17197. * Set a vec4 array in the shader from a number array.
  17198. * @param name Define the name of the uniform as defined in the shader
  17199. * @param value Define the value to give to the uniform
  17200. * @return the material itself allowing "fluent" like uniform updates
  17201. */
  17202. setArray4(name: string, value: number[]): ShaderMaterial;
  17203. private _checkCache;
  17204. /**
  17205. * Specifies that the submesh is ready to be used
  17206. * @param mesh defines the mesh to check
  17207. * @param subMesh defines which submesh to check
  17208. * @param useInstances specifies that instances should be used
  17209. * @returns a boolean indicating that the submesh is ready or not
  17210. */
  17211. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17212. /**
  17213. * Checks if the material is ready to render the requested mesh
  17214. * @param mesh Define the mesh to render
  17215. * @param useInstances Define whether or not the material is used with instances
  17216. * @returns true if ready, otherwise false
  17217. */
  17218. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17219. /**
  17220. * Binds the world matrix to the material
  17221. * @param world defines the world transformation matrix
  17222. * @param effectOverride - If provided, use this effect instead of internal effect
  17223. */
  17224. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17225. /**
  17226. * Binds the submesh to this material by preparing the effect and shader to draw
  17227. * @param world defines the world transformation matrix
  17228. * @param mesh defines the mesh containing the submesh
  17229. * @param subMesh defines the submesh to bind the material to
  17230. */
  17231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17232. /**
  17233. * Binds the material to the mesh
  17234. * @param world defines the world transformation matrix
  17235. * @param mesh defines the mesh to bind the material to
  17236. * @param effectOverride - If provided, use this effect instead of internal effect
  17237. */
  17238. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17239. protected _afterBind(mesh?: Mesh): void;
  17240. /**
  17241. * Gets the active textures from the material
  17242. * @returns an array of textures
  17243. */
  17244. getActiveTextures(): BaseTexture[];
  17245. /**
  17246. * Specifies if the material uses a texture
  17247. * @param texture defines the texture to check against the material
  17248. * @returns a boolean specifying if the material uses the texture
  17249. */
  17250. hasTexture(texture: BaseTexture): boolean;
  17251. /**
  17252. * Makes a duplicate of the material, and gives it a new name
  17253. * @param name defines the new name for the duplicated material
  17254. * @returns the cloned material
  17255. */
  17256. clone(name: string): ShaderMaterial;
  17257. /**
  17258. * Disposes the material
  17259. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17260. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17261. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17262. */
  17263. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17264. /**
  17265. * Serializes this material in a JSON representation
  17266. * @returns the serialized material object
  17267. */
  17268. serialize(): any;
  17269. /**
  17270. * Creates a shader material from parsed shader material data
  17271. * @param source defines the JSON represnetation of the material
  17272. * @param scene defines the hosting scene
  17273. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17274. * @returns a new material
  17275. */
  17276. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17277. /**
  17278. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17279. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17280. * @param url defines the url to load from
  17281. * @param scene defines the hosting scene
  17282. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17283. * @returns a promise that will resolve to the new ShaderMaterial
  17284. */
  17285. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17286. /**
  17287. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17288. * @param snippetId defines the snippet to load
  17289. * @param scene defines the hosting scene
  17290. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17291. * @returns a promise that will resolve to the new ShaderMaterial
  17292. */
  17293. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17294. }
  17295. }
  17296. declare module "babylonjs/Shaders/color.fragment" {
  17297. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17298. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17299. /** @hidden */
  17300. export var colorPixelShader: {
  17301. name: string;
  17302. shader: string;
  17303. };
  17304. }
  17305. declare module "babylonjs/Shaders/color.vertex" {
  17306. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17307. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17308. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17309. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17310. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17311. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17312. /** @hidden */
  17313. export var colorVertexShader: {
  17314. name: string;
  17315. shader: string;
  17316. };
  17317. }
  17318. declare module "babylonjs/Meshes/linesMesh" {
  17319. import { Nullable } from "babylonjs/types";
  17320. import { Scene } from "babylonjs/scene";
  17321. import { Color3 } from "babylonjs/Maths/math.color";
  17322. import { Node } from "babylonjs/node";
  17323. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17324. import { Mesh } from "babylonjs/Meshes/mesh";
  17325. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17326. import { Effect } from "babylonjs/Materials/effect";
  17327. import { Material } from "babylonjs/Materials/material";
  17328. import "babylonjs/Shaders/color.fragment";
  17329. import "babylonjs/Shaders/color.vertex";
  17330. /**
  17331. * Line mesh
  17332. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17333. */
  17334. export class LinesMesh extends Mesh {
  17335. /**
  17336. * If vertex color should be applied to the mesh
  17337. */
  17338. readonly useVertexColor?: boolean | undefined;
  17339. /**
  17340. * If vertex alpha should be applied to the mesh
  17341. */
  17342. readonly useVertexAlpha?: boolean | undefined;
  17343. /**
  17344. * Color of the line (Default: White)
  17345. */
  17346. color: Color3;
  17347. /**
  17348. * Alpha of the line (Default: 1)
  17349. */
  17350. alpha: number;
  17351. /**
  17352. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17353. * This margin is expressed in world space coordinates, so its value may vary.
  17354. * Default value is 0.1
  17355. */
  17356. intersectionThreshold: number;
  17357. private _colorShader;
  17358. private color4;
  17359. /**
  17360. * Creates a new LinesMesh
  17361. * @param name defines the name
  17362. * @param scene defines the hosting scene
  17363. * @param parent defines the parent mesh if any
  17364. * @param source defines the optional source LinesMesh used to clone data from
  17365. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17366. * When false, achieved by calling a clone(), also passing False.
  17367. * This will make creation of children, recursive.
  17368. * @param useVertexColor defines if this LinesMesh supports vertex color
  17369. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17370. */
  17371. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17372. /**
  17373. * If vertex color should be applied to the mesh
  17374. */
  17375. useVertexColor?: boolean | undefined,
  17376. /**
  17377. * If vertex alpha should be applied to the mesh
  17378. */
  17379. useVertexAlpha?: boolean | undefined);
  17380. private _addClipPlaneDefine;
  17381. private _removeClipPlaneDefine;
  17382. isReady(): boolean;
  17383. /**
  17384. * Returns the string "LineMesh"
  17385. */
  17386. getClassName(): string;
  17387. /**
  17388. * @hidden
  17389. */
  17390. get material(): Material;
  17391. /**
  17392. * @hidden
  17393. */
  17394. set material(value: Material);
  17395. /**
  17396. * @hidden
  17397. */
  17398. get checkCollisions(): boolean;
  17399. /** @hidden */
  17400. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17401. /** @hidden */
  17402. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17403. /**
  17404. * Disposes of the line mesh
  17405. * @param doNotRecurse If children should be disposed
  17406. */
  17407. dispose(doNotRecurse?: boolean): void;
  17408. /**
  17409. * Returns a new LineMesh object cloned from the current one.
  17410. */
  17411. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17412. /**
  17413. * Creates a new InstancedLinesMesh object from the mesh model.
  17414. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17415. * @param name defines the name of the new instance
  17416. * @returns a new InstancedLinesMesh
  17417. */
  17418. createInstance(name: string): InstancedLinesMesh;
  17419. }
  17420. /**
  17421. * Creates an instance based on a source LinesMesh
  17422. */
  17423. export class InstancedLinesMesh extends InstancedMesh {
  17424. /**
  17425. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17426. * This margin is expressed in world space coordinates, so its value may vary.
  17427. * Initilized with the intersectionThreshold value of the source LinesMesh
  17428. */
  17429. intersectionThreshold: number;
  17430. constructor(name: string, source: LinesMesh);
  17431. /**
  17432. * Returns the string "InstancedLinesMesh".
  17433. */
  17434. getClassName(): string;
  17435. }
  17436. }
  17437. declare module "babylonjs/Shaders/line.fragment" {
  17438. /** @hidden */
  17439. export var linePixelShader: {
  17440. name: string;
  17441. shader: string;
  17442. };
  17443. }
  17444. declare module "babylonjs/Shaders/line.vertex" {
  17445. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17446. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17447. /** @hidden */
  17448. export var lineVertexShader: {
  17449. name: string;
  17450. shader: string;
  17451. };
  17452. }
  17453. declare module "babylonjs/Rendering/edgesRenderer" {
  17454. import { Nullable } from "babylonjs/types";
  17455. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17458. import { IDisposable } from "babylonjs/scene";
  17459. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17460. import "babylonjs/Shaders/line.fragment";
  17461. import "babylonjs/Shaders/line.vertex";
  17462. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17463. import { SmartArray } from "babylonjs/Misc/smartArray";
  17464. module "babylonjs/scene" {
  17465. interface Scene {
  17466. /** @hidden */
  17467. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17468. }
  17469. }
  17470. module "babylonjs/Meshes/abstractMesh" {
  17471. interface AbstractMesh {
  17472. /**
  17473. * Gets the edgesRenderer associated with the mesh
  17474. */
  17475. edgesRenderer: Nullable<EdgesRenderer>;
  17476. }
  17477. }
  17478. module "babylonjs/Meshes/linesMesh" {
  17479. interface LinesMesh {
  17480. /**
  17481. * Enables the edge rendering mode on the mesh.
  17482. * This mode makes the mesh edges visible
  17483. * @param epsilon defines the maximal distance between two angles to detect a face
  17484. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17485. * @returns the currentAbstractMesh
  17486. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17487. */
  17488. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17489. }
  17490. }
  17491. module "babylonjs/Meshes/linesMesh" {
  17492. interface InstancedLinesMesh {
  17493. /**
  17494. * Enables the edge rendering mode on the mesh.
  17495. * This mode makes the mesh edges visible
  17496. * @param epsilon defines the maximal distance between two angles to detect a face
  17497. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17498. * @returns the current InstancedLinesMesh
  17499. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17500. */
  17501. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17502. }
  17503. }
  17504. /**
  17505. * Defines the minimum contract an Edges renderer should follow.
  17506. */
  17507. export interface IEdgesRenderer extends IDisposable {
  17508. /**
  17509. * Gets or sets a boolean indicating if the edgesRenderer is active
  17510. */
  17511. isEnabled: boolean;
  17512. /**
  17513. * Renders the edges of the attached mesh,
  17514. */
  17515. render(): void;
  17516. /**
  17517. * Checks wether or not the edges renderer is ready to render.
  17518. * @return true if ready, otherwise false.
  17519. */
  17520. isReady(): boolean;
  17521. /**
  17522. * List of instances to render in case the source mesh has instances
  17523. */
  17524. customInstances: SmartArray<Matrix>;
  17525. }
  17526. /**
  17527. * Defines the additional options of the edges renderer
  17528. */
  17529. export interface IEdgesRendererOptions {
  17530. /**
  17531. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17532. * If not defined, the default value is true
  17533. */
  17534. useAlternateEdgeFinder?: boolean;
  17535. /**
  17536. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17537. * If not defined, the default value is true.
  17538. * 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)
  17539. * This option is used only if useAlternateEdgeFinder = true
  17540. */
  17541. useFastVertexMerger?: boolean;
  17542. /**
  17543. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17544. * The default value is 1e-6
  17545. * This option is used only if useAlternateEdgeFinder = true
  17546. */
  17547. epsilonVertexMerge?: number;
  17548. /**
  17549. * 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
  17550. * 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.
  17551. * This option is used only if useAlternateEdgeFinder = true
  17552. */
  17553. applyTessellation?: boolean;
  17554. /**
  17555. * 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
  17556. * The default value is 1e-6
  17557. * This option is used only if useAlternateEdgeFinder = true
  17558. */
  17559. epsilonVertexAligned?: number;
  17560. }
  17561. /**
  17562. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17563. */
  17564. export class EdgesRenderer implements IEdgesRenderer {
  17565. /**
  17566. * Define the size of the edges with an orthographic camera
  17567. */
  17568. edgesWidthScalerForOrthographic: number;
  17569. /**
  17570. * Define the size of the edges with a perspective camera
  17571. */
  17572. edgesWidthScalerForPerspective: number;
  17573. protected _source: AbstractMesh;
  17574. protected _linesPositions: number[];
  17575. protected _linesNormals: number[];
  17576. protected _linesIndices: number[];
  17577. protected _epsilon: number;
  17578. protected _indicesCount: number;
  17579. protected _lineShader: ShaderMaterial;
  17580. protected _ib: DataBuffer;
  17581. protected _buffers: {
  17582. [key: string]: Nullable<VertexBuffer>;
  17583. };
  17584. protected _buffersForInstances: {
  17585. [key: string]: Nullable<VertexBuffer>;
  17586. };
  17587. protected _checkVerticesInsteadOfIndices: boolean;
  17588. protected _options: Nullable<IEdgesRendererOptions>;
  17589. private _meshRebuildObserver;
  17590. private _meshDisposeObserver;
  17591. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17592. isEnabled: boolean;
  17593. /**
  17594. * List of instances to render in case the source mesh has instances
  17595. */
  17596. customInstances: SmartArray<Matrix>;
  17597. private static GetShader;
  17598. /**
  17599. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17600. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17601. * @param source Mesh used to create edges
  17602. * @param epsilon sum of angles in adjacency to check for edge
  17603. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17604. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17605. * @param options The options to apply when generating the edges
  17606. */
  17607. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17608. protected _prepareRessources(): void;
  17609. /** @hidden */
  17610. _rebuild(): void;
  17611. /**
  17612. * Releases the required resources for the edges renderer
  17613. */
  17614. dispose(): void;
  17615. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17616. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17617. /**
  17618. * Checks if the pair of p0 and p1 is en edge
  17619. * @param faceIndex
  17620. * @param edge
  17621. * @param faceNormals
  17622. * @param p0
  17623. * @param p1
  17624. * @private
  17625. */
  17626. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17627. /**
  17628. * push line into the position, normal and index buffer
  17629. * @protected
  17630. */
  17631. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17632. /**
  17633. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17634. */
  17635. private _tessellateTriangle;
  17636. private _generateEdgesLinesAlternate;
  17637. /**
  17638. * Generates lines edges from adjacencjes
  17639. * @private
  17640. */
  17641. _generateEdgesLines(): void;
  17642. /**
  17643. * Checks wether or not the edges renderer is ready to render.
  17644. * @return true if ready, otherwise false.
  17645. */
  17646. isReady(): boolean;
  17647. /**
  17648. * Renders the edges of the attached mesh,
  17649. */
  17650. render(): void;
  17651. }
  17652. /**
  17653. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17654. */
  17655. export class LineEdgesRenderer extends EdgesRenderer {
  17656. /**
  17657. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17658. * @param source LineMesh used to generate edges
  17659. * @param epsilon not important (specified angle for edge detection)
  17660. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17661. */
  17662. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17663. /**
  17664. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17665. */
  17666. _generateEdgesLines(): void;
  17667. }
  17668. }
  17669. declare module "babylonjs/Rendering/renderingGroup" {
  17670. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17671. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17673. import { Nullable } from "babylonjs/types";
  17674. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17675. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17676. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17677. import { Material } from "babylonjs/Materials/material";
  17678. import { Scene } from "babylonjs/scene";
  17679. /**
  17680. * This represents the object necessary to create a rendering group.
  17681. * This is exclusively used and created by the rendering manager.
  17682. * To modify the behavior, you use the available helpers in your scene or meshes.
  17683. * @hidden
  17684. */
  17685. export class RenderingGroup {
  17686. index: number;
  17687. private static _zeroVector;
  17688. private _scene;
  17689. private _opaqueSubMeshes;
  17690. private _transparentSubMeshes;
  17691. private _alphaTestSubMeshes;
  17692. private _depthOnlySubMeshes;
  17693. private _particleSystems;
  17694. private _spriteManagers;
  17695. private _opaqueSortCompareFn;
  17696. private _alphaTestSortCompareFn;
  17697. private _transparentSortCompareFn;
  17698. private _renderOpaque;
  17699. private _renderAlphaTest;
  17700. private _renderTransparent;
  17701. /** @hidden */
  17702. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17703. onBeforeTransparentRendering: () => void;
  17704. /**
  17705. * Set the opaque sort comparison function.
  17706. * If null the sub meshes will be render in the order they were created
  17707. */
  17708. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17709. /**
  17710. * Set the alpha test sort comparison function.
  17711. * If null the sub meshes will be render in the order they were created
  17712. */
  17713. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17714. /**
  17715. * Set the transparent sort comparison function.
  17716. * If null the sub meshes will be render in the order they were created
  17717. */
  17718. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17719. /**
  17720. * Creates a new rendering group.
  17721. * @param index The rendering group index
  17722. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17723. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17724. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17725. */
  17726. 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>);
  17727. /**
  17728. * Render all the sub meshes contained in the group.
  17729. * @param customRenderFunction Used to override the default render behaviour of the group.
  17730. * @returns true if rendered some submeshes.
  17731. */
  17732. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17733. /**
  17734. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17735. * @param subMeshes The submeshes to render
  17736. */
  17737. private renderOpaqueSorted;
  17738. /**
  17739. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17740. * @param subMeshes The submeshes to render
  17741. */
  17742. private renderAlphaTestSorted;
  17743. /**
  17744. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17745. * @param subMeshes The submeshes to render
  17746. */
  17747. private renderTransparentSorted;
  17748. /**
  17749. * Renders the submeshes in a specified order.
  17750. * @param subMeshes The submeshes to sort before render
  17751. * @param sortCompareFn The comparison function use to sort
  17752. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17753. * @param transparent Specifies to activate blending if true
  17754. */
  17755. private static renderSorted;
  17756. /**
  17757. * Renders the submeshes in the order they were dispatched (no sort applied).
  17758. * @param subMeshes The submeshes to render
  17759. */
  17760. private static renderUnsorted;
  17761. /**
  17762. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17763. * are rendered back to front if in the same alpha index.
  17764. *
  17765. * @param a The first submesh
  17766. * @param b The second submesh
  17767. * @returns The result of the comparison
  17768. */
  17769. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17770. /**
  17771. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17772. * are rendered back to front.
  17773. *
  17774. * @param a The first submesh
  17775. * @param b The second submesh
  17776. * @returns The result of the comparison
  17777. */
  17778. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17779. /**
  17780. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17781. * are rendered front to back (prevent overdraw).
  17782. *
  17783. * @param a The first submesh
  17784. * @param b The second submesh
  17785. * @returns The result of the comparison
  17786. */
  17787. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17788. /**
  17789. * Resets the different lists of submeshes to prepare a new frame.
  17790. */
  17791. prepare(): void;
  17792. dispose(): void;
  17793. /**
  17794. * Inserts the submesh in its correct queue depending on its material.
  17795. * @param subMesh The submesh to dispatch
  17796. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17797. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17798. */
  17799. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17800. dispatchSprites(spriteManager: ISpriteManager): void;
  17801. dispatchParticles(particleSystem: IParticleSystem): void;
  17802. private _renderParticles;
  17803. private _renderSprites;
  17804. }
  17805. }
  17806. declare module "babylonjs/Rendering/renderingManager" {
  17807. import { Nullable } from "babylonjs/types";
  17808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17810. import { SmartArray } from "babylonjs/Misc/smartArray";
  17811. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17812. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17813. import { Material } from "babylonjs/Materials/material";
  17814. import { Scene } from "babylonjs/scene";
  17815. import { Camera } from "babylonjs/Cameras/camera";
  17816. /**
  17817. * Interface describing the different options available in the rendering manager
  17818. * regarding Auto Clear between groups.
  17819. */
  17820. export interface IRenderingManagerAutoClearSetup {
  17821. /**
  17822. * Defines whether or not autoclear is enable.
  17823. */
  17824. autoClear: boolean;
  17825. /**
  17826. * Defines whether or not to autoclear the depth buffer.
  17827. */
  17828. depth: boolean;
  17829. /**
  17830. * Defines whether or not to autoclear the stencil buffer.
  17831. */
  17832. stencil: boolean;
  17833. }
  17834. /**
  17835. * This class is used by the onRenderingGroupObservable
  17836. */
  17837. export class RenderingGroupInfo {
  17838. /**
  17839. * The Scene that being rendered
  17840. */
  17841. scene: Scene;
  17842. /**
  17843. * The camera currently used for the rendering pass
  17844. */
  17845. camera: Nullable<Camera>;
  17846. /**
  17847. * The ID of the renderingGroup being processed
  17848. */
  17849. renderingGroupId: number;
  17850. }
  17851. /**
  17852. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17853. * It is enable to manage the different groups as well as the different necessary sort functions.
  17854. * This should not be used directly aside of the few static configurations
  17855. */
  17856. export class RenderingManager {
  17857. /**
  17858. * The max id used for rendering groups (not included)
  17859. */
  17860. static MAX_RENDERINGGROUPS: number;
  17861. /**
  17862. * The min id used for rendering groups (included)
  17863. */
  17864. static MIN_RENDERINGGROUPS: number;
  17865. /**
  17866. * Used to globally prevent autoclearing scenes.
  17867. */
  17868. static AUTOCLEAR: boolean;
  17869. /**
  17870. * @hidden
  17871. */
  17872. _useSceneAutoClearSetup: boolean;
  17873. private _scene;
  17874. private _renderingGroups;
  17875. private _depthStencilBufferAlreadyCleaned;
  17876. private _autoClearDepthStencil;
  17877. private _customOpaqueSortCompareFn;
  17878. private _customAlphaTestSortCompareFn;
  17879. private _customTransparentSortCompareFn;
  17880. private _renderingGroupInfo;
  17881. /**
  17882. * Instantiates a new rendering group for a particular scene
  17883. * @param scene Defines the scene the groups belongs to
  17884. */
  17885. constructor(scene: Scene);
  17886. private _clearDepthStencilBuffer;
  17887. /**
  17888. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17889. * @hidden
  17890. */
  17891. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17892. /**
  17893. * Resets the different information of the group to prepare a new frame
  17894. * @hidden
  17895. */
  17896. reset(): void;
  17897. /**
  17898. * Dispose and release the group and its associated resources.
  17899. * @hidden
  17900. */
  17901. dispose(): void;
  17902. /**
  17903. * Clear the info related to rendering groups preventing retention points during dispose.
  17904. */
  17905. freeRenderingGroups(): void;
  17906. private _prepareRenderingGroup;
  17907. /**
  17908. * Add a sprite manager to the rendering manager in order to render it this frame.
  17909. * @param spriteManager Define the sprite manager to render
  17910. */
  17911. dispatchSprites(spriteManager: ISpriteManager): void;
  17912. /**
  17913. * Add a particle system to the rendering manager in order to render it this frame.
  17914. * @param particleSystem Define the particle system to render
  17915. */
  17916. dispatchParticles(particleSystem: IParticleSystem): void;
  17917. /**
  17918. * Add a submesh to the manager in order to render it this frame
  17919. * @param subMesh The submesh to dispatch
  17920. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17921. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17922. */
  17923. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17924. /**
  17925. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17926. * This allowed control for front to back rendering or reversly depending of the special needs.
  17927. *
  17928. * @param renderingGroupId The rendering group id corresponding to its index
  17929. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17930. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17931. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17932. */
  17933. 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;
  17934. /**
  17935. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17936. *
  17937. * @param renderingGroupId The rendering group id corresponding to its index
  17938. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17939. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17940. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17941. */
  17942. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17943. /**
  17944. * Gets the current auto clear configuration for one rendering group of the rendering
  17945. * manager.
  17946. * @param index the rendering group index to get the information for
  17947. * @returns The auto clear setup for the requested rendering group
  17948. */
  17949. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17950. }
  17951. }
  17952. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17953. import { SmartArray } from "babylonjs/Misc/smartArray";
  17954. import { Nullable } from "babylonjs/types";
  17955. import { Scene } from "babylonjs/scene";
  17956. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17957. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17959. import { Mesh } from "babylonjs/Meshes/mesh";
  17960. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17961. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17962. import { Effect } from "babylonjs/Materials/effect";
  17963. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17964. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17965. import "babylonjs/Shaders/shadowMap.fragment";
  17966. import "babylonjs/Shaders/shadowMap.vertex";
  17967. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17968. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17969. import { Observable } from "babylonjs/Misc/observable";
  17970. /**
  17971. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17972. */
  17973. export interface ICustomShaderOptions {
  17974. /**
  17975. * Gets or sets the custom shader name to use
  17976. */
  17977. shaderName: string;
  17978. /**
  17979. * The list of attribute names used in the shader
  17980. */
  17981. attributes?: string[];
  17982. /**
  17983. * The list of unifrom names used in the shader
  17984. */
  17985. uniforms?: string[];
  17986. /**
  17987. * The list of sampler names used in the shader
  17988. */
  17989. samplers?: string[];
  17990. /**
  17991. * The list of defines used in the shader
  17992. */
  17993. defines?: string[];
  17994. }
  17995. /**
  17996. * Interface to implement to create a shadow generator compatible with BJS.
  17997. */
  17998. export interface IShadowGenerator {
  17999. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18000. id: string;
  18001. /**
  18002. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18003. * @returns The render target texture if present otherwise, null
  18004. */
  18005. getShadowMap(): Nullable<RenderTargetTexture>;
  18006. /**
  18007. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18008. * @param subMesh The submesh we want to render in the shadow map
  18009. * @param useInstances Defines wether will draw in the map using instances
  18010. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18011. * @returns true if ready otherwise, false
  18012. */
  18013. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18014. /**
  18015. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18016. * @param defines Defines of the material we want to update
  18017. * @param lightIndex Index of the light in the enabled light list of the material
  18018. */
  18019. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18020. /**
  18021. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18022. * defined in the generator but impacting the effect).
  18023. * It implies the unifroms available on the materials are the standard BJS ones.
  18024. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18025. * @param effect The effect we are binfing the information for
  18026. */
  18027. bindShadowLight(lightIndex: string, effect: Effect): void;
  18028. /**
  18029. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18030. * (eq to shadow prjection matrix * light transform matrix)
  18031. * @returns The transform matrix used to create the shadow map
  18032. */
  18033. getTransformMatrix(): Matrix;
  18034. /**
  18035. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18036. * Cube and 2D textures for instance.
  18037. */
  18038. recreateShadowMap(): void;
  18039. /**
  18040. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18041. * @param onCompiled Callback triggered at the and of the effects compilation
  18042. * @param options Sets of optional options forcing the compilation with different modes
  18043. */
  18044. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18045. useInstances: boolean;
  18046. }>): void;
  18047. /**
  18048. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18049. * @param options Sets of optional options forcing the compilation with different modes
  18050. * @returns A promise that resolves when the compilation completes
  18051. */
  18052. forceCompilationAsync(options?: Partial<{
  18053. useInstances: boolean;
  18054. }>): Promise<void>;
  18055. /**
  18056. * Serializes the shadow generator setup to a json object.
  18057. * @returns The serialized JSON object
  18058. */
  18059. serialize(): any;
  18060. /**
  18061. * Disposes the Shadow map and related Textures and effects.
  18062. */
  18063. dispose(): void;
  18064. }
  18065. /**
  18066. * Default implementation IShadowGenerator.
  18067. * This is the main object responsible of generating shadows in the framework.
  18068. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18069. */
  18070. export class ShadowGenerator implements IShadowGenerator {
  18071. /**
  18072. * Name of the shadow generator class
  18073. */
  18074. static CLASSNAME: string;
  18075. /**
  18076. * Shadow generator mode None: no filtering applied.
  18077. */
  18078. static readonly FILTER_NONE: number;
  18079. /**
  18080. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18081. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18082. */
  18083. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18084. /**
  18085. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18086. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18087. */
  18088. static readonly FILTER_POISSONSAMPLING: number;
  18089. /**
  18090. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18091. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18092. */
  18093. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18094. /**
  18095. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18096. * edge artifacts on steep falloff.
  18097. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18098. */
  18099. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18100. /**
  18101. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18102. * edge artifacts on steep falloff.
  18103. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18104. */
  18105. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18106. /**
  18107. * Shadow generator mode PCF: Percentage Closer Filtering
  18108. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18109. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18110. */
  18111. static readonly FILTER_PCF: number;
  18112. /**
  18113. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18114. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18115. * Contact Hardening
  18116. */
  18117. static readonly FILTER_PCSS: number;
  18118. /**
  18119. * Reserved for PCF and PCSS
  18120. * Highest Quality.
  18121. *
  18122. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18123. *
  18124. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18125. */
  18126. static readonly QUALITY_HIGH: number;
  18127. /**
  18128. * Reserved for PCF and PCSS
  18129. * Good tradeoff for quality/perf cross devices
  18130. *
  18131. * Execute PCF on a 3*3 kernel.
  18132. *
  18133. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18134. */
  18135. static readonly QUALITY_MEDIUM: number;
  18136. /**
  18137. * Reserved for PCF and PCSS
  18138. * The lowest quality but the fastest.
  18139. *
  18140. * Execute PCF on a 1*1 kernel.
  18141. *
  18142. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18143. */
  18144. static readonly QUALITY_LOW: number;
  18145. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18146. id: string;
  18147. /** Gets or sets the custom shader name to use */
  18148. customShaderOptions: ICustomShaderOptions;
  18149. /**
  18150. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18151. */
  18152. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18153. /**
  18154. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18155. */
  18156. onAfterShadowMapRenderObservable: Observable<Effect>;
  18157. /**
  18158. * Observable triggered before a mesh is rendered in the shadow map.
  18159. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18160. */
  18161. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18162. /**
  18163. * Observable triggered after a mesh is rendered in the shadow map.
  18164. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18165. */
  18166. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18167. protected _bias: number;
  18168. /**
  18169. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18170. */
  18171. get bias(): number;
  18172. /**
  18173. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18174. */
  18175. set bias(bias: number);
  18176. protected _normalBias: number;
  18177. /**
  18178. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18179. */
  18180. get normalBias(): number;
  18181. /**
  18182. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18183. */
  18184. set normalBias(normalBias: number);
  18185. protected _blurBoxOffset: number;
  18186. /**
  18187. * Gets the blur box offset: offset applied during the blur pass.
  18188. * Only useful if useKernelBlur = false
  18189. */
  18190. get blurBoxOffset(): number;
  18191. /**
  18192. * Sets the blur box offset: offset applied during the blur pass.
  18193. * Only useful if useKernelBlur = false
  18194. */
  18195. set blurBoxOffset(value: number);
  18196. protected _blurScale: number;
  18197. /**
  18198. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18199. * 2 means half of the size.
  18200. */
  18201. get blurScale(): number;
  18202. /**
  18203. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18204. * 2 means half of the size.
  18205. */
  18206. set blurScale(value: number);
  18207. protected _blurKernel: number;
  18208. /**
  18209. * Gets the blur kernel: kernel size of the blur pass.
  18210. * Only useful if useKernelBlur = true
  18211. */
  18212. get blurKernel(): number;
  18213. /**
  18214. * Sets the blur kernel: kernel size of the blur pass.
  18215. * Only useful if useKernelBlur = true
  18216. */
  18217. set blurKernel(value: number);
  18218. protected _useKernelBlur: boolean;
  18219. /**
  18220. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18221. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18222. */
  18223. get useKernelBlur(): boolean;
  18224. /**
  18225. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18226. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18227. */
  18228. set useKernelBlur(value: boolean);
  18229. protected _depthScale: number;
  18230. /**
  18231. * Gets the depth scale used in ESM mode.
  18232. */
  18233. get depthScale(): number;
  18234. /**
  18235. * Sets the depth scale used in ESM mode.
  18236. * This can override the scale stored on the light.
  18237. */
  18238. set depthScale(value: number);
  18239. protected _validateFilter(filter: number): number;
  18240. protected _filter: number;
  18241. /**
  18242. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18243. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18244. */
  18245. get filter(): number;
  18246. /**
  18247. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18248. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18249. */
  18250. set filter(value: number);
  18251. /**
  18252. * Gets if the current filter is set to Poisson Sampling.
  18253. */
  18254. get usePoissonSampling(): boolean;
  18255. /**
  18256. * Sets the current filter to Poisson Sampling.
  18257. */
  18258. set usePoissonSampling(value: boolean);
  18259. /**
  18260. * Gets if the current filter is set to ESM.
  18261. */
  18262. get useExponentialShadowMap(): boolean;
  18263. /**
  18264. * Sets the current filter is to ESM.
  18265. */
  18266. set useExponentialShadowMap(value: boolean);
  18267. /**
  18268. * Gets if the current filter is set to filtered ESM.
  18269. */
  18270. get useBlurExponentialShadowMap(): boolean;
  18271. /**
  18272. * Gets if the current filter is set to filtered ESM.
  18273. */
  18274. set useBlurExponentialShadowMap(value: boolean);
  18275. /**
  18276. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18277. * exponential to prevent steep falloff artifacts).
  18278. */
  18279. get useCloseExponentialShadowMap(): boolean;
  18280. /**
  18281. * Sets the current filter to "close ESM" (using the inverse of the
  18282. * exponential to prevent steep falloff artifacts).
  18283. */
  18284. set useCloseExponentialShadowMap(value: boolean);
  18285. /**
  18286. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18287. * exponential to prevent steep falloff artifacts).
  18288. */
  18289. get useBlurCloseExponentialShadowMap(): boolean;
  18290. /**
  18291. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18292. * exponential to prevent steep falloff artifacts).
  18293. */
  18294. set useBlurCloseExponentialShadowMap(value: boolean);
  18295. /**
  18296. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18297. */
  18298. get usePercentageCloserFiltering(): boolean;
  18299. /**
  18300. * Sets the current filter to "PCF" (percentage closer filtering).
  18301. */
  18302. set usePercentageCloserFiltering(value: boolean);
  18303. protected _filteringQuality: number;
  18304. /**
  18305. * Gets the PCF or PCSS Quality.
  18306. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18307. */
  18308. get filteringQuality(): number;
  18309. /**
  18310. * Sets the PCF or PCSS Quality.
  18311. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18312. */
  18313. set filteringQuality(filteringQuality: number);
  18314. /**
  18315. * Gets if the current filter is set to "PCSS" (contact hardening).
  18316. */
  18317. get useContactHardeningShadow(): boolean;
  18318. /**
  18319. * Sets the current filter to "PCSS" (contact hardening).
  18320. */
  18321. set useContactHardeningShadow(value: boolean);
  18322. protected _contactHardeningLightSizeUVRatio: number;
  18323. /**
  18324. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18325. * Using a ratio helps keeping shape stability independently of the map size.
  18326. *
  18327. * It does not account for the light projection as it was having too much
  18328. * instability during the light setup or during light position changes.
  18329. *
  18330. * Only valid if useContactHardeningShadow is true.
  18331. */
  18332. get contactHardeningLightSizeUVRatio(): number;
  18333. /**
  18334. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18335. * Using a ratio helps keeping shape stability independently of the map size.
  18336. *
  18337. * It does not account for the light projection as it was having too much
  18338. * instability during the light setup or during light position changes.
  18339. *
  18340. * Only valid if useContactHardeningShadow is true.
  18341. */
  18342. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18343. protected _darkness: number;
  18344. /** Gets or sets the actual darkness of a shadow */
  18345. get darkness(): number;
  18346. set darkness(value: number);
  18347. /**
  18348. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18349. * 0 means strongest and 1 would means no shadow.
  18350. * @returns the darkness.
  18351. */
  18352. getDarkness(): number;
  18353. /**
  18354. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18355. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18356. * @returns the shadow generator allowing fluent coding.
  18357. */
  18358. setDarkness(darkness: number): ShadowGenerator;
  18359. protected _transparencyShadow: boolean;
  18360. /** Gets or sets the ability to have transparent shadow */
  18361. get transparencyShadow(): boolean;
  18362. set transparencyShadow(value: boolean);
  18363. /**
  18364. * Sets the ability to have transparent shadow (boolean).
  18365. * @param transparent True if transparent else False
  18366. * @returns the shadow generator allowing fluent coding
  18367. */
  18368. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18369. /**
  18370. * Enables or disables shadows with varying strength based on the transparency
  18371. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18372. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18373. * mesh.visibility * alphaTexture.a
  18374. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18375. */
  18376. enableSoftTransparentShadow: boolean;
  18377. protected _shadowMap: Nullable<RenderTargetTexture>;
  18378. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18379. /**
  18380. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18381. * @returns The render target texture if present otherwise, null
  18382. */
  18383. getShadowMap(): Nullable<RenderTargetTexture>;
  18384. /**
  18385. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18386. * @returns The render target texture if the shadow map is present otherwise, null
  18387. */
  18388. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18389. /**
  18390. * Gets the class name of that object
  18391. * @returns "ShadowGenerator"
  18392. */
  18393. getClassName(): string;
  18394. /**
  18395. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18396. * @param mesh Mesh to add
  18397. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18398. * @returns the Shadow Generator itself
  18399. */
  18400. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18401. /**
  18402. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18403. * @param mesh Mesh to remove
  18404. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18405. * @returns the Shadow Generator itself
  18406. */
  18407. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18408. /**
  18409. * Controls the extent to which the shadows fade out at the edge of the frustum
  18410. */
  18411. frustumEdgeFalloff: number;
  18412. protected _light: IShadowLight;
  18413. /**
  18414. * Returns the associated light object.
  18415. * @returns the light generating the shadow
  18416. */
  18417. getLight(): IShadowLight;
  18418. /**
  18419. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18420. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18421. * It might on the other hand introduce peter panning.
  18422. */
  18423. forceBackFacesOnly: boolean;
  18424. protected _scene: Scene;
  18425. protected _lightDirection: Vector3;
  18426. protected _effect: Effect;
  18427. protected _viewMatrix: Matrix;
  18428. protected _projectionMatrix: Matrix;
  18429. protected _transformMatrix: Matrix;
  18430. protected _cachedPosition: Vector3;
  18431. protected _cachedDirection: Vector3;
  18432. protected _cachedDefines: string;
  18433. protected _currentRenderID: number;
  18434. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18435. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18436. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18437. protected _blurPostProcesses: PostProcess[];
  18438. protected _mapSize: number;
  18439. protected _currentFaceIndex: number;
  18440. protected _currentFaceIndexCache: number;
  18441. protected _textureType: number;
  18442. protected _defaultTextureMatrix: Matrix;
  18443. protected _storedUniqueId: Nullable<number>;
  18444. /** @hidden */
  18445. static _SceneComponentInitialization: (scene: Scene) => void;
  18446. /**
  18447. * Creates a ShadowGenerator object.
  18448. * A ShadowGenerator is the required tool to use the shadows.
  18449. * Each light casting shadows needs to use its own ShadowGenerator.
  18450. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18451. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18452. * @param light The light object generating the shadows.
  18453. * @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.
  18454. */
  18455. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18456. protected _initializeGenerator(): void;
  18457. protected _createTargetRenderTexture(): void;
  18458. protected _initializeShadowMap(): void;
  18459. protected _initializeBlurRTTAndPostProcesses(): void;
  18460. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18461. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18462. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18463. protected _applyFilterValues(): void;
  18464. /**
  18465. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18466. * @param onCompiled Callback triggered at the and of the effects compilation
  18467. * @param options Sets of optional options forcing the compilation with different modes
  18468. */
  18469. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18470. useInstances: boolean;
  18471. }>): void;
  18472. /**
  18473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18474. * @param options Sets of optional options forcing the compilation with different modes
  18475. * @returns A promise that resolves when the compilation completes
  18476. */
  18477. forceCompilationAsync(options?: Partial<{
  18478. useInstances: boolean;
  18479. }>): Promise<void>;
  18480. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18481. private _prepareShadowDefines;
  18482. /**
  18483. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18484. * @param subMesh The submesh we want to render in the shadow map
  18485. * @param useInstances Defines wether will draw in the map using instances
  18486. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18487. * @returns true if ready otherwise, false
  18488. */
  18489. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18490. /**
  18491. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18492. * @param defines Defines of the material we want to update
  18493. * @param lightIndex Index of the light in the enabled light list of the material
  18494. */
  18495. prepareDefines(defines: any, lightIndex: number): void;
  18496. /**
  18497. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18498. * defined in the generator but impacting the effect).
  18499. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18500. * @param effect The effect we are binfing the information for
  18501. */
  18502. bindShadowLight(lightIndex: string, effect: Effect): void;
  18503. /**
  18504. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18505. * (eq to shadow prjection matrix * light transform matrix)
  18506. * @returns The transform matrix used to create the shadow map
  18507. */
  18508. getTransformMatrix(): Matrix;
  18509. /**
  18510. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18511. * Cube and 2D textures for instance.
  18512. */
  18513. recreateShadowMap(): void;
  18514. protected _disposeBlurPostProcesses(): void;
  18515. protected _disposeRTTandPostProcesses(): void;
  18516. /**
  18517. * Disposes the ShadowGenerator.
  18518. * Returns nothing.
  18519. */
  18520. dispose(): void;
  18521. /**
  18522. * Serializes the shadow generator setup to a json object.
  18523. * @returns The serialized JSON object
  18524. */
  18525. serialize(): any;
  18526. /**
  18527. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18528. * @param parsedShadowGenerator The JSON object to parse
  18529. * @param scene The scene to create the shadow map for
  18530. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18531. * @returns The parsed shadow generator
  18532. */
  18533. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18534. }
  18535. }
  18536. declare module "babylonjs/Lights/light" {
  18537. import { Nullable } from "babylonjs/types";
  18538. import { Scene } from "babylonjs/scene";
  18539. import { Vector3 } from "babylonjs/Maths/math.vector";
  18540. import { Color3 } from "babylonjs/Maths/math.color";
  18541. import { Node } from "babylonjs/node";
  18542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18543. import { Effect } from "babylonjs/Materials/effect";
  18544. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18545. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18546. /**
  18547. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18548. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18549. * 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.
  18550. */
  18551. export abstract class Light extends Node {
  18552. /**
  18553. * Falloff Default: light is falling off following the material specification:
  18554. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18555. */
  18556. static readonly FALLOFF_DEFAULT: number;
  18557. /**
  18558. * Falloff Physical: light is falling off following the inverse squared distance law.
  18559. */
  18560. static readonly FALLOFF_PHYSICAL: number;
  18561. /**
  18562. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18563. * to enhance interoperability with other engines.
  18564. */
  18565. static readonly FALLOFF_GLTF: number;
  18566. /**
  18567. * Falloff Standard: light is falling off like in the standard material
  18568. * to enhance interoperability with other materials.
  18569. */
  18570. static readonly FALLOFF_STANDARD: number;
  18571. /**
  18572. * If every light affecting the material is in this lightmapMode,
  18573. * material.lightmapTexture adds or multiplies
  18574. * (depends on material.useLightmapAsShadowmap)
  18575. * after every other light calculations.
  18576. */
  18577. static readonly LIGHTMAP_DEFAULT: number;
  18578. /**
  18579. * material.lightmapTexture as only diffuse lighting from this light
  18580. * adds only specular lighting from this light
  18581. * adds dynamic shadows
  18582. */
  18583. static readonly LIGHTMAP_SPECULAR: number;
  18584. /**
  18585. * material.lightmapTexture as only lighting
  18586. * no light calculation from this light
  18587. * only adds dynamic shadows from this light
  18588. */
  18589. static readonly LIGHTMAP_SHADOWSONLY: number;
  18590. /**
  18591. * Each light type uses the default quantity according to its type:
  18592. * point/spot lights use luminous intensity
  18593. * directional lights use illuminance
  18594. */
  18595. static readonly INTENSITYMODE_AUTOMATIC: number;
  18596. /**
  18597. * lumen (lm)
  18598. */
  18599. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18600. /**
  18601. * candela (lm/sr)
  18602. */
  18603. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18604. /**
  18605. * lux (lm/m^2)
  18606. */
  18607. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18608. /**
  18609. * nit (cd/m^2)
  18610. */
  18611. static readonly INTENSITYMODE_LUMINANCE: number;
  18612. /**
  18613. * Light type const id of the point light.
  18614. */
  18615. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18616. /**
  18617. * Light type const id of the directional light.
  18618. */
  18619. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18620. /**
  18621. * Light type const id of the spot light.
  18622. */
  18623. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18624. /**
  18625. * Light type const id of the hemispheric light.
  18626. */
  18627. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18628. /**
  18629. * Diffuse gives the basic color to an object.
  18630. */
  18631. diffuse: Color3;
  18632. /**
  18633. * Specular produces a highlight color on an object.
  18634. * Note: This is note affecting PBR materials.
  18635. */
  18636. specular: Color3;
  18637. /**
  18638. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18639. * falling off base on range or angle.
  18640. * This can be set to any values in Light.FALLOFF_x.
  18641. *
  18642. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18643. * other types of materials.
  18644. */
  18645. falloffType: number;
  18646. /**
  18647. * Strength of the light.
  18648. * Note: By default it is define in the framework own unit.
  18649. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18650. */
  18651. intensity: number;
  18652. private _range;
  18653. protected _inverseSquaredRange: number;
  18654. /**
  18655. * Defines how far from the source the light is impacting in scene units.
  18656. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18657. */
  18658. get range(): number;
  18659. /**
  18660. * Defines how far from the source the light is impacting in scene units.
  18661. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18662. */
  18663. set range(value: number);
  18664. /**
  18665. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18666. * of light.
  18667. */
  18668. private _photometricScale;
  18669. private _intensityMode;
  18670. /**
  18671. * Gets the photometric scale used to interpret the intensity.
  18672. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18673. */
  18674. get intensityMode(): number;
  18675. /**
  18676. * Sets the photometric scale used to interpret the intensity.
  18677. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18678. */
  18679. set intensityMode(value: number);
  18680. private _radius;
  18681. /**
  18682. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18683. */
  18684. get radius(): number;
  18685. /**
  18686. * sets the light radius used by PBR Materials to simulate soft area lights.
  18687. */
  18688. set radius(value: number);
  18689. private _renderPriority;
  18690. /**
  18691. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18692. * exceeding the number allowed of the materials.
  18693. */
  18694. renderPriority: number;
  18695. private _shadowEnabled;
  18696. /**
  18697. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18698. * the current shadow generator.
  18699. */
  18700. get shadowEnabled(): boolean;
  18701. /**
  18702. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18703. * the current shadow generator.
  18704. */
  18705. set shadowEnabled(value: boolean);
  18706. private _includedOnlyMeshes;
  18707. /**
  18708. * Gets the only meshes impacted by this light.
  18709. */
  18710. get includedOnlyMeshes(): AbstractMesh[];
  18711. /**
  18712. * Sets the only meshes impacted by this light.
  18713. */
  18714. set includedOnlyMeshes(value: AbstractMesh[]);
  18715. private _excludedMeshes;
  18716. /**
  18717. * Gets the meshes not impacted by this light.
  18718. */
  18719. get excludedMeshes(): AbstractMesh[];
  18720. /**
  18721. * Sets the meshes not impacted by this light.
  18722. */
  18723. set excludedMeshes(value: AbstractMesh[]);
  18724. private _excludeWithLayerMask;
  18725. /**
  18726. * Gets the layer id use to find what meshes are not impacted by the light.
  18727. * Inactive if 0
  18728. */
  18729. get excludeWithLayerMask(): number;
  18730. /**
  18731. * Sets the layer id use to find what meshes are not impacted by the light.
  18732. * Inactive if 0
  18733. */
  18734. set excludeWithLayerMask(value: number);
  18735. private _includeOnlyWithLayerMask;
  18736. /**
  18737. * Gets the layer id use to find what meshes are impacted by the light.
  18738. * Inactive if 0
  18739. */
  18740. get includeOnlyWithLayerMask(): number;
  18741. /**
  18742. * Sets the layer id use to find what meshes are impacted by the light.
  18743. * Inactive if 0
  18744. */
  18745. set includeOnlyWithLayerMask(value: number);
  18746. private _lightmapMode;
  18747. /**
  18748. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18749. */
  18750. get lightmapMode(): number;
  18751. /**
  18752. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18753. */
  18754. set lightmapMode(value: number);
  18755. /**
  18756. * Shadow generator associted to the light.
  18757. * @hidden Internal use only.
  18758. */
  18759. _shadowGenerator: Nullable<IShadowGenerator>;
  18760. /**
  18761. * @hidden Internal use only.
  18762. */
  18763. _excludedMeshesIds: string[];
  18764. /**
  18765. * @hidden Internal use only.
  18766. */
  18767. _includedOnlyMeshesIds: string[];
  18768. /**
  18769. * The current light unifom buffer.
  18770. * @hidden Internal use only.
  18771. */
  18772. _uniformBuffer: UniformBuffer;
  18773. /** @hidden */
  18774. _renderId: number;
  18775. /**
  18776. * Creates a Light object in the scene.
  18777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18778. * @param name The firendly name of the light
  18779. * @param scene The scene the light belongs too
  18780. */
  18781. constructor(name: string, scene: Scene);
  18782. protected abstract _buildUniformLayout(): void;
  18783. /**
  18784. * Sets the passed Effect "effect" with the Light information.
  18785. * @param effect The effect to update
  18786. * @param lightIndex The index of the light in the effect to update
  18787. * @returns The light
  18788. */
  18789. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18790. /**
  18791. * Sets the passed Effect "effect" with the Light textures.
  18792. * @param effect The effect to update
  18793. * @param lightIndex The index of the light in the effect to update
  18794. * @returns The light
  18795. */
  18796. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18797. /**
  18798. * Binds the lights information from the scene to the effect for the given mesh.
  18799. * @param lightIndex Light index
  18800. * @param scene The scene where the light belongs to
  18801. * @param effect The effect we are binding the data to
  18802. * @param useSpecular Defines if specular is supported
  18803. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18804. */
  18805. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18806. /**
  18807. * Sets the passed Effect "effect" with the Light information.
  18808. * @param effect The effect to update
  18809. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18810. * @returns The light
  18811. */
  18812. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18813. /**
  18814. * Returns the string "Light".
  18815. * @returns the class name
  18816. */
  18817. getClassName(): string;
  18818. /** @hidden */
  18819. readonly _isLight: boolean;
  18820. /**
  18821. * Converts the light information to a readable string for debug purpose.
  18822. * @param fullDetails Supports for multiple levels of logging within scene loading
  18823. * @returns the human readable light info
  18824. */
  18825. toString(fullDetails?: boolean): string;
  18826. /** @hidden */
  18827. protected _syncParentEnabledState(): void;
  18828. /**
  18829. * Set the enabled state of this node.
  18830. * @param value - the new enabled state
  18831. */
  18832. setEnabled(value: boolean): void;
  18833. /**
  18834. * Returns the Light associated shadow generator if any.
  18835. * @return the associated shadow generator.
  18836. */
  18837. getShadowGenerator(): Nullable<IShadowGenerator>;
  18838. /**
  18839. * Returns a Vector3, the absolute light position in the World.
  18840. * @returns the world space position of the light
  18841. */
  18842. getAbsolutePosition(): Vector3;
  18843. /**
  18844. * Specifies if the light will affect the passed mesh.
  18845. * @param mesh The mesh to test against the light
  18846. * @return true the mesh is affected otherwise, false.
  18847. */
  18848. canAffectMesh(mesh: AbstractMesh): boolean;
  18849. /**
  18850. * Sort function to order lights for rendering.
  18851. * @param a First Light object to compare to second.
  18852. * @param b Second Light object to compare first.
  18853. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18854. */
  18855. static CompareLightsPriority(a: Light, b: Light): number;
  18856. /**
  18857. * Releases resources associated with this node.
  18858. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18859. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18860. */
  18861. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18862. /**
  18863. * Returns the light type ID (integer).
  18864. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18865. */
  18866. getTypeID(): number;
  18867. /**
  18868. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18869. * @returns the scaled intensity in intensity mode unit
  18870. */
  18871. getScaledIntensity(): number;
  18872. /**
  18873. * Returns a new Light object, named "name", from the current one.
  18874. * @param name The name of the cloned light
  18875. * @param newParent The parent of this light, if it has one
  18876. * @returns the new created light
  18877. */
  18878. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18879. /**
  18880. * Serializes the current light into a Serialization object.
  18881. * @returns the serialized object.
  18882. */
  18883. serialize(): any;
  18884. /**
  18885. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18886. * This new light is named "name" and added to the passed scene.
  18887. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18888. * @param name The friendly name of the light
  18889. * @param scene The scene the new light will belong to
  18890. * @returns the constructor function
  18891. */
  18892. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18893. /**
  18894. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18895. * @param parsedLight The JSON representation of the light
  18896. * @param scene The scene to create the parsed light in
  18897. * @returns the created light after parsing
  18898. */
  18899. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18900. private _hookArrayForExcluded;
  18901. private _hookArrayForIncludedOnly;
  18902. private _resyncMeshes;
  18903. /**
  18904. * Forces the meshes to update their light related information in their rendering used effects
  18905. * @hidden Internal Use Only
  18906. */
  18907. _markMeshesAsLightDirty(): void;
  18908. /**
  18909. * Recomputes the cached photometric scale if needed.
  18910. */
  18911. private _computePhotometricScale;
  18912. /**
  18913. * Returns the Photometric Scale according to the light type and intensity mode.
  18914. */
  18915. private _getPhotometricScale;
  18916. /**
  18917. * Reorder the light in the scene according to their defined priority.
  18918. * @hidden Internal Use Only
  18919. */
  18920. _reorderLightsInScene(): void;
  18921. /**
  18922. * Prepares the list of defines specific to the light type.
  18923. * @param defines the list of defines
  18924. * @param lightIndex defines the index of the light for the effect
  18925. */
  18926. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18927. }
  18928. }
  18929. declare module "babylonjs/Cameras/targetCamera" {
  18930. import { Nullable } from "babylonjs/types";
  18931. import { Camera } from "babylonjs/Cameras/camera";
  18932. import { Scene } from "babylonjs/scene";
  18933. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18934. /**
  18935. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18936. * This is the base of the follow, arc rotate cameras and Free camera
  18937. * @see https://doc.babylonjs.com/features/cameras
  18938. */
  18939. export class TargetCamera extends Camera {
  18940. private static _RigCamTransformMatrix;
  18941. private static _TargetTransformMatrix;
  18942. private static _TargetFocalPoint;
  18943. private _tmpUpVector;
  18944. private _tmpTargetVector;
  18945. /**
  18946. * Define the current direction the camera is moving to
  18947. */
  18948. cameraDirection: Vector3;
  18949. /**
  18950. * Define the current rotation the camera is rotating to
  18951. */
  18952. cameraRotation: Vector2;
  18953. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18954. ignoreParentScaling: boolean;
  18955. /**
  18956. * When set, the up vector of the camera will be updated by the rotation of the camera
  18957. */
  18958. updateUpVectorFromRotation: boolean;
  18959. private _tmpQuaternion;
  18960. /**
  18961. * Define the current rotation of the camera
  18962. */
  18963. rotation: Vector3;
  18964. /**
  18965. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18966. */
  18967. rotationQuaternion: Quaternion;
  18968. /**
  18969. * Define the current speed of the camera
  18970. */
  18971. speed: number;
  18972. /**
  18973. * Add constraint to the camera to prevent it to move freely in all directions and
  18974. * around all axis.
  18975. */
  18976. noRotationConstraint: boolean;
  18977. /**
  18978. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18979. * panning
  18980. */
  18981. invertRotation: boolean;
  18982. /**
  18983. * Speed multiplier for inverse camera panning
  18984. */
  18985. inverseRotationSpeed: number;
  18986. /**
  18987. * Define the current target of the camera as an object or a position.
  18988. */
  18989. lockedTarget: any;
  18990. /** @hidden */
  18991. _currentTarget: Vector3;
  18992. /** @hidden */
  18993. _initialFocalDistance: number;
  18994. /** @hidden */
  18995. _viewMatrix: Matrix;
  18996. /** @hidden */
  18997. _camMatrix: Matrix;
  18998. /** @hidden */
  18999. _cameraTransformMatrix: Matrix;
  19000. /** @hidden */
  19001. _cameraRotationMatrix: Matrix;
  19002. /** @hidden */
  19003. _referencePoint: Vector3;
  19004. /** @hidden */
  19005. _transformedReferencePoint: Vector3;
  19006. /** @hidden */
  19007. _reset: () => void;
  19008. private _defaultUp;
  19009. /**
  19010. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19011. * This is the base of the follow, arc rotate cameras and Free camera
  19012. * @see https://doc.babylonjs.com/features/cameras
  19013. * @param name Defines the name of the camera in the scene
  19014. * @param position Defines the start position of the camera in the scene
  19015. * @param scene Defines the scene the camera belongs to
  19016. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19017. */
  19018. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19019. /**
  19020. * Gets the position in front of the camera at a given distance.
  19021. * @param distance The distance from the camera we want the position to be
  19022. * @returns the position
  19023. */
  19024. getFrontPosition(distance: number): Vector3;
  19025. /** @hidden */
  19026. _getLockedTargetPosition(): Nullable<Vector3>;
  19027. private _storedPosition;
  19028. private _storedRotation;
  19029. private _storedRotationQuaternion;
  19030. /**
  19031. * Store current camera state of the camera (fov, position, rotation, etc..)
  19032. * @returns the camera
  19033. */
  19034. storeState(): Camera;
  19035. /**
  19036. * Restored camera state. You must call storeState() first
  19037. * @returns whether it was successful or not
  19038. * @hidden
  19039. */
  19040. _restoreStateValues(): boolean;
  19041. /** @hidden */
  19042. _initCache(): void;
  19043. /** @hidden */
  19044. _updateCache(ignoreParentClass?: boolean): void;
  19045. /** @hidden */
  19046. _isSynchronizedViewMatrix(): boolean;
  19047. /** @hidden */
  19048. _computeLocalCameraSpeed(): number;
  19049. /**
  19050. * Defines the target the camera should look at.
  19051. * @param target Defines the new target as a Vector or a mesh
  19052. */
  19053. setTarget(target: Vector3): void;
  19054. /**
  19055. * Defines the target point of the camera.
  19056. * The camera looks towards it form the radius distance.
  19057. */
  19058. get target(): Vector3;
  19059. set target(value: Vector3);
  19060. /**
  19061. * Return the current target position of the camera. This value is expressed in local space.
  19062. * @returns the target position
  19063. */
  19064. getTarget(): Vector3;
  19065. /** @hidden */
  19066. _decideIfNeedsToMove(): boolean;
  19067. /** @hidden */
  19068. _updatePosition(): void;
  19069. /** @hidden */
  19070. _checkInputs(): void;
  19071. protected _updateCameraRotationMatrix(): void;
  19072. /**
  19073. * 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)
  19074. * @returns the current camera
  19075. */
  19076. private _rotateUpVectorWithCameraRotationMatrix;
  19077. private _cachedRotationZ;
  19078. private _cachedQuaternionRotationZ;
  19079. /** @hidden */
  19080. _getViewMatrix(): Matrix;
  19081. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19082. /**
  19083. * @hidden
  19084. */
  19085. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19086. /**
  19087. * @hidden
  19088. */
  19089. _updateRigCameras(): void;
  19090. private _getRigCamPositionAndTarget;
  19091. /**
  19092. * Gets the current object class name.
  19093. * @return the class name
  19094. */
  19095. getClassName(): string;
  19096. }
  19097. }
  19098. declare module "babylonjs/Events/keyboardEvents" {
  19099. /**
  19100. * Gather the list of keyboard event types as constants.
  19101. */
  19102. export class KeyboardEventTypes {
  19103. /**
  19104. * The keydown event is fired when a key becomes active (pressed).
  19105. */
  19106. static readonly KEYDOWN: number;
  19107. /**
  19108. * The keyup event is fired when a key has been released.
  19109. */
  19110. static readonly KEYUP: number;
  19111. }
  19112. /**
  19113. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19114. */
  19115. export class KeyboardInfo {
  19116. /**
  19117. * Defines the type of event (KeyboardEventTypes)
  19118. */
  19119. type: number;
  19120. /**
  19121. * Defines the related dom event
  19122. */
  19123. event: KeyboardEvent;
  19124. /**
  19125. * Instantiates a new keyboard info.
  19126. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19127. * @param type Defines the type of event (KeyboardEventTypes)
  19128. * @param event Defines the related dom event
  19129. */
  19130. constructor(
  19131. /**
  19132. * Defines the type of event (KeyboardEventTypes)
  19133. */
  19134. type: number,
  19135. /**
  19136. * Defines the related dom event
  19137. */
  19138. event: KeyboardEvent);
  19139. }
  19140. /**
  19141. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19142. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19143. */
  19144. export class KeyboardInfoPre extends KeyboardInfo {
  19145. /**
  19146. * Defines the type of event (KeyboardEventTypes)
  19147. */
  19148. type: number;
  19149. /**
  19150. * Defines the related dom event
  19151. */
  19152. event: KeyboardEvent;
  19153. /**
  19154. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19155. */
  19156. skipOnPointerObservable: boolean;
  19157. /**
  19158. * Instantiates a new keyboard pre info.
  19159. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19160. * @param type Defines the type of event (KeyboardEventTypes)
  19161. * @param event Defines the related dom event
  19162. */
  19163. constructor(
  19164. /**
  19165. * Defines the type of event (KeyboardEventTypes)
  19166. */
  19167. type: number,
  19168. /**
  19169. * Defines the related dom event
  19170. */
  19171. event: KeyboardEvent);
  19172. }
  19173. }
  19174. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19175. import { Nullable } from "babylonjs/types";
  19176. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19177. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19178. /**
  19179. * Manage the keyboard inputs to control the movement of a free camera.
  19180. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19181. */
  19182. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19183. /**
  19184. * Defines the camera the input is attached to.
  19185. */
  19186. camera: FreeCamera;
  19187. /**
  19188. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19189. */
  19190. keysUp: number[];
  19191. /**
  19192. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19193. */
  19194. keysUpward: number[];
  19195. /**
  19196. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19197. */
  19198. keysDown: number[];
  19199. /**
  19200. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19201. */
  19202. keysDownward: number[];
  19203. /**
  19204. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19205. */
  19206. keysLeft: number[];
  19207. /**
  19208. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19209. */
  19210. keysRight: number[];
  19211. private _keys;
  19212. private _onCanvasBlurObserver;
  19213. private _onKeyboardObserver;
  19214. private _engine;
  19215. private _scene;
  19216. /**
  19217. * Attach the input controls to a specific dom element to get the input from.
  19218. * @param element Defines the element the controls should be listened from
  19219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19220. */
  19221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19222. /**
  19223. * Detach the current controls from the specified dom element.
  19224. * @param element Defines the element to stop listening the inputs from
  19225. */
  19226. detachControl(element: Nullable<HTMLElement>): void;
  19227. /**
  19228. * Update the current camera state depending on the inputs that have been used this frame.
  19229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19230. */
  19231. checkInputs(): void;
  19232. /**
  19233. * Gets the class name of the current intput.
  19234. * @returns the class name
  19235. */
  19236. getClassName(): string;
  19237. /** @hidden */
  19238. _onLostFocus(): void;
  19239. /**
  19240. * Get the friendly name associated with the input class.
  19241. * @returns the input friendly name
  19242. */
  19243. getSimpleName(): string;
  19244. }
  19245. }
  19246. declare module "babylonjs/Events/pointerEvents" {
  19247. import { Nullable } from "babylonjs/types";
  19248. import { Vector2 } from "babylonjs/Maths/math.vector";
  19249. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19250. import { Ray } from "babylonjs/Culling/ray";
  19251. /**
  19252. * Gather the list of pointer event types as constants.
  19253. */
  19254. export class PointerEventTypes {
  19255. /**
  19256. * 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.
  19257. */
  19258. static readonly POINTERDOWN: number;
  19259. /**
  19260. * The pointerup event is fired when a pointer is no longer active.
  19261. */
  19262. static readonly POINTERUP: number;
  19263. /**
  19264. * The pointermove event is fired when a pointer changes coordinates.
  19265. */
  19266. static readonly POINTERMOVE: number;
  19267. /**
  19268. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19269. */
  19270. static readonly POINTERWHEEL: number;
  19271. /**
  19272. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19273. */
  19274. static readonly POINTERPICK: number;
  19275. /**
  19276. * The pointertap event is fired when a the object has been touched and released without drag.
  19277. */
  19278. static readonly POINTERTAP: number;
  19279. /**
  19280. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19281. */
  19282. static readonly POINTERDOUBLETAP: number;
  19283. }
  19284. /**
  19285. * Base class of pointer info types.
  19286. */
  19287. export class PointerInfoBase {
  19288. /**
  19289. * Defines the type of event (PointerEventTypes)
  19290. */
  19291. type: number;
  19292. /**
  19293. * Defines the related dom event
  19294. */
  19295. event: PointerEvent | MouseWheelEvent;
  19296. /**
  19297. * Instantiates the base class of pointers info.
  19298. * @param type Defines the type of event (PointerEventTypes)
  19299. * @param event Defines the related dom event
  19300. */
  19301. constructor(
  19302. /**
  19303. * Defines the type of event (PointerEventTypes)
  19304. */
  19305. type: number,
  19306. /**
  19307. * Defines the related dom event
  19308. */
  19309. event: PointerEvent | MouseWheelEvent);
  19310. }
  19311. /**
  19312. * This class is used to store pointer related info for the onPrePointerObservable event.
  19313. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19314. */
  19315. export class PointerInfoPre extends PointerInfoBase {
  19316. /**
  19317. * Ray from a pointer if availible (eg. 6dof controller)
  19318. */
  19319. ray: Nullable<Ray>;
  19320. /**
  19321. * Defines the local position of the pointer on the canvas.
  19322. */
  19323. localPosition: Vector2;
  19324. /**
  19325. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19326. */
  19327. skipOnPointerObservable: boolean;
  19328. /**
  19329. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19330. * @param type Defines the type of event (PointerEventTypes)
  19331. * @param event Defines the related dom event
  19332. * @param localX Defines the local x coordinates of the pointer when the event occured
  19333. * @param localY Defines the local y coordinates of the pointer when the event occured
  19334. */
  19335. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19336. }
  19337. /**
  19338. * This type contains all the data related to a pointer event in Babylon.js.
  19339. * 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.
  19340. */
  19341. export class PointerInfo extends PointerInfoBase {
  19342. /**
  19343. * Defines the picking info associated to the info (if any)\
  19344. */
  19345. pickInfo: Nullable<PickingInfo>;
  19346. /**
  19347. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19348. * @param type Defines the type of event (PointerEventTypes)
  19349. * @param event Defines the related dom event
  19350. * @param pickInfo Defines the picking info associated to the info (if any)\
  19351. */
  19352. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19353. /**
  19354. * Defines the picking info associated to the info (if any)\
  19355. */
  19356. pickInfo: Nullable<PickingInfo>);
  19357. }
  19358. /**
  19359. * Data relating to a touch event on the screen.
  19360. */
  19361. export interface PointerTouch {
  19362. /**
  19363. * X coordinate of touch.
  19364. */
  19365. x: number;
  19366. /**
  19367. * Y coordinate of touch.
  19368. */
  19369. y: number;
  19370. /**
  19371. * Id of touch. Unique for each finger.
  19372. */
  19373. pointerId: number;
  19374. /**
  19375. * Event type passed from DOM.
  19376. */
  19377. type: any;
  19378. }
  19379. }
  19380. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19381. import { Observable } from "babylonjs/Misc/observable";
  19382. import { Nullable } from "babylonjs/types";
  19383. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19384. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19385. /**
  19386. * Manage the mouse inputs to control the movement of a free camera.
  19387. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19388. */
  19389. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19390. /**
  19391. * Define if touch is enabled in the mouse input
  19392. */
  19393. touchEnabled: boolean;
  19394. /**
  19395. * Defines the camera the input is attached to.
  19396. */
  19397. camera: FreeCamera;
  19398. /**
  19399. * Defines the buttons associated with the input to handle camera move.
  19400. */
  19401. buttons: number[];
  19402. /**
  19403. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19404. */
  19405. angularSensibility: number;
  19406. private _pointerInput;
  19407. private _onMouseMove;
  19408. private _observer;
  19409. private previousPosition;
  19410. /**
  19411. * Observable for when a pointer move event occurs containing the move offset
  19412. */
  19413. onPointerMovedObservable: Observable<{
  19414. offsetX: number;
  19415. offsetY: number;
  19416. }>;
  19417. /**
  19418. * @hidden
  19419. * If the camera should be rotated automatically based on pointer movement
  19420. */
  19421. _allowCameraRotation: boolean;
  19422. /**
  19423. * Manage the mouse inputs to control the movement of a free camera.
  19424. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19425. * @param touchEnabled Defines if touch is enabled or not
  19426. */
  19427. constructor(
  19428. /**
  19429. * Define if touch is enabled in the mouse input
  19430. */
  19431. touchEnabled?: boolean);
  19432. /**
  19433. * Attach the input controls to a specific dom element to get the input from.
  19434. * @param element Defines the element the controls should be listened from
  19435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19436. */
  19437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19438. /**
  19439. * Called on JS contextmenu event.
  19440. * Override this method to provide functionality.
  19441. */
  19442. protected onContextMenu(evt: PointerEvent): void;
  19443. /**
  19444. * Detach the current controls from the specified dom element.
  19445. * @param element Defines the element to stop listening the inputs from
  19446. */
  19447. detachControl(element: Nullable<HTMLElement>): void;
  19448. /**
  19449. * Gets the class name of the current intput.
  19450. * @returns the class name
  19451. */
  19452. getClassName(): string;
  19453. /**
  19454. * Get the friendly name associated with the input class.
  19455. * @returns the input friendly name
  19456. */
  19457. getSimpleName(): string;
  19458. }
  19459. }
  19460. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19461. import { Nullable } from "babylonjs/types";
  19462. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19463. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19464. /**
  19465. * Manage the touch inputs to control the movement of a free camera.
  19466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19467. */
  19468. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19469. /**
  19470. * Define if mouse events can be treated as touch events
  19471. */
  19472. allowMouse: boolean;
  19473. /**
  19474. * Defines the camera the input is attached to.
  19475. */
  19476. camera: FreeCamera;
  19477. /**
  19478. * Defines the touch sensibility for rotation.
  19479. * The higher the faster.
  19480. */
  19481. touchAngularSensibility: number;
  19482. /**
  19483. * Defines the touch sensibility for move.
  19484. * The higher the faster.
  19485. */
  19486. touchMoveSensibility: number;
  19487. private _offsetX;
  19488. private _offsetY;
  19489. private _pointerPressed;
  19490. private _pointerInput;
  19491. private _observer;
  19492. private _onLostFocus;
  19493. /**
  19494. * Manage the touch inputs to control the movement of a free camera.
  19495. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19496. * @param allowMouse Defines if mouse events can be treated as touch events
  19497. */
  19498. constructor(
  19499. /**
  19500. * Define if mouse events can be treated as touch events
  19501. */
  19502. allowMouse?: boolean);
  19503. /**
  19504. * Attach the input controls to a specific dom element to get the input from.
  19505. * @param element Defines the element the controls should be listened from
  19506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19507. */
  19508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19509. /**
  19510. * Detach the current controls from the specified dom element.
  19511. * @param element Defines the element to stop listening the inputs from
  19512. */
  19513. detachControl(element: Nullable<HTMLElement>): void;
  19514. /**
  19515. * Update the current camera state depending on the inputs that have been used this frame.
  19516. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19517. */
  19518. checkInputs(): void;
  19519. /**
  19520. * Gets the class name of the current intput.
  19521. * @returns the class name
  19522. */
  19523. getClassName(): string;
  19524. /**
  19525. * Get the friendly name associated with the input class.
  19526. * @returns the input friendly name
  19527. */
  19528. getSimpleName(): string;
  19529. }
  19530. }
  19531. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19533. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19534. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19535. import { Nullable } from "babylonjs/types";
  19536. /**
  19537. * Default Inputs manager for the FreeCamera.
  19538. * It groups all the default supported inputs for ease of use.
  19539. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19540. */
  19541. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19542. /**
  19543. * @hidden
  19544. */
  19545. _mouseInput: Nullable<FreeCameraMouseInput>;
  19546. /**
  19547. * Instantiates a new FreeCameraInputsManager.
  19548. * @param camera Defines the camera the inputs belong to
  19549. */
  19550. constructor(camera: FreeCamera);
  19551. /**
  19552. * Add keyboard input support to the input manager.
  19553. * @returns the current input manager
  19554. */
  19555. addKeyboard(): FreeCameraInputsManager;
  19556. /**
  19557. * Add mouse input support to the input manager.
  19558. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19559. * @returns the current input manager
  19560. */
  19561. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19562. /**
  19563. * Removes the mouse input support from the manager
  19564. * @returns the current input manager
  19565. */
  19566. removeMouse(): FreeCameraInputsManager;
  19567. /**
  19568. * Add touch input support to the input manager.
  19569. * @returns the current input manager
  19570. */
  19571. addTouch(): FreeCameraInputsManager;
  19572. /**
  19573. * Remove all attached input methods from a camera
  19574. */
  19575. clear(): void;
  19576. }
  19577. }
  19578. declare module "babylonjs/Cameras/freeCamera" {
  19579. import { Vector3 } from "babylonjs/Maths/math.vector";
  19580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19581. import { Scene } from "babylonjs/scene";
  19582. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19583. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19584. /**
  19585. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19586. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19587. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19588. */
  19589. export class FreeCamera extends TargetCamera {
  19590. /**
  19591. * Define the collision ellipsoid of the camera.
  19592. * This is helpful to simulate a camera body like the player body around the camera
  19593. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19594. */
  19595. ellipsoid: Vector3;
  19596. /**
  19597. * Define an offset for the position of the ellipsoid around the camera.
  19598. * This can be helpful to determine the center of the body near the gravity center of the body
  19599. * instead of its head.
  19600. */
  19601. ellipsoidOffset: Vector3;
  19602. /**
  19603. * Enable or disable collisions of the camera with the rest of the scene objects.
  19604. */
  19605. checkCollisions: boolean;
  19606. /**
  19607. * Enable or disable gravity on the camera.
  19608. */
  19609. applyGravity: boolean;
  19610. /**
  19611. * Define the input manager associated to the camera.
  19612. */
  19613. inputs: FreeCameraInputsManager;
  19614. /**
  19615. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19616. * Higher values reduce sensitivity.
  19617. */
  19618. get angularSensibility(): number;
  19619. /**
  19620. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19621. * Higher values reduce sensitivity.
  19622. */
  19623. set angularSensibility(value: number);
  19624. /**
  19625. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19626. */
  19627. get keysUp(): number[];
  19628. set keysUp(value: number[]);
  19629. /**
  19630. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19631. */
  19632. get keysUpward(): number[];
  19633. set keysUpward(value: number[]);
  19634. /**
  19635. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19636. */
  19637. get keysDown(): number[];
  19638. set keysDown(value: number[]);
  19639. /**
  19640. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19641. */
  19642. get keysDownward(): number[];
  19643. set keysDownward(value: number[]);
  19644. /**
  19645. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19646. */
  19647. get keysLeft(): number[];
  19648. set keysLeft(value: number[]);
  19649. /**
  19650. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19651. */
  19652. get keysRight(): number[];
  19653. set keysRight(value: number[]);
  19654. /**
  19655. * Event raised when the camera collide with a mesh in the scene.
  19656. */
  19657. onCollide: (collidedMesh: AbstractMesh) => void;
  19658. private _collider;
  19659. private _needMoveForGravity;
  19660. private _oldPosition;
  19661. private _diffPosition;
  19662. private _newPosition;
  19663. /** @hidden */
  19664. _localDirection: Vector3;
  19665. /** @hidden */
  19666. _transformedDirection: Vector3;
  19667. /**
  19668. * Instantiates a Free Camera.
  19669. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19670. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19671. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19672. * @param name Define the name of the camera in the scene
  19673. * @param position Define the start position of the camera in the scene
  19674. * @param scene Define the scene the camera belongs to
  19675. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19676. */
  19677. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19678. /**
  19679. * Attached controls to the current camera.
  19680. * @param element Defines the element the controls should be listened from
  19681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19682. */
  19683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19684. /**
  19685. * Detach the current controls from the camera.
  19686. * The camera will stop reacting to inputs.
  19687. * @param element Defines the element to stop listening the inputs from
  19688. */
  19689. detachControl(element: HTMLElement): void;
  19690. private _collisionMask;
  19691. /**
  19692. * Define a collision mask to limit the list of object the camera can collide with
  19693. */
  19694. get collisionMask(): number;
  19695. set collisionMask(mask: number);
  19696. /** @hidden */
  19697. _collideWithWorld(displacement: Vector3): void;
  19698. private _onCollisionPositionChange;
  19699. /** @hidden */
  19700. _checkInputs(): void;
  19701. /** @hidden */
  19702. _decideIfNeedsToMove(): boolean;
  19703. /** @hidden */
  19704. _updatePosition(): void;
  19705. /**
  19706. * Destroy the camera and release the current resources hold by it.
  19707. */
  19708. dispose(): void;
  19709. /**
  19710. * Gets the current object class name.
  19711. * @return the class name
  19712. */
  19713. getClassName(): string;
  19714. }
  19715. }
  19716. declare module "babylonjs/Gamepads/gamepad" {
  19717. import { Observable } from "babylonjs/Misc/observable";
  19718. /**
  19719. * Represents a gamepad control stick position
  19720. */
  19721. export class StickValues {
  19722. /**
  19723. * The x component of the control stick
  19724. */
  19725. x: number;
  19726. /**
  19727. * The y component of the control stick
  19728. */
  19729. y: number;
  19730. /**
  19731. * Initializes the gamepad x and y control stick values
  19732. * @param x The x component of the gamepad control stick value
  19733. * @param y The y component of the gamepad control stick value
  19734. */
  19735. constructor(
  19736. /**
  19737. * The x component of the control stick
  19738. */
  19739. x: number,
  19740. /**
  19741. * The y component of the control stick
  19742. */
  19743. y: number);
  19744. }
  19745. /**
  19746. * An interface which manages callbacks for gamepad button changes
  19747. */
  19748. export interface GamepadButtonChanges {
  19749. /**
  19750. * Called when a gamepad has been changed
  19751. */
  19752. changed: boolean;
  19753. /**
  19754. * Called when a gamepad press event has been triggered
  19755. */
  19756. pressChanged: boolean;
  19757. /**
  19758. * Called when a touch event has been triggered
  19759. */
  19760. touchChanged: boolean;
  19761. /**
  19762. * Called when a value has changed
  19763. */
  19764. valueChanged: boolean;
  19765. }
  19766. /**
  19767. * Represents a gamepad
  19768. */
  19769. export class Gamepad {
  19770. /**
  19771. * The id of the gamepad
  19772. */
  19773. id: string;
  19774. /**
  19775. * The index of the gamepad
  19776. */
  19777. index: number;
  19778. /**
  19779. * The browser gamepad
  19780. */
  19781. browserGamepad: any;
  19782. /**
  19783. * Specifies what type of gamepad this represents
  19784. */
  19785. type: number;
  19786. private _leftStick;
  19787. private _rightStick;
  19788. /** @hidden */
  19789. _isConnected: boolean;
  19790. private _leftStickAxisX;
  19791. private _leftStickAxisY;
  19792. private _rightStickAxisX;
  19793. private _rightStickAxisY;
  19794. /**
  19795. * Triggered when the left control stick has been changed
  19796. */
  19797. private _onleftstickchanged;
  19798. /**
  19799. * Triggered when the right control stick has been changed
  19800. */
  19801. private _onrightstickchanged;
  19802. /**
  19803. * Represents a gamepad controller
  19804. */
  19805. static GAMEPAD: number;
  19806. /**
  19807. * Represents a generic controller
  19808. */
  19809. static GENERIC: number;
  19810. /**
  19811. * Represents an XBox controller
  19812. */
  19813. static XBOX: number;
  19814. /**
  19815. * Represents a pose-enabled controller
  19816. */
  19817. static POSE_ENABLED: number;
  19818. /**
  19819. * Represents an Dual Shock controller
  19820. */
  19821. static DUALSHOCK: number;
  19822. /**
  19823. * Specifies whether the left control stick should be Y-inverted
  19824. */
  19825. protected _invertLeftStickY: boolean;
  19826. /**
  19827. * Specifies if the gamepad has been connected
  19828. */
  19829. get isConnected(): boolean;
  19830. /**
  19831. * Initializes the gamepad
  19832. * @param id The id of the gamepad
  19833. * @param index The index of the gamepad
  19834. * @param browserGamepad The browser gamepad
  19835. * @param leftStickX The x component of the left joystick
  19836. * @param leftStickY The y component of the left joystick
  19837. * @param rightStickX The x component of the right joystick
  19838. * @param rightStickY The y component of the right joystick
  19839. */
  19840. constructor(
  19841. /**
  19842. * The id of the gamepad
  19843. */
  19844. id: string,
  19845. /**
  19846. * The index of the gamepad
  19847. */
  19848. index: number,
  19849. /**
  19850. * The browser gamepad
  19851. */
  19852. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19853. /**
  19854. * Callback triggered when the left joystick has changed
  19855. * @param callback
  19856. */
  19857. onleftstickchanged(callback: (values: StickValues) => void): void;
  19858. /**
  19859. * Callback triggered when the right joystick has changed
  19860. * @param callback
  19861. */
  19862. onrightstickchanged(callback: (values: StickValues) => void): void;
  19863. /**
  19864. * Gets the left joystick
  19865. */
  19866. get leftStick(): StickValues;
  19867. /**
  19868. * Sets the left joystick values
  19869. */
  19870. set leftStick(newValues: StickValues);
  19871. /**
  19872. * Gets the right joystick
  19873. */
  19874. get rightStick(): StickValues;
  19875. /**
  19876. * Sets the right joystick value
  19877. */
  19878. set rightStick(newValues: StickValues);
  19879. /**
  19880. * Updates the gamepad joystick positions
  19881. */
  19882. update(): void;
  19883. /**
  19884. * Disposes the gamepad
  19885. */
  19886. dispose(): void;
  19887. }
  19888. /**
  19889. * Represents a generic gamepad
  19890. */
  19891. export class GenericPad extends Gamepad {
  19892. private _buttons;
  19893. private _onbuttondown;
  19894. private _onbuttonup;
  19895. /**
  19896. * Observable triggered when a button has been pressed
  19897. */
  19898. onButtonDownObservable: Observable<number>;
  19899. /**
  19900. * Observable triggered when a button has been released
  19901. */
  19902. onButtonUpObservable: Observable<number>;
  19903. /**
  19904. * Callback triggered when a button has been pressed
  19905. * @param callback Called when a button has been pressed
  19906. */
  19907. onbuttondown(callback: (buttonPressed: number) => void): void;
  19908. /**
  19909. * Callback triggered when a button has been released
  19910. * @param callback Called when a button has been released
  19911. */
  19912. onbuttonup(callback: (buttonReleased: number) => void): void;
  19913. /**
  19914. * Initializes the generic gamepad
  19915. * @param id The id of the generic gamepad
  19916. * @param index The index of the generic gamepad
  19917. * @param browserGamepad The browser gamepad
  19918. */
  19919. constructor(id: string, index: number, browserGamepad: any);
  19920. private _setButtonValue;
  19921. /**
  19922. * Updates the generic gamepad
  19923. */
  19924. update(): void;
  19925. /**
  19926. * Disposes the generic gamepad
  19927. */
  19928. dispose(): void;
  19929. }
  19930. }
  19931. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19932. import { Observable } from "babylonjs/Misc/observable";
  19933. import { Nullable } from "babylonjs/types";
  19934. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19935. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19937. import { Ray } from "babylonjs/Culling/ray";
  19938. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19939. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19940. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19941. /**
  19942. * Defines the types of pose enabled controllers that are supported
  19943. */
  19944. export enum PoseEnabledControllerType {
  19945. /**
  19946. * HTC Vive
  19947. */
  19948. VIVE = 0,
  19949. /**
  19950. * Oculus Rift
  19951. */
  19952. OCULUS = 1,
  19953. /**
  19954. * Windows mixed reality
  19955. */
  19956. WINDOWS = 2,
  19957. /**
  19958. * Samsung gear VR
  19959. */
  19960. GEAR_VR = 3,
  19961. /**
  19962. * Google Daydream
  19963. */
  19964. DAYDREAM = 4,
  19965. /**
  19966. * Generic
  19967. */
  19968. GENERIC = 5
  19969. }
  19970. /**
  19971. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19972. */
  19973. export interface MutableGamepadButton {
  19974. /**
  19975. * Value of the button/trigger
  19976. */
  19977. value: number;
  19978. /**
  19979. * If the button/trigger is currently touched
  19980. */
  19981. touched: boolean;
  19982. /**
  19983. * If the button/trigger is currently pressed
  19984. */
  19985. pressed: boolean;
  19986. }
  19987. /**
  19988. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19989. * @hidden
  19990. */
  19991. export interface ExtendedGamepadButton extends GamepadButton {
  19992. /**
  19993. * If the button/trigger is currently pressed
  19994. */
  19995. readonly pressed: boolean;
  19996. /**
  19997. * If the button/trigger is currently touched
  19998. */
  19999. readonly touched: boolean;
  20000. /**
  20001. * Value of the button/trigger
  20002. */
  20003. readonly value: number;
  20004. }
  20005. /** @hidden */
  20006. export interface _GamePadFactory {
  20007. /**
  20008. * Returns whether or not the current gamepad can be created for this type of controller.
  20009. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20010. * @returns true if it can be created, otherwise false
  20011. */
  20012. canCreate(gamepadInfo: any): boolean;
  20013. /**
  20014. * Creates a new instance of the Gamepad.
  20015. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20016. * @returns the new gamepad instance
  20017. */
  20018. create(gamepadInfo: any): Gamepad;
  20019. }
  20020. /**
  20021. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20022. */
  20023. export class PoseEnabledControllerHelper {
  20024. /** @hidden */
  20025. static _ControllerFactories: _GamePadFactory[];
  20026. /** @hidden */
  20027. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20028. /**
  20029. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20030. * @param vrGamepad the gamepad to initialized
  20031. * @returns a vr controller of the type the gamepad identified as
  20032. */
  20033. static InitiateController(vrGamepad: any): Gamepad;
  20034. }
  20035. /**
  20036. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20037. */
  20038. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20039. /**
  20040. * If the controller is used in a webXR session
  20041. */
  20042. isXR: boolean;
  20043. private _deviceRoomPosition;
  20044. private _deviceRoomRotationQuaternion;
  20045. /**
  20046. * The device position in babylon space
  20047. */
  20048. devicePosition: Vector3;
  20049. /**
  20050. * The device rotation in babylon space
  20051. */
  20052. deviceRotationQuaternion: Quaternion;
  20053. /**
  20054. * The scale factor of the device in babylon space
  20055. */
  20056. deviceScaleFactor: number;
  20057. /**
  20058. * (Likely devicePosition should be used instead) The device position in its room space
  20059. */
  20060. position: Vector3;
  20061. /**
  20062. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20063. */
  20064. rotationQuaternion: Quaternion;
  20065. /**
  20066. * The type of controller (Eg. Windows mixed reality)
  20067. */
  20068. controllerType: PoseEnabledControllerType;
  20069. protected _calculatedPosition: Vector3;
  20070. private _calculatedRotation;
  20071. /**
  20072. * The raw pose from the device
  20073. */
  20074. rawPose: DevicePose;
  20075. private _trackPosition;
  20076. private _maxRotationDistFromHeadset;
  20077. private _draggedRoomRotation;
  20078. /**
  20079. * @hidden
  20080. */
  20081. _disableTrackPosition(fixedPosition: Vector3): void;
  20082. /**
  20083. * Internal, the mesh attached to the controller
  20084. * @hidden
  20085. */
  20086. _mesh: Nullable<AbstractMesh>;
  20087. private _poseControlledCamera;
  20088. private _leftHandSystemQuaternion;
  20089. /**
  20090. * Internal, matrix used to convert room space to babylon space
  20091. * @hidden
  20092. */
  20093. _deviceToWorld: Matrix;
  20094. /**
  20095. * Node to be used when casting a ray from the controller
  20096. * @hidden
  20097. */
  20098. _pointingPoseNode: Nullable<TransformNode>;
  20099. /**
  20100. * Name of the child mesh that can be used to cast a ray from the controller
  20101. */
  20102. static readonly POINTING_POSE: string;
  20103. /**
  20104. * Creates a new PoseEnabledController from a gamepad
  20105. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20106. */
  20107. constructor(browserGamepad: any);
  20108. private _workingMatrix;
  20109. /**
  20110. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20111. */
  20112. update(): void;
  20113. /**
  20114. * Updates only the pose device and mesh without doing any button event checking
  20115. */
  20116. protected _updatePoseAndMesh(): void;
  20117. /**
  20118. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20119. * @param poseData raw pose fromthe device
  20120. */
  20121. updateFromDevice(poseData: DevicePose): void;
  20122. /**
  20123. * @hidden
  20124. */
  20125. _meshAttachedObservable: Observable<AbstractMesh>;
  20126. /**
  20127. * Attaches a mesh to the controller
  20128. * @param mesh the mesh to be attached
  20129. */
  20130. attachToMesh(mesh: AbstractMesh): void;
  20131. /**
  20132. * Attaches the controllers mesh to a camera
  20133. * @param camera the camera the mesh should be attached to
  20134. */
  20135. attachToPoseControlledCamera(camera: TargetCamera): void;
  20136. /**
  20137. * Disposes of the controller
  20138. */
  20139. dispose(): void;
  20140. /**
  20141. * The mesh that is attached to the controller
  20142. */
  20143. get mesh(): Nullable<AbstractMesh>;
  20144. /**
  20145. * Gets the ray of the controller in the direction the controller is pointing
  20146. * @param length the length the resulting ray should be
  20147. * @returns a ray in the direction the controller is pointing
  20148. */
  20149. getForwardRay(length?: number): Ray;
  20150. }
  20151. }
  20152. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20153. import { Observable } from "babylonjs/Misc/observable";
  20154. import { Scene } from "babylonjs/scene";
  20155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20156. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20157. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20158. import { Nullable } from "babylonjs/types";
  20159. /**
  20160. * Defines the WebVRController object that represents controllers tracked in 3D space
  20161. */
  20162. export abstract class WebVRController extends PoseEnabledController {
  20163. /**
  20164. * Internal, the default controller model for the controller
  20165. */
  20166. protected _defaultModel: Nullable<AbstractMesh>;
  20167. /**
  20168. * Fired when the trigger state has changed
  20169. */
  20170. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20171. /**
  20172. * Fired when the main button state has changed
  20173. */
  20174. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20175. /**
  20176. * Fired when the secondary button state has changed
  20177. */
  20178. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20179. /**
  20180. * Fired when the pad state has changed
  20181. */
  20182. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20183. /**
  20184. * Fired when controllers stick values have changed
  20185. */
  20186. onPadValuesChangedObservable: Observable<StickValues>;
  20187. /**
  20188. * Array of button availible on the controller
  20189. */
  20190. protected _buttons: Array<MutableGamepadButton>;
  20191. private _onButtonStateChange;
  20192. /**
  20193. * Fired when a controller button's state has changed
  20194. * @param callback the callback containing the button that was modified
  20195. */
  20196. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20197. /**
  20198. * X and Y axis corresponding to the controllers joystick
  20199. */
  20200. pad: StickValues;
  20201. /**
  20202. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20203. */
  20204. hand: string;
  20205. /**
  20206. * The default controller model for the controller
  20207. */
  20208. get defaultModel(): Nullable<AbstractMesh>;
  20209. /**
  20210. * Creates a new WebVRController from a gamepad
  20211. * @param vrGamepad the gamepad that the WebVRController should be created from
  20212. */
  20213. constructor(vrGamepad: any);
  20214. /**
  20215. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20216. */
  20217. update(): void;
  20218. /**
  20219. * Function to be called when a button is modified
  20220. */
  20221. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20222. /**
  20223. * Loads a mesh and attaches it to the controller
  20224. * @param scene the scene the mesh should be added to
  20225. * @param meshLoaded callback for when the mesh has been loaded
  20226. */
  20227. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20228. private _setButtonValue;
  20229. private _changes;
  20230. private _checkChanges;
  20231. /**
  20232. * Disposes of th webVRCOntroller
  20233. */
  20234. dispose(): void;
  20235. }
  20236. }
  20237. declare module "babylonjs/Lights/hemisphericLight" {
  20238. import { Nullable } from "babylonjs/types";
  20239. import { Scene } from "babylonjs/scene";
  20240. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20241. import { Color3 } from "babylonjs/Maths/math.color";
  20242. import { Effect } from "babylonjs/Materials/effect";
  20243. import { Light } from "babylonjs/Lights/light";
  20244. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20245. /**
  20246. * The HemisphericLight simulates the ambient environment light,
  20247. * so the passed direction is the light reflection direction, not the incoming direction.
  20248. */
  20249. export class HemisphericLight extends Light {
  20250. /**
  20251. * The groundColor is the light in the opposite direction to the one specified during creation.
  20252. * 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.
  20253. */
  20254. groundColor: Color3;
  20255. /**
  20256. * The light reflection direction, not the incoming direction.
  20257. */
  20258. direction: Vector3;
  20259. /**
  20260. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20261. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20262. * The HemisphericLight can't cast shadows.
  20263. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20264. * @param name The friendly name of the light
  20265. * @param direction The direction of the light reflection
  20266. * @param scene The scene the light belongs to
  20267. */
  20268. constructor(name: string, direction: Vector3, scene: Scene);
  20269. protected _buildUniformLayout(): void;
  20270. /**
  20271. * Returns the string "HemisphericLight".
  20272. * @return The class name
  20273. */
  20274. getClassName(): string;
  20275. /**
  20276. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20277. * Returns the updated direction.
  20278. * @param target The target the direction should point to
  20279. * @return The computed direction
  20280. */
  20281. setDirectionToTarget(target: Vector3): Vector3;
  20282. /**
  20283. * Returns the shadow generator associated to the light.
  20284. * @returns Always null for hemispheric lights because it does not support shadows.
  20285. */
  20286. getShadowGenerator(): Nullable<IShadowGenerator>;
  20287. /**
  20288. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20289. * @param effect The effect to update
  20290. * @param lightIndex The index of the light in the effect to update
  20291. * @returns The hemispheric light
  20292. */
  20293. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20294. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20295. /**
  20296. * Computes the world matrix of the node
  20297. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20298. * @param useWasUpdatedFlag defines a reserved property
  20299. * @returns the world matrix
  20300. */
  20301. computeWorldMatrix(): Matrix;
  20302. /**
  20303. * Returns the integer 3.
  20304. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20305. */
  20306. getTypeID(): number;
  20307. /**
  20308. * Prepares the list of defines specific to the light type.
  20309. * @param defines the list of defines
  20310. * @param lightIndex defines the index of the light for the effect
  20311. */
  20312. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20313. }
  20314. }
  20315. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20316. /** @hidden */
  20317. export var vrMultiviewToSingleviewPixelShader: {
  20318. name: string;
  20319. shader: string;
  20320. };
  20321. }
  20322. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20323. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20324. import { Scene } from "babylonjs/scene";
  20325. /**
  20326. * Renders to multiple views with a single draw call
  20327. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20328. */
  20329. export class MultiviewRenderTarget extends RenderTargetTexture {
  20330. /**
  20331. * Creates a multiview render target
  20332. * @param scene scene used with the render target
  20333. * @param size the size of the render target (used for each view)
  20334. */
  20335. constructor(scene: Scene, size?: number | {
  20336. width: number;
  20337. height: number;
  20338. } | {
  20339. ratio: number;
  20340. });
  20341. /**
  20342. * @hidden
  20343. * @param faceIndex the face index, if its a cube texture
  20344. */
  20345. _bindFrameBuffer(faceIndex?: number): void;
  20346. /**
  20347. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20348. * @returns the view count
  20349. */
  20350. getViewCount(): number;
  20351. }
  20352. }
  20353. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20354. import { Camera } from "babylonjs/Cameras/camera";
  20355. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20356. import { Nullable } from "babylonjs/types";
  20357. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20358. import { Matrix } from "babylonjs/Maths/math.vector";
  20359. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20360. module "babylonjs/Engines/engine" {
  20361. interface Engine {
  20362. /**
  20363. * Creates a new multiview render target
  20364. * @param width defines the width of the texture
  20365. * @param height defines the height of the texture
  20366. * @returns the created multiview texture
  20367. */
  20368. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20369. /**
  20370. * Binds a multiview framebuffer to be drawn to
  20371. * @param multiviewTexture texture to bind
  20372. */
  20373. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20374. }
  20375. }
  20376. module "babylonjs/Cameras/camera" {
  20377. interface Camera {
  20378. /**
  20379. * @hidden
  20380. * 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)
  20381. */
  20382. _useMultiviewToSingleView: boolean;
  20383. /**
  20384. * @hidden
  20385. * 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)
  20386. */
  20387. _multiviewTexture: Nullable<RenderTargetTexture>;
  20388. /**
  20389. * @hidden
  20390. * ensures the multiview texture of the camera exists and has the specified width/height
  20391. * @param width height to set on the multiview texture
  20392. * @param height width to set on the multiview texture
  20393. */
  20394. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20395. }
  20396. }
  20397. module "babylonjs/scene" {
  20398. interface Scene {
  20399. /** @hidden */
  20400. _transformMatrixR: Matrix;
  20401. /** @hidden */
  20402. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20403. /** @hidden */
  20404. _createMultiviewUbo(): void;
  20405. /** @hidden */
  20406. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20407. /** @hidden */
  20408. _renderMultiviewToSingleView(camera: Camera): void;
  20409. }
  20410. }
  20411. }
  20412. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20413. import { Camera } from "babylonjs/Cameras/camera";
  20414. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20415. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20416. import "babylonjs/Engines/Extensions/engine.multiview";
  20417. /**
  20418. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20419. * This will not be used for webXR as it supports displaying texture arrays directly
  20420. */
  20421. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20422. /**
  20423. * Gets a string identifying the name of the class
  20424. * @returns "VRMultiviewToSingleviewPostProcess" string
  20425. */
  20426. getClassName(): string;
  20427. /**
  20428. * Initializes a VRMultiviewToSingleview
  20429. * @param name name of the post process
  20430. * @param camera camera to be applied to
  20431. * @param scaleFactor scaling factor to the size of the output texture
  20432. */
  20433. constructor(name: string, camera: Camera, scaleFactor: number);
  20434. }
  20435. }
  20436. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20437. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20438. import { Nullable } from "babylonjs/types";
  20439. import { Size } from "babylonjs/Maths/math.size";
  20440. import { Observable } from "babylonjs/Misc/observable";
  20441. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20442. /**
  20443. * Interface used to define additional presentation attributes
  20444. */
  20445. export interface IVRPresentationAttributes {
  20446. /**
  20447. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20448. */
  20449. highRefreshRate: boolean;
  20450. /**
  20451. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20452. */
  20453. foveationLevel: number;
  20454. }
  20455. module "babylonjs/Engines/engine" {
  20456. interface Engine {
  20457. /** @hidden */
  20458. _vrDisplay: any;
  20459. /** @hidden */
  20460. _vrSupported: boolean;
  20461. /** @hidden */
  20462. _oldSize: Size;
  20463. /** @hidden */
  20464. _oldHardwareScaleFactor: number;
  20465. /** @hidden */
  20466. _vrExclusivePointerMode: boolean;
  20467. /** @hidden */
  20468. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20469. /** @hidden */
  20470. _onVRDisplayPointerRestricted: () => void;
  20471. /** @hidden */
  20472. _onVRDisplayPointerUnrestricted: () => void;
  20473. /** @hidden */
  20474. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20475. /** @hidden */
  20476. _onVrDisplayDisconnect: Nullable<() => void>;
  20477. /** @hidden */
  20478. _onVrDisplayPresentChange: Nullable<() => void>;
  20479. /**
  20480. * Observable signaled when VR display mode changes
  20481. */
  20482. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20483. /**
  20484. * Observable signaled when VR request present is complete
  20485. */
  20486. onVRRequestPresentComplete: Observable<boolean>;
  20487. /**
  20488. * Observable signaled when VR request present starts
  20489. */
  20490. onVRRequestPresentStart: Observable<Engine>;
  20491. /**
  20492. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20493. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20494. */
  20495. isInVRExclusivePointerMode: boolean;
  20496. /**
  20497. * Gets a boolean indicating if a webVR device was detected
  20498. * @returns true if a webVR device was detected
  20499. */
  20500. isVRDevicePresent(): boolean;
  20501. /**
  20502. * Gets the current webVR device
  20503. * @returns the current webVR device (or null)
  20504. */
  20505. getVRDevice(): any;
  20506. /**
  20507. * Initializes a webVR display and starts listening to display change events
  20508. * The onVRDisplayChangedObservable will be notified upon these changes
  20509. * @returns A promise containing a VRDisplay and if vr is supported
  20510. */
  20511. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20512. /** @hidden */
  20513. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20514. /**
  20515. * Gets or sets the presentation attributes used to configure VR rendering
  20516. */
  20517. vrPresentationAttributes?: IVRPresentationAttributes;
  20518. /**
  20519. * Call this function to switch to webVR mode
  20520. * Will do nothing if webVR is not supported or if there is no webVR device
  20521. * @param options the webvr options provided to the camera. mainly used for multiview
  20522. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20523. */
  20524. enableVR(options: WebVROptions): void;
  20525. /** @hidden */
  20526. _onVRFullScreenTriggered(): void;
  20527. }
  20528. }
  20529. }
  20530. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20531. import { Nullable } from "babylonjs/types";
  20532. import { Observable } from "babylonjs/Misc/observable";
  20533. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20534. import { Scene } from "babylonjs/scene";
  20535. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20536. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20537. import { Node } from "babylonjs/node";
  20538. import { Ray } from "babylonjs/Culling/ray";
  20539. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20540. import "babylonjs/Engines/Extensions/engine.webVR";
  20541. /**
  20542. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20543. * IMPORTANT!! The data is right-hand data.
  20544. * @export
  20545. * @interface DevicePose
  20546. */
  20547. export interface DevicePose {
  20548. /**
  20549. * The position of the device, values in array are [x,y,z].
  20550. */
  20551. readonly position: Nullable<Float32Array>;
  20552. /**
  20553. * The linearVelocity of the device, values in array are [x,y,z].
  20554. */
  20555. readonly linearVelocity: Nullable<Float32Array>;
  20556. /**
  20557. * The linearAcceleration of the device, values in array are [x,y,z].
  20558. */
  20559. readonly linearAcceleration: Nullable<Float32Array>;
  20560. /**
  20561. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20562. */
  20563. readonly orientation: Nullable<Float32Array>;
  20564. /**
  20565. * The angularVelocity of the device, values in array are [x,y,z].
  20566. */
  20567. readonly angularVelocity: Nullable<Float32Array>;
  20568. /**
  20569. * The angularAcceleration of the device, values in array are [x,y,z].
  20570. */
  20571. readonly angularAcceleration: Nullable<Float32Array>;
  20572. }
  20573. /**
  20574. * Interface representing a pose controlled object in Babylon.
  20575. * A pose controlled object has both regular pose values as well as pose values
  20576. * from an external device such as a VR head mounted display
  20577. */
  20578. export interface PoseControlled {
  20579. /**
  20580. * The position of the object in babylon space.
  20581. */
  20582. position: Vector3;
  20583. /**
  20584. * The rotation quaternion of the object in babylon space.
  20585. */
  20586. rotationQuaternion: Quaternion;
  20587. /**
  20588. * The position of the device in babylon space.
  20589. */
  20590. devicePosition?: Vector3;
  20591. /**
  20592. * The rotation quaternion of the device in babylon space.
  20593. */
  20594. deviceRotationQuaternion: Quaternion;
  20595. /**
  20596. * The raw pose coming from the device.
  20597. */
  20598. rawPose: Nullable<DevicePose>;
  20599. /**
  20600. * The scale of the device to be used when translating from device space to babylon space.
  20601. */
  20602. deviceScaleFactor: number;
  20603. /**
  20604. * Updates the poseControlled values based on the input device pose.
  20605. * @param poseData the pose data to update the object with
  20606. */
  20607. updateFromDevice(poseData: DevicePose): void;
  20608. }
  20609. /**
  20610. * Set of options to customize the webVRCamera
  20611. */
  20612. export interface WebVROptions {
  20613. /**
  20614. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20615. */
  20616. trackPosition?: boolean;
  20617. /**
  20618. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20619. */
  20620. positionScale?: number;
  20621. /**
  20622. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20623. */
  20624. displayName?: string;
  20625. /**
  20626. * Should the native controller meshes be initialized. (default: true)
  20627. */
  20628. controllerMeshes?: boolean;
  20629. /**
  20630. * Creating a default HemiLight only on controllers. (default: true)
  20631. */
  20632. defaultLightingOnControllers?: boolean;
  20633. /**
  20634. * If you don't want to use the default VR button of the helper. (default: false)
  20635. */
  20636. useCustomVRButton?: boolean;
  20637. /**
  20638. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20639. */
  20640. customVRButton?: HTMLButtonElement;
  20641. /**
  20642. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20643. */
  20644. rayLength?: number;
  20645. /**
  20646. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20647. */
  20648. defaultHeight?: number;
  20649. /**
  20650. * If multiview should be used if availible (default: false)
  20651. */
  20652. useMultiview?: boolean;
  20653. }
  20654. /**
  20655. * This represents a WebVR camera.
  20656. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20657. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20658. */
  20659. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20660. private webVROptions;
  20661. /**
  20662. * @hidden
  20663. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20664. */
  20665. _vrDevice: any;
  20666. /**
  20667. * The rawPose of the vrDevice.
  20668. */
  20669. rawPose: Nullable<DevicePose>;
  20670. private _onVREnabled;
  20671. private _specsVersion;
  20672. private _attached;
  20673. private _frameData;
  20674. protected _descendants: Array<Node>;
  20675. private _deviceRoomPosition;
  20676. /** @hidden */
  20677. _deviceRoomRotationQuaternion: Quaternion;
  20678. private _standingMatrix;
  20679. /**
  20680. * Represents device position in babylon space.
  20681. */
  20682. devicePosition: Vector3;
  20683. /**
  20684. * Represents device rotation in babylon space.
  20685. */
  20686. deviceRotationQuaternion: Quaternion;
  20687. /**
  20688. * The scale of the device to be used when translating from device space to babylon space.
  20689. */
  20690. deviceScaleFactor: number;
  20691. private _deviceToWorld;
  20692. private _worldToDevice;
  20693. /**
  20694. * References to the webVR controllers for the vrDevice.
  20695. */
  20696. controllers: Array<WebVRController>;
  20697. /**
  20698. * Emits an event when a controller is attached.
  20699. */
  20700. onControllersAttachedObservable: Observable<WebVRController[]>;
  20701. /**
  20702. * Emits an event when a controller's mesh has been loaded;
  20703. */
  20704. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20705. /**
  20706. * Emits an event when the HMD's pose has been updated.
  20707. */
  20708. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20709. private _poseSet;
  20710. /**
  20711. * If the rig cameras be used as parent instead of this camera.
  20712. */
  20713. rigParenting: boolean;
  20714. private _lightOnControllers;
  20715. private _defaultHeight?;
  20716. /**
  20717. * Instantiates a WebVRFreeCamera.
  20718. * @param name The name of the WebVRFreeCamera
  20719. * @param position The starting anchor position for the camera
  20720. * @param scene The scene the camera belongs to
  20721. * @param webVROptions a set of customizable options for the webVRCamera
  20722. */
  20723. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20724. /**
  20725. * Gets the device distance from the ground in meters.
  20726. * @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.
  20727. */
  20728. deviceDistanceToRoomGround(): number;
  20729. /**
  20730. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20731. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20732. */
  20733. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20734. /**
  20735. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20736. * @returns A promise with a boolean set to if the standing matrix is supported.
  20737. */
  20738. useStandingMatrixAsync(): Promise<boolean>;
  20739. /**
  20740. * Disposes the camera
  20741. */
  20742. dispose(): void;
  20743. /**
  20744. * Gets a vrController by name.
  20745. * @param name The name of the controller to retreive
  20746. * @returns the controller matching the name specified or null if not found
  20747. */
  20748. getControllerByName(name: string): Nullable<WebVRController>;
  20749. private _leftController;
  20750. /**
  20751. * The controller corresponding to the users left hand.
  20752. */
  20753. get leftController(): Nullable<WebVRController>;
  20754. private _rightController;
  20755. /**
  20756. * The controller corresponding to the users right hand.
  20757. */
  20758. get rightController(): Nullable<WebVRController>;
  20759. /**
  20760. * Casts a ray forward from the vrCamera's gaze.
  20761. * @param length Length of the ray (default: 100)
  20762. * @returns the ray corresponding to the gaze
  20763. */
  20764. getForwardRay(length?: number): Ray;
  20765. /**
  20766. * @hidden
  20767. * Updates the camera based on device's frame data
  20768. */
  20769. _checkInputs(): void;
  20770. /**
  20771. * Updates the poseControlled values based on the input device pose.
  20772. * @param poseData Pose coming from the device
  20773. */
  20774. updateFromDevice(poseData: DevicePose): void;
  20775. private _htmlElementAttached;
  20776. private _detachIfAttached;
  20777. /**
  20778. * WebVR's attach control will start broadcasting frames to the device.
  20779. * Note that in certain browsers (chrome for example) this function must be called
  20780. * within a user-interaction callback. Example:
  20781. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20782. *
  20783. * @param element html element to attach the vrDevice to
  20784. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20785. */
  20786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20787. /**
  20788. * Detaches the camera from the html element and disables VR
  20789. *
  20790. * @param element html element to detach from
  20791. */
  20792. detachControl(element: HTMLElement): void;
  20793. /**
  20794. * @returns the name of this class
  20795. */
  20796. getClassName(): string;
  20797. /**
  20798. * Calls resetPose on the vrDisplay
  20799. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20800. */
  20801. resetToCurrentRotation(): void;
  20802. /**
  20803. * @hidden
  20804. * Updates the rig cameras (left and right eye)
  20805. */
  20806. _updateRigCameras(): void;
  20807. private _workingVector;
  20808. private _oneVector;
  20809. private _workingMatrix;
  20810. private updateCacheCalled;
  20811. private _correctPositionIfNotTrackPosition;
  20812. /**
  20813. * @hidden
  20814. * Updates the cached values of the camera
  20815. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20816. */
  20817. _updateCache(ignoreParentClass?: boolean): void;
  20818. /**
  20819. * @hidden
  20820. * Get current device position in babylon world
  20821. */
  20822. _computeDevicePosition(): void;
  20823. /**
  20824. * Updates the current device position and rotation in the babylon world
  20825. */
  20826. update(): void;
  20827. /**
  20828. * @hidden
  20829. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20830. * @returns an identity matrix
  20831. */
  20832. _getViewMatrix(): Matrix;
  20833. private _tmpMatrix;
  20834. /**
  20835. * This function is called by the two RIG cameras.
  20836. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20837. * @hidden
  20838. */
  20839. _getWebVRViewMatrix(): Matrix;
  20840. /** @hidden */
  20841. _getWebVRProjectionMatrix(): Matrix;
  20842. private _onGamepadConnectedObserver;
  20843. private _onGamepadDisconnectedObserver;
  20844. private _updateCacheWhenTrackingDisabledObserver;
  20845. /**
  20846. * Initializes the controllers and their meshes
  20847. */
  20848. initControllers(): void;
  20849. }
  20850. }
  20851. declare module "babylonjs/Materials/materialHelper" {
  20852. import { Nullable } from "babylonjs/types";
  20853. import { Scene } from "babylonjs/scene";
  20854. import { Engine } from "babylonjs/Engines/engine";
  20855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20856. import { Light } from "babylonjs/Lights/light";
  20857. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20858. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20860. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20861. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20862. /**
  20863. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20864. *
  20865. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20866. *
  20867. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20868. */
  20869. export class MaterialHelper {
  20870. /**
  20871. * Bind the current view position to an effect.
  20872. * @param effect The effect to be bound
  20873. * @param scene The scene the eyes position is used from
  20874. * @param variableName name of the shader variable that will hold the eye position
  20875. */
  20876. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20877. /**
  20878. * Helps preparing the defines values about the UVs in used in the effect.
  20879. * UVs are shared as much as we can accross channels in the shaders.
  20880. * @param texture The texture we are preparing the UVs for
  20881. * @param defines The defines to update
  20882. * @param key The channel key "diffuse", "specular"... used in the shader
  20883. */
  20884. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20885. /**
  20886. * Binds a texture matrix value to its corrsponding uniform
  20887. * @param texture The texture to bind the matrix for
  20888. * @param uniformBuffer The uniform buffer receivin the data
  20889. * @param key The channel key "diffuse", "specular"... used in the shader
  20890. */
  20891. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20892. /**
  20893. * Gets the current status of the fog (should it be enabled?)
  20894. * @param mesh defines the mesh to evaluate for fog support
  20895. * @param scene defines the hosting scene
  20896. * @returns true if fog must be enabled
  20897. */
  20898. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20899. /**
  20900. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20901. * @param mesh defines the current mesh
  20902. * @param scene defines the current scene
  20903. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20904. * @param pointsCloud defines if point cloud rendering has to be turned on
  20905. * @param fogEnabled defines if fog has to be turned on
  20906. * @param alphaTest defines if alpha testing has to be turned on
  20907. * @param defines defines the current list of defines
  20908. */
  20909. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20910. /**
  20911. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20912. * @param scene defines the current scene
  20913. * @param engine defines the current engine
  20914. * @param defines specifies the list of active defines
  20915. * @param useInstances defines if instances have to be turned on
  20916. * @param useClipPlane defines if clip plane have to be turned on
  20917. * @param useInstances defines if instances have to be turned on
  20918. * @param useThinInstances defines if thin instances have to be turned on
  20919. */
  20920. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20921. /**
  20922. * Prepares the defines for bones
  20923. * @param mesh The mesh containing the geometry data we will draw
  20924. * @param defines The defines to update
  20925. */
  20926. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20927. /**
  20928. * Prepares the defines for morph targets
  20929. * @param mesh The mesh containing the geometry data we will draw
  20930. * @param defines The defines to update
  20931. */
  20932. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20933. /**
  20934. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20935. * @param mesh The mesh containing the geometry data we will draw
  20936. * @param defines The defines to update
  20937. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20938. * @param useBones Precise whether bones should be used or not (override mesh info)
  20939. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20940. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20941. * @returns false if defines are considered not dirty and have not been checked
  20942. */
  20943. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20944. /**
  20945. * Prepares the defines related to multiview
  20946. * @param scene The scene we are intending to draw
  20947. * @param defines The defines to update
  20948. */
  20949. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20950. /**
  20951. * Prepares the defines related to the prepass
  20952. * @param scene The scene we are intending to draw
  20953. * @param defines The defines to update
  20954. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20955. */
  20956. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20957. /**
  20958. * Prepares the defines related to the light information passed in parameter
  20959. * @param scene The scene we are intending to draw
  20960. * @param mesh The mesh the effect is compiling for
  20961. * @param light The light the effect is compiling for
  20962. * @param lightIndex The index of the light
  20963. * @param defines The defines to update
  20964. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20965. * @param state Defines the current state regarding what is needed (normals, etc...)
  20966. */
  20967. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20968. needNormals: boolean;
  20969. needRebuild: boolean;
  20970. shadowEnabled: boolean;
  20971. specularEnabled: boolean;
  20972. lightmapMode: boolean;
  20973. }): void;
  20974. /**
  20975. * Prepares the defines related to the light information passed in parameter
  20976. * @param scene The scene we are intending to draw
  20977. * @param mesh The mesh the effect is compiling for
  20978. * @param defines The defines to update
  20979. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20980. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20981. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20982. * @returns true if normals will be required for the rest of the effect
  20983. */
  20984. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20985. /**
  20986. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20987. * @param lightIndex defines the light index
  20988. * @param uniformsList The uniform list
  20989. * @param samplersList The sampler list
  20990. * @param projectedLightTexture defines if projected texture must be used
  20991. * @param uniformBuffersList defines an optional list of uniform buffers
  20992. */
  20993. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20994. /**
  20995. * Prepares the uniforms and samplers list to be used in the effect
  20996. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20997. * @param samplersList The sampler list
  20998. * @param defines The defines helping in the list generation
  20999. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21000. */
  21001. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21002. /**
  21003. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21004. * @param defines The defines to update while falling back
  21005. * @param fallbacks The authorized effect fallbacks
  21006. * @param maxSimultaneousLights The maximum number of lights allowed
  21007. * @param rank the current rank of the Effect
  21008. * @returns The newly affected rank
  21009. */
  21010. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21011. private static _TmpMorphInfluencers;
  21012. /**
  21013. * Prepares the list of attributes required for morph targets according to the effect defines.
  21014. * @param attribs The current list of supported attribs
  21015. * @param mesh The mesh to prepare the morph targets attributes for
  21016. * @param influencers The number of influencers
  21017. */
  21018. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21019. /**
  21020. * Prepares the list of attributes required for morph targets according to the effect defines.
  21021. * @param attribs The current list of supported attribs
  21022. * @param mesh The mesh to prepare the morph targets attributes for
  21023. * @param defines The current Defines of the effect
  21024. */
  21025. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21026. /**
  21027. * Prepares the list of attributes required for bones according to the effect defines.
  21028. * @param attribs The current list of supported attribs
  21029. * @param mesh The mesh to prepare the bones attributes for
  21030. * @param defines The current Defines of the effect
  21031. * @param fallbacks The current efffect fallback strategy
  21032. */
  21033. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21034. /**
  21035. * Check and prepare the list of attributes required for instances according to the effect defines.
  21036. * @param attribs The current list of supported attribs
  21037. * @param defines The current MaterialDefines of the effect
  21038. */
  21039. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21040. /**
  21041. * Add the list of attributes required for instances to the attribs array.
  21042. * @param attribs The current list of supported attribs
  21043. */
  21044. static PushAttributesForInstances(attribs: string[]): void;
  21045. /**
  21046. * Binds the light information to the effect.
  21047. * @param light The light containing the generator
  21048. * @param effect The effect we are binding the data to
  21049. * @param lightIndex The light index in the effect used to render
  21050. */
  21051. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21052. /**
  21053. * Binds the lights information from the scene to the effect for the given mesh.
  21054. * @param light Light to bind
  21055. * @param lightIndex Light index
  21056. * @param scene The scene where the light belongs to
  21057. * @param effect The effect we are binding the data to
  21058. * @param useSpecular Defines if specular is supported
  21059. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21060. */
  21061. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21062. /**
  21063. * Binds the lights information from the scene to the effect for the given mesh.
  21064. * @param scene The scene the lights belongs to
  21065. * @param mesh The mesh we are binding the information to render
  21066. * @param effect The effect we are binding the data to
  21067. * @param defines The generated defines for the effect
  21068. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21069. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21070. */
  21071. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21072. private static _tempFogColor;
  21073. /**
  21074. * Binds the fog information from the scene to the effect for the given mesh.
  21075. * @param scene The scene the lights belongs to
  21076. * @param mesh The mesh we are binding the information to render
  21077. * @param effect The effect we are binding the data to
  21078. * @param linearSpace Defines if the fog effect is applied in linear space
  21079. */
  21080. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21081. /**
  21082. * Binds the bones information from the mesh to the effect.
  21083. * @param mesh The mesh we are binding the information to render
  21084. * @param effect The effect we are binding the data to
  21085. */
  21086. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21087. /**
  21088. * Binds the morph targets information from the mesh to the effect.
  21089. * @param abstractMesh The mesh we are binding the information to render
  21090. * @param effect The effect we are binding the data to
  21091. */
  21092. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21093. /**
  21094. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21095. * @param defines The generated defines used in the effect
  21096. * @param effect The effect we are binding the data to
  21097. * @param scene The scene we are willing to render with logarithmic scale for
  21098. */
  21099. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21100. /**
  21101. * Binds the clip plane information from the scene to the effect.
  21102. * @param scene The scene the clip plane information are extracted from
  21103. * @param effect The effect we are binding the data to
  21104. */
  21105. static BindClipPlane(effect: Effect, scene: Scene): void;
  21106. }
  21107. }
  21108. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21110. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21111. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21112. import { Nullable } from "babylonjs/types";
  21113. import { Effect } from "babylonjs/Materials/effect";
  21114. import { Matrix } from "babylonjs/Maths/math.vector";
  21115. import { Scene } from "babylonjs/scene";
  21116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21118. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21119. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21120. import { Observable } from "babylonjs/Misc/observable";
  21121. /**
  21122. * Block used to expose an input value
  21123. */
  21124. export class InputBlock extends NodeMaterialBlock {
  21125. private _mode;
  21126. private _associatedVariableName;
  21127. private _storedValue;
  21128. private _valueCallback;
  21129. private _type;
  21130. private _animationType;
  21131. /** Gets or set a value used to limit the range of float values */
  21132. min: number;
  21133. /** Gets or set a value used to limit the range of float values */
  21134. max: number;
  21135. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21136. isBoolean: boolean;
  21137. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21138. matrixMode: number;
  21139. /** @hidden */
  21140. _systemValue: Nullable<NodeMaterialSystemValues>;
  21141. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21142. isConstant: boolean;
  21143. /** Gets or sets the group to use to display this block in the Inspector */
  21144. groupInInspector: string;
  21145. /** Gets an observable raised when the value is changed */
  21146. onValueChangedObservable: Observable<InputBlock>;
  21147. /**
  21148. * Gets or sets the connection point type (default is float)
  21149. */
  21150. get type(): NodeMaterialBlockConnectionPointTypes;
  21151. /**
  21152. * Creates a new InputBlock
  21153. * @param name defines the block name
  21154. * @param target defines the target of that block (Vertex by default)
  21155. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21156. */
  21157. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21158. /**
  21159. * Validates if a name is a reserve word.
  21160. * @param newName the new name to be given to the node.
  21161. * @returns false if the name is a reserve word, else true.
  21162. */
  21163. validateBlockName(newName: string): boolean;
  21164. /**
  21165. * Gets the output component
  21166. */
  21167. get output(): NodeMaterialConnectionPoint;
  21168. /**
  21169. * Set the source of this connection point to a vertex attribute
  21170. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21171. * @returns the current connection point
  21172. */
  21173. setAsAttribute(attributeName?: string): InputBlock;
  21174. /**
  21175. * Set the source of this connection point to a system value
  21176. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21177. * @returns the current connection point
  21178. */
  21179. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21180. /**
  21181. * Gets or sets the value of that point.
  21182. * Please note that this value will be ignored if valueCallback is defined
  21183. */
  21184. get value(): any;
  21185. set value(value: any);
  21186. /**
  21187. * Gets or sets a callback used to get the value of that point.
  21188. * Please note that setting this value will force the connection point to ignore the value property
  21189. */
  21190. get valueCallback(): () => any;
  21191. set valueCallback(value: () => any);
  21192. /**
  21193. * Gets or sets the associated variable name in the shader
  21194. */
  21195. get associatedVariableName(): string;
  21196. set associatedVariableName(value: string);
  21197. /** Gets or sets the type of animation applied to the input */
  21198. get animationType(): AnimatedInputBlockTypes;
  21199. set animationType(value: AnimatedInputBlockTypes);
  21200. /**
  21201. * Gets a boolean indicating that this connection point not defined yet
  21202. */
  21203. get isUndefined(): boolean;
  21204. /**
  21205. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21206. * In this case the connection point name must be the name of the uniform to use.
  21207. * Can only be set on inputs
  21208. */
  21209. get isUniform(): boolean;
  21210. set isUniform(value: boolean);
  21211. /**
  21212. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21213. * In this case the connection point name must be the name of the attribute to use
  21214. * Can only be set on inputs
  21215. */
  21216. get isAttribute(): boolean;
  21217. set isAttribute(value: boolean);
  21218. /**
  21219. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21220. * Can only be set on exit points
  21221. */
  21222. get isVarying(): boolean;
  21223. set isVarying(value: boolean);
  21224. /**
  21225. * Gets a boolean indicating that the current connection point is a system value
  21226. */
  21227. get isSystemValue(): boolean;
  21228. /**
  21229. * Gets or sets the current well known value or null if not defined as a system value
  21230. */
  21231. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21232. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21233. /**
  21234. * Gets the current class name
  21235. * @returns the class name
  21236. */
  21237. getClassName(): string;
  21238. /**
  21239. * Animate the input if animationType !== None
  21240. * @param scene defines the rendering scene
  21241. */
  21242. animate(scene: Scene): void;
  21243. private _emitDefine;
  21244. initialize(state: NodeMaterialBuildState): void;
  21245. /**
  21246. * Set the input block to its default value (based on its type)
  21247. */
  21248. setDefaultValue(): void;
  21249. private _emitConstant;
  21250. /** @hidden */
  21251. get _noContextSwitch(): boolean;
  21252. private _emit;
  21253. /** @hidden */
  21254. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21255. /** @hidden */
  21256. _transmit(effect: Effect, scene: Scene): void;
  21257. protected _buildBlock(state: NodeMaterialBuildState): void;
  21258. protected _dumpPropertiesCode(): string;
  21259. dispose(): void;
  21260. serialize(): any;
  21261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21262. }
  21263. }
  21264. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21265. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21266. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21267. import { Nullable } from "babylonjs/types";
  21268. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21269. import { Observable } from "babylonjs/Misc/observable";
  21270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21271. /**
  21272. * Enum used to define the compatibility state between two connection points
  21273. */
  21274. export enum NodeMaterialConnectionPointCompatibilityStates {
  21275. /** Points are compatibles */
  21276. Compatible = 0,
  21277. /** Points are incompatible because of their types */
  21278. TypeIncompatible = 1,
  21279. /** Points are incompatible because of their targets (vertex vs fragment) */
  21280. TargetIncompatible = 2
  21281. }
  21282. /**
  21283. * Defines the direction of a connection point
  21284. */
  21285. export enum NodeMaterialConnectionPointDirection {
  21286. /** Input */
  21287. Input = 0,
  21288. /** Output */
  21289. Output = 1
  21290. }
  21291. /**
  21292. * Defines a connection point for a block
  21293. */
  21294. export class NodeMaterialConnectionPoint {
  21295. /** @hidden */
  21296. _ownerBlock: NodeMaterialBlock;
  21297. /** @hidden */
  21298. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21299. private _endpoints;
  21300. private _associatedVariableName;
  21301. private _direction;
  21302. /** @hidden */
  21303. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21304. /** @hidden */
  21305. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21306. private _type;
  21307. /** @hidden */
  21308. _enforceAssociatedVariableName: boolean;
  21309. /** Gets the direction of the point */
  21310. get direction(): NodeMaterialConnectionPointDirection;
  21311. /** Indicates that this connection point needs dual validation before being connected to another point */
  21312. needDualDirectionValidation: boolean;
  21313. /**
  21314. * Gets or sets the additional types supported by this connection point
  21315. */
  21316. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21317. /**
  21318. * Gets or sets the additional types excluded by this connection point
  21319. */
  21320. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21321. /**
  21322. * Observable triggered when this point is connected
  21323. */
  21324. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21325. /**
  21326. * Gets or sets the associated variable name in the shader
  21327. */
  21328. get associatedVariableName(): string;
  21329. set associatedVariableName(value: string);
  21330. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21331. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21332. /**
  21333. * Gets or sets the connection point type (default is float)
  21334. */
  21335. get type(): NodeMaterialBlockConnectionPointTypes;
  21336. set type(value: NodeMaterialBlockConnectionPointTypes);
  21337. /**
  21338. * Gets or sets the connection point name
  21339. */
  21340. name: string;
  21341. /**
  21342. * Gets or sets the connection point name
  21343. */
  21344. displayName: string;
  21345. /**
  21346. * Gets or sets a boolean indicating that this connection point can be omitted
  21347. */
  21348. isOptional: boolean;
  21349. /**
  21350. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21351. */
  21352. isExposedOnFrame: boolean;
  21353. /**
  21354. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21355. */
  21356. define: string;
  21357. /** @hidden */
  21358. _prioritizeVertex: boolean;
  21359. private _target;
  21360. /** Gets or sets the target of that connection point */
  21361. get target(): NodeMaterialBlockTargets;
  21362. set target(value: NodeMaterialBlockTargets);
  21363. /**
  21364. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21365. */
  21366. get isConnected(): boolean;
  21367. /**
  21368. * Gets a boolean indicating that the current point is connected to an input block
  21369. */
  21370. get isConnectedToInputBlock(): boolean;
  21371. /**
  21372. * Gets a the connected input block (if any)
  21373. */
  21374. get connectInputBlock(): Nullable<InputBlock>;
  21375. /** Get the other side of the connection (if any) */
  21376. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21377. /** Get the block that owns this connection point */
  21378. get ownerBlock(): NodeMaterialBlock;
  21379. /** Get the block connected on the other side of this connection (if any) */
  21380. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21381. /** Get the block connected on the endpoints of this connection (if any) */
  21382. get connectedBlocks(): Array<NodeMaterialBlock>;
  21383. /** Gets the list of connected endpoints */
  21384. get endpoints(): NodeMaterialConnectionPoint[];
  21385. /** Gets a boolean indicating if that output point is connected to at least one input */
  21386. get hasEndpoints(): boolean;
  21387. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21388. get isConnectedInVertexShader(): boolean;
  21389. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21390. get isConnectedInFragmentShader(): boolean;
  21391. /**
  21392. * Creates a block suitable to be used as an input for this input point.
  21393. * If null is returned, a block based on the point type will be created.
  21394. * @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
  21395. */
  21396. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21397. /**
  21398. * Creates a new connection point
  21399. * @param name defines the connection point name
  21400. * @param ownerBlock defines the block hosting this connection point
  21401. * @param direction defines the direction of the connection point
  21402. */
  21403. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21404. /**
  21405. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21406. * @returns the class name
  21407. */
  21408. getClassName(): string;
  21409. /**
  21410. * Gets a boolean indicating if the current point can be connected to another point
  21411. * @param connectionPoint defines the other connection point
  21412. * @returns a boolean
  21413. */
  21414. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21415. /**
  21416. * Gets a number indicating if the current point can be connected to another point
  21417. * @param connectionPoint defines the other connection point
  21418. * @returns a number defining the compatibility state
  21419. */
  21420. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21421. /**
  21422. * Connect this point to another connection point
  21423. * @param connectionPoint defines the other connection point
  21424. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21425. * @returns the current connection point
  21426. */
  21427. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21428. /**
  21429. * Disconnect this point from one of his endpoint
  21430. * @param endpoint defines the other connection point
  21431. * @returns the current connection point
  21432. */
  21433. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21434. /**
  21435. * Serializes this point in a JSON representation
  21436. * @param isInput defines if the connection point is an input (default is true)
  21437. * @returns the serialized point object
  21438. */
  21439. serialize(isInput?: boolean): any;
  21440. /**
  21441. * Release resources
  21442. */
  21443. dispose(): void;
  21444. }
  21445. }
  21446. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21447. /**
  21448. * Enum used to define the material modes
  21449. */
  21450. export enum NodeMaterialModes {
  21451. /** Regular material */
  21452. Material = 0,
  21453. /** For post process */
  21454. PostProcess = 1,
  21455. /** For particle system */
  21456. Particle = 2,
  21457. /** For procedural texture */
  21458. ProceduralTexture = 3
  21459. }
  21460. }
  21461. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21464. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21467. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21468. import { Effect } from "babylonjs/Materials/effect";
  21469. import { Mesh } from "babylonjs/Meshes/mesh";
  21470. import { Nullable } from "babylonjs/types";
  21471. import { Texture } from "babylonjs/Materials/Textures/texture";
  21472. import { Scene } from "babylonjs/scene";
  21473. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21474. /**
  21475. * Block used to read a texture from a sampler
  21476. */
  21477. export class TextureBlock extends NodeMaterialBlock {
  21478. private _defineName;
  21479. private _linearDefineName;
  21480. private _gammaDefineName;
  21481. private _tempTextureRead;
  21482. private _samplerName;
  21483. private _transformedUVName;
  21484. private _textureTransformName;
  21485. private _textureInfoName;
  21486. private _mainUVName;
  21487. private _mainUVDefineName;
  21488. private _fragmentOnly;
  21489. /**
  21490. * Gets or sets the texture associated with the node
  21491. */
  21492. texture: Nullable<Texture>;
  21493. /**
  21494. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21495. */
  21496. convertToGammaSpace: boolean;
  21497. /**
  21498. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21499. */
  21500. convertToLinearSpace: boolean;
  21501. /**
  21502. * Create a new TextureBlock
  21503. * @param name defines the block name
  21504. */
  21505. constructor(name: string, fragmentOnly?: boolean);
  21506. /**
  21507. * Gets the current class name
  21508. * @returns the class name
  21509. */
  21510. getClassName(): string;
  21511. /**
  21512. * Gets the uv input component
  21513. */
  21514. get uv(): NodeMaterialConnectionPoint;
  21515. /**
  21516. * Gets the rgba output component
  21517. */
  21518. get rgba(): NodeMaterialConnectionPoint;
  21519. /**
  21520. * Gets the rgb output component
  21521. */
  21522. get rgb(): NodeMaterialConnectionPoint;
  21523. /**
  21524. * Gets the r output component
  21525. */
  21526. get r(): NodeMaterialConnectionPoint;
  21527. /**
  21528. * Gets the g output component
  21529. */
  21530. get g(): NodeMaterialConnectionPoint;
  21531. /**
  21532. * Gets the b output component
  21533. */
  21534. get b(): NodeMaterialConnectionPoint;
  21535. /**
  21536. * Gets the a output component
  21537. */
  21538. get a(): NodeMaterialConnectionPoint;
  21539. get target(): NodeMaterialBlockTargets;
  21540. autoConfigure(material: NodeMaterial): void;
  21541. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21542. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21543. isReady(): boolean;
  21544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21545. private get _isMixed();
  21546. private _injectVertexCode;
  21547. private _writeTextureRead;
  21548. private _writeOutput;
  21549. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21550. protected _dumpPropertiesCode(): string;
  21551. serialize(): any;
  21552. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21553. }
  21554. }
  21555. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21556. /** @hidden */
  21557. export var reflectionFunction: {
  21558. name: string;
  21559. shader: string;
  21560. };
  21561. }
  21562. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21568. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21569. import { Effect } from "babylonjs/Materials/effect";
  21570. import { Mesh } from "babylonjs/Meshes/mesh";
  21571. import { Nullable } from "babylonjs/types";
  21572. import { Scene } from "babylonjs/scene";
  21573. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21574. /**
  21575. * Base block used to read a reflection texture from a sampler
  21576. */
  21577. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21578. /** @hidden */
  21579. _define3DName: string;
  21580. /** @hidden */
  21581. _defineCubicName: string;
  21582. /** @hidden */
  21583. _defineExplicitName: string;
  21584. /** @hidden */
  21585. _defineProjectionName: string;
  21586. /** @hidden */
  21587. _defineLocalCubicName: string;
  21588. /** @hidden */
  21589. _defineSphericalName: string;
  21590. /** @hidden */
  21591. _definePlanarName: string;
  21592. /** @hidden */
  21593. _defineEquirectangularName: string;
  21594. /** @hidden */
  21595. _defineMirroredEquirectangularFixedName: string;
  21596. /** @hidden */
  21597. _defineEquirectangularFixedName: string;
  21598. /** @hidden */
  21599. _defineSkyboxName: string;
  21600. /** @hidden */
  21601. _defineOppositeZ: string;
  21602. /** @hidden */
  21603. _cubeSamplerName: string;
  21604. /** @hidden */
  21605. _2DSamplerName: string;
  21606. protected _positionUVWName: string;
  21607. protected _directionWName: string;
  21608. protected _reflectionVectorName: string;
  21609. /** @hidden */
  21610. _reflectionCoordsName: string;
  21611. /** @hidden */
  21612. _reflectionMatrixName: string;
  21613. protected _reflectionColorName: string;
  21614. /**
  21615. * Gets or sets the texture associated with the node
  21616. */
  21617. texture: Nullable<BaseTexture>;
  21618. /**
  21619. * Create a new ReflectionTextureBaseBlock
  21620. * @param name defines the block name
  21621. */
  21622. constructor(name: string);
  21623. /**
  21624. * Gets the current class name
  21625. * @returns the class name
  21626. */
  21627. getClassName(): string;
  21628. /**
  21629. * Gets the world position input component
  21630. */
  21631. abstract get position(): NodeMaterialConnectionPoint;
  21632. /**
  21633. * Gets the world position input component
  21634. */
  21635. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21636. /**
  21637. * Gets the world normal input component
  21638. */
  21639. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21640. /**
  21641. * Gets the world input component
  21642. */
  21643. abstract get world(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the camera (or eye) position component
  21646. */
  21647. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the view input component
  21650. */
  21651. abstract get view(): NodeMaterialConnectionPoint;
  21652. protected _getTexture(): Nullable<BaseTexture>;
  21653. autoConfigure(material: NodeMaterial): void;
  21654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21655. isReady(): boolean;
  21656. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21657. /**
  21658. * Gets the code to inject in the vertex shader
  21659. * @param state current state of the node material building
  21660. * @returns the shader code
  21661. */
  21662. handleVertexSide(state: NodeMaterialBuildState): string;
  21663. /**
  21664. * Handles the inits for the fragment code path
  21665. * @param state node material build state
  21666. */
  21667. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21668. /**
  21669. * Generates the reflection coords code for the fragment code path
  21670. * @param worldNormalVarName name of the world normal variable
  21671. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21672. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21673. * @returns the shader code
  21674. */
  21675. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21676. /**
  21677. * Generates the reflection color code for the fragment code path
  21678. * @param lodVarName name of the lod variable
  21679. * @param swizzleLookupTexture swizzle to use for the final color variable
  21680. * @returns the shader code
  21681. */
  21682. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21683. /**
  21684. * Generates the code corresponding to the connected output points
  21685. * @param state node material build state
  21686. * @param varName name of the variable to output
  21687. * @returns the shader code
  21688. */
  21689. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21690. protected _buildBlock(state: NodeMaterialBuildState): this;
  21691. protected _dumpPropertiesCode(): string;
  21692. serialize(): any;
  21693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21694. }
  21695. }
  21696. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21698. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21699. import { Nullable } from "babylonjs/types";
  21700. /**
  21701. * Defines a connection point to be used for points with a custom object type
  21702. */
  21703. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21704. private _blockType;
  21705. private _blockName;
  21706. private _nameForCheking?;
  21707. /**
  21708. * Creates a new connection point
  21709. * @param name defines the connection point name
  21710. * @param ownerBlock defines the block hosting this connection point
  21711. * @param direction defines the direction of the connection point
  21712. */
  21713. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21714. /**
  21715. * Gets a number indicating if the current point can be connected to another point
  21716. * @param connectionPoint defines the other connection point
  21717. * @returns a number defining the compatibility state
  21718. */
  21719. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21720. /**
  21721. * Creates a block suitable to be used as an input for this input point.
  21722. * If null is returned, a block based on the point type will be created.
  21723. * @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
  21724. */
  21725. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21726. }
  21727. }
  21728. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21729. /**
  21730. * Enum defining the type of properties that can be edited in the property pages in the NME
  21731. */
  21732. export enum PropertyTypeForEdition {
  21733. /** property is a boolean */
  21734. Boolean = 0,
  21735. /** property is a float */
  21736. Float = 1,
  21737. /** property is a Vector2 */
  21738. Vector2 = 2,
  21739. /** property is a list of values */
  21740. List = 3
  21741. }
  21742. /**
  21743. * Interface that defines an option in a variable of type list
  21744. */
  21745. export interface IEditablePropertyListOption {
  21746. /** label of the option */
  21747. "label": string;
  21748. /** value of the option */
  21749. "value": number;
  21750. }
  21751. /**
  21752. * Interface that defines the options available for an editable property
  21753. */
  21754. export interface IEditablePropertyOption {
  21755. /** min value */
  21756. "min"?: number;
  21757. /** max value */
  21758. "max"?: number;
  21759. /** notifiers: indicates which actions to take when the property is changed */
  21760. "notifiers"?: {
  21761. /** the material should be rebuilt */
  21762. "rebuild"?: boolean;
  21763. /** the preview should be updated */
  21764. "update"?: boolean;
  21765. };
  21766. /** list of the options for a variable of type list */
  21767. "options"?: IEditablePropertyListOption[];
  21768. }
  21769. /**
  21770. * Interface that describes an editable property
  21771. */
  21772. export interface IPropertyDescriptionForEdition {
  21773. /** name of the property */
  21774. "propertyName": string;
  21775. /** display name of the property */
  21776. "displayName": string;
  21777. /** type of the property */
  21778. "type": PropertyTypeForEdition;
  21779. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21780. "groupName": string;
  21781. /** options for the property */
  21782. "options": IEditablePropertyOption;
  21783. }
  21784. /**
  21785. * Decorator that flags a property in a node material block as being editable
  21786. */
  21787. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21788. }
  21789. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21791. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21792. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21794. import { Nullable } from "babylonjs/types";
  21795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21796. import { Mesh } from "babylonjs/Meshes/mesh";
  21797. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21798. import { Effect } from "babylonjs/Materials/effect";
  21799. import { Scene } from "babylonjs/scene";
  21800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21801. /**
  21802. * Block used to implement the refraction part of the sub surface module of the PBR material
  21803. */
  21804. export class RefractionBlock extends NodeMaterialBlock {
  21805. /** @hidden */
  21806. _define3DName: string;
  21807. /** @hidden */
  21808. _refractionMatrixName: string;
  21809. /** @hidden */
  21810. _defineLODRefractionAlpha: string;
  21811. /** @hidden */
  21812. _defineLinearSpecularRefraction: string;
  21813. /** @hidden */
  21814. _defineOppositeZ: string;
  21815. /** @hidden */
  21816. _cubeSamplerName: string;
  21817. /** @hidden */
  21818. _2DSamplerName: string;
  21819. /** @hidden */
  21820. _vRefractionMicrosurfaceInfosName: string;
  21821. /** @hidden */
  21822. _vRefractionInfosName: string;
  21823. private _scene;
  21824. /**
  21825. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21826. * Materials half opaque for instance using refraction could benefit from this control.
  21827. */
  21828. linkRefractionWithTransparency: boolean;
  21829. /**
  21830. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21831. */
  21832. invertRefractionY: boolean;
  21833. /**
  21834. * Gets or sets the texture associated with the node
  21835. */
  21836. texture: Nullable<BaseTexture>;
  21837. /**
  21838. * Create a new RefractionBlock
  21839. * @param name defines the block name
  21840. */
  21841. constructor(name: string);
  21842. /**
  21843. * Gets the current class name
  21844. * @returns the class name
  21845. */
  21846. getClassName(): string;
  21847. /**
  21848. * Gets the intensity input component
  21849. */
  21850. get intensity(): NodeMaterialConnectionPoint;
  21851. /**
  21852. * Gets the index of refraction input component
  21853. */
  21854. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21855. /**
  21856. * Gets the tint at distance input component
  21857. */
  21858. get tintAtDistance(): NodeMaterialConnectionPoint;
  21859. /**
  21860. * Gets the view input component
  21861. */
  21862. get view(): NodeMaterialConnectionPoint;
  21863. /**
  21864. * Gets the refraction object output component
  21865. */
  21866. get refraction(): NodeMaterialConnectionPoint;
  21867. /**
  21868. * Returns true if the block has a texture
  21869. */
  21870. get hasTexture(): boolean;
  21871. protected _getTexture(): Nullable<BaseTexture>;
  21872. autoConfigure(material: NodeMaterial): void;
  21873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21874. isReady(): boolean;
  21875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21876. /**
  21877. * Gets the main code of the block (fragment side)
  21878. * @param state current state of the node material building
  21879. * @returns the shader code
  21880. */
  21881. getCode(state: NodeMaterialBuildState): string;
  21882. protected _buildBlock(state: NodeMaterialBuildState): this;
  21883. protected _dumpPropertiesCode(): string;
  21884. serialize(): any;
  21885. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21886. }
  21887. }
  21888. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21891. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21894. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21896. import { Nullable } from "babylonjs/types";
  21897. import { Scene } from "babylonjs/scene";
  21898. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21899. /**
  21900. * Base block used as input for post process
  21901. */
  21902. export class CurrentScreenBlock extends NodeMaterialBlock {
  21903. private _samplerName;
  21904. private _linearDefineName;
  21905. private _gammaDefineName;
  21906. private _mainUVName;
  21907. private _tempTextureRead;
  21908. /**
  21909. * Gets or sets the texture associated with the node
  21910. */
  21911. texture: Nullable<BaseTexture>;
  21912. /**
  21913. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21914. */
  21915. convertToGammaSpace: boolean;
  21916. /**
  21917. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21918. */
  21919. convertToLinearSpace: boolean;
  21920. /**
  21921. * Create a new CurrentScreenBlock
  21922. * @param name defines the block name
  21923. */
  21924. constructor(name: string);
  21925. /**
  21926. * Gets the current class name
  21927. * @returns the class name
  21928. */
  21929. getClassName(): string;
  21930. /**
  21931. * Gets the uv input component
  21932. */
  21933. get uv(): NodeMaterialConnectionPoint;
  21934. /**
  21935. * Gets the rgba output component
  21936. */
  21937. get rgba(): NodeMaterialConnectionPoint;
  21938. /**
  21939. * Gets the rgb output component
  21940. */
  21941. get rgb(): NodeMaterialConnectionPoint;
  21942. /**
  21943. * Gets the r output component
  21944. */
  21945. get r(): NodeMaterialConnectionPoint;
  21946. /**
  21947. * Gets the g output component
  21948. */
  21949. get g(): NodeMaterialConnectionPoint;
  21950. /**
  21951. * Gets the b output component
  21952. */
  21953. get b(): NodeMaterialConnectionPoint;
  21954. /**
  21955. * Gets the a output component
  21956. */
  21957. get a(): NodeMaterialConnectionPoint;
  21958. /**
  21959. * Initialize the block and prepare the context for build
  21960. * @param state defines the state that will be used for the build
  21961. */
  21962. initialize(state: NodeMaterialBuildState): void;
  21963. get target(): NodeMaterialBlockTargets;
  21964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21965. isReady(): boolean;
  21966. private _injectVertexCode;
  21967. private _writeTextureRead;
  21968. private _writeOutput;
  21969. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21970. serialize(): any;
  21971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21972. }
  21973. }
  21974. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21979. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21981. import { Nullable } from "babylonjs/types";
  21982. import { Scene } from "babylonjs/scene";
  21983. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21984. /**
  21985. * Base block used for the particle texture
  21986. */
  21987. export class ParticleTextureBlock extends NodeMaterialBlock {
  21988. private _samplerName;
  21989. private _linearDefineName;
  21990. private _gammaDefineName;
  21991. private _tempTextureRead;
  21992. /**
  21993. * Gets or sets the texture associated with the node
  21994. */
  21995. texture: Nullable<BaseTexture>;
  21996. /**
  21997. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21998. */
  21999. convertToGammaSpace: boolean;
  22000. /**
  22001. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22002. */
  22003. convertToLinearSpace: boolean;
  22004. /**
  22005. * Create a new ParticleTextureBlock
  22006. * @param name defines the block name
  22007. */
  22008. constructor(name: string);
  22009. /**
  22010. * Gets the current class name
  22011. * @returns the class name
  22012. */
  22013. getClassName(): string;
  22014. /**
  22015. * Gets the uv input component
  22016. */
  22017. get uv(): NodeMaterialConnectionPoint;
  22018. /**
  22019. * Gets the rgba output component
  22020. */
  22021. get rgba(): NodeMaterialConnectionPoint;
  22022. /**
  22023. * Gets the rgb output component
  22024. */
  22025. get rgb(): NodeMaterialConnectionPoint;
  22026. /**
  22027. * Gets the r output component
  22028. */
  22029. get r(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the g output component
  22032. */
  22033. get g(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Gets the b output component
  22036. */
  22037. get b(): NodeMaterialConnectionPoint;
  22038. /**
  22039. * Gets the a output component
  22040. */
  22041. get a(): NodeMaterialConnectionPoint;
  22042. /**
  22043. * Initialize the block and prepare the context for build
  22044. * @param state defines the state that will be used for the build
  22045. */
  22046. initialize(state: NodeMaterialBuildState): void;
  22047. autoConfigure(material: NodeMaterial): void;
  22048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22049. isReady(): boolean;
  22050. private _writeOutput;
  22051. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22052. serialize(): any;
  22053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22054. }
  22055. }
  22056. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22059. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22060. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22061. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22062. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22063. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22064. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22065. import { Scene } from "babylonjs/scene";
  22066. /**
  22067. * Class used to store shared data between 2 NodeMaterialBuildState
  22068. */
  22069. export class NodeMaterialBuildStateSharedData {
  22070. /**
  22071. * Gets the list of emitted varyings
  22072. */
  22073. temps: string[];
  22074. /**
  22075. * Gets the list of emitted varyings
  22076. */
  22077. varyings: string[];
  22078. /**
  22079. * Gets the varying declaration string
  22080. */
  22081. varyingDeclaration: string;
  22082. /**
  22083. * Input blocks
  22084. */
  22085. inputBlocks: InputBlock[];
  22086. /**
  22087. * Input blocks
  22088. */
  22089. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22090. /**
  22091. * Bindable blocks (Blocks that need to set data to the effect)
  22092. */
  22093. bindableBlocks: NodeMaterialBlock[];
  22094. /**
  22095. * List of blocks that can provide a compilation fallback
  22096. */
  22097. blocksWithFallbacks: NodeMaterialBlock[];
  22098. /**
  22099. * List of blocks that can provide a define update
  22100. */
  22101. blocksWithDefines: NodeMaterialBlock[];
  22102. /**
  22103. * List of blocks that can provide a repeatable content
  22104. */
  22105. repeatableContentBlocks: NodeMaterialBlock[];
  22106. /**
  22107. * List of blocks that can provide a dynamic list of uniforms
  22108. */
  22109. dynamicUniformBlocks: NodeMaterialBlock[];
  22110. /**
  22111. * List of blocks that can block the isReady function for the material
  22112. */
  22113. blockingBlocks: NodeMaterialBlock[];
  22114. /**
  22115. * Gets the list of animated inputs
  22116. */
  22117. animatedInputs: InputBlock[];
  22118. /**
  22119. * Build Id used to avoid multiple recompilations
  22120. */
  22121. buildId: number;
  22122. /** List of emitted variables */
  22123. variableNames: {
  22124. [key: string]: number;
  22125. };
  22126. /** List of emitted defines */
  22127. defineNames: {
  22128. [key: string]: number;
  22129. };
  22130. /** Should emit comments? */
  22131. emitComments: boolean;
  22132. /** Emit build activity */
  22133. verbose: boolean;
  22134. /** Gets or sets the hosting scene */
  22135. scene: Scene;
  22136. /**
  22137. * Gets the compilation hints emitted at compilation time
  22138. */
  22139. hints: {
  22140. needWorldViewMatrix: boolean;
  22141. needWorldViewProjectionMatrix: boolean;
  22142. needAlphaBlending: boolean;
  22143. needAlphaTesting: boolean;
  22144. };
  22145. /**
  22146. * List of compilation checks
  22147. */
  22148. checks: {
  22149. emitVertex: boolean;
  22150. emitFragment: boolean;
  22151. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22152. };
  22153. /**
  22154. * Is vertex program allowed to be empty?
  22155. */
  22156. allowEmptyVertexProgram: boolean;
  22157. /** Creates a new shared data */
  22158. constructor();
  22159. /**
  22160. * Emits console errors and exceptions if there is a failing check
  22161. */
  22162. emitErrors(): void;
  22163. }
  22164. }
  22165. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22166. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22167. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22168. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22169. /**
  22170. * Class used to store node based material build state
  22171. */
  22172. export class NodeMaterialBuildState {
  22173. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22174. supportUniformBuffers: boolean;
  22175. /**
  22176. * Gets the list of emitted attributes
  22177. */
  22178. attributes: string[];
  22179. /**
  22180. * Gets the list of emitted uniforms
  22181. */
  22182. uniforms: string[];
  22183. /**
  22184. * Gets the list of emitted constants
  22185. */
  22186. constants: string[];
  22187. /**
  22188. * Gets the list of emitted samplers
  22189. */
  22190. samplers: string[];
  22191. /**
  22192. * Gets the list of emitted functions
  22193. */
  22194. functions: {
  22195. [key: string]: string;
  22196. };
  22197. /**
  22198. * Gets the list of emitted extensions
  22199. */
  22200. extensions: {
  22201. [key: string]: string;
  22202. };
  22203. /**
  22204. * Gets the target of the compilation state
  22205. */
  22206. target: NodeMaterialBlockTargets;
  22207. /**
  22208. * Gets the list of emitted counters
  22209. */
  22210. counters: {
  22211. [key: string]: number;
  22212. };
  22213. /**
  22214. * Shared data between multiple NodeMaterialBuildState instances
  22215. */
  22216. sharedData: NodeMaterialBuildStateSharedData;
  22217. /** @hidden */
  22218. _vertexState: NodeMaterialBuildState;
  22219. /** @hidden */
  22220. _attributeDeclaration: string;
  22221. /** @hidden */
  22222. _uniformDeclaration: string;
  22223. /** @hidden */
  22224. _constantDeclaration: string;
  22225. /** @hidden */
  22226. _samplerDeclaration: string;
  22227. /** @hidden */
  22228. _varyingTransfer: string;
  22229. /** @hidden */
  22230. _injectAtEnd: string;
  22231. private _repeatableContentAnchorIndex;
  22232. /** @hidden */
  22233. _builtCompilationString: string;
  22234. /**
  22235. * Gets the emitted compilation strings
  22236. */
  22237. compilationString: string;
  22238. /**
  22239. * Finalize the compilation strings
  22240. * @param state defines the current compilation state
  22241. */
  22242. finalize(state: NodeMaterialBuildState): void;
  22243. /** @hidden */
  22244. get _repeatableContentAnchor(): string;
  22245. /** @hidden */
  22246. _getFreeVariableName(prefix: string): string;
  22247. /** @hidden */
  22248. _getFreeDefineName(prefix: string): string;
  22249. /** @hidden */
  22250. _excludeVariableName(name: string): void;
  22251. /** @hidden */
  22252. _emit2DSampler(name: string): void;
  22253. /** @hidden */
  22254. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22255. /** @hidden */
  22256. _emitExtension(name: string, extension: string, define?: string): void;
  22257. /** @hidden */
  22258. _emitFunction(name: string, code: string, comments: string): void;
  22259. /** @hidden */
  22260. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22261. replaceStrings?: {
  22262. search: RegExp;
  22263. replace: string;
  22264. }[];
  22265. repeatKey?: string;
  22266. }): string;
  22267. /** @hidden */
  22268. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22269. repeatKey?: string;
  22270. removeAttributes?: boolean;
  22271. removeUniforms?: boolean;
  22272. removeVaryings?: boolean;
  22273. removeIfDef?: boolean;
  22274. replaceStrings?: {
  22275. search: RegExp;
  22276. replace: string;
  22277. }[];
  22278. }, storeKey?: string): void;
  22279. /** @hidden */
  22280. _registerTempVariable(name: string): boolean;
  22281. /** @hidden */
  22282. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22283. /** @hidden */
  22284. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22285. /** @hidden */
  22286. _emitFloat(value: number): string;
  22287. }
  22288. }
  22289. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22290. /**
  22291. * Helper class used to generate session unique ID
  22292. */
  22293. export class UniqueIdGenerator {
  22294. private static _UniqueIdCounter;
  22295. /**
  22296. * Gets an unique (relatively to the current scene) Id
  22297. */
  22298. static get UniqueId(): number;
  22299. }
  22300. }
  22301. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22302. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22304. import { Nullable } from "babylonjs/types";
  22305. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22306. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22307. import { Effect } from "babylonjs/Materials/effect";
  22308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22309. import { Mesh } from "babylonjs/Meshes/mesh";
  22310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22311. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22312. import { Scene } from "babylonjs/scene";
  22313. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22314. /**
  22315. * Defines a block that can be used inside a node based material
  22316. */
  22317. export class NodeMaterialBlock {
  22318. private _buildId;
  22319. private _buildTarget;
  22320. private _target;
  22321. private _isFinalMerger;
  22322. private _isInput;
  22323. private _name;
  22324. protected _isUnique: boolean;
  22325. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22326. inputsAreExclusive: boolean;
  22327. /** @hidden */
  22328. _codeVariableName: string;
  22329. /** @hidden */
  22330. _inputs: NodeMaterialConnectionPoint[];
  22331. /** @hidden */
  22332. _outputs: NodeMaterialConnectionPoint[];
  22333. /** @hidden */
  22334. _preparationId: number;
  22335. /**
  22336. * Gets the name of the block
  22337. */
  22338. get name(): string;
  22339. /**
  22340. * Sets the name of the block. Will check if the name is valid.
  22341. */
  22342. set name(newName: string);
  22343. /**
  22344. * Gets or sets the unique id of the node
  22345. */
  22346. uniqueId: number;
  22347. /**
  22348. * Gets or sets the comments associated with this block
  22349. */
  22350. comments: string;
  22351. /**
  22352. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22353. */
  22354. get isUnique(): boolean;
  22355. /**
  22356. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22357. */
  22358. get isFinalMerger(): boolean;
  22359. /**
  22360. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22361. */
  22362. get isInput(): boolean;
  22363. /**
  22364. * Gets or sets the build Id
  22365. */
  22366. get buildId(): number;
  22367. set buildId(value: number);
  22368. /**
  22369. * Gets or sets the target of the block
  22370. */
  22371. get target(): NodeMaterialBlockTargets;
  22372. set target(value: NodeMaterialBlockTargets);
  22373. /**
  22374. * Gets the list of input points
  22375. */
  22376. get inputs(): NodeMaterialConnectionPoint[];
  22377. /** Gets the list of output points */
  22378. get outputs(): NodeMaterialConnectionPoint[];
  22379. /**
  22380. * Find an input by its name
  22381. * @param name defines the name of the input to look for
  22382. * @returns the input or null if not found
  22383. */
  22384. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22385. /**
  22386. * Find an output by its name
  22387. * @param name defines the name of the outputto look for
  22388. * @returns the output or null if not found
  22389. */
  22390. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22391. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22392. visibleInInspector: boolean;
  22393. /**
  22394. * Creates a new NodeMaterialBlock
  22395. * @param name defines the block name
  22396. * @param target defines the target of that block (Vertex by default)
  22397. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22398. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22399. */
  22400. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22401. /**
  22402. * Initialize the block and prepare the context for build
  22403. * @param state defines the state that will be used for the build
  22404. */
  22405. initialize(state: NodeMaterialBuildState): void;
  22406. /**
  22407. * Bind data to effect. Will only be called for blocks with isBindable === true
  22408. * @param effect defines the effect to bind data to
  22409. * @param nodeMaterial defines the hosting NodeMaterial
  22410. * @param mesh defines the mesh that will be rendered
  22411. * @param subMesh defines the submesh that will be rendered
  22412. */
  22413. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22414. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22415. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22416. protected _writeFloat(value: number): string;
  22417. /**
  22418. * Gets the current class name e.g. "NodeMaterialBlock"
  22419. * @returns the class name
  22420. */
  22421. getClassName(): string;
  22422. /**
  22423. * Register a new input. Must be called inside a block constructor
  22424. * @param name defines the connection point name
  22425. * @param type defines the connection point type
  22426. * @param isOptional defines a boolean indicating that this input can be omitted
  22427. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22428. * @param point an already created connection point. If not provided, create a new one
  22429. * @returns the current block
  22430. */
  22431. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22432. /**
  22433. * Register a new output. Must be called inside a block constructor
  22434. * @param name defines the connection point name
  22435. * @param type defines the connection point type
  22436. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22437. * @param point an already created connection point. If not provided, create a new one
  22438. * @returns the current block
  22439. */
  22440. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22441. /**
  22442. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22443. * @param forOutput defines an optional connection point to check compatibility with
  22444. * @returns the first available input or null
  22445. */
  22446. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22447. /**
  22448. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22449. * @param forBlock defines an optional block to check compatibility with
  22450. * @returns the first available input or null
  22451. */
  22452. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22453. /**
  22454. * Gets the sibling of the given output
  22455. * @param current defines the current output
  22456. * @returns the next output in the list or null
  22457. */
  22458. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22459. /**
  22460. * Connect current block with another block
  22461. * @param other defines the block to connect with
  22462. * @param options define the various options to help pick the right connections
  22463. * @returns the current block
  22464. */
  22465. connectTo(other: NodeMaterialBlock, options?: {
  22466. input?: string;
  22467. output?: string;
  22468. outputSwizzle?: string;
  22469. }): this | undefined;
  22470. protected _buildBlock(state: NodeMaterialBuildState): void;
  22471. /**
  22472. * Add uniforms, samplers and uniform buffers at compilation time
  22473. * @param state defines the state to update
  22474. * @param nodeMaterial defines the node material requesting the update
  22475. * @param defines defines the material defines to update
  22476. * @param uniformBuffers defines the list of uniform buffer names
  22477. */
  22478. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22479. /**
  22480. * Add potential fallbacks if shader compilation fails
  22481. * @param mesh defines the mesh to be rendered
  22482. * @param fallbacks defines the current prioritized list of fallbacks
  22483. */
  22484. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22485. /**
  22486. * Initialize defines for shader compilation
  22487. * @param mesh defines the mesh to be rendered
  22488. * @param nodeMaterial defines the node material requesting the update
  22489. * @param defines defines the material defines to update
  22490. * @param useInstances specifies that instances should be used
  22491. */
  22492. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22493. /**
  22494. * Update defines for shader compilation
  22495. * @param mesh defines the mesh to be rendered
  22496. * @param nodeMaterial defines the node material requesting the update
  22497. * @param defines defines the material defines to update
  22498. * @param useInstances specifies that instances should be used
  22499. * @param subMesh defines which submesh to render
  22500. */
  22501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22502. /**
  22503. * Lets the block try to connect some inputs automatically
  22504. * @param material defines the hosting NodeMaterial
  22505. */
  22506. autoConfigure(material: NodeMaterial): void;
  22507. /**
  22508. * Function called when a block is declared as repeatable content generator
  22509. * @param vertexShaderState defines the current compilation state for the vertex shader
  22510. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22511. * @param mesh defines the mesh to be rendered
  22512. * @param defines defines the material defines to update
  22513. */
  22514. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22515. /**
  22516. * Checks if the block is ready
  22517. * @param mesh defines the mesh to be rendered
  22518. * @param nodeMaterial defines the node material requesting the update
  22519. * @param defines defines the material defines to update
  22520. * @param useInstances specifies that instances should be used
  22521. * @returns true if the block is ready
  22522. */
  22523. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22524. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22525. private _processBuild;
  22526. /**
  22527. * Validates the new name for the block node.
  22528. * @param newName the new name to be given to the node.
  22529. * @returns false if the name is a reserve word, else true.
  22530. */
  22531. validateBlockName(newName: string): boolean;
  22532. /**
  22533. * Compile the current node and generate the shader code
  22534. * @param state defines the current compilation state (uniforms, samplers, current string)
  22535. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22536. * @returns true if already built
  22537. */
  22538. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22539. protected _inputRename(name: string): string;
  22540. protected _outputRename(name: string): string;
  22541. protected _dumpPropertiesCode(): string;
  22542. /** @hidden */
  22543. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22544. /** @hidden */
  22545. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22546. /**
  22547. * Clone the current block to a new identical block
  22548. * @param scene defines the hosting scene
  22549. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22550. * @returns a copy of the current block
  22551. */
  22552. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22553. /**
  22554. * Serializes this block in a JSON representation
  22555. * @returns the serialized block object
  22556. */
  22557. serialize(): any;
  22558. /** @hidden */
  22559. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22560. private _deserializePortDisplayNamesAndExposedOnFrame;
  22561. /**
  22562. * Release resources
  22563. */
  22564. dispose(): void;
  22565. }
  22566. }
  22567. declare module "babylonjs/Materials/pushMaterial" {
  22568. import { Nullable } from "babylonjs/types";
  22569. import { Scene } from "babylonjs/scene";
  22570. import { Matrix } from "babylonjs/Maths/math.vector";
  22571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22572. import { Mesh } from "babylonjs/Meshes/mesh";
  22573. import { Material } from "babylonjs/Materials/material";
  22574. import { Effect } from "babylonjs/Materials/effect";
  22575. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22576. /**
  22577. * Base class of materials working in push mode in babylon JS
  22578. * @hidden
  22579. */
  22580. export class PushMaterial extends Material {
  22581. protected _activeEffect: Effect;
  22582. protected _normalMatrix: Matrix;
  22583. constructor(name: string, scene: Scene);
  22584. getEffect(): Effect;
  22585. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22586. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22587. /**
  22588. * Binds the given world matrix to the active effect
  22589. *
  22590. * @param world the matrix to bind
  22591. */
  22592. bindOnlyWorldMatrix(world: Matrix): void;
  22593. /**
  22594. * Binds the given normal matrix to the active effect
  22595. *
  22596. * @param normalMatrix the matrix to bind
  22597. */
  22598. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22599. bind(world: Matrix, mesh?: Mesh): void;
  22600. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22601. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22602. }
  22603. }
  22604. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22605. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22606. /**
  22607. * Root class for all node material optimizers
  22608. */
  22609. export class NodeMaterialOptimizer {
  22610. /**
  22611. * Function used to optimize a NodeMaterial graph
  22612. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22613. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22614. */
  22615. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22616. }
  22617. }
  22618. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22622. import { Scene } from "babylonjs/scene";
  22623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22624. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22625. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22626. /**
  22627. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22628. */
  22629. export class TransformBlock extends NodeMaterialBlock {
  22630. /**
  22631. * Defines the value to use to complement W value to transform it to a Vector4
  22632. */
  22633. complementW: number;
  22634. /**
  22635. * Defines the value to use to complement z value to transform it to a Vector4
  22636. */
  22637. complementZ: number;
  22638. /**
  22639. * Creates a new TransformBlock
  22640. * @param name defines the block name
  22641. */
  22642. constructor(name: string);
  22643. /**
  22644. * Gets the current class name
  22645. * @returns the class name
  22646. */
  22647. getClassName(): string;
  22648. /**
  22649. * Gets the vector input
  22650. */
  22651. get vector(): NodeMaterialConnectionPoint;
  22652. /**
  22653. * Gets the output component
  22654. */
  22655. get output(): NodeMaterialConnectionPoint;
  22656. /**
  22657. * Gets the xyz output component
  22658. */
  22659. get xyz(): NodeMaterialConnectionPoint;
  22660. /**
  22661. * Gets the matrix transform input
  22662. */
  22663. get transform(): NodeMaterialConnectionPoint;
  22664. protected _buildBlock(state: NodeMaterialBuildState): this;
  22665. /**
  22666. * Update defines for shader compilation
  22667. * @param mesh defines the mesh to be rendered
  22668. * @param nodeMaterial defines the node material requesting the update
  22669. * @param defines defines the material defines to update
  22670. * @param useInstances specifies that instances should be used
  22671. * @param subMesh defines which submesh to render
  22672. */
  22673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22674. serialize(): any;
  22675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22676. protected _dumpPropertiesCode(): string;
  22677. }
  22678. }
  22679. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22683. /**
  22684. * Block used to output the vertex position
  22685. */
  22686. export class VertexOutputBlock extends NodeMaterialBlock {
  22687. /**
  22688. * Creates a new VertexOutputBlock
  22689. * @param name defines the block name
  22690. */
  22691. constructor(name: string);
  22692. /**
  22693. * Gets the current class name
  22694. * @returns the class name
  22695. */
  22696. getClassName(): string;
  22697. /**
  22698. * Gets the vector input component
  22699. */
  22700. get vector(): NodeMaterialConnectionPoint;
  22701. protected _buildBlock(state: NodeMaterialBuildState): this;
  22702. }
  22703. }
  22704. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22708. /**
  22709. * Block used to output the final color
  22710. */
  22711. export class FragmentOutputBlock extends NodeMaterialBlock {
  22712. /**
  22713. * Create a new FragmentOutputBlock
  22714. * @param name defines the block name
  22715. */
  22716. constructor(name: string);
  22717. /**
  22718. * Gets the current class name
  22719. * @returns the class name
  22720. */
  22721. getClassName(): string;
  22722. /**
  22723. * Gets the rgba input component
  22724. */
  22725. get rgba(): NodeMaterialConnectionPoint;
  22726. /**
  22727. * Gets the rgb input component
  22728. */
  22729. get rgb(): NodeMaterialConnectionPoint;
  22730. /**
  22731. * Gets the a input component
  22732. */
  22733. get a(): NodeMaterialConnectionPoint;
  22734. protected _buildBlock(state: NodeMaterialBuildState): this;
  22735. }
  22736. }
  22737. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22741. /**
  22742. * Block used for the particle ramp gradient section
  22743. */
  22744. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22745. /**
  22746. * Create a new ParticleRampGradientBlock
  22747. * @param name defines the block name
  22748. */
  22749. constructor(name: string);
  22750. /**
  22751. * Gets the current class name
  22752. * @returns the class name
  22753. */
  22754. getClassName(): string;
  22755. /**
  22756. * Gets the color input component
  22757. */
  22758. get color(): NodeMaterialConnectionPoint;
  22759. /**
  22760. * Gets the rampColor output component
  22761. */
  22762. get rampColor(): NodeMaterialConnectionPoint;
  22763. /**
  22764. * Initialize the block and prepare the context for build
  22765. * @param state defines the state that will be used for the build
  22766. */
  22767. initialize(state: NodeMaterialBuildState): void;
  22768. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22769. }
  22770. }
  22771. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22775. /**
  22776. * Block used for the particle blend multiply section
  22777. */
  22778. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22779. /**
  22780. * Create a new ParticleBlendMultiplyBlock
  22781. * @param name defines the block name
  22782. */
  22783. constructor(name: string);
  22784. /**
  22785. * Gets the current class name
  22786. * @returns the class name
  22787. */
  22788. getClassName(): string;
  22789. /**
  22790. * Gets the color input component
  22791. */
  22792. get color(): NodeMaterialConnectionPoint;
  22793. /**
  22794. * Gets the alphaTexture input component
  22795. */
  22796. get alphaTexture(): NodeMaterialConnectionPoint;
  22797. /**
  22798. * Gets the alphaColor input component
  22799. */
  22800. get alphaColor(): NodeMaterialConnectionPoint;
  22801. /**
  22802. * Gets the blendColor output component
  22803. */
  22804. get blendColor(): NodeMaterialConnectionPoint;
  22805. /**
  22806. * Initialize the block and prepare the context for build
  22807. * @param state defines the state that will be used for the build
  22808. */
  22809. initialize(state: NodeMaterialBuildState): void;
  22810. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22811. }
  22812. }
  22813. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22817. /**
  22818. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22819. */
  22820. export class VectorMergerBlock extends NodeMaterialBlock {
  22821. /**
  22822. * Create a new VectorMergerBlock
  22823. * @param name defines the block name
  22824. */
  22825. constructor(name: string);
  22826. /**
  22827. * Gets the current class name
  22828. * @returns the class name
  22829. */
  22830. getClassName(): string;
  22831. /**
  22832. * Gets the xyz component (input)
  22833. */
  22834. get xyzIn(): NodeMaterialConnectionPoint;
  22835. /**
  22836. * Gets the xy component (input)
  22837. */
  22838. get xyIn(): NodeMaterialConnectionPoint;
  22839. /**
  22840. * Gets the x component (input)
  22841. */
  22842. get x(): NodeMaterialConnectionPoint;
  22843. /**
  22844. * Gets the y component (input)
  22845. */
  22846. get y(): NodeMaterialConnectionPoint;
  22847. /**
  22848. * Gets the z component (input)
  22849. */
  22850. get z(): NodeMaterialConnectionPoint;
  22851. /**
  22852. * Gets the w component (input)
  22853. */
  22854. get w(): NodeMaterialConnectionPoint;
  22855. /**
  22856. * Gets the xyzw component (output)
  22857. */
  22858. get xyzw(): NodeMaterialConnectionPoint;
  22859. /**
  22860. * Gets the xyz component (output)
  22861. */
  22862. get xyzOut(): NodeMaterialConnectionPoint;
  22863. /**
  22864. * Gets the xy component (output)
  22865. */
  22866. get xyOut(): NodeMaterialConnectionPoint;
  22867. /**
  22868. * Gets the xy component (output)
  22869. * @deprecated Please use xyOut instead.
  22870. */
  22871. get xy(): NodeMaterialConnectionPoint;
  22872. /**
  22873. * Gets the xyz component (output)
  22874. * @deprecated Please use xyzOut instead.
  22875. */
  22876. get xyz(): NodeMaterialConnectionPoint;
  22877. protected _buildBlock(state: NodeMaterialBuildState): this;
  22878. }
  22879. }
  22880. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22884. import { Vector2 } from "babylonjs/Maths/math.vector";
  22885. import { Scene } from "babylonjs/scene";
  22886. /**
  22887. * Block used to remap a float from a range to a new one
  22888. */
  22889. export class RemapBlock extends NodeMaterialBlock {
  22890. /**
  22891. * Gets or sets the source range
  22892. */
  22893. sourceRange: Vector2;
  22894. /**
  22895. * Gets or sets the target range
  22896. */
  22897. targetRange: Vector2;
  22898. /**
  22899. * Creates a new RemapBlock
  22900. * @param name defines the block name
  22901. */
  22902. constructor(name: string);
  22903. /**
  22904. * Gets the current class name
  22905. * @returns the class name
  22906. */
  22907. getClassName(): string;
  22908. /**
  22909. * Gets the input component
  22910. */
  22911. get input(): NodeMaterialConnectionPoint;
  22912. /**
  22913. * Gets the source min input component
  22914. */
  22915. get sourceMin(): NodeMaterialConnectionPoint;
  22916. /**
  22917. * Gets the source max input component
  22918. */
  22919. get sourceMax(): NodeMaterialConnectionPoint;
  22920. /**
  22921. * Gets the target min input component
  22922. */
  22923. get targetMin(): NodeMaterialConnectionPoint;
  22924. /**
  22925. * Gets the target max input component
  22926. */
  22927. get targetMax(): NodeMaterialConnectionPoint;
  22928. /**
  22929. * Gets the output component
  22930. */
  22931. get output(): NodeMaterialConnectionPoint;
  22932. protected _buildBlock(state: NodeMaterialBuildState): this;
  22933. protected _dumpPropertiesCode(): string;
  22934. serialize(): any;
  22935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22936. }
  22937. }
  22938. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22939. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22940. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22941. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22942. /**
  22943. * Block used to multiply 2 values
  22944. */
  22945. export class MultiplyBlock extends NodeMaterialBlock {
  22946. /**
  22947. * Creates a new MultiplyBlock
  22948. * @param name defines the block name
  22949. */
  22950. constructor(name: string);
  22951. /**
  22952. * Gets the current class name
  22953. * @returns the class name
  22954. */
  22955. getClassName(): string;
  22956. /**
  22957. * Gets the left operand input component
  22958. */
  22959. get left(): NodeMaterialConnectionPoint;
  22960. /**
  22961. * Gets the right operand input component
  22962. */
  22963. get right(): NodeMaterialConnectionPoint;
  22964. /**
  22965. * Gets the output component
  22966. */
  22967. get output(): NodeMaterialConnectionPoint;
  22968. protected _buildBlock(state: NodeMaterialBuildState): this;
  22969. }
  22970. }
  22971. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22975. /**
  22976. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22977. */
  22978. export class ColorSplitterBlock extends NodeMaterialBlock {
  22979. /**
  22980. * Create a new ColorSplitterBlock
  22981. * @param name defines the block name
  22982. */
  22983. constructor(name: string);
  22984. /**
  22985. * Gets the current class name
  22986. * @returns the class name
  22987. */
  22988. getClassName(): string;
  22989. /**
  22990. * Gets the rgba component (input)
  22991. */
  22992. get rgba(): NodeMaterialConnectionPoint;
  22993. /**
  22994. * Gets the rgb component (input)
  22995. */
  22996. get rgbIn(): NodeMaterialConnectionPoint;
  22997. /**
  22998. * Gets the rgb component (output)
  22999. */
  23000. get rgbOut(): NodeMaterialConnectionPoint;
  23001. /**
  23002. * Gets the r component (output)
  23003. */
  23004. get r(): NodeMaterialConnectionPoint;
  23005. /**
  23006. * Gets the g component (output)
  23007. */
  23008. get g(): NodeMaterialConnectionPoint;
  23009. /**
  23010. * Gets the b component (output)
  23011. */
  23012. get b(): NodeMaterialConnectionPoint;
  23013. /**
  23014. * Gets the a component (output)
  23015. */
  23016. get a(): NodeMaterialConnectionPoint;
  23017. protected _inputRename(name: string): string;
  23018. protected _outputRename(name: string): string;
  23019. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23020. }
  23021. }
  23022. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23026. import { Scene } from "babylonjs/scene";
  23027. /**
  23028. * Operations supported by the Trigonometry block
  23029. */
  23030. export enum TrigonometryBlockOperations {
  23031. /** Cos */
  23032. Cos = 0,
  23033. /** Sin */
  23034. Sin = 1,
  23035. /** Abs */
  23036. Abs = 2,
  23037. /** Exp */
  23038. Exp = 3,
  23039. /** Exp2 */
  23040. Exp2 = 4,
  23041. /** Round */
  23042. Round = 5,
  23043. /** Floor */
  23044. Floor = 6,
  23045. /** Ceiling */
  23046. Ceiling = 7,
  23047. /** Square root */
  23048. Sqrt = 8,
  23049. /** Log */
  23050. Log = 9,
  23051. /** Tangent */
  23052. Tan = 10,
  23053. /** Arc tangent */
  23054. ArcTan = 11,
  23055. /** Arc cosinus */
  23056. ArcCos = 12,
  23057. /** Arc sinus */
  23058. ArcSin = 13,
  23059. /** Fraction */
  23060. Fract = 14,
  23061. /** Sign */
  23062. Sign = 15,
  23063. /** To radians (from degrees) */
  23064. Radians = 16,
  23065. /** To degrees (from radians) */
  23066. Degrees = 17
  23067. }
  23068. /**
  23069. * Block used to apply trigonometry operation to floats
  23070. */
  23071. export class TrigonometryBlock extends NodeMaterialBlock {
  23072. /**
  23073. * Gets or sets the operation applied by the block
  23074. */
  23075. operation: TrigonometryBlockOperations;
  23076. /**
  23077. * Creates a new TrigonometryBlock
  23078. * @param name defines the block name
  23079. */
  23080. constructor(name: string);
  23081. /**
  23082. * Gets the current class name
  23083. * @returns the class name
  23084. */
  23085. getClassName(): string;
  23086. /**
  23087. * Gets the input component
  23088. */
  23089. get input(): NodeMaterialConnectionPoint;
  23090. /**
  23091. * Gets the output component
  23092. */
  23093. get output(): NodeMaterialConnectionPoint;
  23094. protected _buildBlock(state: NodeMaterialBuildState): this;
  23095. serialize(): any;
  23096. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23097. protected _dumpPropertiesCode(): string;
  23098. }
  23099. }
  23100. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23102. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23103. import { Scene } from "babylonjs/scene";
  23104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23105. import { Matrix } from "babylonjs/Maths/math.vector";
  23106. import { Mesh } from "babylonjs/Meshes/mesh";
  23107. import { Engine } from "babylonjs/Engines/engine";
  23108. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23109. import { Observable } from "babylonjs/Misc/observable";
  23110. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23111. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23112. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23113. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23114. import { Nullable } from "babylonjs/types";
  23115. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23116. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23117. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23118. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23119. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23120. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23121. import { Effect } from "babylonjs/Materials/effect";
  23122. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23123. import { Camera } from "babylonjs/Cameras/camera";
  23124. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23125. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23126. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23127. /**
  23128. * Interface used to configure the node material editor
  23129. */
  23130. export interface INodeMaterialEditorOptions {
  23131. /** Define the URl to load node editor script */
  23132. editorURL?: string;
  23133. }
  23134. /** @hidden */
  23135. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23136. NORMAL: boolean;
  23137. TANGENT: boolean;
  23138. UV1: boolean;
  23139. /** BONES */
  23140. NUM_BONE_INFLUENCERS: number;
  23141. BonesPerMesh: number;
  23142. BONETEXTURE: boolean;
  23143. /** MORPH TARGETS */
  23144. MORPHTARGETS: boolean;
  23145. MORPHTARGETS_NORMAL: boolean;
  23146. MORPHTARGETS_TANGENT: boolean;
  23147. MORPHTARGETS_UV: boolean;
  23148. NUM_MORPH_INFLUENCERS: number;
  23149. /** IMAGE PROCESSING */
  23150. IMAGEPROCESSING: boolean;
  23151. VIGNETTE: boolean;
  23152. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23153. VIGNETTEBLENDMODEOPAQUE: boolean;
  23154. TONEMAPPING: boolean;
  23155. TONEMAPPING_ACES: boolean;
  23156. CONTRAST: boolean;
  23157. EXPOSURE: boolean;
  23158. COLORCURVES: boolean;
  23159. COLORGRADING: boolean;
  23160. COLORGRADING3D: boolean;
  23161. SAMPLER3DGREENDEPTH: boolean;
  23162. SAMPLER3DBGRMAP: boolean;
  23163. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23164. /** MISC. */
  23165. BUMPDIRECTUV: number;
  23166. constructor();
  23167. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23168. }
  23169. /**
  23170. * Class used to configure NodeMaterial
  23171. */
  23172. export interface INodeMaterialOptions {
  23173. /**
  23174. * Defines if blocks should emit comments
  23175. */
  23176. emitComments: boolean;
  23177. }
  23178. /**
  23179. * Class used to create a node based material built by assembling shader blocks
  23180. */
  23181. export class NodeMaterial extends PushMaterial {
  23182. private static _BuildIdGenerator;
  23183. private _options;
  23184. private _vertexCompilationState;
  23185. private _fragmentCompilationState;
  23186. private _sharedData;
  23187. private _buildId;
  23188. private _buildWasSuccessful;
  23189. private _cachedWorldViewMatrix;
  23190. private _cachedWorldViewProjectionMatrix;
  23191. private _optimizers;
  23192. private _animationFrame;
  23193. /** Define the Url to load node editor script */
  23194. static EditorURL: string;
  23195. /** Define the Url to load snippets */
  23196. static SnippetUrl: string;
  23197. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23198. static IgnoreTexturesAtLoadTime: boolean;
  23199. private BJSNODEMATERIALEDITOR;
  23200. /** Get the inspector from bundle or global */
  23201. private _getGlobalNodeMaterialEditor;
  23202. /**
  23203. * Snippet ID if the material was created from the snippet server
  23204. */
  23205. snippetId: string;
  23206. /**
  23207. * Gets or sets data used by visual editor
  23208. * @see https://nme.babylonjs.com
  23209. */
  23210. editorData: any;
  23211. /**
  23212. * 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)
  23213. */
  23214. ignoreAlpha: boolean;
  23215. /**
  23216. * Defines the maximum number of lights that can be used in the material
  23217. */
  23218. maxSimultaneousLights: number;
  23219. /**
  23220. * Observable raised when the material is built
  23221. */
  23222. onBuildObservable: Observable<NodeMaterial>;
  23223. /**
  23224. * Gets or sets the root nodes of the material vertex shader
  23225. */
  23226. _vertexOutputNodes: NodeMaterialBlock[];
  23227. /**
  23228. * Gets or sets the root nodes of the material fragment (pixel) shader
  23229. */
  23230. _fragmentOutputNodes: NodeMaterialBlock[];
  23231. /** Gets or sets options to control the node material overall behavior */
  23232. get options(): INodeMaterialOptions;
  23233. set options(options: INodeMaterialOptions);
  23234. /**
  23235. * Default configuration related to image processing available in the standard Material.
  23236. */
  23237. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23238. /**
  23239. * Gets the image processing configuration used either in this material.
  23240. */
  23241. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23242. /**
  23243. * Sets the Default image processing configuration used either in the this material.
  23244. *
  23245. * If sets to null, the scene one is in use.
  23246. */
  23247. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23248. /**
  23249. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23250. */
  23251. attachedBlocks: NodeMaterialBlock[];
  23252. /**
  23253. * Specifies the mode of the node material
  23254. * @hidden
  23255. */
  23256. _mode: NodeMaterialModes;
  23257. /**
  23258. * Gets the mode property
  23259. */
  23260. get mode(): NodeMaterialModes;
  23261. /**
  23262. * Create a new node based material
  23263. * @param name defines the material name
  23264. * @param scene defines the hosting scene
  23265. * @param options defines creation option
  23266. */
  23267. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23268. /**
  23269. * Gets the current class name of the material e.g. "NodeMaterial"
  23270. * @returns the class name
  23271. */
  23272. getClassName(): string;
  23273. /**
  23274. * Keep track of the image processing observer to allow dispose and replace.
  23275. */
  23276. private _imageProcessingObserver;
  23277. /**
  23278. * Attaches a new image processing configuration to the Standard Material.
  23279. * @param configuration
  23280. */
  23281. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23282. /**
  23283. * Get a block by its name
  23284. * @param name defines the name of the block to retrieve
  23285. * @returns the required block or null if not found
  23286. */
  23287. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23288. /**
  23289. * Get a block by its name
  23290. * @param predicate defines the predicate used to find the good candidate
  23291. * @returns the required block or null if not found
  23292. */
  23293. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23294. /**
  23295. * Get an input block by its name
  23296. * @param predicate defines the predicate used to find the good candidate
  23297. * @returns the required input block or null if not found
  23298. */
  23299. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23300. /**
  23301. * Gets the list of input blocks attached to this material
  23302. * @returns an array of InputBlocks
  23303. */
  23304. getInputBlocks(): InputBlock[];
  23305. /**
  23306. * Adds a new optimizer to the list of optimizers
  23307. * @param optimizer defines the optimizers to add
  23308. * @returns the current material
  23309. */
  23310. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23311. /**
  23312. * Remove an optimizer from the list of optimizers
  23313. * @param optimizer defines the optimizers to remove
  23314. * @returns the current material
  23315. */
  23316. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23317. /**
  23318. * Add a new block to the list of output nodes
  23319. * @param node defines the node to add
  23320. * @returns the current material
  23321. */
  23322. addOutputNode(node: NodeMaterialBlock): this;
  23323. /**
  23324. * Remove a block from the list of root nodes
  23325. * @param node defines the node to remove
  23326. * @returns the current material
  23327. */
  23328. removeOutputNode(node: NodeMaterialBlock): this;
  23329. private _addVertexOutputNode;
  23330. private _removeVertexOutputNode;
  23331. private _addFragmentOutputNode;
  23332. private _removeFragmentOutputNode;
  23333. /**
  23334. * Specifies if the material will require alpha blending
  23335. * @returns a boolean specifying if alpha blending is needed
  23336. */
  23337. needAlphaBlending(): boolean;
  23338. /**
  23339. * Specifies if this material should be rendered in alpha test mode
  23340. * @returns a boolean specifying if an alpha test is needed.
  23341. */
  23342. needAlphaTesting(): boolean;
  23343. private _initializeBlock;
  23344. private _resetDualBlocks;
  23345. /**
  23346. * Remove a block from the current node material
  23347. * @param block defines the block to remove
  23348. */
  23349. removeBlock(block: NodeMaterialBlock): void;
  23350. /**
  23351. * Build the material and generates the inner effect
  23352. * @param verbose defines if the build should log activity
  23353. */
  23354. build(verbose?: boolean): void;
  23355. /**
  23356. * Runs an otpimization phase to try to improve the shader code
  23357. */
  23358. optimize(): void;
  23359. private _prepareDefinesForAttributes;
  23360. /**
  23361. * Create a post process from the material
  23362. * @param camera The camera to apply the render pass to.
  23363. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23365. * @param engine The engine which the post process will be applied. (default: current engine)
  23366. * @param reusable If the post process can be reused on the same frame. (default: false)
  23367. * @param textureType Type of textures used when performing the post process. (default: 0)
  23368. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23369. * @returns the post process created
  23370. */
  23371. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23372. /**
  23373. * Create the post process effect from the material
  23374. * @param postProcess The post process to create the effect for
  23375. */
  23376. createEffectForPostProcess(postProcess: PostProcess): void;
  23377. private _createEffectForPostProcess;
  23378. /**
  23379. * Create a new procedural texture based on this node material
  23380. * @param size defines the size of the texture
  23381. * @param scene defines the hosting scene
  23382. * @returns the new procedural texture attached to this node material
  23383. */
  23384. createProceduralTexture(size: number | {
  23385. width: number;
  23386. height: number;
  23387. layers?: number;
  23388. }, scene: Scene): Nullable<ProceduralTexture>;
  23389. private _createEffectForParticles;
  23390. private _checkInternals;
  23391. /**
  23392. * Create the effect to be used as the custom effect for a particle system
  23393. * @param particleSystem Particle system to create the effect for
  23394. * @param onCompiled defines a function to call when the effect creation is successful
  23395. * @param onError defines a function to call when the effect creation has failed
  23396. */
  23397. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23398. private _processDefines;
  23399. /**
  23400. * Get if the submesh is ready to be used and all its information available.
  23401. * Child classes can use it to update shaders
  23402. * @param mesh defines the mesh to check
  23403. * @param subMesh defines which submesh to check
  23404. * @param useInstances specifies that instances should be used
  23405. * @returns a boolean indicating that the submesh is ready or not
  23406. */
  23407. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23408. /**
  23409. * Get a string representing the shaders built by the current node graph
  23410. */
  23411. get compiledShaders(): string;
  23412. /**
  23413. * Binds the world matrix to the material
  23414. * @param world defines the world transformation matrix
  23415. */
  23416. bindOnlyWorldMatrix(world: Matrix): void;
  23417. /**
  23418. * Binds the submesh to this material by preparing the effect and shader to draw
  23419. * @param world defines the world transformation matrix
  23420. * @param mesh defines the mesh containing the submesh
  23421. * @param subMesh defines the submesh to bind the material to
  23422. */
  23423. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23424. /**
  23425. * Gets the active textures from the material
  23426. * @returns an array of textures
  23427. */
  23428. getActiveTextures(): BaseTexture[];
  23429. /**
  23430. * Gets the list of texture blocks
  23431. * @returns an array of texture blocks
  23432. */
  23433. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23434. /**
  23435. * Specifies if the material uses a texture
  23436. * @param texture defines the texture to check against the material
  23437. * @returns a boolean specifying if the material uses the texture
  23438. */
  23439. hasTexture(texture: BaseTexture): boolean;
  23440. /**
  23441. * Disposes the material
  23442. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23443. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23444. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23445. */
  23446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23447. /** Creates the node editor window. */
  23448. private _createNodeEditor;
  23449. /**
  23450. * Launch the node material editor
  23451. * @param config Define the configuration of the editor
  23452. * @return a promise fulfilled when the node editor is visible
  23453. */
  23454. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23455. /**
  23456. * Clear the current material
  23457. */
  23458. clear(): void;
  23459. /**
  23460. * Clear the current material and set it to a default state
  23461. */
  23462. setToDefault(): void;
  23463. /**
  23464. * Clear the current material and set it to a default state for post process
  23465. */
  23466. setToDefaultPostProcess(): void;
  23467. /**
  23468. * Clear the current material and set it to a default state for procedural texture
  23469. */
  23470. setToDefaultProceduralTexture(): void;
  23471. /**
  23472. * Clear the current material and set it to a default state for particle
  23473. */
  23474. setToDefaultParticle(): void;
  23475. /**
  23476. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23477. * @param url defines the url to load from
  23478. * @returns a promise that will fullfil when the material is fully loaded
  23479. */
  23480. loadAsync(url: string): Promise<void>;
  23481. private _gatherBlocks;
  23482. /**
  23483. * Generate a string containing the code declaration required to create an equivalent of this material
  23484. * @returns a string
  23485. */
  23486. generateCode(): string;
  23487. /**
  23488. * Serializes this material in a JSON representation
  23489. * @returns the serialized material object
  23490. */
  23491. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23492. private _restoreConnections;
  23493. /**
  23494. * Clear the current graph and load a new one from a serialization object
  23495. * @param source defines the JSON representation of the material
  23496. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23497. * @param merge defines whether or not the source must be merged or replace the current content
  23498. */
  23499. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23500. /**
  23501. * Makes a duplicate of the current material.
  23502. * @param name - name to use for the new material.
  23503. */
  23504. clone(name: string): NodeMaterial;
  23505. /**
  23506. * Creates a node material from parsed material data
  23507. * @param source defines the JSON representation of the material
  23508. * @param scene defines the hosting scene
  23509. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23510. * @returns a new node material
  23511. */
  23512. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23513. /**
  23514. * Creates a node material from a snippet saved in a remote file
  23515. * @param name defines the name of the material to create
  23516. * @param url defines the url to load from
  23517. * @param scene defines the hosting scene
  23518. * @returns a promise that will resolve to the new node material
  23519. */
  23520. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23521. /**
  23522. * Creates a node material from a snippet saved by the node material editor
  23523. * @param snippetId defines the snippet to load
  23524. * @param scene defines the hosting scene
  23525. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23526. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23527. * @returns a promise that will resolve to the new node material
  23528. */
  23529. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23530. /**
  23531. * Creates a new node material set to default basic configuration
  23532. * @param name defines the name of the material
  23533. * @param scene defines the hosting scene
  23534. * @returns a new NodeMaterial
  23535. */
  23536. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23537. }
  23538. }
  23539. declare module "babylonjs/PostProcesses/postProcess" {
  23540. import { Nullable } from "babylonjs/types";
  23541. import { SmartArray } from "babylonjs/Misc/smartArray";
  23542. import { Observable } from "babylonjs/Misc/observable";
  23543. import { Vector2 } from "babylonjs/Maths/math.vector";
  23544. import { Camera } from "babylonjs/Cameras/camera";
  23545. import { Effect } from "babylonjs/Materials/effect";
  23546. import "babylonjs/Shaders/postprocess.vertex";
  23547. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23548. import { Engine } from "babylonjs/Engines/engine";
  23549. import { Color4 } from "babylonjs/Maths/math.color";
  23550. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23551. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23552. import { Scene } from "babylonjs/scene";
  23553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23554. /**
  23555. * Size options for a post process
  23556. */
  23557. export type PostProcessOptions = {
  23558. width: number;
  23559. height: number;
  23560. };
  23561. /**
  23562. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23563. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23564. */
  23565. export class PostProcess {
  23566. /**
  23567. * Gets or sets the unique id of the post process
  23568. */
  23569. uniqueId: number;
  23570. /** Name of the PostProcess. */
  23571. name: string;
  23572. /**
  23573. * Width of the texture to apply the post process on
  23574. */
  23575. width: number;
  23576. /**
  23577. * Height of the texture to apply the post process on
  23578. */
  23579. height: number;
  23580. /**
  23581. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23582. */
  23583. nodeMaterialSource: Nullable<NodeMaterial>;
  23584. /**
  23585. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23586. * @hidden
  23587. */
  23588. _outputTexture: Nullable<InternalTexture>;
  23589. /**
  23590. * Sampling mode used by the shader
  23591. * See https://doc.babylonjs.com/classes/3.1/texture
  23592. */
  23593. renderTargetSamplingMode: number;
  23594. /**
  23595. * Clear color to use when screen clearing
  23596. */
  23597. clearColor: Color4;
  23598. /**
  23599. * If the buffer needs to be cleared before applying the post process. (default: true)
  23600. * Should be set to false if shader will overwrite all previous pixels.
  23601. */
  23602. autoClear: boolean;
  23603. /**
  23604. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23605. */
  23606. alphaMode: number;
  23607. /**
  23608. * Sets the setAlphaBlendConstants of the babylon engine
  23609. */
  23610. alphaConstants: Color4;
  23611. /**
  23612. * Animations to be used for the post processing
  23613. */
  23614. animations: import("babylonjs/Animations/animation").Animation[];
  23615. /**
  23616. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23617. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23618. */
  23619. enablePixelPerfectMode: boolean;
  23620. /**
  23621. * Force the postprocess to be applied without taking in account viewport
  23622. */
  23623. forceFullscreenViewport: boolean;
  23624. /**
  23625. * List of inspectable custom properties (used by the Inspector)
  23626. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23627. */
  23628. inspectableCustomProperties: IInspectable[];
  23629. /**
  23630. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23631. *
  23632. * | Value | Type | Description |
  23633. * | ----- | ----------------------------------- | ----------- |
  23634. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23635. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23636. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23637. *
  23638. */
  23639. scaleMode: number;
  23640. /**
  23641. * Force textures to be a power of two (default: false)
  23642. */
  23643. alwaysForcePOT: boolean;
  23644. private _samples;
  23645. /**
  23646. * Number of sample textures (default: 1)
  23647. */
  23648. get samples(): number;
  23649. set samples(n: number);
  23650. /**
  23651. * Modify the scale of the post process to be the same as the viewport (default: false)
  23652. */
  23653. adaptScaleToCurrentViewport: boolean;
  23654. private _camera;
  23655. protected _scene: Scene;
  23656. private _engine;
  23657. private _options;
  23658. private _reusable;
  23659. private _textureType;
  23660. private _textureFormat;
  23661. /**
  23662. * Smart array of input and output textures for the post process.
  23663. * @hidden
  23664. */
  23665. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23666. /**
  23667. * The index in _textures that corresponds to the output texture.
  23668. * @hidden
  23669. */
  23670. _currentRenderTextureInd: number;
  23671. private _effect;
  23672. private _samplers;
  23673. private _fragmentUrl;
  23674. private _vertexUrl;
  23675. private _parameters;
  23676. private _scaleRatio;
  23677. protected _indexParameters: any;
  23678. private _shareOutputWithPostProcess;
  23679. private _texelSize;
  23680. private _forcedOutputTexture;
  23681. /**
  23682. * Returns the fragment url or shader name used in the post process.
  23683. * @returns the fragment url or name in the shader store.
  23684. */
  23685. getEffectName(): string;
  23686. /**
  23687. * An event triggered when the postprocess is activated.
  23688. */
  23689. onActivateObservable: Observable<Camera>;
  23690. private _onActivateObserver;
  23691. /**
  23692. * A function that is added to the onActivateObservable
  23693. */
  23694. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23695. /**
  23696. * An event triggered when the postprocess changes its size.
  23697. */
  23698. onSizeChangedObservable: Observable<PostProcess>;
  23699. private _onSizeChangedObserver;
  23700. /**
  23701. * A function that is added to the onSizeChangedObservable
  23702. */
  23703. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23704. /**
  23705. * An event triggered when the postprocess applies its effect.
  23706. */
  23707. onApplyObservable: Observable<Effect>;
  23708. private _onApplyObserver;
  23709. /**
  23710. * A function that is added to the onApplyObservable
  23711. */
  23712. set onApply(callback: (effect: Effect) => void);
  23713. /**
  23714. * An event triggered before rendering the postprocess
  23715. */
  23716. onBeforeRenderObservable: Observable<Effect>;
  23717. private _onBeforeRenderObserver;
  23718. /**
  23719. * A function that is added to the onBeforeRenderObservable
  23720. */
  23721. set onBeforeRender(callback: (effect: Effect) => void);
  23722. /**
  23723. * An event triggered after rendering the postprocess
  23724. */
  23725. onAfterRenderObservable: Observable<Effect>;
  23726. private _onAfterRenderObserver;
  23727. /**
  23728. * A function that is added to the onAfterRenderObservable
  23729. */
  23730. set onAfterRender(callback: (efect: Effect) => void);
  23731. /**
  23732. * 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
  23733. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23734. */
  23735. get inputTexture(): InternalTexture;
  23736. set inputTexture(value: InternalTexture);
  23737. /**
  23738. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23739. * the only way to unset it is to use this function to restore its internal state
  23740. */
  23741. restoreDefaultInputTexture(): void;
  23742. /**
  23743. * Gets the camera which post process is applied to.
  23744. * @returns The camera the post process is applied to.
  23745. */
  23746. getCamera(): Camera;
  23747. /**
  23748. * Gets the texel size of the postprocess.
  23749. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23750. */
  23751. get texelSize(): Vector2;
  23752. /**
  23753. * Creates a new instance PostProcess
  23754. * @param name The name of the PostProcess.
  23755. * @param fragmentUrl The url of the fragment shader to be used.
  23756. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23757. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23758. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23759. * @param camera The camera to apply the render pass to.
  23760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23761. * @param engine The engine which the post process will be applied. (default: current engine)
  23762. * @param reusable If the post process can be reused on the same frame. (default: false)
  23763. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23764. * @param textureType Type of textures used when performing the post process. (default: 0)
  23765. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23766. * @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
  23767. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23768. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23769. */
  23770. 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);
  23771. /**
  23772. * Gets a string identifying the name of the class
  23773. * @returns "PostProcess" string
  23774. */
  23775. getClassName(): string;
  23776. /**
  23777. * Gets the engine which this post process belongs to.
  23778. * @returns The engine the post process was enabled with.
  23779. */
  23780. getEngine(): Engine;
  23781. /**
  23782. * The effect that is created when initializing the post process.
  23783. * @returns The created effect corresponding the the postprocess.
  23784. */
  23785. getEffect(): Effect;
  23786. /**
  23787. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23788. * @param postProcess The post process to share the output with.
  23789. * @returns This post process.
  23790. */
  23791. shareOutputWith(postProcess: PostProcess): PostProcess;
  23792. /**
  23793. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23794. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23795. */
  23796. useOwnOutput(): void;
  23797. /**
  23798. * Updates the effect with the current post process compile time values and recompiles the shader.
  23799. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23800. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23801. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23802. * @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
  23803. * @param onCompiled Called when the shader has been compiled.
  23804. * @param onError Called if there is an error when compiling a shader.
  23805. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23806. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23807. */
  23808. 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;
  23809. /**
  23810. * The post process is reusable if it can be used multiple times within one frame.
  23811. * @returns If the post process is reusable
  23812. */
  23813. isReusable(): boolean;
  23814. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23815. markTextureDirty(): void;
  23816. /**
  23817. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23818. * 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.
  23819. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23820. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23821. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23822. * @returns The target texture that was bound to be written to.
  23823. */
  23824. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23825. /**
  23826. * If the post process is supported.
  23827. */
  23828. get isSupported(): boolean;
  23829. /**
  23830. * The aspect ratio of the output texture.
  23831. */
  23832. get aspectRatio(): number;
  23833. /**
  23834. * Get a value indicating if the post-process is ready to be used
  23835. * @returns true if the post-process is ready (shader is compiled)
  23836. */
  23837. isReady(): boolean;
  23838. /**
  23839. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23840. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23841. */
  23842. apply(): Nullable<Effect>;
  23843. private _disposeTextures;
  23844. /**
  23845. * Disposes the post process.
  23846. * @param camera The camera to dispose the post process on.
  23847. */
  23848. dispose(camera?: Camera): void;
  23849. /**
  23850. * Serializes the particle system to a JSON object
  23851. * @returns the JSON object
  23852. */
  23853. serialize(): any;
  23854. /**
  23855. * Creates a material from parsed material data
  23856. * @param parsedPostProcess defines parsed post process data
  23857. * @param scene defines the hosting scene
  23858. * @param rootUrl defines the root URL to use to load textures
  23859. * @returns a new post process
  23860. */
  23861. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23862. }
  23863. }
  23864. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23865. /** @hidden */
  23866. export var kernelBlurVaryingDeclaration: {
  23867. name: string;
  23868. shader: string;
  23869. };
  23870. }
  23871. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23872. /** @hidden */
  23873. export var kernelBlurFragment: {
  23874. name: string;
  23875. shader: string;
  23876. };
  23877. }
  23878. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23879. /** @hidden */
  23880. export var kernelBlurFragment2: {
  23881. name: string;
  23882. shader: string;
  23883. };
  23884. }
  23885. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23886. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23887. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23888. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23889. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23890. /** @hidden */
  23891. export var kernelBlurPixelShader: {
  23892. name: string;
  23893. shader: string;
  23894. };
  23895. }
  23896. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23897. /** @hidden */
  23898. export var kernelBlurVertex: {
  23899. name: string;
  23900. shader: string;
  23901. };
  23902. }
  23903. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23904. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23905. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23906. /** @hidden */
  23907. export var kernelBlurVertexShader: {
  23908. name: string;
  23909. shader: string;
  23910. };
  23911. }
  23912. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23913. import { Vector2 } from "babylonjs/Maths/math.vector";
  23914. import { Nullable } from "babylonjs/types";
  23915. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23916. import { Camera } from "babylonjs/Cameras/camera";
  23917. import { Effect } from "babylonjs/Materials/effect";
  23918. import { Engine } from "babylonjs/Engines/engine";
  23919. import "babylonjs/Shaders/kernelBlur.fragment";
  23920. import "babylonjs/Shaders/kernelBlur.vertex";
  23921. import { Scene } from "babylonjs/scene";
  23922. /**
  23923. * The Blur Post Process which blurs an image based on a kernel and direction.
  23924. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23925. */
  23926. export class BlurPostProcess extends PostProcess {
  23927. private blockCompilation;
  23928. protected _kernel: number;
  23929. protected _idealKernel: number;
  23930. protected _packedFloat: boolean;
  23931. private _staticDefines;
  23932. /** The direction in which to blur the image. */
  23933. direction: Vector2;
  23934. /**
  23935. * Sets the length in pixels of the blur sample region
  23936. */
  23937. set kernel(v: number);
  23938. /**
  23939. * Gets the length in pixels of the blur sample region
  23940. */
  23941. get kernel(): number;
  23942. /**
  23943. * Sets wether or not the blur needs to unpack/repack floats
  23944. */
  23945. set packedFloat(v: boolean);
  23946. /**
  23947. * Gets wether or not the blur is unpacking/repacking floats
  23948. */
  23949. get packedFloat(): boolean;
  23950. /**
  23951. * Gets a string identifying the name of the class
  23952. * @returns "BlurPostProcess" string
  23953. */
  23954. getClassName(): string;
  23955. /**
  23956. * Creates a new instance BlurPostProcess
  23957. * @param name The name of the effect.
  23958. * @param direction The direction in which to blur the image.
  23959. * @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.
  23960. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23961. * @param camera The camera to apply the render pass to.
  23962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23963. * @param engine The engine which the post process will be applied. (default: current engine)
  23964. * @param reusable If the post process can be reused on the same frame. (default: false)
  23965. * @param textureType Type of textures used when performing the post process. (default: 0)
  23966. * @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)
  23967. */
  23968. 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);
  23969. /**
  23970. * Updates the effect with the current post process compile time values and recompiles the shader.
  23971. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23972. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23973. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23974. * @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
  23975. * @param onCompiled Called when the shader has been compiled.
  23976. * @param onError Called if there is an error when compiling a shader.
  23977. */
  23978. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23979. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23980. /**
  23981. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23982. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23983. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23984. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23985. * The gaps between physical kernels are compensated for in the weighting of the samples
  23986. * @param idealKernel Ideal blur kernel.
  23987. * @return Nearest best kernel.
  23988. */
  23989. protected _nearestBestKernel(idealKernel: number): number;
  23990. /**
  23991. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23992. * @param x The point on the Gaussian distribution to sample.
  23993. * @return the value of the Gaussian function at x.
  23994. */
  23995. protected _gaussianWeight(x: number): number;
  23996. /**
  23997. * Generates a string that can be used as a floating point number in GLSL.
  23998. * @param x Value to print.
  23999. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24000. * @return GLSL float string.
  24001. */
  24002. protected _glslFloat(x: number, decimalFigures?: number): string;
  24003. /** @hidden */
  24004. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24005. }
  24006. }
  24007. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24008. import { Scene } from "babylonjs/scene";
  24009. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24010. import { Plane } from "babylonjs/Maths/math.plane";
  24011. /**
  24012. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24013. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24014. * You can then easily use it as a reflectionTexture on a flat surface.
  24015. * In case the surface is not a plane, please consider relying on reflection probes.
  24016. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24017. */
  24018. export class MirrorTexture extends RenderTargetTexture {
  24019. private scene;
  24020. /**
  24021. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24022. * 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.
  24023. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24024. */
  24025. mirrorPlane: Plane;
  24026. /**
  24027. * Define the blur ratio used to blur the reflection if needed.
  24028. */
  24029. set blurRatio(value: number);
  24030. get blurRatio(): number;
  24031. /**
  24032. * Define the adaptive blur kernel used to blur the reflection if needed.
  24033. * This will autocompute the closest best match for the `blurKernel`
  24034. */
  24035. set adaptiveBlurKernel(value: number);
  24036. /**
  24037. * Define the blur kernel used to blur the reflection if needed.
  24038. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24039. */
  24040. set blurKernel(value: number);
  24041. /**
  24042. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24043. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24044. */
  24045. set blurKernelX(value: number);
  24046. get blurKernelX(): number;
  24047. /**
  24048. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24049. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24050. */
  24051. set blurKernelY(value: number);
  24052. get blurKernelY(): number;
  24053. private _autoComputeBlurKernel;
  24054. protected _onRatioRescale(): void;
  24055. private _updateGammaSpace;
  24056. private _imageProcessingConfigChangeObserver;
  24057. private _transformMatrix;
  24058. private _mirrorMatrix;
  24059. private _savedViewMatrix;
  24060. private _blurX;
  24061. private _blurY;
  24062. private _adaptiveBlurKernel;
  24063. private _blurKernelX;
  24064. private _blurKernelY;
  24065. private _blurRatio;
  24066. /**
  24067. * Instantiates a Mirror Texture.
  24068. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24069. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24070. * You can then easily use it as a reflectionTexture on a flat surface.
  24071. * In case the surface is not a plane, please consider relying on reflection probes.
  24072. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24073. * @param name
  24074. * @param size
  24075. * @param scene
  24076. * @param generateMipMaps
  24077. * @param type
  24078. * @param samplingMode
  24079. * @param generateDepthBuffer
  24080. */
  24081. constructor(name: string, size: number | {
  24082. width: number;
  24083. height: number;
  24084. } | {
  24085. ratio: number;
  24086. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24087. private _preparePostProcesses;
  24088. /**
  24089. * Clone the mirror texture.
  24090. * @returns the cloned texture
  24091. */
  24092. clone(): MirrorTexture;
  24093. /**
  24094. * Serialize the texture to a JSON representation you could use in Parse later on
  24095. * @returns the serialized JSON representation
  24096. */
  24097. serialize(): any;
  24098. /**
  24099. * Dispose the texture and release its associated resources.
  24100. */
  24101. dispose(): void;
  24102. }
  24103. }
  24104. declare module "babylonjs/Materials/Textures/texture" {
  24105. import { Observable } from "babylonjs/Misc/observable";
  24106. import { Nullable } from "babylonjs/types";
  24107. import { Matrix } from "babylonjs/Maths/math.vector";
  24108. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24109. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24110. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24111. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24112. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24113. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24114. import { Scene } from "babylonjs/scene";
  24115. /**
  24116. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24117. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24118. */
  24119. export class Texture extends BaseTexture {
  24120. /**
  24121. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24122. */
  24123. static SerializeBuffers: boolean;
  24124. /** @hidden */
  24125. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24126. /** @hidden */
  24127. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24128. /** @hidden */
  24129. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24130. /** nearest is mag = nearest and min = nearest and mip = linear */
  24131. static readonly NEAREST_SAMPLINGMODE: number;
  24132. /** nearest is mag = nearest and min = nearest and mip = linear */
  24133. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24134. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24135. static readonly BILINEAR_SAMPLINGMODE: number;
  24136. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24137. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24138. /** Trilinear is mag = linear and min = linear and mip = linear */
  24139. static readonly TRILINEAR_SAMPLINGMODE: number;
  24140. /** Trilinear is mag = linear and min = linear and mip = linear */
  24141. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24142. /** mag = nearest and min = nearest and mip = nearest */
  24143. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24144. /** mag = nearest and min = linear and mip = nearest */
  24145. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24146. /** mag = nearest and min = linear and mip = linear */
  24147. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24148. /** mag = nearest and min = linear and mip = none */
  24149. static readonly NEAREST_LINEAR: number;
  24150. /** mag = nearest and min = nearest and mip = none */
  24151. static readonly NEAREST_NEAREST: number;
  24152. /** mag = linear and min = nearest and mip = nearest */
  24153. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24154. /** mag = linear and min = nearest and mip = linear */
  24155. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24156. /** mag = linear and min = linear and mip = none */
  24157. static readonly LINEAR_LINEAR: number;
  24158. /** mag = linear and min = nearest and mip = none */
  24159. static readonly LINEAR_NEAREST: number;
  24160. /** Explicit coordinates mode */
  24161. static readonly EXPLICIT_MODE: number;
  24162. /** Spherical coordinates mode */
  24163. static readonly SPHERICAL_MODE: number;
  24164. /** Planar coordinates mode */
  24165. static readonly PLANAR_MODE: number;
  24166. /** Cubic coordinates mode */
  24167. static readonly CUBIC_MODE: number;
  24168. /** Projection coordinates mode */
  24169. static readonly PROJECTION_MODE: number;
  24170. /** Inverse Cubic coordinates mode */
  24171. static readonly SKYBOX_MODE: number;
  24172. /** Inverse Cubic coordinates mode */
  24173. static readonly INVCUBIC_MODE: number;
  24174. /** Equirectangular coordinates mode */
  24175. static readonly EQUIRECTANGULAR_MODE: number;
  24176. /** Equirectangular Fixed coordinates mode */
  24177. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24178. /** Equirectangular Fixed Mirrored coordinates mode */
  24179. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24180. /** Texture is not repeating outside of 0..1 UVs */
  24181. static readonly CLAMP_ADDRESSMODE: number;
  24182. /** Texture is repeating outside of 0..1 UVs */
  24183. static readonly WRAP_ADDRESSMODE: number;
  24184. /** Texture is repeating and mirrored */
  24185. static readonly MIRROR_ADDRESSMODE: number;
  24186. /**
  24187. * 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
  24188. */
  24189. static UseSerializedUrlIfAny: boolean;
  24190. /**
  24191. * Define the url of the texture.
  24192. */
  24193. url: Nullable<string>;
  24194. /**
  24195. * Define an offset on the texture to offset the u coordinates of the UVs
  24196. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24197. */
  24198. uOffset: number;
  24199. /**
  24200. * Define an offset on the texture to offset the v coordinates of the UVs
  24201. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24202. */
  24203. vOffset: number;
  24204. /**
  24205. * Define an offset on the texture to scale the u coordinates of the UVs
  24206. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24207. */
  24208. uScale: number;
  24209. /**
  24210. * Define an offset on the texture to scale the v coordinates of the UVs
  24211. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24212. */
  24213. vScale: number;
  24214. /**
  24215. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24216. * @see https://doc.babylonjs.com/how_to/more_materials
  24217. */
  24218. uAng: number;
  24219. /**
  24220. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24221. * @see https://doc.babylonjs.com/how_to/more_materials
  24222. */
  24223. vAng: number;
  24224. /**
  24225. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24226. * @see https://doc.babylonjs.com/how_to/more_materials
  24227. */
  24228. wAng: number;
  24229. /**
  24230. * Defines the center of rotation (U)
  24231. */
  24232. uRotationCenter: number;
  24233. /**
  24234. * Defines the center of rotation (V)
  24235. */
  24236. vRotationCenter: number;
  24237. /**
  24238. * Defines the center of rotation (W)
  24239. */
  24240. wRotationCenter: number;
  24241. /**
  24242. * Are mip maps generated for this texture or not.
  24243. */
  24244. get noMipmap(): boolean;
  24245. /**
  24246. * List of inspectable custom properties (used by the Inspector)
  24247. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24248. */
  24249. inspectableCustomProperties: Nullable<IInspectable[]>;
  24250. private _noMipmap;
  24251. /** @hidden */
  24252. _invertY: boolean;
  24253. private _rowGenerationMatrix;
  24254. private _cachedTextureMatrix;
  24255. private _projectionModeMatrix;
  24256. private _t0;
  24257. private _t1;
  24258. private _t2;
  24259. private _cachedUOffset;
  24260. private _cachedVOffset;
  24261. private _cachedUScale;
  24262. private _cachedVScale;
  24263. private _cachedUAng;
  24264. private _cachedVAng;
  24265. private _cachedWAng;
  24266. private _cachedProjectionMatrixId;
  24267. private _cachedCoordinatesMode;
  24268. /** @hidden */
  24269. protected _initialSamplingMode: number;
  24270. /** @hidden */
  24271. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24272. private _deleteBuffer;
  24273. protected _format: Nullable<number>;
  24274. private _delayedOnLoad;
  24275. private _delayedOnError;
  24276. private _mimeType?;
  24277. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24278. get mimeType(): string | undefined;
  24279. /**
  24280. * Observable triggered once the texture has been loaded.
  24281. */
  24282. onLoadObservable: Observable<Texture>;
  24283. protected _isBlocking: boolean;
  24284. /**
  24285. * Is the texture preventing material to render while loading.
  24286. * If false, a default texture will be used instead of the loading one during the preparation step.
  24287. */
  24288. set isBlocking(value: boolean);
  24289. get isBlocking(): boolean;
  24290. /**
  24291. * Get the current sampling mode associated with the texture.
  24292. */
  24293. get samplingMode(): number;
  24294. /**
  24295. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24296. */
  24297. get invertY(): boolean;
  24298. /**
  24299. * Instantiates a new texture.
  24300. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24301. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24302. * @param url defines the url of the picture to load as a texture
  24303. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24304. * @param noMipmap defines if the texture will require mip maps or not
  24305. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24306. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24307. * @param onLoad defines a callback triggered when the texture has been loaded
  24308. * @param onError defines a callback triggered when an error occurred during the loading session
  24309. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24310. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24311. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24312. * @param mimeType defines an optional mime type information
  24313. */
  24314. 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);
  24315. /**
  24316. * Update the url (and optional buffer) of this texture if url was null during construction.
  24317. * @param url the url of the texture
  24318. * @param buffer the buffer of the texture (defaults to null)
  24319. * @param onLoad callback called when the texture is loaded (defaults to null)
  24320. */
  24321. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24322. /**
  24323. * Finish the loading sequence of a texture flagged as delayed load.
  24324. * @hidden
  24325. */
  24326. delayLoad(): void;
  24327. private _prepareRowForTextureGeneration;
  24328. /**
  24329. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24330. * @returns the transform matrix of the texture.
  24331. */
  24332. getTextureMatrix(uBase?: number): Matrix;
  24333. /**
  24334. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24335. * @returns The reflection texture transform
  24336. */
  24337. getReflectionTextureMatrix(): Matrix;
  24338. /**
  24339. * Clones the texture.
  24340. * @returns the cloned texture
  24341. */
  24342. clone(): Texture;
  24343. /**
  24344. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24345. * @returns The JSON representation of the texture
  24346. */
  24347. serialize(): any;
  24348. /**
  24349. * Get the current class name of the texture useful for serialization or dynamic coding.
  24350. * @returns "Texture"
  24351. */
  24352. getClassName(): string;
  24353. /**
  24354. * Dispose the texture and release its associated resources.
  24355. */
  24356. dispose(): void;
  24357. /**
  24358. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24359. * @param parsedTexture Define the JSON representation of the texture
  24360. * @param scene Define the scene the parsed texture should be instantiated in
  24361. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24362. * @returns The parsed texture if successful
  24363. */
  24364. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24365. /**
  24366. * Creates a texture from its base 64 representation.
  24367. * @param data Define the base64 payload without the data: prefix
  24368. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24369. * @param scene Define the scene the texture should belong to
  24370. * @param noMipmap Forces the texture to not create mip map information if true
  24371. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24372. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24373. * @param onLoad define a callback triggered when the texture has been loaded
  24374. * @param onError define a callback triggered when an error occurred during the loading session
  24375. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24376. * @returns the created texture
  24377. */
  24378. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24379. /**
  24380. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24381. * @param data Define the base64 payload without the data: prefix
  24382. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24383. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24384. * @param scene Define the scene the texture should belong to
  24385. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24386. * @param noMipmap Forces the texture to not create mip map information if true
  24387. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24388. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24389. * @param onLoad define a callback triggered when the texture has been loaded
  24390. * @param onError define a callback triggered when an error occurred during the loading session
  24391. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24392. * @returns the created texture
  24393. */
  24394. 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;
  24395. }
  24396. }
  24397. declare module "babylonjs/PostProcesses/postProcessManager" {
  24398. import { Nullable } from "babylonjs/types";
  24399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24400. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24401. import { Scene } from "babylonjs/scene";
  24402. /**
  24403. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24404. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24405. */
  24406. export class PostProcessManager {
  24407. private _scene;
  24408. private _indexBuffer;
  24409. private _vertexBuffers;
  24410. /**
  24411. * Creates a new instance PostProcess
  24412. * @param scene The scene that the post process is associated with.
  24413. */
  24414. constructor(scene: Scene);
  24415. private _prepareBuffers;
  24416. private _buildIndexBuffer;
  24417. /**
  24418. * Rebuilds the vertex buffers of the manager.
  24419. * @hidden
  24420. */
  24421. _rebuild(): void;
  24422. /**
  24423. * Prepares a frame to be run through a post process.
  24424. * @param sourceTexture The input texture to the post procesess. (default: null)
  24425. * @param postProcesses An array of post processes to be run. (default: null)
  24426. * @returns True if the post processes were able to be run.
  24427. * @hidden
  24428. */
  24429. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24430. /**
  24431. * Manually render a set of post processes to a texture.
  24432. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24433. * @param postProcesses An array of post processes to be run.
  24434. * @param targetTexture The target texture to render to.
  24435. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24436. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24437. * @param lodLevel defines which lod of the texture to render to
  24438. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24439. */
  24440. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24441. /**
  24442. * Finalize the result of the output of the postprocesses.
  24443. * @param doNotPresent If true the result will not be displayed to the screen.
  24444. * @param targetTexture The target texture to render to.
  24445. * @param faceIndex The index of the face to bind the target texture to.
  24446. * @param postProcesses The array of post processes to render.
  24447. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24448. * @hidden
  24449. */
  24450. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24451. /**
  24452. * Disposes of the post process manager.
  24453. */
  24454. dispose(): void;
  24455. }
  24456. }
  24457. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24458. import { Observable } from "babylonjs/Misc/observable";
  24459. import { SmartArray } from "babylonjs/Misc/smartArray";
  24460. import { Nullable, Immutable } from "babylonjs/types";
  24461. import { Camera } from "babylonjs/Cameras/camera";
  24462. import { Scene } from "babylonjs/scene";
  24463. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24464. import { Color4 } from "babylonjs/Maths/math.color";
  24465. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24467. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24468. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24469. import { Texture } from "babylonjs/Materials/Textures/texture";
  24470. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24471. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24472. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24473. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24474. import { Engine } from "babylonjs/Engines/engine";
  24475. /**
  24476. * This Helps creating a texture that will be created from a camera in your scene.
  24477. * It is basically a dynamic texture that could be used to create special effects for instance.
  24478. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24479. */
  24480. export class RenderTargetTexture extends Texture {
  24481. /**
  24482. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24483. */
  24484. static readonly REFRESHRATE_RENDER_ONCE: number;
  24485. /**
  24486. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24487. */
  24488. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24489. /**
  24490. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24491. * the central point of your effect and can save a lot of performances.
  24492. */
  24493. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24494. /**
  24495. * Use this predicate to dynamically define the list of mesh you want to render.
  24496. * If set, the renderList property will be overwritten.
  24497. */
  24498. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24499. private _renderList;
  24500. /**
  24501. * Use this list to define the list of mesh you want to render.
  24502. */
  24503. get renderList(): Nullable<Array<AbstractMesh>>;
  24504. set renderList(value: Nullable<Array<AbstractMesh>>);
  24505. /**
  24506. * Use this function to overload the renderList array at rendering time.
  24507. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24508. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24509. * the cube (if the RTT is a cube, else layerOrFace=0).
  24510. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24511. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24512. * hold dummy elements!
  24513. */
  24514. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24515. private _hookArray;
  24516. /**
  24517. * Define if particles should be rendered in your texture.
  24518. */
  24519. renderParticles: boolean;
  24520. /**
  24521. * Define if sprites should be rendered in your texture.
  24522. */
  24523. renderSprites: boolean;
  24524. /**
  24525. * Define the camera used to render the texture.
  24526. */
  24527. activeCamera: Nullable<Camera>;
  24528. /**
  24529. * Override the mesh isReady function with your own one.
  24530. */
  24531. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24532. /**
  24533. * Override the render function of the texture with your own one.
  24534. */
  24535. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24536. /**
  24537. * Define if camera post processes should be use while rendering the texture.
  24538. */
  24539. useCameraPostProcesses: boolean;
  24540. /**
  24541. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24542. */
  24543. ignoreCameraViewport: boolean;
  24544. private _postProcessManager;
  24545. private _postProcesses;
  24546. private _resizeObserver;
  24547. /**
  24548. * An event triggered when the texture is unbind.
  24549. */
  24550. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24551. /**
  24552. * An event triggered when the texture is unbind.
  24553. */
  24554. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24555. private _onAfterUnbindObserver;
  24556. /**
  24557. * Set a after unbind callback in the texture.
  24558. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24559. */
  24560. set onAfterUnbind(callback: () => void);
  24561. /**
  24562. * An event triggered before rendering the texture
  24563. */
  24564. onBeforeRenderObservable: Observable<number>;
  24565. private _onBeforeRenderObserver;
  24566. /**
  24567. * Set a before render callback in the texture.
  24568. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24569. */
  24570. set onBeforeRender(callback: (faceIndex: number) => void);
  24571. /**
  24572. * An event triggered after rendering the texture
  24573. */
  24574. onAfterRenderObservable: Observable<number>;
  24575. private _onAfterRenderObserver;
  24576. /**
  24577. * Set a after render callback in the texture.
  24578. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24579. */
  24580. set onAfterRender(callback: (faceIndex: number) => void);
  24581. /**
  24582. * An event triggered after the texture clear
  24583. */
  24584. onClearObservable: Observable<Engine>;
  24585. private _onClearObserver;
  24586. /**
  24587. * Set a clear callback in the texture.
  24588. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24589. */
  24590. set onClear(callback: (Engine: Engine) => void);
  24591. /**
  24592. * An event triggered when the texture is resized.
  24593. */
  24594. onResizeObservable: Observable<RenderTargetTexture>;
  24595. /**
  24596. * Define the clear color of the Render Target if it should be different from the scene.
  24597. */
  24598. clearColor: Color4;
  24599. protected _size: number | {
  24600. width: number;
  24601. height: number;
  24602. layers?: number;
  24603. };
  24604. protected _initialSizeParameter: number | {
  24605. width: number;
  24606. height: number;
  24607. } | {
  24608. ratio: number;
  24609. };
  24610. protected _sizeRatio: Nullable<number>;
  24611. /** @hidden */
  24612. _generateMipMaps: boolean;
  24613. protected _renderingManager: RenderingManager;
  24614. /** @hidden */
  24615. _waitingRenderList?: string[];
  24616. protected _doNotChangeAspectRatio: boolean;
  24617. protected _currentRefreshId: number;
  24618. protected _refreshRate: number;
  24619. protected _textureMatrix: Matrix;
  24620. protected _samples: number;
  24621. protected _renderTargetOptions: RenderTargetCreationOptions;
  24622. /**
  24623. * Gets render target creation options that were used.
  24624. */
  24625. get renderTargetOptions(): RenderTargetCreationOptions;
  24626. protected _onRatioRescale(): void;
  24627. /**
  24628. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24629. * It must define where the camera used to render the texture is set
  24630. */
  24631. boundingBoxPosition: Vector3;
  24632. private _boundingBoxSize;
  24633. /**
  24634. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24635. * When defined, the cubemap will switch to local mode
  24636. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24637. * @example https://www.babylonjs-playground.com/#RNASML
  24638. */
  24639. set boundingBoxSize(value: Vector3);
  24640. get boundingBoxSize(): Vector3;
  24641. /**
  24642. * In case the RTT has been created with a depth texture, get the associated
  24643. * depth texture.
  24644. * Otherwise, return null.
  24645. */
  24646. get depthStencilTexture(): Nullable<InternalTexture>;
  24647. /**
  24648. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24649. * or used a shadow, depth texture...
  24650. * @param name The friendly name of the texture
  24651. * @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)
  24652. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24653. * @param generateMipMaps True if mip maps need to be generated after render.
  24654. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24655. * @param type The type of the buffer in the RTT (int, half float, float...)
  24656. * @param isCube True if a cube texture needs to be created
  24657. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24658. * @param generateDepthBuffer True to generate a depth buffer
  24659. * @param generateStencilBuffer True to generate a stencil buffer
  24660. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24661. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24662. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24663. */
  24664. constructor(name: string, size: number | {
  24665. width: number;
  24666. height: number;
  24667. layers?: number;
  24668. } | {
  24669. ratio: number;
  24670. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24671. /**
  24672. * Creates a depth stencil texture.
  24673. * This is only available in WebGL 2 or with the depth texture extension available.
  24674. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24675. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24676. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24677. */
  24678. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24679. private _processSizeParameter;
  24680. /**
  24681. * Define the number of samples to use in case of MSAA.
  24682. * It defaults to one meaning no MSAA has been enabled.
  24683. */
  24684. get samples(): number;
  24685. set samples(value: number);
  24686. /**
  24687. * Resets the refresh counter of the texture and start bak from scratch.
  24688. * Could be useful to regenerate the texture if it is setup to render only once.
  24689. */
  24690. resetRefreshCounter(): void;
  24691. /**
  24692. * Define the refresh rate of the texture or the rendering frequency.
  24693. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24694. */
  24695. get refreshRate(): number;
  24696. set refreshRate(value: number);
  24697. /**
  24698. * Adds a post process to the render target rendering passes.
  24699. * @param postProcess define the post process to add
  24700. */
  24701. addPostProcess(postProcess: PostProcess): void;
  24702. /**
  24703. * Clear all the post processes attached to the render target
  24704. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24705. */
  24706. clearPostProcesses(dispose?: boolean): void;
  24707. /**
  24708. * Remove one of the post process from the list of attached post processes to the texture
  24709. * @param postProcess define the post process to remove from the list
  24710. */
  24711. removePostProcess(postProcess: PostProcess): void;
  24712. /** @hidden */
  24713. _shouldRender(): boolean;
  24714. /**
  24715. * Gets the actual render size of the texture.
  24716. * @returns the width of the render size
  24717. */
  24718. getRenderSize(): number;
  24719. /**
  24720. * Gets the actual render width of the texture.
  24721. * @returns the width of the render size
  24722. */
  24723. getRenderWidth(): number;
  24724. /**
  24725. * Gets the actual render height of the texture.
  24726. * @returns the height of the render size
  24727. */
  24728. getRenderHeight(): number;
  24729. /**
  24730. * Gets the actual number of layers of the texture.
  24731. * @returns the number of layers
  24732. */
  24733. getRenderLayers(): number;
  24734. /**
  24735. * Get if the texture can be rescaled or not.
  24736. */
  24737. get canRescale(): boolean;
  24738. /**
  24739. * Resize the texture using a ratio.
  24740. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24741. */
  24742. scale(ratio: number): void;
  24743. /**
  24744. * Get the texture reflection matrix used to rotate/transform the reflection.
  24745. * @returns the reflection matrix
  24746. */
  24747. getReflectionTextureMatrix(): Matrix;
  24748. /**
  24749. * Resize the texture to a new desired size.
  24750. * Be carrefull as it will recreate all the data in the new texture.
  24751. * @param size Define the new size. It can be:
  24752. * - a number for squared texture,
  24753. * - an object containing { width: number, height: number }
  24754. * - or an object containing a ratio { ratio: number }
  24755. */
  24756. resize(size: number | {
  24757. width: number;
  24758. height: number;
  24759. } | {
  24760. ratio: number;
  24761. }): void;
  24762. private _defaultRenderListPrepared;
  24763. /**
  24764. * Renders all the objects from the render list into the texture.
  24765. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24766. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24767. */
  24768. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24769. private _bestReflectionRenderTargetDimension;
  24770. private _prepareRenderingManager;
  24771. /**
  24772. * @hidden
  24773. * @param faceIndex face index to bind to if this is a cubetexture
  24774. * @param layer defines the index of the texture to bind in the array
  24775. */
  24776. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24777. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24778. private renderToTarget;
  24779. /**
  24780. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24781. * This allowed control for front to back rendering or reversly depending of the special needs.
  24782. *
  24783. * @param renderingGroupId The rendering group id corresponding to its index
  24784. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24785. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24786. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24787. */
  24788. 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;
  24789. /**
  24790. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24791. *
  24792. * @param renderingGroupId The rendering group id corresponding to its index
  24793. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24794. */
  24795. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24796. /**
  24797. * Clones the texture.
  24798. * @returns the cloned texture
  24799. */
  24800. clone(): RenderTargetTexture;
  24801. /**
  24802. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24803. * @returns The JSON representation of the texture
  24804. */
  24805. serialize(): any;
  24806. /**
  24807. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24808. */
  24809. disposeFramebufferObjects(): void;
  24810. /**
  24811. * Dispose the texture and release its associated resources.
  24812. */
  24813. dispose(): void;
  24814. /** @hidden */
  24815. _rebuild(): void;
  24816. /**
  24817. * Clear the info related to rendering groups preventing retention point in material dispose.
  24818. */
  24819. freeRenderingGroups(): void;
  24820. /**
  24821. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24822. * @returns the view count
  24823. */
  24824. getViewCount(): number;
  24825. }
  24826. }
  24827. declare module "babylonjs/Misc/guid" {
  24828. /**
  24829. * Class used to manipulate GUIDs
  24830. */
  24831. export class GUID {
  24832. /**
  24833. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24834. * Be aware Math.random() could cause collisions, but:
  24835. * "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"
  24836. * @returns a pseudo random id
  24837. */
  24838. static RandomId(): string;
  24839. }
  24840. }
  24841. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24842. import { Nullable } from "babylonjs/types";
  24843. import { Scene } from "babylonjs/scene";
  24844. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24845. import { Material } from "babylonjs/Materials/material";
  24846. import { Effect } from "babylonjs/Materials/effect";
  24847. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24848. /**
  24849. * Options to be used when creating a shadow depth material
  24850. */
  24851. export interface IIOptionShadowDepthMaterial {
  24852. /** Variables in the vertex shader code that need to have their names remapped.
  24853. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24854. * "var_name" should be either: worldPos or vNormalW
  24855. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24856. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24857. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24858. */
  24859. remappedVariables?: string[];
  24860. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24861. standalone?: boolean;
  24862. }
  24863. /**
  24864. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24865. */
  24866. export class ShadowDepthWrapper {
  24867. private _scene;
  24868. private _options?;
  24869. private _baseMaterial;
  24870. private _onEffectCreatedObserver;
  24871. private _subMeshToEffect;
  24872. private _subMeshToDepthEffect;
  24873. private _meshes;
  24874. /** @hidden */
  24875. _matriceNames: any;
  24876. /** Gets the standalone status of the wrapper */
  24877. get standalone(): boolean;
  24878. /** Gets the base material the wrapper is built upon */
  24879. get baseMaterial(): Material;
  24880. /**
  24881. * Instantiate a new shadow depth wrapper.
  24882. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24883. * generate the shadow depth map. For more information, please refer to the documentation:
  24884. * https://doc.babylonjs.com/babylon101/shadows
  24885. * @param baseMaterial Material to wrap
  24886. * @param scene Define the scene the material belongs to
  24887. * @param options Options used to create the wrapper
  24888. */
  24889. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24890. /**
  24891. * Gets the effect to use to generate the depth map
  24892. * @param subMesh subMesh to get the effect for
  24893. * @param shadowGenerator shadow generator to get the effect for
  24894. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24895. */
  24896. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24897. /**
  24898. * Specifies that the submesh is ready to be used for depth rendering
  24899. * @param subMesh submesh to check
  24900. * @param defines the list of defines to take into account when checking the effect
  24901. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24902. * @param useInstances specifies that instances should be used
  24903. * @returns a boolean indicating that the submesh is ready or not
  24904. */
  24905. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24906. /**
  24907. * Disposes the resources
  24908. */
  24909. dispose(): void;
  24910. private _makeEffect;
  24911. }
  24912. }
  24913. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24914. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24915. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24916. import { Nullable } from "babylonjs/types";
  24917. module "babylonjs/Engines/thinEngine" {
  24918. interface ThinEngine {
  24919. /**
  24920. * Unbind a list of render target textures from the webGL context
  24921. * This is used only when drawBuffer extension or webGL2 are active
  24922. * @param textures defines the render target textures to unbind
  24923. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24924. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24925. */
  24926. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24927. /**
  24928. * Create a multi render target texture
  24929. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24930. * @param size defines the size of the texture
  24931. * @param options defines the creation options
  24932. * @returns the cube texture as an InternalTexture
  24933. */
  24934. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24935. /**
  24936. * Update the sample count for a given multiple render target texture
  24937. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24938. * @param textures defines the textures to update
  24939. * @param samples defines the sample count to set
  24940. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24941. */
  24942. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24943. /**
  24944. * Select a subsets of attachments to draw to.
  24945. * @param attachments gl attachments
  24946. */
  24947. bindAttachments(attachments: number[]): void;
  24948. }
  24949. }
  24950. }
  24951. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24952. import { Scene } from "babylonjs/scene";
  24953. import { Engine } from "babylonjs/Engines/engine";
  24954. import { Texture } from "babylonjs/Materials/Textures/texture";
  24955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24956. import "babylonjs/Engines/Extensions/engine.multiRender";
  24957. /**
  24958. * Creation options of the multi render target texture.
  24959. */
  24960. export interface IMultiRenderTargetOptions {
  24961. /**
  24962. * Define if the texture needs to create mip maps after render.
  24963. */
  24964. generateMipMaps?: boolean;
  24965. /**
  24966. * Define the types of all the draw buffers we want to create
  24967. */
  24968. types?: number[];
  24969. /**
  24970. * Define the sampling modes of all the draw buffers we want to create
  24971. */
  24972. samplingModes?: number[];
  24973. /**
  24974. * Define if a depth buffer is required
  24975. */
  24976. generateDepthBuffer?: boolean;
  24977. /**
  24978. * Define if a stencil buffer is required
  24979. */
  24980. generateStencilBuffer?: boolean;
  24981. /**
  24982. * Define if a depth texture is required instead of a depth buffer
  24983. */
  24984. generateDepthTexture?: boolean;
  24985. /**
  24986. * Define the number of desired draw buffers
  24987. */
  24988. textureCount?: number;
  24989. /**
  24990. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24991. */
  24992. doNotChangeAspectRatio?: boolean;
  24993. /**
  24994. * Define the default type of the buffers we are creating
  24995. */
  24996. defaultType?: number;
  24997. }
  24998. /**
  24999. * A multi render target, like a render target provides the ability to render to a texture.
  25000. * Unlike the render target, it can render to several draw buffers in one draw.
  25001. * This is specially interesting in deferred rendering or for any effects requiring more than
  25002. * just one color from a single pass.
  25003. */
  25004. export class MultiRenderTarget extends RenderTargetTexture {
  25005. private _internalTextures;
  25006. private _textures;
  25007. private _multiRenderTargetOptions;
  25008. private _count;
  25009. /**
  25010. * Get if draw buffers are currently supported by the used hardware and browser.
  25011. */
  25012. get isSupported(): boolean;
  25013. /**
  25014. * Get the list of textures generated by the multi render target.
  25015. */
  25016. get textures(): Texture[];
  25017. /**
  25018. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  25019. */
  25020. get count(): number;
  25021. /**
  25022. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25023. */
  25024. get depthTexture(): Texture;
  25025. /**
  25026. * Set the wrapping mode on U of all the textures we are rendering to.
  25027. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25028. */
  25029. set wrapU(wrap: number);
  25030. /**
  25031. * Set the wrapping mode on V of all the textures we are rendering to.
  25032. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25033. */
  25034. set wrapV(wrap: number);
  25035. /**
  25036. * Instantiate a new multi render target texture.
  25037. * A multi render target, like a render target provides the ability to render to a texture.
  25038. * Unlike the render target, it can render to several draw buffers in one draw.
  25039. * This is specially interesting in deferred rendering or for any effects requiring more than
  25040. * just one color from a single pass.
  25041. * @param name Define the name of the texture
  25042. * @param size Define the size of the buffers to render to
  25043. * @param count Define the number of target we are rendering into
  25044. * @param scene Define the scene the texture belongs to
  25045. * @param options Define the options used to create the multi render target
  25046. */
  25047. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25048. /** @hidden */
  25049. _rebuild(): void;
  25050. private _createInternalTextures;
  25051. private _createTextures;
  25052. /**
  25053. * Define the number of samples used if MSAA is enabled.
  25054. */
  25055. get samples(): number;
  25056. set samples(value: number);
  25057. /**
  25058. * Resize all the textures in the multi render target.
  25059. * Be carrefull as it will recreate all the data in the new texture.
  25060. * @param size Define the new size
  25061. */
  25062. resize(size: any): void;
  25063. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25064. /**
  25065. * Dispose the render targets and their associated resources
  25066. */
  25067. dispose(): void;
  25068. /**
  25069. * Release all the underlying texture used as draw buffers.
  25070. */
  25071. releaseInternalTextures(): void;
  25072. }
  25073. }
  25074. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  25075. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  25076. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25077. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  25078. /** @hidden */
  25079. export var imageProcessingPixelShader: {
  25080. name: string;
  25081. shader: string;
  25082. };
  25083. }
  25084. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  25085. import { Nullable } from "babylonjs/types";
  25086. import { Color4 } from "babylonjs/Maths/math.color";
  25087. import { Camera } from "babylonjs/Cameras/camera";
  25088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25089. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  25090. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  25091. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25092. import { Engine } from "babylonjs/Engines/engine";
  25093. import "babylonjs/Shaders/imageProcessing.fragment";
  25094. import "babylonjs/Shaders/postprocess.vertex";
  25095. /**
  25096. * ImageProcessingPostProcess
  25097. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  25098. */
  25099. export class ImageProcessingPostProcess extends PostProcess {
  25100. /**
  25101. * Default configuration related to image processing available in the PBR Material.
  25102. */
  25103. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25104. /**
  25105. * Gets the image processing configuration used either in this material.
  25106. */
  25107. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25108. /**
  25109. * Sets the Default image processing configuration used either in the this material.
  25110. *
  25111. * If sets to null, the scene one is in use.
  25112. */
  25113. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25114. /**
  25115. * Keep track of the image processing observer to allow dispose and replace.
  25116. */
  25117. private _imageProcessingObserver;
  25118. /**
  25119. * Attaches a new image processing configuration to the PBR Material.
  25120. * @param configuration
  25121. */
  25122. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25123. /**
  25124. * If the post process is supported.
  25125. */
  25126. get isSupported(): boolean;
  25127. /**
  25128. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25129. */
  25130. get colorCurves(): Nullable<ColorCurves>;
  25131. /**
  25132. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25133. */
  25134. set colorCurves(value: Nullable<ColorCurves>);
  25135. /**
  25136. * Gets wether the color curves effect is enabled.
  25137. */
  25138. get colorCurvesEnabled(): boolean;
  25139. /**
  25140. * Sets wether the color curves effect is enabled.
  25141. */
  25142. set colorCurvesEnabled(value: boolean);
  25143. /**
  25144. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25145. */
  25146. get colorGradingTexture(): Nullable<BaseTexture>;
  25147. /**
  25148. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25149. */
  25150. set colorGradingTexture(value: Nullable<BaseTexture>);
  25151. /**
  25152. * Gets wether the color grading effect is enabled.
  25153. */
  25154. get colorGradingEnabled(): boolean;
  25155. /**
  25156. * Gets wether the color grading effect is enabled.
  25157. */
  25158. set colorGradingEnabled(value: boolean);
  25159. /**
  25160. * Gets exposure used in the effect.
  25161. */
  25162. get exposure(): number;
  25163. /**
  25164. * Sets exposure used in the effect.
  25165. */
  25166. set exposure(value: number);
  25167. /**
  25168. * Gets wether tonemapping is enabled or not.
  25169. */
  25170. get toneMappingEnabled(): boolean;
  25171. /**
  25172. * Sets wether tonemapping is enabled or not
  25173. */
  25174. set toneMappingEnabled(value: boolean);
  25175. /**
  25176. * Gets the type of tone mapping effect.
  25177. */
  25178. get toneMappingType(): number;
  25179. /**
  25180. * Sets the type of tone mapping effect.
  25181. */
  25182. set toneMappingType(value: number);
  25183. /**
  25184. * Gets contrast used in the effect.
  25185. */
  25186. get contrast(): number;
  25187. /**
  25188. * Sets contrast used in the effect.
  25189. */
  25190. set contrast(value: number);
  25191. /**
  25192. * Gets Vignette stretch size.
  25193. */
  25194. get vignetteStretch(): number;
  25195. /**
  25196. * Sets Vignette stretch size.
  25197. */
  25198. set vignetteStretch(value: number);
  25199. /**
  25200. * Gets Vignette centre X Offset.
  25201. */
  25202. get vignetteCentreX(): number;
  25203. /**
  25204. * Sets Vignette centre X Offset.
  25205. */
  25206. set vignetteCentreX(value: number);
  25207. /**
  25208. * Gets Vignette centre Y Offset.
  25209. */
  25210. get vignetteCentreY(): number;
  25211. /**
  25212. * Sets Vignette centre Y Offset.
  25213. */
  25214. set vignetteCentreY(value: number);
  25215. /**
  25216. * Gets Vignette weight or intensity of the vignette effect.
  25217. */
  25218. get vignetteWeight(): number;
  25219. /**
  25220. * Sets Vignette weight or intensity of the vignette effect.
  25221. */
  25222. set vignetteWeight(value: number);
  25223. /**
  25224. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25225. * if vignetteEnabled is set to true.
  25226. */
  25227. get vignetteColor(): Color4;
  25228. /**
  25229. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25230. * if vignetteEnabled is set to true.
  25231. */
  25232. set vignetteColor(value: Color4);
  25233. /**
  25234. * Gets Camera field of view used by the Vignette effect.
  25235. */
  25236. get vignetteCameraFov(): number;
  25237. /**
  25238. * Sets Camera field of view used by the Vignette effect.
  25239. */
  25240. set vignetteCameraFov(value: number);
  25241. /**
  25242. * Gets the vignette blend mode allowing different kind of effect.
  25243. */
  25244. get vignetteBlendMode(): number;
  25245. /**
  25246. * Sets the vignette blend mode allowing different kind of effect.
  25247. */
  25248. set vignetteBlendMode(value: number);
  25249. /**
  25250. * Gets wether the vignette effect is enabled.
  25251. */
  25252. get vignetteEnabled(): boolean;
  25253. /**
  25254. * Sets wether the vignette effect is enabled.
  25255. */
  25256. set vignetteEnabled(value: boolean);
  25257. private _fromLinearSpace;
  25258. /**
  25259. * Gets wether the input of the processing is in Gamma or Linear Space.
  25260. */
  25261. get fromLinearSpace(): boolean;
  25262. /**
  25263. * Sets wether the input of the processing is in Gamma or Linear Space.
  25264. */
  25265. set fromLinearSpace(value: boolean);
  25266. /**
  25267. * Defines cache preventing GC.
  25268. */
  25269. private _defines;
  25270. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25271. /**
  25272. * "ImageProcessingPostProcess"
  25273. * @returns "ImageProcessingPostProcess"
  25274. */
  25275. getClassName(): string;
  25276. /**
  25277. * @hidden
  25278. */
  25279. _updateParameters(): void;
  25280. dispose(camera?: Camera): void;
  25281. }
  25282. }
  25283. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25284. /** @hidden */
  25285. export var fibonacci: {
  25286. name: string;
  25287. shader: string;
  25288. };
  25289. }
  25290. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25291. /** @hidden */
  25292. export var subSurfaceScatteringFunctions: {
  25293. name: string;
  25294. shader: string;
  25295. };
  25296. }
  25297. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25298. /** @hidden */
  25299. export var diffusionProfile: {
  25300. name: string;
  25301. shader: string;
  25302. };
  25303. }
  25304. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25305. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25306. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25307. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25308. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25309. /** @hidden */
  25310. export var subSurfaceScatteringPixelShader: {
  25311. name: string;
  25312. shader: string;
  25313. };
  25314. }
  25315. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25316. import { Nullable } from "babylonjs/types";
  25317. import { Camera } from "babylonjs/Cameras/camera";
  25318. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25319. import { Engine } from "babylonjs/Engines/engine";
  25320. import { Scene } from "babylonjs/scene";
  25321. import "babylonjs/Shaders/imageProcessing.fragment";
  25322. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25323. import "babylonjs/Shaders/postprocess.vertex";
  25324. /**
  25325. * Sub surface scattering post process
  25326. */
  25327. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25328. /**
  25329. * Gets a string identifying the name of the class
  25330. * @returns "SubSurfaceScatteringPostProcess" string
  25331. */
  25332. getClassName(): string;
  25333. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25334. }
  25335. }
  25336. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25337. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25338. /**
  25339. * Interface for defining prepass effects in the prepass post-process pipeline
  25340. */
  25341. export interface PrePassEffectConfiguration {
  25342. /**
  25343. * Post process to attach for this effect
  25344. */
  25345. postProcess: PostProcess;
  25346. /**
  25347. * Is the effect enabled
  25348. */
  25349. enabled: boolean;
  25350. /**
  25351. * Disposes the effect configuration
  25352. */
  25353. dispose(): void;
  25354. /**
  25355. * Disposes the effect configuration
  25356. */
  25357. createPostProcess: () => PostProcess;
  25358. }
  25359. }
  25360. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25361. import { Scene } from "babylonjs/scene";
  25362. import { Color3 } from "babylonjs/Maths/math.color";
  25363. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25364. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25365. /**
  25366. * Contains all parameters needed for the prepass to perform
  25367. * screen space subsurface scattering
  25368. */
  25369. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25370. private _ssDiffusionS;
  25371. private _ssFilterRadii;
  25372. private _ssDiffusionD;
  25373. /**
  25374. * Post process to attach for screen space subsurface scattering
  25375. */
  25376. postProcess: SubSurfaceScatteringPostProcess;
  25377. /**
  25378. * Diffusion profile color for subsurface scattering
  25379. */
  25380. get ssDiffusionS(): number[];
  25381. /**
  25382. * Diffusion profile max color channel value for subsurface scattering
  25383. */
  25384. get ssDiffusionD(): number[];
  25385. /**
  25386. * Diffusion profile filter radius for subsurface scattering
  25387. */
  25388. get ssFilterRadii(): number[];
  25389. /**
  25390. * Is subsurface enabled
  25391. */
  25392. enabled: boolean;
  25393. /**
  25394. * Diffusion profile colors for subsurface scattering
  25395. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25396. * See ...
  25397. * Note that you can only store up to 5 of them
  25398. */
  25399. ssDiffusionProfileColors: Color3[];
  25400. /**
  25401. * Defines the ratio real world => scene units.
  25402. * Used for subsurface scattering
  25403. */
  25404. metersPerUnit: number;
  25405. private _scene;
  25406. /**
  25407. * Builds a subsurface configuration object
  25408. * @param scene The scene
  25409. */
  25410. constructor(scene: Scene);
  25411. /**
  25412. * Adds a new diffusion profile.
  25413. * Useful for more realistic subsurface scattering on diverse materials.
  25414. * @param color The color of the diffusion profile. Should be the average color of the material.
  25415. * @return The index of the diffusion profile for the material subsurface configuration
  25416. */
  25417. addDiffusionProfile(color: Color3): number;
  25418. /**
  25419. * Creates the sss post process
  25420. * @return The created post process
  25421. */
  25422. createPostProcess(): SubSurfaceScatteringPostProcess;
  25423. /**
  25424. * Deletes all diffusion profiles.
  25425. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25426. */
  25427. clearAllDiffusionProfiles(): void;
  25428. /**
  25429. * Disposes this object
  25430. */
  25431. dispose(): void;
  25432. /**
  25433. * @hidden
  25434. * https://zero-radiance.github.io/post/sampling-diffusion/
  25435. *
  25436. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25437. * ------------------------------------------------------------------------------------
  25438. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25439. * PDF[r, phi, s] = r * R[r, phi, s]
  25440. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25441. * ------------------------------------------------------------------------------------
  25442. * We importance sample the color channel with the widest scattering distance.
  25443. */
  25444. getDiffusionProfileParameters(color: Color3): number;
  25445. /**
  25446. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25447. * 'u' is the random number (the value of the CDF): [0, 1).
  25448. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25449. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25450. */
  25451. private _sampleBurleyDiffusionProfile;
  25452. }
  25453. }
  25454. declare module "babylonjs/Rendering/prePassRenderer" {
  25455. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25456. import { Scene } from "babylonjs/scene";
  25457. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25458. import { Effect } from "babylonjs/Materials/effect";
  25459. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25460. /**
  25461. * Renders a pre pass of the scene
  25462. * This means every mesh in the scene will be rendered to a render target texture
  25463. * And then this texture will be composited to the rendering canvas with post processes
  25464. * It is necessary for effects like subsurface scattering or deferred shading
  25465. */
  25466. export class PrePassRenderer {
  25467. /** @hidden */
  25468. static _SceneComponentInitialization: (scene: Scene) => void;
  25469. private _scene;
  25470. private _engine;
  25471. private _isDirty;
  25472. /**
  25473. * Number of textures in the multi render target texture where the scene is directly rendered
  25474. */
  25475. readonly mrtCount: number;
  25476. /**
  25477. * The render target where the scene is directly rendered
  25478. */
  25479. prePassRT: MultiRenderTarget;
  25480. private _mrtTypes;
  25481. private _multiRenderAttachments;
  25482. private _defaultAttachments;
  25483. private _clearAttachments;
  25484. private _postProcesses;
  25485. private readonly _clearColor;
  25486. /**
  25487. * Image processing post process for composition
  25488. */
  25489. imageProcessingPostProcess: ImageProcessingPostProcess;
  25490. /**
  25491. * Configuration for sub surface scattering post process
  25492. */
  25493. subSurfaceConfiguration: SubSurfaceConfiguration;
  25494. /**
  25495. * Should materials render their geometry on the MRT
  25496. */
  25497. materialsShouldRenderGeometry: boolean;
  25498. /**
  25499. * Should materials render the irradiance information on the MRT
  25500. */
  25501. materialsShouldRenderIrradiance: boolean;
  25502. private _enabled;
  25503. /**
  25504. * Indicates if the prepass is enabled
  25505. */
  25506. get enabled(): boolean;
  25507. /**
  25508. * How many samples are used for MSAA of the scene render target
  25509. */
  25510. get samples(): number;
  25511. set samples(n: number);
  25512. /**
  25513. * Instanciates a prepass renderer
  25514. * @param scene The scene
  25515. */
  25516. constructor(scene: Scene);
  25517. private _initializeAttachments;
  25518. private _createCompositionEffect;
  25519. /**
  25520. * Indicates if rendering a prepass is supported
  25521. */
  25522. get isSupported(): boolean;
  25523. /**
  25524. * Sets the proper output textures to draw in the engine.
  25525. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25526. */
  25527. bindAttachmentsForEffect(effect: Effect): void;
  25528. /**
  25529. * @hidden
  25530. */
  25531. _beforeCameraDraw(): void;
  25532. /**
  25533. * @hidden
  25534. */
  25535. _afterCameraDraw(): void;
  25536. private _checkRTSize;
  25537. private _bindFrameBuffer;
  25538. /**
  25539. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25540. */
  25541. clear(): void;
  25542. private _setState;
  25543. private _enable;
  25544. private _disable;
  25545. private _resetPostProcessChain;
  25546. private _bindPostProcessChain;
  25547. /**
  25548. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25549. */
  25550. markAsDirty(): void;
  25551. private _update;
  25552. /**
  25553. * Disposes the prepass renderer.
  25554. */
  25555. dispose(): void;
  25556. }
  25557. }
  25558. declare module "babylonjs/Materials/material" {
  25559. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25560. import { SmartArray } from "babylonjs/Misc/smartArray";
  25561. import { Observable } from "babylonjs/Misc/observable";
  25562. import { Nullable } from "babylonjs/types";
  25563. import { Scene } from "babylonjs/scene";
  25564. import { Matrix } from "babylonjs/Maths/math.vector";
  25565. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25567. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25568. import { Effect } from "babylonjs/Materials/effect";
  25569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25570. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25571. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25572. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25573. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25574. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25575. import { Mesh } from "babylonjs/Meshes/mesh";
  25576. import { Animation } from "babylonjs/Animations/animation";
  25577. /**
  25578. * Options for compiling materials.
  25579. */
  25580. export interface IMaterialCompilationOptions {
  25581. /**
  25582. * Defines whether clip planes are enabled.
  25583. */
  25584. clipPlane: boolean;
  25585. /**
  25586. * Defines whether instances are enabled.
  25587. */
  25588. useInstances: boolean;
  25589. }
  25590. /**
  25591. * Options passed when calling customShaderNameResolve
  25592. */
  25593. export interface ICustomShaderNameResolveOptions {
  25594. /**
  25595. * 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
  25596. */
  25597. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25598. }
  25599. /**
  25600. * Base class for the main features of a material in Babylon.js
  25601. */
  25602. export class Material implements IAnimatable {
  25603. /**
  25604. * Returns the triangle fill mode
  25605. */
  25606. static readonly TriangleFillMode: number;
  25607. /**
  25608. * Returns the wireframe mode
  25609. */
  25610. static readonly WireFrameFillMode: number;
  25611. /**
  25612. * Returns the point fill mode
  25613. */
  25614. static readonly PointFillMode: number;
  25615. /**
  25616. * Returns the point list draw mode
  25617. */
  25618. static readonly PointListDrawMode: number;
  25619. /**
  25620. * Returns the line list draw mode
  25621. */
  25622. static readonly LineListDrawMode: number;
  25623. /**
  25624. * Returns the line loop draw mode
  25625. */
  25626. static readonly LineLoopDrawMode: number;
  25627. /**
  25628. * Returns the line strip draw mode
  25629. */
  25630. static readonly LineStripDrawMode: number;
  25631. /**
  25632. * Returns the triangle strip draw mode
  25633. */
  25634. static readonly TriangleStripDrawMode: number;
  25635. /**
  25636. * Returns the triangle fan draw mode
  25637. */
  25638. static readonly TriangleFanDrawMode: number;
  25639. /**
  25640. * Stores the clock-wise side orientation
  25641. */
  25642. static readonly ClockWiseSideOrientation: number;
  25643. /**
  25644. * Stores the counter clock-wise side orientation
  25645. */
  25646. static readonly CounterClockWiseSideOrientation: number;
  25647. /**
  25648. * The dirty texture flag value
  25649. */
  25650. static readonly TextureDirtyFlag: number;
  25651. /**
  25652. * The dirty light flag value
  25653. */
  25654. static readonly LightDirtyFlag: number;
  25655. /**
  25656. * The dirty fresnel flag value
  25657. */
  25658. static readonly FresnelDirtyFlag: number;
  25659. /**
  25660. * The dirty attribute flag value
  25661. */
  25662. static readonly AttributesDirtyFlag: number;
  25663. /**
  25664. * The dirty misc flag value
  25665. */
  25666. static readonly MiscDirtyFlag: number;
  25667. /**
  25668. * The all dirty flag value
  25669. */
  25670. static readonly AllDirtyFlag: number;
  25671. /**
  25672. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25673. */
  25674. static readonly MATERIAL_OPAQUE: number;
  25675. /**
  25676. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25677. */
  25678. static readonly MATERIAL_ALPHATEST: number;
  25679. /**
  25680. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25681. */
  25682. static readonly MATERIAL_ALPHABLEND: number;
  25683. /**
  25684. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25685. * They are also discarded below the alpha cutoff threshold to improve performances.
  25686. */
  25687. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25688. /**
  25689. * The Whiteout method is used to blend normals.
  25690. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25691. */
  25692. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25693. /**
  25694. * The Reoriented Normal Mapping method is used to blend normals.
  25695. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25696. */
  25697. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25698. /**
  25699. * Custom callback helping to override the default shader used in the material.
  25700. */
  25701. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25702. /**
  25703. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25704. */
  25705. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25706. /**
  25707. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25708. * This means that the material can keep using a previous shader while a new one is being compiled.
  25709. * This is mostly used when shader parallel compilation is supported (true by default)
  25710. */
  25711. allowShaderHotSwapping: boolean;
  25712. /**
  25713. * The ID of the material
  25714. */
  25715. id: string;
  25716. /**
  25717. * Gets or sets the unique id of the material
  25718. */
  25719. uniqueId: number;
  25720. /**
  25721. * The name of the material
  25722. */
  25723. name: string;
  25724. /**
  25725. * Gets or sets user defined metadata
  25726. */
  25727. metadata: any;
  25728. /**
  25729. * For internal use only. Please do not use.
  25730. */
  25731. reservedDataStore: any;
  25732. /**
  25733. * Specifies if the ready state should be checked on each call
  25734. */
  25735. checkReadyOnEveryCall: boolean;
  25736. /**
  25737. * Specifies if the ready state should be checked once
  25738. */
  25739. checkReadyOnlyOnce: boolean;
  25740. /**
  25741. * The state of the material
  25742. */
  25743. state: string;
  25744. /**
  25745. * If the material can be rendered to several textures with MRT extension
  25746. */
  25747. get canRenderToMRT(): boolean;
  25748. /**
  25749. * The alpha value of the material
  25750. */
  25751. protected _alpha: number;
  25752. /**
  25753. * List of inspectable custom properties (used by the Inspector)
  25754. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25755. */
  25756. inspectableCustomProperties: IInspectable[];
  25757. /**
  25758. * Sets the alpha value of the material
  25759. */
  25760. set alpha(value: number);
  25761. /**
  25762. * Gets the alpha value of the material
  25763. */
  25764. get alpha(): number;
  25765. /**
  25766. * Specifies if back face culling is enabled
  25767. */
  25768. protected _backFaceCulling: boolean;
  25769. /**
  25770. * Sets the back-face culling state
  25771. */
  25772. set backFaceCulling(value: boolean);
  25773. /**
  25774. * Gets the back-face culling state
  25775. */
  25776. get backFaceCulling(): boolean;
  25777. /**
  25778. * Stores the value for side orientation
  25779. */
  25780. sideOrientation: number;
  25781. /**
  25782. * Callback triggered when the material is compiled
  25783. */
  25784. onCompiled: Nullable<(effect: Effect) => void>;
  25785. /**
  25786. * Callback triggered when an error occurs
  25787. */
  25788. onError: Nullable<(effect: Effect, errors: string) => void>;
  25789. /**
  25790. * Callback triggered to get the render target textures
  25791. */
  25792. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25793. /**
  25794. * Gets a boolean indicating that current material needs to register RTT
  25795. */
  25796. get hasRenderTargetTextures(): boolean;
  25797. /**
  25798. * Specifies if the material should be serialized
  25799. */
  25800. doNotSerialize: boolean;
  25801. /**
  25802. * @hidden
  25803. */
  25804. _storeEffectOnSubMeshes: boolean;
  25805. /**
  25806. * Stores the animations for the material
  25807. */
  25808. animations: Nullable<Array<Animation>>;
  25809. /**
  25810. * An event triggered when the material is disposed
  25811. */
  25812. onDisposeObservable: Observable<Material>;
  25813. /**
  25814. * An observer which watches for dispose events
  25815. */
  25816. private _onDisposeObserver;
  25817. private _onUnBindObservable;
  25818. /**
  25819. * Called during a dispose event
  25820. */
  25821. set onDispose(callback: () => void);
  25822. private _onBindObservable;
  25823. /**
  25824. * An event triggered when the material is bound
  25825. */
  25826. get onBindObservable(): Observable<AbstractMesh>;
  25827. /**
  25828. * An observer which watches for bind events
  25829. */
  25830. private _onBindObserver;
  25831. /**
  25832. * Called during a bind event
  25833. */
  25834. set onBind(callback: (Mesh: AbstractMesh) => void);
  25835. /**
  25836. * An event triggered when the material is unbound
  25837. */
  25838. get onUnBindObservable(): Observable<Material>;
  25839. protected _onEffectCreatedObservable: Nullable<Observable<{
  25840. effect: Effect;
  25841. subMesh: Nullable<SubMesh>;
  25842. }>>;
  25843. /**
  25844. * An event triggered when the effect is (re)created
  25845. */
  25846. get onEffectCreatedObservable(): Observable<{
  25847. effect: Effect;
  25848. subMesh: Nullable<SubMesh>;
  25849. }>;
  25850. /**
  25851. * Stores the value of the alpha mode
  25852. */
  25853. private _alphaMode;
  25854. /**
  25855. * Sets the value of the alpha mode.
  25856. *
  25857. * | Value | Type | Description |
  25858. * | --- | --- | --- |
  25859. * | 0 | ALPHA_DISABLE | |
  25860. * | 1 | ALPHA_ADD | |
  25861. * | 2 | ALPHA_COMBINE | |
  25862. * | 3 | ALPHA_SUBTRACT | |
  25863. * | 4 | ALPHA_MULTIPLY | |
  25864. * | 5 | ALPHA_MAXIMIZED | |
  25865. * | 6 | ALPHA_ONEONE | |
  25866. * | 7 | ALPHA_PREMULTIPLIED | |
  25867. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25868. * | 9 | ALPHA_INTERPOLATE | |
  25869. * | 10 | ALPHA_SCREENMODE | |
  25870. *
  25871. */
  25872. set alphaMode(value: number);
  25873. /**
  25874. * Gets the value of the alpha mode
  25875. */
  25876. get alphaMode(): number;
  25877. /**
  25878. * Stores the state of the need depth pre-pass value
  25879. */
  25880. private _needDepthPrePass;
  25881. /**
  25882. * Sets the need depth pre-pass value
  25883. */
  25884. set needDepthPrePass(value: boolean);
  25885. /**
  25886. * Gets the depth pre-pass value
  25887. */
  25888. get needDepthPrePass(): boolean;
  25889. /**
  25890. * Specifies if depth writing should be disabled
  25891. */
  25892. disableDepthWrite: boolean;
  25893. /**
  25894. * Specifies if color writing should be disabled
  25895. */
  25896. disableColorWrite: boolean;
  25897. /**
  25898. * Specifies if depth writing should be forced
  25899. */
  25900. forceDepthWrite: boolean;
  25901. /**
  25902. * Specifies the depth function that should be used. 0 means the default engine function
  25903. */
  25904. depthFunction: number;
  25905. /**
  25906. * Specifies if there should be a separate pass for culling
  25907. */
  25908. separateCullingPass: boolean;
  25909. /**
  25910. * Stores the state specifing if fog should be enabled
  25911. */
  25912. private _fogEnabled;
  25913. /**
  25914. * Sets the state for enabling fog
  25915. */
  25916. set fogEnabled(value: boolean);
  25917. /**
  25918. * Gets the value of the fog enabled state
  25919. */
  25920. get fogEnabled(): boolean;
  25921. /**
  25922. * Stores the size of points
  25923. */
  25924. pointSize: number;
  25925. /**
  25926. * Stores the z offset value
  25927. */
  25928. zOffset: number;
  25929. get wireframe(): boolean;
  25930. /**
  25931. * Sets the state of wireframe mode
  25932. */
  25933. set wireframe(value: boolean);
  25934. /**
  25935. * Gets the value specifying if point clouds are enabled
  25936. */
  25937. get pointsCloud(): boolean;
  25938. /**
  25939. * Sets the state of point cloud mode
  25940. */
  25941. set pointsCloud(value: boolean);
  25942. /**
  25943. * Gets the material fill mode
  25944. */
  25945. get fillMode(): number;
  25946. /**
  25947. * Sets the material fill mode
  25948. */
  25949. set fillMode(value: number);
  25950. /**
  25951. * @hidden
  25952. * Stores the effects for the material
  25953. */
  25954. _effect: Nullable<Effect>;
  25955. /**
  25956. * Specifies if uniform buffers should be used
  25957. */
  25958. private _useUBO;
  25959. /**
  25960. * Stores a reference to the scene
  25961. */
  25962. private _scene;
  25963. /**
  25964. * Stores the fill mode state
  25965. */
  25966. private _fillMode;
  25967. /**
  25968. * Specifies if the depth write state should be cached
  25969. */
  25970. private _cachedDepthWriteState;
  25971. /**
  25972. * Specifies if the color write state should be cached
  25973. */
  25974. private _cachedColorWriteState;
  25975. /**
  25976. * Specifies if the depth function state should be cached
  25977. */
  25978. private _cachedDepthFunctionState;
  25979. /**
  25980. * Stores the uniform buffer
  25981. */
  25982. protected _uniformBuffer: UniformBuffer;
  25983. /** @hidden */
  25984. _indexInSceneMaterialArray: number;
  25985. /** @hidden */
  25986. meshMap: Nullable<{
  25987. [id: string]: AbstractMesh | undefined;
  25988. }>;
  25989. /**
  25990. * Creates a material instance
  25991. * @param name defines the name of the material
  25992. * @param scene defines the scene to reference
  25993. * @param doNotAdd specifies if the material should be added to the scene
  25994. */
  25995. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25996. /**
  25997. * Returns a string representation of the current material
  25998. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25999. * @returns a string with material information
  26000. */
  26001. toString(fullDetails?: boolean): string;
  26002. /**
  26003. * Gets the class name of the material
  26004. * @returns a string with the class name of the material
  26005. */
  26006. getClassName(): string;
  26007. /**
  26008. * Specifies if updates for the material been locked
  26009. */
  26010. get isFrozen(): boolean;
  26011. /**
  26012. * Locks updates for the material
  26013. */
  26014. freeze(): void;
  26015. /**
  26016. * Unlocks updates for the material
  26017. */
  26018. unfreeze(): void;
  26019. /**
  26020. * Specifies if the material is ready to be used
  26021. * @param mesh defines the mesh to check
  26022. * @param useInstances specifies if instances should be used
  26023. * @returns a boolean indicating if the material is ready to be used
  26024. */
  26025. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26026. /**
  26027. * Specifies that the submesh is ready to be used
  26028. * @param mesh defines the mesh to check
  26029. * @param subMesh defines which submesh to check
  26030. * @param useInstances specifies that instances should be used
  26031. * @returns a boolean indicating that the submesh is ready or not
  26032. */
  26033. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26034. /**
  26035. * Returns the material effect
  26036. * @returns the effect associated with the material
  26037. */
  26038. getEffect(): Nullable<Effect>;
  26039. /**
  26040. * Returns the current scene
  26041. * @returns a Scene
  26042. */
  26043. getScene(): Scene;
  26044. /**
  26045. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26046. */
  26047. protected _forceAlphaTest: boolean;
  26048. /**
  26049. * The transparency mode of the material.
  26050. */
  26051. protected _transparencyMode: Nullable<number>;
  26052. /**
  26053. * Gets the current transparency mode.
  26054. */
  26055. get transparencyMode(): Nullable<number>;
  26056. /**
  26057. * Sets the transparency mode of the material.
  26058. *
  26059. * | Value | Type | Description |
  26060. * | ----- | ----------------------------------- | ----------- |
  26061. * | 0 | OPAQUE | |
  26062. * | 1 | ALPHATEST | |
  26063. * | 2 | ALPHABLEND | |
  26064. * | 3 | ALPHATESTANDBLEND | |
  26065. *
  26066. */
  26067. set transparencyMode(value: Nullable<number>);
  26068. /**
  26069. * Returns true if alpha blending should be disabled.
  26070. */
  26071. protected get _disableAlphaBlending(): boolean;
  26072. /**
  26073. * Specifies whether or not this material should be rendered in alpha blend mode.
  26074. * @returns a boolean specifying if alpha blending is needed
  26075. */
  26076. needAlphaBlending(): boolean;
  26077. /**
  26078. * Specifies if the mesh will require alpha blending
  26079. * @param mesh defines the mesh to check
  26080. * @returns a boolean specifying if alpha blending is needed for the mesh
  26081. */
  26082. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  26083. /**
  26084. * Specifies whether or not this material should be rendered in alpha test mode.
  26085. * @returns a boolean specifying if an alpha test is needed.
  26086. */
  26087. needAlphaTesting(): boolean;
  26088. /**
  26089. * Specifies if material alpha testing should be turned on for the mesh
  26090. * @param mesh defines the mesh to check
  26091. */
  26092. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26093. /**
  26094. * Gets the texture used for the alpha test
  26095. * @returns the texture to use for alpha testing
  26096. */
  26097. getAlphaTestTexture(): Nullable<BaseTexture>;
  26098. /**
  26099. * Marks the material to indicate that it needs to be re-calculated
  26100. */
  26101. markDirty(): void;
  26102. /** @hidden */
  26103. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26104. /**
  26105. * Binds the material to the mesh
  26106. * @param world defines the world transformation matrix
  26107. * @param mesh defines the mesh to bind the material to
  26108. */
  26109. bind(world: Matrix, mesh?: Mesh): void;
  26110. /**
  26111. * Binds the submesh to the material
  26112. * @param world defines the world transformation matrix
  26113. * @param mesh defines the mesh containing the submesh
  26114. * @param subMesh defines the submesh to bind the material to
  26115. */
  26116. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26117. /**
  26118. * Binds the world matrix to the material
  26119. * @param world defines the world transformation matrix
  26120. */
  26121. bindOnlyWorldMatrix(world: Matrix): void;
  26122. /**
  26123. * Binds the scene's uniform buffer to the effect.
  26124. * @param effect defines the effect to bind to the scene uniform buffer
  26125. * @param sceneUbo defines the uniform buffer storing scene data
  26126. */
  26127. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26128. /**
  26129. * Binds the view matrix to the effect
  26130. * @param effect defines the effect to bind the view matrix to
  26131. */
  26132. bindView(effect: Effect): void;
  26133. /**
  26134. * Binds the view projection matrix to the effect
  26135. * @param effect defines the effect to bind the view projection matrix to
  26136. */
  26137. bindViewProjection(effect: Effect): void;
  26138. /**
  26139. * Processes to execute after binding the material to a mesh
  26140. * @param mesh defines the rendered mesh
  26141. */
  26142. protected _afterBind(mesh?: Mesh): void;
  26143. /**
  26144. * Unbinds the material from the mesh
  26145. */
  26146. unbind(): void;
  26147. /**
  26148. * Gets the active textures from the material
  26149. * @returns an array of textures
  26150. */
  26151. getActiveTextures(): BaseTexture[];
  26152. /**
  26153. * Specifies if the material uses a texture
  26154. * @param texture defines the texture to check against the material
  26155. * @returns a boolean specifying if the material uses the texture
  26156. */
  26157. hasTexture(texture: BaseTexture): boolean;
  26158. /**
  26159. * Makes a duplicate of the material, and gives it a new name
  26160. * @param name defines the new name for the duplicated material
  26161. * @returns the cloned material
  26162. */
  26163. clone(name: string): Nullable<Material>;
  26164. /**
  26165. * Gets the meshes bound to the material
  26166. * @returns an array of meshes bound to the material
  26167. */
  26168. getBindedMeshes(): AbstractMesh[];
  26169. /**
  26170. * Force shader compilation
  26171. * @param mesh defines the mesh associated with this material
  26172. * @param onCompiled defines a function to execute once the material is compiled
  26173. * @param options defines the options to configure the compilation
  26174. * @param onError defines a function to execute if the material fails compiling
  26175. */
  26176. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26177. /**
  26178. * Force shader compilation
  26179. * @param mesh defines the mesh that will use this material
  26180. * @param options defines additional options for compiling the shaders
  26181. * @returns a promise that resolves when the compilation completes
  26182. */
  26183. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26184. private static readonly _AllDirtyCallBack;
  26185. private static readonly _ImageProcessingDirtyCallBack;
  26186. private static readonly _TextureDirtyCallBack;
  26187. private static readonly _FresnelDirtyCallBack;
  26188. private static readonly _MiscDirtyCallBack;
  26189. private static readonly _LightsDirtyCallBack;
  26190. private static readonly _AttributeDirtyCallBack;
  26191. private static _FresnelAndMiscDirtyCallBack;
  26192. private static _TextureAndMiscDirtyCallBack;
  26193. private static readonly _DirtyCallbackArray;
  26194. private static readonly _RunDirtyCallBacks;
  26195. /**
  26196. * Marks a define in the material to indicate that it needs to be re-computed
  26197. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26198. */
  26199. markAsDirty(flag: number): void;
  26200. /**
  26201. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26202. * @param func defines a function which checks material defines against the submeshes
  26203. */
  26204. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26205. /**
  26206. * Indicates that the scene should check if the rendering now needs a prepass
  26207. */
  26208. protected _markScenePrePassDirty(): void;
  26209. /**
  26210. * Indicates that we need to re-calculated for all submeshes
  26211. */
  26212. protected _markAllSubMeshesAsAllDirty(): void;
  26213. /**
  26214. * Indicates that image processing needs to be re-calculated for all submeshes
  26215. */
  26216. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26217. /**
  26218. * Indicates that textures need to be re-calculated for all submeshes
  26219. */
  26220. protected _markAllSubMeshesAsTexturesDirty(): void;
  26221. /**
  26222. * Indicates that fresnel needs to be re-calculated for all submeshes
  26223. */
  26224. protected _markAllSubMeshesAsFresnelDirty(): void;
  26225. /**
  26226. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26227. */
  26228. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26229. /**
  26230. * Indicates that lights need to be re-calculated for all submeshes
  26231. */
  26232. protected _markAllSubMeshesAsLightsDirty(): void;
  26233. /**
  26234. * Indicates that attributes need to be re-calculated for all submeshes
  26235. */
  26236. protected _markAllSubMeshesAsAttributesDirty(): void;
  26237. /**
  26238. * Indicates that misc needs to be re-calculated for all submeshes
  26239. */
  26240. protected _markAllSubMeshesAsMiscDirty(): void;
  26241. /**
  26242. * Indicates that textures and misc need to be re-calculated for all submeshes
  26243. */
  26244. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26245. /**
  26246. * Sets the required values to the prepass renderer.
  26247. * @param prePassRenderer defines the prepass renderer to setup.
  26248. * @returns true if the pre pass is needed.
  26249. */
  26250. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26251. /**
  26252. * Disposes the material
  26253. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26254. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26255. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26256. */
  26257. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26258. /** @hidden */
  26259. private releaseVertexArrayObject;
  26260. /**
  26261. * Serializes this material
  26262. * @returns the serialized material object
  26263. */
  26264. serialize(): any;
  26265. /**
  26266. * Creates a material from parsed material data
  26267. * @param parsedMaterial defines parsed material data
  26268. * @param scene defines the hosting scene
  26269. * @param rootUrl defines the root URL to use to load textures
  26270. * @returns a new material
  26271. */
  26272. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26273. }
  26274. }
  26275. declare module "babylonjs/Materials/multiMaterial" {
  26276. import { Nullable } from "babylonjs/types";
  26277. import { Scene } from "babylonjs/scene";
  26278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26279. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26281. import { Material } from "babylonjs/Materials/material";
  26282. /**
  26283. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26284. * separate meshes. This can be use to improve performances.
  26285. * @see https://doc.babylonjs.com/how_to/multi_materials
  26286. */
  26287. export class MultiMaterial extends Material {
  26288. private _subMaterials;
  26289. /**
  26290. * Gets or Sets the list of Materials used within the multi material.
  26291. * They need to be ordered according to the submeshes order in the associated mesh
  26292. */
  26293. get subMaterials(): Nullable<Material>[];
  26294. set subMaterials(value: Nullable<Material>[]);
  26295. /**
  26296. * Function used to align with Node.getChildren()
  26297. * @returns the list of Materials used within the multi material
  26298. */
  26299. getChildren(): Nullable<Material>[];
  26300. /**
  26301. * Instantiates a new Multi Material
  26302. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26303. * separate meshes. This can be use to improve performances.
  26304. * @see https://doc.babylonjs.com/how_to/multi_materials
  26305. * @param name Define the name in the scene
  26306. * @param scene Define the scene the material belongs to
  26307. */
  26308. constructor(name: string, scene: Scene);
  26309. private _hookArray;
  26310. /**
  26311. * Get one of the submaterial by its index in the submaterials array
  26312. * @param index The index to look the sub material at
  26313. * @returns The Material if the index has been defined
  26314. */
  26315. getSubMaterial(index: number): Nullable<Material>;
  26316. /**
  26317. * Get the list of active textures for the whole sub materials list.
  26318. * @returns All the textures that will be used during the rendering
  26319. */
  26320. getActiveTextures(): BaseTexture[];
  26321. /**
  26322. * Gets the current class name of the material e.g. "MultiMaterial"
  26323. * Mainly use in serialization.
  26324. * @returns the class name
  26325. */
  26326. getClassName(): string;
  26327. /**
  26328. * Checks if the material is ready to render the requested sub mesh
  26329. * @param mesh Define the mesh the submesh belongs to
  26330. * @param subMesh Define the sub mesh to look readyness for
  26331. * @param useInstances Define whether or not the material is used with instances
  26332. * @returns true if ready, otherwise false
  26333. */
  26334. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26335. /**
  26336. * Clones the current material and its related sub materials
  26337. * @param name Define the name of the newly cloned material
  26338. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26339. * @returns the cloned material
  26340. */
  26341. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26342. /**
  26343. * Serializes the materials into a JSON representation.
  26344. * @returns the JSON representation
  26345. */
  26346. serialize(): any;
  26347. /**
  26348. * Dispose the material and release its associated resources
  26349. * @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)
  26350. * @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)
  26351. * @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)
  26352. */
  26353. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26354. /**
  26355. * Creates a MultiMaterial from parsed MultiMaterial data.
  26356. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26357. * @param scene defines the hosting scene
  26358. * @returns a new MultiMaterial
  26359. */
  26360. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26361. }
  26362. }
  26363. declare module "babylonjs/Meshes/subMesh" {
  26364. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26365. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26366. import { Engine } from "babylonjs/Engines/engine";
  26367. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26368. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26369. import { Effect } from "babylonjs/Materials/effect";
  26370. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26371. import { Plane } from "babylonjs/Maths/math.plane";
  26372. import { Collider } from "babylonjs/Collisions/collider";
  26373. import { Material } from "babylonjs/Materials/material";
  26374. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26376. import { Mesh } from "babylonjs/Meshes/mesh";
  26377. import { Ray } from "babylonjs/Culling/ray";
  26378. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26379. /**
  26380. * Defines a subdivision inside a mesh
  26381. */
  26382. export class SubMesh implements ICullable {
  26383. /** the material index to use */
  26384. materialIndex: number;
  26385. /** vertex index start */
  26386. verticesStart: number;
  26387. /** vertices count */
  26388. verticesCount: number;
  26389. /** index start */
  26390. indexStart: number;
  26391. /** indices count */
  26392. indexCount: number;
  26393. /** @hidden */
  26394. _materialDefines: Nullable<MaterialDefines>;
  26395. /** @hidden */
  26396. _materialEffect: Nullable<Effect>;
  26397. /** @hidden */
  26398. _effectOverride: Nullable<Effect>;
  26399. /**
  26400. * Gets material defines used by the effect associated to the sub mesh
  26401. */
  26402. get materialDefines(): Nullable<MaterialDefines>;
  26403. /**
  26404. * Sets material defines used by the effect associated to the sub mesh
  26405. */
  26406. set materialDefines(defines: Nullable<MaterialDefines>);
  26407. /**
  26408. * Gets associated effect
  26409. */
  26410. get effect(): Nullable<Effect>;
  26411. /**
  26412. * Sets associated effect (effect used to render this submesh)
  26413. * @param effect defines the effect to associate with
  26414. * @param defines defines the set of defines used to compile this effect
  26415. */
  26416. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26417. /** @hidden */
  26418. _linesIndexCount: number;
  26419. private _mesh;
  26420. private _renderingMesh;
  26421. private _boundingInfo;
  26422. private _linesIndexBuffer;
  26423. /** @hidden */
  26424. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26425. /** @hidden */
  26426. _trianglePlanes: Plane[];
  26427. /** @hidden */
  26428. _lastColliderTransformMatrix: Nullable<Matrix>;
  26429. /** @hidden */
  26430. _renderId: number;
  26431. /** @hidden */
  26432. _alphaIndex: number;
  26433. /** @hidden */
  26434. _distanceToCamera: number;
  26435. /** @hidden */
  26436. _id: number;
  26437. private _currentMaterial;
  26438. /**
  26439. * Add a new submesh to a mesh
  26440. * @param materialIndex defines the material index to use
  26441. * @param verticesStart defines vertex index start
  26442. * @param verticesCount defines vertices count
  26443. * @param indexStart defines index start
  26444. * @param indexCount defines indices count
  26445. * @param mesh defines the parent mesh
  26446. * @param renderingMesh defines an optional rendering mesh
  26447. * @param createBoundingBox defines if bounding box should be created for this submesh
  26448. * @returns the new submesh
  26449. */
  26450. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26451. /**
  26452. * Creates a new submesh
  26453. * @param materialIndex defines the material index to use
  26454. * @param verticesStart defines vertex index start
  26455. * @param verticesCount defines vertices count
  26456. * @param indexStart defines index start
  26457. * @param indexCount defines indices count
  26458. * @param mesh defines the parent mesh
  26459. * @param renderingMesh defines an optional rendering mesh
  26460. * @param createBoundingBox defines if bounding box should be created for this submesh
  26461. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26462. */
  26463. constructor(
  26464. /** the material index to use */
  26465. materialIndex: number,
  26466. /** vertex index start */
  26467. verticesStart: number,
  26468. /** vertices count */
  26469. verticesCount: number,
  26470. /** index start */
  26471. indexStart: number,
  26472. /** indices count */
  26473. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26474. /**
  26475. * Returns true if this submesh covers the entire parent mesh
  26476. * @ignorenaming
  26477. */
  26478. get IsGlobal(): boolean;
  26479. /**
  26480. * Returns the submesh BoudingInfo object
  26481. * @returns current bounding info (or mesh's one if the submesh is global)
  26482. */
  26483. getBoundingInfo(): BoundingInfo;
  26484. /**
  26485. * Sets the submesh BoundingInfo
  26486. * @param boundingInfo defines the new bounding info to use
  26487. * @returns the SubMesh
  26488. */
  26489. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26490. /**
  26491. * Returns the mesh of the current submesh
  26492. * @return the parent mesh
  26493. */
  26494. getMesh(): AbstractMesh;
  26495. /**
  26496. * Returns the rendering mesh of the submesh
  26497. * @returns the rendering mesh (could be different from parent mesh)
  26498. */
  26499. getRenderingMesh(): Mesh;
  26500. /**
  26501. * Returns the replacement mesh of the submesh
  26502. * @returns the replacement mesh (could be different from parent mesh)
  26503. */
  26504. getReplacementMesh(): Nullable<AbstractMesh>;
  26505. /**
  26506. * Returns the effective mesh of the submesh
  26507. * @returns the effective mesh (could be different from parent mesh)
  26508. */
  26509. getEffectiveMesh(): AbstractMesh;
  26510. /**
  26511. * Returns the submesh material
  26512. * @returns null or the current material
  26513. */
  26514. getMaterial(): Nullable<Material>;
  26515. private _IsMultiMaterial;
  26516. /**
  26517. * Sets a new updated BoundingInfo object to the submesh
  26518. * @param data defines an optional position array to use to determine the bounding info
  26519. * @returns the SubMesh
  26520. */
  26521. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26522. /** @hidden */
  26523. _checkCollision(collider: Collider): boolean;
  26524. /**
  26525. * Updates the submesh BoundingInfo
  26526. * @param world defines the world matrix to use to update the bounding info
  26527. * @returns the submesh
  26528. */
  26529. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26530. /**
  26531. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26532. * @param frustumPlanes defines the frustum planes
  26533. * @returns true if the submesh is intersecting with the frustum
  26534. */
  26535. isInFrustum(frustumPlanes: Plane[]): boolean;
  26536. /**
  26537. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26538. * @param frustumPlanes defines the frustum planes
  26539. * @returns true if the submesh is inside the frustum
  26540. */
  26541. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26542. /**
  26543. * Renders the submesh
  26544. * @param enableAlphaMode defines if alpha needs to be used
  26545. * @returns the submesh
  26546. */
  26547. render(enableAlphaMode: boolean): SubMesh;
  26548. /**
  26549. * @hidden
  26550. */
  26551. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26552. /**
  26553. * Checks if the submesh intersects with a ray
  26554. * @param ray defines the ray to test
  26555. * @returns true is the passed ray intersects the submesh bounding box
  26556. */
  26557. canIntersects(ray: Ray): boolean;
  26558. /**
  26559. * Intersects current submesh with a ray
  26560. * @param ray defines the ray to test
  26561. * @param positions defines mesh's positions array
  26562. * @param indices defines mesh's indices array
  26563. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26564. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26565. * @returns intersection info or null if no intersection
  26566. */
  26567. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26568. /** @hidden */
  26569. private _intersectLines;
  26570. /** @hidden */
  26571. private _intersectUnIndexedLines;
  26572. /** @hidden */
  26573. private _intersectTriangles;
  26574. /** @hidden */
  26575. private _intersectUnIndexedTriangles;
  26576. /** @hidden */
  26577. _rebuild(): void;
  26578. /**
  26579. * Creates a new submesh from the passed mesh
  26580. * @param newMesh defines the new hosting mesh
  26581. * @param newRenderingMesh defines an optional rendering mesh
  26582. * @returns the new submesh
  26583. */
  26584. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26585. /**
  26586. * Release associated resources
  26587. */
  26588. dispose(): void;
  26589. /**
  26590. * Gets the class name
  26591. * @returns the string "SubMesh".
  26592. */
  26593. getClassName(): string;
  26594. /**
  26595. * Creates a new submesh from indices data
  26596. * @param materialIndex the index of the main mesh material
  26597. * @param startIndex the index where to start the copy in the mesh indices array
  26598. * @param indexCount the number of indices to copy then from the startIndex
  26599. * @param mesh the main mesh to create the submesh from
  26600. * @param renderingMesh the optional rendering mesh
  26601. * @returns a new submesh
  26602. */
  26603. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26604. }
  26605. }
  26606. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26607. /**
  26608. * Class used to represent data loading progression
  26609. */
  26610. export class SceneLoaderFlags {
  26611. private static _ForceFullSceneLoadingForIncremental;
  26612. private static _ShowLoadingScreen;
  26613. private static _CleanBoneMatrixWeights;
  26614. private static _loggingLevel;
  26615. /**
  26616. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26617. */
  26618. static get ForceFullSceneLoadingForIncremental(): boolean;
  26619. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26620. /**
  26621. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26622. */
  26623. static get ShowLoadingScreen(): boolean;
  26624. static set ShowLoadingScreen(value: boolean);
  26625. /**
  26626. * Defines the current logging level (while loading the scene)
  26627. * @ignorenaming
  26628. */
  26629. static get loggingLevel(): number;
  26630. static set loggingLevel(value: number);
  26631. /**
  26632. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26633. */
  26634. static get CleanBoneMatrixWeights(): boolean;
  26635. static set CleanBoneMatrixWeights(value: boolean);
  26636. }
  26637. }
  26638. declare module "babylonjs/Meshes/geometry" {
  26639. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26640. import { Scene } from "babylonjs/scene";
  26641. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26642. import { Engine } from "babylonjs/Engines/engine";
  26643. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26644. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26645. import { Effect } from "babylonjs/Materials/effect";
  26646. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26647. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26648. import { Mesh } from "babylonjs/Meshes/mesh";
  26649. /**
  26650. * Class used to store geometry data (vertex buffers + index buffer)
  26651. */
  26652. export class Geometry implements IGetSetVerticesData {
  26653. /**
  26654. * Gets or sets the ID of the geometry
  26655. */
  26656. id: string;
  26657. /**
  26658. * Gets or sets the unique ID of the geometry
  26659. */
  26660. uniqueId: number;
  26661. /**
  26662. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26663. */
  26664. delayLoadState: number;
  26665. /**
  26666. * Gets the file containing the data to load when running in delay load state
  26667. */
  26668. delayLoadingFile: Nullable<string>;
  26669. /**
  26670. * Callback called when the geometry is updated
  26671. */
  26672. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26673. private _scene;
  26674. private _engine;
  26675. private _meshes;
  26676. private _totalVertices;
  26677. /** @hidden */
  26678. _indices: IndicesArray;
  26679. /** @hidden */
  26680. _vertexBuffers: {
  26681. [key: string]: VertexBuffer;
  26682. };
  26683. private _isDisposed;
  26684. private _extend;
  26685. private _boundingBias;
  26686. /** @hidden */
  26687. _delayInfo: Array<string>;
  26688. private _indexBuffer;
  26689. private _indexBufferIsUpdatable;
  26690. /** @hidden */
  26691. _boundingInfo: Nullable<BoundingInfo>;
  26692. /** @hidden */
  26693. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26694. /** @hidden */
  26695. _softwareSkinningFrameId: number;
  26696. private _vertexArrayObjects;
  26697. private _updatable;
  26698. /** @hidden */
  26699. _positions: Nullable<Vector3[]>;
  26700. /**
  26701. * 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
  26702. */
  26703. get boundingBias(): Vector2;
  26704. /**
  26705. * 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
  26706. */
  26707. set boundingBias(value: Vector2);
  26708. /**
  26709. * Static function used to attach a new empty geometry to a mesh
  26710. * @param mesh defines the mesh to attach the geometry to
  26711. * @returns the new Geometry
  26712. */
  26713. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26714. /** Get the list of meshes using this geometry */
  26715. get meshes(): Mesh[];
  26716. /**
  26717. * 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
  26718. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26719. */
  26720. useBoundingInfoFromGeometry: boolean;
  26721. /**
  26722. * Creates a new geometry
  26723. * @param id defines the unique ID
  26724. * @param scene defines the hosting scene
  26725. * @param vertexData defines the VertexData used to get geometry data
  26726. * @param updatable defines if geometry must be updatable (false by default)
  26727. * @param mesh defines the mesh that will be associated with the geometry
  26728. */
  26729. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26730. /**
  26731. * Gets the current extend of the geometry
  26732. */
  26733. get extend(): {
  26734. minimum: Vector3;
  26735. maximum: Vector3;
  26736. };
  26737. /**
  26738. * Gets the hosting scene
  26739. * @returns the hosting Scene
  26740. */
  26741. getScene(): Scene;
  26742. /**
  26743. * Gets the hosting engine
  26744. * @returns the hosting Engine
  26745. */
  26746. getEngine(): Engine;
  26747. /**
  26748. * Defines if the geometry is ready to use
  26749. * @returns true if the geometry is ready to be used
  26750. */
  26751. isReady(): boolean;
  26752. /**
  26753. * Gets a value indicating that the geometry should not be serialized
  26754. */
  26755. get doNotSerialize(): boolean;
  26756. /** @hidden */
  26757. _rebuild(): void;
  26758. /**
  26759. * Affects all geometry data in one call
  26760. * @param vertexData defines the geometry data
  26761. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26762. */
  26763. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26764. /**
  26765. * Set specific vertex data
  26766. * @param kind defines the data kind (Position, normal, etc...)
  26767. * @param data defines the vertex data to use
  26768. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26769. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26770. */
  26771. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26772. /**
  26773. * Removes a specific vertex data
  26774. * @param kind defines the data kind (Position, normal, etc...)
  26775. */
  26776. removeVerticesData(kind: string): void;
  26777. /**
  26778. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26779. * @param buffer defines the vertex buffer to use
  26780. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26781. */
  26782. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26783. /**
  26784. * Update a specific vertex buffer
  26785. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26786. * It will do nothing if the buffer is not updatable
  26787. * @param kind defines the data kind (Position, normal, etc...)
  26788. * @param data defines the data to use
  26789. * @param offset defines the offset in the target buffer where to store the data
  26790. * @param useBytes set to true if the offset is in bytes
  26791. */
  26792. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26793. /**
  26794. * Update a specific vertex buffer
  26795. * This function will create a new buffer if the current one is not updatable
  26796. * @param kind defines the data kind (Position, normal, etc...)
  26797. * @param data defines the data to use
  26798. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26799. */
  26800. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26801. private _updateBoundingInfo;
  26802. /** @hidden */
  26803. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26804. /**
  26805. * Gets total number of vertices
  26806. * @returns the total number of vertices
  26807. */
  26808. getTotalVertices(): number;
  26809. /**
  26810. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26811. * @param kind defines the data kind (Position, normal, etc...)
  26812. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26813. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26814. * @returns a float array containing vertex data
  26815. */
  26816. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26817. /**
  26818. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26819. * @param kind defines the data kind (Position, normal, etc...)
  26820. * @returns true if the vertex buffer with the specified kind is updatable
  26821. */
  26822. isVertexBufferUpdatable(kind: string): boolean;
  26823. /**
  26824. * Gets a specific vertex buffer
  26825. * @param kind defines the data kind (Position, normal, etc...)
  26826. * @returns a VertexBuffer
  26827. */
  26828. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26829. /**
  26830. * Returns all vertex buffers
  26831. * @return an object holding all vertex buffers indexed by kind
  26832. */
  26833. getVertexBuffers(): Nullable<{
  26834. [key: string]: VertexBuffer;
  26835. }>;
  26836. /**
  26837. * Gets a boolean indicating if specific vertex buffer is present
  26838. * @param kind defines the data kind (Position, normal, etc...)
  26839. * @returns true if data is present
  26840. */
  26841. isVerticesDataPresent(kind: string): boolean;
  26842. /**
  26843. * Gets a list of all attached data kinds (Position, normal, etc...)
  26844. * @returns a list of string containing all kinds
  26845. */
  26846. getVerticesDataKinds(): string[];
  26847. /**
  26848. * Update index buffer
  26849. * @param indices defines the indices to store in the index buffer
  26850. * @param offset defines the offset in the target buffer where to store the data
  26851. * @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)
  26852. */
  26853. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26854. /**
  26855. * Creates a new index buffer
  26856. * @param indices defines the indices to store in the index buffer
  26857. * @param totalVertices defines the total number of vertices (could be null)
  26858. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26859. */
  26860. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26861. /**
  26862. * Return the total number of indices
  26863. * @returns the total number of indices
  26864. */
  26865. getTotalIndices(): number;
  26866. /**
  26867. * Gets the index buffer array
  26868. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26869. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26870. * @returns the index buffer array
  26871. */
  26872. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26873. /**
  26874. * Gets the index buffer
  26875. * @return the index buffer
  26876. */
  26877. getIndexBuffer(): Nullable<DataBuffer>;
  26878. /** @hidden */
  26879. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26880. /**
  26881. * Release the associated resources for a specific mesh
  26882. * @param mesh defines the source mesh
  26883. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26884. */
  26885. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26886. /**
  26887. * Apply current geometry to a given mesh
  26888. * @param mesh defines the mesh to apply geometry to
  26889. */
  26890. applyToMesh(mesh: Mesh): void;
  26891. private _updateExtend;
  26892. private _applyToMesh;
  26893. private notifyUpdate;
  26894. /**
  26895. * Load the geometry if it was flagged as delay loaded
  26896. * @param scene defines the hosting scene
  26897. * @param onLoaded defines a callback called when the geometry is loaded
  26898. */
  26899. load(scene: Scene, onLoaded?: () => void): void;
  26900. private _queueLoad;
  26901. /**
  26902. * Invert the geometry to move from a right handed system to a left handed one.
  26903. */
  26904. toLeftHanded(): void;
  26905. /** @hidden */
  26906. _resetPointsArrayCache(): void;
  26907. /** @hidden */
  26908. _generatePointsArray(): boolean;
  26909. /**
  26910. * Gets a value indicating if the geometry is disposed
  26911. * @returns true if the geometry was disposed
  26912. */
  26913. isDisposed(): boolean;
  26914. private _disposeVertexArrayObjects;
  26915. /**
  26916. * Free all associated resources
  26917. */
  26918. dispose(): void;
  26919. /**
  26920. * Clone the current geometry into a new geometry
  26921. * @param id defines the unique ID of the new geometry
  26922. * @returns a new geometry object
  26923. */
  26924. copy(id: string): Geometry;
  26925. /**
  26926. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26927. * @return a JSON representation of the current geometry data (without the vertices data)
  26928. */
  26929. serialize(): any;
  26930. private toNumberArray;
  26931. /**
  26932. * Serialize all vertices data into a JSON oject
  26933. * @returns a JSON representation of the current geometry data
  26934. */
  26935. serializeVerticeData(): any;
  26936. /**
  26937. * Extracts a clone of a mesh geometry
  26938. * @param mesh defines the source mesh
  26939. * @param id defines the unique ID of the new geometry object
  26940. * @returns the new geometry object
  26941. */
  26942. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26943. /**
  26944. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26945. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26946. * Be aware Math.random() could cause collisions, but:
  26947. * "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"
  26948. * @returns a string containing a new GUID
  26949. */
  26950. static RandomId(): string;
  26951. /** @hidden */
  26952. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26953. private static _CleanMatricesWeights;
  26954. /**
  26955. * Create a new geometry from persisted data (Using .babylon file format)
  26956. * @param parsedVertexData defines the persisted data
  26957. * @param scene defines the hosting scene
  26958. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26959. * @returns the new geometry object
  26960. */
  26961. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26962. }
  26963. }
  26964. declare module "babylonjs/Meshes/mesh.vertexData" {
  26965. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26966. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26967. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26968. import { Geometry } from "babylonjs/Meshes/geometry";
  26969. import { Mesh } from "babylonjs/Meshes/mesh";
  26970. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26971. /**
  26972. * Define an interface for all classes that will get and set the data on vertices
  26973. */
  26974. export interface IGetSetVerticesData {
  26975. /**
  26976. * Gets a boolean indicating if specific vertex data is present
  26977. * @param kind defines the vertex data kind to use
  26978. * @returns true is data kind is present
  26979. */
  26980. isVerticesDataPresent(kind: string): boolean;
  26981. /**
  26982. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26983. * @param kind defines the data kind (Position, normal, etc...)
  26984. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26985. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26986. * @returns a float array containing vertex data
  26987. */
  26988. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26989. /**
  26990. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26991. * @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.
  26992. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26993. * @returns the indices array or an empty array if the mesh has no geometry
  26994. */
  26995. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26996. /**
  26997. * Set specific vertex data
  26998. * @param kind defines the data kind (Position, normal, etc...)
  26999. * @param data defines the vertex data to use
  27000. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27001. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27002. */
  27003. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27004. /**
  27005. * Update a specific associated vertex buffer
  27006. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27007. * - VertexBuffer.PositionKind
  27008. * - VertexBuffer.UVKind
  27009. * - VertexBuffer.UV2Kind
  27010. * - VertexBuffer.UV3Kind
  27011. * - VertexBuffer.UV4Kind
  27012. * - VertexBuffer.UV5Kind
  27013. * - VertexBuffer.UV6Kind
  27014. * - VertexBuffer.ColorKind
  27015. * - VertexBuffer.MatricesIndicesKind
  27016. * - VertexBuffer.MatricesIndicesExtraKind
  27017. * - VertexBuffer.MatricesWeightsKind
  27018. * - VertexBuffer.MatricesWeightsExtraKind
  27019. * @param data defines the data source
  27020. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27021. * @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)
  27022. */
  27023. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27024. /**
  27025. * Creates a new index buffer
  27026. * @param indices defines the indices to store in the index buffer
  27027. * @param totalVertices defines the total number of vertices (could be null)
  27028. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27029. */
  27030. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27031. }
  27032. /**
  27033. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27034. */
  27035. export class VertexData {
  27036. /**
  27037. * Mesh side orientation : usually the external or front surface
  27038. */
  27039. static readonly FRONTSIDE: number;
  27040. /**
  27041. * Mesh side orientation : usually the internal or back surface
  27042. */
  27043. static readonly BACKSIDE: number;
  27044. /**
  27045. * Mesh side orientation : both internal and external or front and back surfaces
  27046. */
  27047. static readonly DOUBLESIDE: number;
  27048. /**
  27049. * Mesh side orientation : by default, `FRONTSIDE`
  27050. */
  27051. static readonly DEFAULTSIDE: number;
  27052. /**
  27053. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27054. */
  27055. positions: Nullable<FloatArray>;
  27056. /**
  27057. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27058. */
  27059. normals: Nullable<FloatArray>;
  27060. /**
  27061. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27062. */
  27063. tangents: Nullable<FloatArray>;
  27064. /**
  27065. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27066. */
  27067. uvs: Nullable<FloatArray>;
  27068. /**
  27069. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27070. */
  27071. uvs2: Nullable<FloatArray>;
  27072. /**
  27073. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27074. */
  27075. uvs3: Nullable<FloatArray>;
  27076. /**
  27077. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27078. */
  27079. uvs4: Nullable<FloatArray>;
  27080. /**
  27081. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27082. */
  27083. uvs5: Nullable<FloatArray>;
  27084. /**
  27085. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27086. */
  27087. uvs6: Nullable<FloatArray>;
  27088. /**
  27089. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27090. */
  27091. colors: Nullable<FloatArray>;
  27092. /**
  27093. * 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).
  27094. */
  27095. matricesIndices: Nullable<FloatArray>;
  27096. /**
  27097. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27098. */
  27099. matricesWeights: Nullable<FloatArray>;
  27100. /**
  27101. * An array extending the number of possible indices
  27102. */
  27103. matricesIndicesExtra: Nullable<FloatArray>;
  27104. /**
  27105. * An array extending the number of possible weights when the number of indices is extended
  27106. */
  27107. matricesWeightsExtra: Nullable<FloatArray>;
  27108. /**
  27109. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27110. */
  27111. indices: Nullable<IndicesArray>;
  27112. /**
  27113. * Uses the passed data array to set the set the values for the specified kind of data
  27114. * @param data a linear array of floating numbers
  27115. * @param kind the type of data that is being set, eg positions, colors etc
  27116. */
  27117. set(data: FloatArray, kind: string): void;
  27118. /**
  27119. * Associates the vertexData to the passed Mesh.
  27120. * Sets it as updatable or not (default `false`)
  27121. * @param mesh the mesh the vertexData is applied to
  27122. * @param updatable when used and having the value true allows new data to update the vertexData
  27123. * @returns the VertexData
  27124. */
  27125. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27126. /**
  27127. * Associates the vertexData to the passed Geometry.
  27128. * Sets it as updatable or not (default `false`)
  27129. * @param geometry the geometry the vertexData is applied to
  27130. * @param updatable when used and having the value true allows new data to update the vertexData
  27131. * @returns VertexData
  27132. */
  27133. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27134. /**
  27135. * Updates the associated mesh
  27136. * @param mesh the mesh to be updated
  27137. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27138. * @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
  27139. * @returns VertexData
  27140. */
  27141. updateMesh(mesh: Mesh): VertexData;
  27142. /**
  27143. * Updates the associated geometry
  27144. * @param geometry the geometry to be updated
  27145. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27146. * @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
  27147. * @returns VertexData.
  27148. */
  27149. updateGeometry(geometry: Geometry): VertexData;
  27150. private _applyTo;
  27151. private _update;
  27152. /**
  27153. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27154. * @param matrix the transforming matrix
  27155. * @returns the VertexData
  27156. */
  27157. transform(matrix: Matrix): VertexData;
  27158. /**
  27159. * Merges the passed VertexData into the current one
  27160. * @param other the VertexData to be merged into the current one
  27161. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27162. * @returns the modified VertexData
  27163. */
  27164. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27165. private _mergeElement;
  27166. private _validate;
  27167. /**
  27168. * Serializes the VertexData
  27169. * @returns a serialized object
  27170. */
  27171. serialize(): any;
  27172. /**
  27173. * Extracts the vertexData from a mesh
  27174. * @param mesh the mesh from which to extract the VertexData
  27175. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27176. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27177. * @returns the object VertexData associated to the passed mesh
  27178. */
  27179. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27180. /**
  27181. * Extracts the vertexData from the geometry
  27182. * @param geometry the geometry from which to extract the VertexData
  27183. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27184. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27185. * @returns the object VertexData associated to the passed mesh
  27186. */
  27187. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27188. private static _ExtractFrom;
  27189. /**
  27190. * Creates the VertexData for a Ribbon
  27191. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27192. * * pathArray array of paths, each of which an array of successive Vector3
  27193. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27194. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27195. * * 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
  27196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27197. * * 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)
  27198. * * 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)
  27199. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27200. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27201. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27202. * @returns the VertexData of the ribbon
  27203. */
  27204. static CreateRibbon(options: {
  27205. pathArray: Vector3[][];
  27206. closeArray?: boolean;
  27207. closePath?: boolean;
  27208. offset?: number;
  27209. sideOrientation?: number;
  27210. frontUVs?: Vector4;
  27211. backUVs?: Vector4;
  27212. invertUV?: boolean;
  27213. uvs?: Vector2[];
  27214. colors?: Color4[];
  27215. }): VertexData;
  27216. /**
  27217. * Creates the VertexData for a box
  27218. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27219. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27220. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27221. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27222. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27223. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27224. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27226. * * 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)
  27227. * * 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)
  27228. * @returns the VertexData of the box
  27229. */
  27230. static CreateBox(options: {
  27231. size?: number;
  27232. width?: number;
  27233. height?: number;
  27234. depth?: number;
  27235. faceUV?: Vector4[];
  27236. faceColors?: Color4[];
  27237. sideOrientation?: number;
  27238. frontUVs?: Vector4;
  27239. backUVs?: Vector4;
  27240. }): VertexData;
  27241. /**
  27242. * Creates the VertexData for a tiled box
  27243. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27244. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27245. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27246. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27248. * @returns the VertexData of the box
  27249. */
  27250. static CreateTiledBox(options: {
  27251. pattern?: number;
  27252. width?: number;
  27253. height?: number;
  27254. depth?: number;
  27255. tileSize?: number;
  27256. tileWidth?: number;
  27257. tileHeight?: number;
  27258. alignHorizontal?: number;
  27259. alignVertical?: number;
  27260. faceUV?: Vector4[];
  27261. faceColors?: Color4[];
  27262. sideOrientation?: number;
  27263. }): VertexData;
  27264. /**
  27265. * Creates the VertexData for a tiled plane
  27266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27267. * * pattern a limited pattern arrangement depending on the number
  27268. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27269. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27270. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27272. * * 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)
  27273. * * 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)
  27274. * @returns the VertexData of the tiled plane
  27275. */
  27276. static CreateTiledPlane(options: {
  27277. pattern?: number;
  27278. tileSize?: number;
  27279. tileWidth?: number;
  27280. tileHeight?: number;
  27281. size?: number;
  27282. width?: number;
  27283. height?: number;
  27284. alignHorizontal?: number;
  27285. alignVertical?: number;
  27286. sideOrientation?: number;
  27287. frontUVs?: Vector4;
  27288. backUVs?: Vector4;
  27289. }): VertexData;
  27290. /**
  27291. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27292. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27293. * * segments sets the number of horizontal strips optional, default 32
  27294. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27295. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27296. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27297. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27298. * * 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
  27299. * * 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
  27300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27301. * * 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)
  27302. * * 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)
  27303. * @returns the VertexData of the ellipsoid
  27304. */
  27305. static CreateSphere(options: {
  27306. segments?: number;
  27307. diameter?: number;
  27308. diameterX?: number;
  27309. diameterY?: number;
  27310. diameterZ?: number;
  27311. arc?: number;
  27312. slice?: number;
  27313. sideOrientation?: number;
  27314. frontUVs?: Vector4;
  27315. backUVs?: Vector4;
  27316. }): VertexData;
  27317. /**
  27318. * Creates the VertexData for a cylinder, cone or prism
  27319. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27320. * * height sets the height (y direction) of the cylinder, optional, default 2
  27321. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27322. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27323. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27324. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27325. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27326. * * 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
  27327. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27328. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27329. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27330. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27331. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27332. * * 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)
  27333. * * 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)
  27334. * @returns the VertexData of the cylinder, cone or prism
  27335. */
  27336. static CreateCylinder(options: {
  27337. height?: number;
  27338. diameterTop?: number;
  27339. diameterBottom?: number;
  27340. diameter?: number;
  27341. tessellation?: number;
  27342. subdivisions?: number;
  27343. arc?: number;
  27344. faceColors?: Color4[];
  27345. faceUV?: Vector4[];
  27346. hasRings?: boolean;
  27347. enclose?: boolean;
  27348. sideOrientation?: number;
  27349. frontUVs?: Vector4;
  27350. backUVs?: Vector4;
  27351. }): VertexData;
  27352. /**
  27353. * Creates the VertexData for a torus
  27354. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27355. * * diameter the diameter of the torus, optional default 1
  27356. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27357. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27359. * * 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)
  27360. * * 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)
  27361. * @returns the VertexData of the torus
  27362. */
  27363. static CreateTorus(options: {
  27364. diameter?: number;
  27365. thickness?: number;
  27366. tessellation?: number;
  27367. sideOrientation?: number;
  27368. frontUVs?: Vector4;
  27369. backUVs?: Vector4;
  27370. }): VertexData;
  27371. /**
  27372. * Creates the VertexData of the LineSystem
  27373. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27374. * - lines an array of lines, each line being an array of successive Vector3
  27375. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27376. * @returns the VertexData of the LineSystem
  27377. */
  27378. static CreateLineSystem(options: {
  27379. lines: Vector3[][];
  27380. colors?: Nullable<Color4[][]>;
  27381. }): VertexData;
  27382. /**
  27383. * Create the VertexData for a DashedLines
  27384. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27385. * - points an array successive Vector3
  27386. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27387. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27388. * - dashNb the intended total number of dashes, optional, default 200
  27389. * @returns the VertexData for the DashedLines
  27390. */
  27391. static CreateDashedLines(options: {
  27392. points: Vector3[];
  27393. dashSize?: number;
  27394. gapSize?: number;
  27395. dashNb?: number;
  27396. }): VertexData;
  27397. /**
  27398. * Creates the VertexData for a Ground
  27399. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27400. * - width the width (x direction) of the ground, optional, default 1
  27401. * - height the height (z direction) of the ground, optional, default 1
  27402. * - subdivisions the number of subdivisions per side, optional, default 1
  27403. * @returns the VertexData of the Ground
  27404. */
  27405. static CreateGround(options: {
  27406. width?: number;
  27407. height?: number;
  27408. subdivisions?: number;
  27409. subdivisionsX?: number;
  27410. subdivisionsY?: number;
  27411. }): VertexData;
  27412. /**
  27413. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27414. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27415. * * xmin the ground minimum X coordinate, optional, default -1
  27416. * * zmin the ground minimum Z coordinate, optional, default -1
  27417. * * xmax the ground maximum X coordinate, optional, default 1
  27418. * * zmax the ground maximum Z coordinate, optional, default 1
  27419. * * 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}
  27420. * * 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}
  27421. * @returns the VertexData of the TiledGround
  27422. */
  27423. static CreateTiledGround(options: {
  27424. xmin: number;
  27425. zmin: number;
  27426. xmax: number;
  27427. zmax: number;
  27428. subdivisions?: {
  27429. w: number;
  27430. h: number;
  27431. };
  27432. precision?: {
  27433. w: number;
  27434. h: number;
  27435. };
  27436. }): VertexData;
  27437. /**
  27438. * Creates the VertexData of the Ground designed from a heightmap
  27439. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27440. * * width the width (x direction) of the ground
  27441. * * height the height (z direction) of the ground
  27442. * * subdivisions the number of subdivisions per side
  27443. * * minHeight the minimum altitude on the ground, optional, default 0
  27444. * * maxHeight the maximum altitude on the ground, optional default 1
  27445. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27446. * * buffer the array holding the image color data
  27447. * * bufferWidth the width of image
  27448. * * bufferHeight the height of image
  27449. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27450. * @returns the VertexData of the Ground designed from a heightmap
  27451. */
  27452. static CreateGroundFromHeightMap(options: {
  27453. width: number;
  27454. height: number;
  27455. subdivisions: number;
  27456. minHeight: number;
  27457. maxHeight: number;
  27458. colorFilter: Color3;
  27459. buffer: Uint8Array;
  27460. bufferWidth: number;
  27461. bufferHeight: number;
  27462. alphaFilter: number;
  27463. }): VertexData;
  27464. /**
  27465. * Creates the VertexData for a Plane
  27466. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27467. * * size sets the width and height of the plane to the value of size, optional default 1
  27468. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27469. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27471. * * 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)
  27472. * * 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)
  27473. * @returns the VertexData of the box
  27474. */
  27475. static CreatePlane(options: {
  27476. size?: number;
  27477. width?: number;
  27478. height?: number;
  27479. sideOrientation?: number;
  27480. frontUVs?: Vector4;
  27481. backUVs?: Vector4;
  27482. }): VertexData;
  27483. /**
  27484. * Creates the VertexData of the Disc or regular Polygon
  27485. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27486. * * radius the radius of the disc, optional default 0.5
  27487. * * tessellation the number of polygon sides, optional, default 64
  27488. * * 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
  27489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27490. * * 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)
  27491. * * 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)
  27492. * @returns the VertexData of the box
  27493. */
  27494. static CreateDisc(options: {
  27495. radius?: number;
  27496. tessellation?: number;
  27497. arc?: number;
  27498. sideOrientation?: number;
  27499. frontUVs?: Vector4;
  27500. backUVs?: Vector4;
  27501. }): VertexData;
  27502. /**
  27503. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27504. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27505. * @param polygon a mesh built from polygonTriangulation.build()
  27506. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27507. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27508. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27509. * @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)
  27510. * @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)
  27511. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27512. * @returns the VertexData of the Polygon
  27513. */
  27514. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27515. /**
  27516. * Creates the VertexData of the IcoSphere
  27517. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27518. * * radius the radius of the IcoSphere, optional default 1
  27519. * * radiusX allows stretching in the x direction, optional, default radius
  27520. * * radiusY allows stretching in the y direction, optional, default radius
  27521. * * radiusZ allows stretching in the z direction, optional, default radius
  27522. * * flat when true creates a flat shaded mesh, optional, default true
  27523. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27525. * * 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)
  27526. * * 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)
  27527. * @returns the VertexData of the IcoSphere
  27528. */
  27529. static CreateIcoSphere(options: {
  27530. radius?: number;
  27531. radiusX?: number;
  27532. radiusY?: number;
  27533. radiusZ?: number;
  27534. flat?: boolean;
  27535. subdivisions?: number;
  27536. sideOrientation?: number;
  27537. frontUVs?: Vector4;
  27538. backUVs?: Vector4;
  27539. }): VertexData;
  27540. /**
  27541. * Creates the VertexData for a Polyhedron
  27542. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27543. * * type provided types are:
  27544. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27545. * * 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)
  27546. * * size the size of the IcoSphere, optional default 1
  27547. * * sizeX allows stretching in the x direction, optional, default size
  27548. * * sizeY allows stretching in the y direction, optional, default size
  27549. * * sizeZ allows stretching in the z direction, optional, default size
  27550. * * 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
  27551. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27552. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27553. * * flat when true creates a flat shaded mesh, optional, default true
  27554. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27556. * * 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)
  27557. * * 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)
  27558. * @returns the VertexData of the Polyhedron
  27559. */
  27560. static CreatePolyhedron(options: {
  27561. type?: number;
  27562. size?: number;
  27563. sizeX?: number;
  27564. sizeY?: number;
  27565. sizeZ?: number;
  27566. custom?: any;
  27567. faceUV?: Vector4[];
  27568. faceColors?: Color4[];
  27569. flat?: boolean;
  27570. sideOrientation?: number;
  27571. frontUVs?: Vector4;
  27572. backUVs?: Vector4;
  27573. }): VertexData;
  27574. /**
  27575. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27576. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27577. * @returns the VertexData of the Capsule
  27578. */
  27579. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27580. /**
  27581. * Creates the VertexData for a TorusKnot
  27582. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27583. * * radius the radius of the torus knot, optional, default 2
  27584. * * tube the thickness of the tube, optional, default 0.5
  27585. * * radialSegments the number of sides on each tube segments, optional, default 32
  27586. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27587. * * p the number of windings around the z axis, optional, default 2
  27588. * * q the number of windings around the x axis, optional, default 3
  27589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27590. * * 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)
  27591. * * 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)
  27592. * @returns the VertexData of the Torus Knot
  27593. */
  27594. static CreateTorusKnot(options: {
  27595. radius?: number;
  27596. tube?: number;
  27597. radialSegments?: number;
  27598. tubularSegments?: number;
  27599. p?: number;
  27600. q?: number;
  27601. sideOrientation?: number;
  27602. frontUVs?: Vector4;
  27603. backUVs?: Vector4;
  27604. }): VertexData;
  27605. /**
  27606. * Compute normals for given positions and indices
  27607. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27608. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27609. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27610. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27611. * * facetNormals : optional array of facet normals (vector3)
  27612. * * facetPositions : optional array of facet positions (vector3)
  27613. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27614. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27615. * * bInfo : optional bounding info, required for facetPartitioning computation
  27616. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27617. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27618. * * useRightHandedSystem: optional boolean to for right handed system computation
  27619. * * depthSort : optional boolean to enable the facet depth sort computation
  27620. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27621. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27622. */
  27623. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27624. facetNormals?: any;
  27625. facetPositions?: any;
  27626. facetPartitioning?: any;
  27627. ratio?: number;
  27628. bInfo?: any;
  27629. bbSize?: Vector3;
  27630. subDiv?: any;
  27631. useRightHandedSystem?: boolean;
  27632. depthSort?: boolean;
  27633. distanceTo?: Vector3;
  27634. depthSortedFacets?: any;
  27635. }): void;
  27636. /** @hidden */
  27637. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27638. /**
  27639. * Applies VertexData created from the imported parameters to the geometry
  27640. * @param parsedVertexData the parsed data from an imported file
  27641. * @param geometry the geometry to apply the VertexData to
  27642. */
  27643. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27644. }
  27645. }
  27646. declare module "babylonjs/Morph/morphTarget" {
  27647. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27648. import { Observable } from "babylonjs/Misc/observable";
  27649. import { Nullable, FloatArray } from "babylonjs/types";
  27650. import { Scene } from "babylonjs/scene";
  27651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27652. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27653. /**
  27654. * Defines a target to use with MorphTargetManager
  27655. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27656. */
  27657. export class MorphTarget implements IAnimatable {
  27658. /** defines the name of the target */
  27659. name: string;
  27660. /**
  27661. * Gets or sets the list of animations
  27662. */
  27663. animations: import("babylonjs/Animations/animation").Animation[];
  27664. private _scene;
  27665. private _positions;
  27666. private _normals;
  27667. private _tangents;
  27668. private _uvs;
  27669. private _influence;
  27670. private _uniqueId;
  27671. /**
  27672. * Observable raised when the influence changes
  27673. */
  27674. onInfluenceChanged: Observable<boolean>;
  27675. /** @hidden */
  27676. _onDataLayoutChanged: Observable<void>;
  27677. /**
  27678. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27679. */
  27680. get influence(): number;
  27681. set influence(influence: number);
  27682. /**
  27683. * Gets or sets the id of the morph Target
  27684. */
  27685. id: string;
  27686. private _animationPropertiesOverride;
  27687. /**
  27688. * Gets or sets the animation properties override
  27689. */
  27690. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27691. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27692. /**
  27693. * Creates a new MorphTarget
  27694. * @param name defines the name of the target
  27695. * @param influence defines the influence to use
  27696. * @param scene defines the scene the morphtarget belongs to
  27697. */
  27698. constructor(
  27699. /** defines the name of the target */
  27700. name: string, influence?: number, scene?: Nullable<Scene>);
  27701. /**
  27702. * Gets the unique ID of this manager
  27703. */
  27704. get uniqueId(): number;
  27705. /**
  27706. * Gets a boolean defining if the target contains position data
  27707. */
  27708. get hasPositions(): boolean;
  27709. /**
  27710. * Gets a boolean defining if the target contains normal data
  27711. */
  27712. get hasNormals(): boolean;
  27713. /**
  27714. * Gets a boolean defining if the target contains tangent data
  27715. */
  27716. get hasTangents(): boolean;
  27717. /**
  27718. * Gets a boolean defining if the target contains texture coordinates data
  27719. */
  27720. get hasUVs(): boolean;
  27721. /**
  27722. * Affects position data to this target
  27723. * @param data defines the position data to use
  27724. */
  27725. setPositions(data: Nullable<FloatArray>): void;
  27726. /**
  27727. * Gets the position data stored in this target
  27728. * @returns a FloatArray containing the position data (or null if not present)
  27729. */
  27730. getPositions(): Nullable<FloatArray>;
  27731. /**
  27732. * Affects normal data to this target
  27733. * @param data defines the normal data to use
  27734. */
  27735. setNormals(data: Nullable<FloatArray>): void;
  27736. /**
  27737. * Gets the normal data stored in this target
  27738. * @returns a FloatArray containing the normal data (or null if not present)
  27739. */
  27740. getNormals(): Nullable<FloatArray>;
  27741. /**
  27742. * Affects tangent data to this target
  27743. * @param data defines the tangent data to use
  27744. */
  27745. setTangents(data: Nullable<FloatArray>): void;
  27746. /**
  27747. * Gets the tangent data stored in this target
  27748. * @returns a FloatArray containing the tangent data (or null if not present)
  27749. */
  27750. getTangents(): Nullable<FloatArray>;
  27751. /**
  27752. * Affects texture coordinates data to this target
  27753. * @param data defines the texture coordinates data to use
  27754. */
  27755. setUVs(data: Nullable<FloatArray>): void;
  27756. /**
  27757. * Gets the texture coordinates data stored in this target
  27758. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27759. */
  27760. getUVs(): Nullable<FloatArray>;
  27761. /**
  27762. * Clone the current target
  27763. * @returns a new MorphTarget
  27764. */
  27765. clone(): MorphTarget;
  27766. /**
  27767. * Serializes the current target into a Serialization object
  27768. * @returns the serialized object
  27769. */
  27770. serialize(): any;
  27771. /**
  27772. * Returns the string "MorphTarget"
  27773. * @returns "MorphTarget"
  27774. */
  27775. getClassName(): string;
  27776. /**
  27777. * Creates a new target from serialized data
  27778. * @param serializationObject defines the serialized data to use
  27779. * @returns a new MorphTarget
  27780. */
  27781. static Parse(serializationObject: any): MorphTarget;
  27782. /**
  27783. * Creates a MorphTarget from mesh data
  27784. * @param mesh defines the source mesh
  27785. * @param name defines the name to use for the new target
  27786. * @param influence defines the influence to attach to the target
  27787. * @returns a new MorphTarget
  27788. */
  27789. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27790. }
  27791. }
  27792. declare module "babylonjs/Morph/morphTargetManager" {
  27793. import { Nullable } from "babylonjs/types";
  27794. import { Scene } from "babylonjs/scene";
  27795. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27796. /**
  27797. * This class is used to deform meshes using morphing between different targets
  27798. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27799. */
  27800. export class MorphTargetManager {
  27801. private _targets;
  27802. private _targetInfluenceChangedObservers;
  27803. private _targetDataLayoutChangedObservers;
  27804. private _activeTargets;
  27805. private _scene;
  27806. private _influences;
  27807. private _supportsNormals;
  27808. private _supportsTangents;
  27809. private _supportsUVs;
  27810. private _vertexCount;
  27811. private _uniqueId;
  27812. private _tempInfluences;
  27813. /**
  27814. * Gets or sets a boolean indicating if normals must be morphed
  27815. */
  27816. enableNormalMorphing: boolean;
  27817. /**
  27818. * Gets or sets a boolean indicating if tangents must be morphed
  27819. */
  27820. enableTangentMorphing: boolean;
  27821. /**
  27822. * Gets or sets a boolean indicating if UV must be morphed
  27823. */
  27824. enableUVMorphing: boolean;
  27825. /**
  27826. * Creates a new MorphTargetManager
  27827. * @param scene defines the current scene
  27828. */
  27829. constructor(scene?: Nullable<Scene>);
  27830. /**
  27831. * Gets the unique ID of this manager
  27832. */
  27833. get uniqueId(): number;
  27834. /**
  27835. * Gets the number of vertices handled by this manager
  27836. */
  27837. get vertexCount(): number;
  27838. /**
  27839. * Gets a boolean indicating if this manager supports morphing of normals
  27840. */
  27841. get supportsNormals(): boolean;
  27842. /**
  27843. * Gets a boolean indicating if this manager supports morphing of tangents
  27844. */
  27845. get supportsTangents(): boolean;
  27846. /**
  27847. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27848. */
  27849. get supportsUVs(): boolean;
  27850. /**
  27851. * Gets the number of targets stored in this manager
  27852. */
  27853. get numTargets(): number;
  27854. /**
  27855. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27856. */
  27857. get numInfluencers(): number;
  27858. /**
  27859. * Gets the list of influences (one per target)
  27860. */
  27861. get influences(): Float32Array;
  27862. /**
  27863. * Gets the active target at specified index. An active target is a target with an influence > 0
  27864. * @param index defines the index to check
  27865. * @returns the requested target
  27866. */
  27867. getActiveTarget(index: number): MorphTarget;
  27868. /**
  27869. * Gets the target at specified index
  27870. * @param index defines the index to check
  27871. * @returns the requested target
  27872. */
  27873. getTarget(index: number): MorphTarget;
  27874. /**
  27875. * Add a new target to this manager
  27876. * @param target defines the target to add
  27877. */
  27878. addTarget(target: MorphTarget): void;
  27879. /**
  27880. * Removes a target from the manager
  27881. * @param target defines the target to remove
  27882. */
  27883. removeTarget(target: MorphTarget): void;
  27884. /**
  27885. * Clone the current manager
  27886. * @returns a new MorphTargetManager
  27887. */
  27888. clone(): MorphTargetManager;
  27889. /**
  27890. * Serializes the current manager into a Serialization object
  27891. * @returns the serialized object
  27892. */
  27893. serialize(): any;
  27894. private _syncActiveTargets;
  27895. /**
  27896. * Syncrhonize the targets with all the meshes using this morph target manager
  27897. */
  27898. synchronize(): void;
  27899. /**
  27900. * Creates a new MorphTargetManager from serialized data
  27901. * @param serializationObject defines the serialized data
  27902. * @param scene defines the hosting scene
  27903. * @returns the new MorphTargetManager
  27904. */
  27905. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27906. }
  27907. }
  27908. declare module "babylonjs/Meshes/meshLODLevel" {
  27909. import { Mesh } from "babylonjs/Meshes/mesh";
  27910. import { Nullable } from "babylonjs/types";
  27911. /**
  27912. * Class used to represent a specific level of detail of a mesh
  27913. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27914. */
  27915. export class MeshLODLevel {
  27916. /** Defines the distance where this level should start being displayed */
  27917. distance: number;
  27918. /** Defines the mesh to use to render this level */
  27919. mesh: Nullable<Mesh>;
  27920. /**
  27921. * Creates a new LOD level
  27922. * @param distance defines the distance where this level should star being displayed
  27923. * @param mesh defines the mesh to use to render this level
  27924. */
  27925. constructor(
  27926. /** Defines the distance where this level should start being displayed */
  27927. distance: number,
  27928. /** Defines the mesh to use to render this level */
  27929. mesh: Nullable<Mesh>);
  27930. }
  27931. }
  27932. declare module "babylonjs/Misc/canvasGenerator" {
  27933. /**
  27934. * Helper class used to generate a canvas to manipulate images
  27935. */
  27936. export class CanvasGenerator {
  27937. /**
  27938. * Create a new canvas (or offscreen canvas depending on the context)
  27939. * @param width defines the expected width
  27940. * @param height defines the expected height
  27941. * @return a new canvas or offscreen canvas
  27942. */
  27943. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27944. }
  27945. }
  27946. declare module "babylonjs/Meshes/groundMesh" {
  27947. import { Scene } from "babylonjs/scene";
  27948. import { Vector3 } from "babylonjs/Maths/math.vector";
  27949. import { Mesh } from "babylonjs/Meshes/mesh";
  27950. /**
  27951. * Mesh representing the gorund
  27952. */
  27953. export class GroundMesh extends Mesh {
  27954. /** If octree should be generated */
  27955. generateOctree: boolean;
  27956. private _heightQuads;
  27957. /** @hidden */
  27958. _subdivisionsX: number;
  27959. /** @hidden */
  27960. _subdivisionsY: number;
  27961. /** @hidden */
  27962. _width: number;
  27963. /** @hidden */
  27964. _height: number;
  27965. /** @hidden */
  27966. _minX: number;
  27967. /** @hidden */
  27968. _maxX: number;
  27969. /** @hidden */
  27970. _minZ: number;
  27971. /** @hidden */
  27972. _maxZ: number;
  27973. constructor(name: string, scene: Scene);
  27974. /**
  27975. * "GroundMesh"
  27976. * @returns "GroundMesh"
  27977. */
  27978. getClassName(): string;
  27979. /**
  27980. * The minimum of x and y subdivisions
  27981. */
  27982. get subdivisions(): number;
  27983. /**
  27984. * X subdivisions
  27985. */
  27986. get subdivisionsX(): number;
  27987. /**
  27988. * Y subdivisions
  27989. */
  27990. get subdivisionsY(): number;
  27991. /**
  27992. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27993. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27994. * @param chunksCount the number of subdivisions for x and y
  27995. * @param octreeBlocksSize (Default: 32)
  27996. */
  27997. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27998. /**
  27999. * Returns a height (y) value in the Worl system :
  28000. * the ground altitude at the coordinates (x, z) expressed in the World system.
  28001. * @param x x coordinate
  28002. * @param z z coordinate
  28003. * @returns the ground y position if (x, z) are outside the ground surface.
  28004. */
  28005. getHeightAtCoordinates(x: number, z: number): number;
  28006. /**
  28007. * Returns a normalized vector (Vector3) orthogonal to the ground
  28008. * at the ground coordinates (x, z) expressed in the World system.
  28009. * @param x x coordinate
  28010. * @param z z coordinate
  28011. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  28012. */
  28013. getNormalAtCoordinates(x: number, z: number): Vector3;
  28014. /**
  28015. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  28016. * at the ground coordinates (x, z) expressed in the World system.
  28017. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  28018. * @param x x coordinate
  28019. * @param z z coordinate
  28020. * @param ref vector to store the result
  28021. * @returns the GroundMesh.
  28022. */
  28023. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  28024. /**
  28025. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  28026. * if the ground has been updated.
  28027. * This can be used in the render loop.
  28028. * @returns the GroundMesh.
  28029. */
  28030. updateCoordinateHeights(): GroundMesh;
  28031. private _getFacetAt;
  28032. private _initHeightQuads;
  28033. private _computeHeightQuads;
  28034. /**
  28035. * Serializes this ground mesh
  28036. * @param serializationObject object to write serialization to
  28037. */
  28038. serialize(serializationObject: any): void;
  28039. /**
  28040. * Parses a serialized ground mesh
  28041. * @param parsedMesh the serialized mesh
  28042. * @param scene the scene to create the ground mesh in
  28043. * @returns the created ground mesh
  28044. */
  28045. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  28046. }
  28047. }
  28048. declare module "babylonjs/Physics/physicsJoint" {
  28049. import { Vector3 } from "babylonjs/Maths/math.vector";
  28050. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  28051. /**
  28052. * Interface for Physics-Joint data
  28053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28054. */
  28055. export interface PhysicsJointData {
  28056. /**
  28057. * The main pivot of the joint
  28058. */
  28059. mainPivot?: Vector3;
  28060. /**
  28061. * The connected pivot of the joint
  28062. */
  28063. connectedPivot?: Vector3;
  28064. /**
  28065. * The main axis of the joint
  28066. */
  28067. mainAxis?: Vector3;
  28068. /**
  28069. * The connected axis of the joint
  28070. */
  28071. connectedAxis?: Vector3;
  28072. /**
  28073. * The collision of the joint
  28074. */
  28075. collision?: boolean;
  28076. /**
  28077. * Native Oimo/Cannon/Energy data
  28078. */
  28079. nativeParams?: any;
  28080. }
  28081. /**
  28082. * This is a holder class for the physics joint created by the physics plugin
  28083. * It holds a set of functions to control the underlying joint
  28084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28085. */
  28086. export class PhysicsJoint {
  28087. /**
  28088. * The type of the physics joint
  28089. */
  28090. type: number;
  28091. /**
  28092. * The data for the physics joint
  28093. */
  28094. jointData: PhysicsJointData;
  28095. private _physicsJoint;
  28096. protected _physicsPlugin: IPhysicsEnginePlugin;
  28097. /**
  28098. * Initializes the physics joint
  28099. * @param type The type of the physics joint
  28100. * @param jointData The data for the physics joint
  28101. */
  28102. constructor(
  28103. /**
  28104. * The type of the physics joint
  28105. */
  28106. type: number,
  28107. /**
  28108. * The data for the physics joint
  28109. */
  28110. jointData: PhysicsJointData);
  28111. /**
  28112. * Gets the physics joint
  28113. */
  28114. get physicsJoint(): any;
  28115. /**
  28116. * Sets the physics joint
  28117. */
  28118. set physicsJoint(newJoint: any);
  28119. /**
  28120. * Sets the physics plugin
  28121. */
  28122. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28123. /**
  28124. * Execute a function that is physics-plugin specific.
  28125. * @param {Function} func the function that will be executed.
  28126. * It accepts two parameters: the physics world and the physics joint
  28127. */
  28128. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28129. /**
  28130. * Distance-Joint type
  28131. */
  28132. static DistanceJoint: number;
  28133. /**
  28134. * Hinge-Joint type
  28135. */
  28136. static HingeJoint: number;
  28137. /**
  28138. * Ball-and-Socket joint type
  28139. */
  28140. static BallAndSocketJoint: number;
  28141. /**
  28142. * Wheel-Joint type
  28143. */
  28144. static WheelJoint: number;
  28145. /**
  28146. * Slider-Joint type
  28147. */
  28148. static SliderJoint: number;
  28149. /**
  28150. * Prismatic-Joint type
  28151. */
  28152. static PrismaticJoint: number;
  28153. /**
  28154. * Universal-Joint type
  28155. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28156. */
  28157. static UniversalJoint: number;
  28158. /**
  28159. * Hinge-Joint 2 type
  28160. */
  28161. static Hinge2Joint: number;
  28162. /**
  28163. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28164. */
  28165. static PointToPointJoint: number;
  28166. /**
  28167. * Spring-Joint type
  28168. */
  28169. static SpringJoint: number;
  28170. /**
  28171. * Lock-Joint type
  28172. */
  28173. static LockJoint: number;
  28174. }
  28175. /**
  28176. * A class representing a physics distance joint
  28177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28178. */
  28179. export class DistanceJoint extends PhysicsJoint {
  28180. /**
  28181. *
  28182. * @param jointData The data for the Distance-Joint
  28183. */
  28184. constructor(jointData: DistanceJointData);
  28185. /**
  28186. * Update the predefined distance.
  28187. * @param maxDistance The maximum preferred distance
  28188. * @param minDistance The minimum preferred distance
  28189. */
  28190. updateDistance(maxDistance: number, minDistance?: number): void;
  28191. }
  28192. /**
  28193. * Represents a Motor-Enabled Joint
  28194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28195. */
  28196. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28197. /**
  28198. * Initializes the Motor-Enabled Joint
  28199. * @param type The type of the joint
  28200. * @param jointData The physica joint data for the joint
  28201. */
  28202. constructor(type: number, jointData: PhysicsJointData);
  28203. /**
  28204. * Set the motor values.
  28205. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28206. * @param force the force to apply
  28207. * @param maxForce max force for this motor.
  28208. */
  28209. setMotor(force?: number, maxForce?: number): void;
  28210. /**
  28211. * Set the motor's limits.
  28212. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28213. * @param upperLimit The upper limit of the motor
  28214. * @param lowerLimit The lower limit of the motor
  28215. */
  28216. setLimit(upperLimit: number, lowerLimit?: number): void;
  28217. }
  28218. /**
  28219. * This class represents a single physics Hinge-Joint
  28220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28221. */
  28222. export class HingeJoint extends MotorEnabledJoint {
  28223. /**
  28224. * Initializes the Hinge-Joint
  28225. * @param jointData The joint data for the Hinge-Joint
  28226. */
  28227. constructor(jointData: PhysicsJointData);
  28228. /**
  28229. * Set the motor values.
  28230. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28231. * @param {number} force the force to apply
  28232. * @param {number} maxForce max force for this motor.
  28233. */
  28234. setMotor(force?: number, maxForce?: number): void;
  28235. /**
  28236. * Set the motor's limits.
  28237. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28238. * @param upperLimit The upper limit of the motor
  28239. * @param lowerLimit The lower limit of the motor
  28240. */
  28241. setLimit(upperLimit: number, lowerLimit?: number): void;
  28242. }
  28243. /**
  28244. * This class represents a dual hinge physics joint (same as wheel joint)
  28245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28246. */
  28247. export class Hinge2Joint extends MotorEnabledJoint {
  28248. /**
  28249. * Initializes the Hinge2-Joint
  28250. * @param jointData The joint data for the Hinge2-Joint
  28251. */
  28252. constructor(jointData: PhysicsJointData);
  28253. /**
  28254. * Set the motor values.
  28255. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28256. * @param {number} targetSpeed the speed the motor is to reach
  28257. * @param {number} maxForce max force for this motor.
  28258. * @param {motorIndex} the motor's index, 0 or 1.
  28259. */
  28260. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28261. /**
  28262. * Set the motor limits.
  28263. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28264. * @param {number} upperLimit the upper limit
  28265. * @param {number} lowerLimit lower limit
  28266. * @param {motorIndex} the motor's index, 0 or 1.
  28267. */
  28268. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28269. }
  28270. /**
  28271. * Interface for a motor enabled joint
  28272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28273. */
  28274. export interface IMotorEnabledJoint {
  28275. /**
  28276. * Physics joint
  28277. */
  28278. physicsJoint: any;
  28279. /**
  28280. * Sets the motor of the motor-enabled joint
  28281. * @param force The force of the motor
  28282. * @param maxForce The maximum force of the motor
  28283. * @param motorIndex The index of the motor
  28284. */
  28285. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28286. /**
  28287. * Sets the limit of the motor
  28288. * @param upperLimit The upper limit of the motor
  28289. * @param lowerLimit The lower limit of the motor
  28290. * @param motorIndex The index of the motor
  28291. */
  28292. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28293. }
  28294. /**
  28295. * Joint data for a Distance-Joint
  28296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28297. */
  28298. export interface DistanceJointData extends PhysicsJointData {
  28299. /**
  28300. * Max distance the 2 joint objects can be apart
  28301. */
  28302. maxDistance: number;
  28303. }
  28304. /**
  28305. * Joint data from a spring joint
  28306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28307. */
  28308. export interface SpringJointData extends PhysicsJointData {
  28309. /**
  28310. * Length of the spring
  28311. */
  28312. length: number;
  28313. /**
  28314. * Stiffness of the spring
  28315. */
  28316. stiffness: number;
  28317. /**
  28318. * Damping of the spring
  28319. */
  28320. damping: number;
  28321. /** this callback will be called when applying the force to the impostors. */
  28322. forceApplicationCallback: () => void;
  28323. }
  28324. }
  28325. declare module "babylonjs/Physics/physicsRaycastResult" {
  28326. import { Vector3 } from "babylonjs/Maths/math.vector";
  28327. /**
  28328. * Holds the data for the raycast result
  28329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28330. */
  28331. export class PhysicsRaycastResult {
  28332. private _hasHit;
  28333. private _hitDistance;
  28334. private _hitNormalWorld;
  28335. private _hitPointWorld;
  28336. private _rayFromWorld;
  28337. private _rayToWorld;
  28338. /**
  28339. * Gets if there was a hit
  28340. */
  28341. get hasHit(): boolean;
  28342. /**
  28343. * Gets the distance from the hit
  28344. */
  28345. get hitDistance(): number;
  28346. /**
  28347. * Gets the hit normal/direction in the world
  28348. */
  28349. get hitNormalWorld(): Vector3;
  28350. /**
  28351. * Gets the hit point in the world
  28352. */
  28353. get hitPointWorld(): Vector3;
  28354. /**
  28355. * Gets the ray "start point" of the ray in the world
  28356. */
  28357. get rayFromWorld(): Vector3;
  28358. /**
  28359. * Gets the ray "end point" of the ray in the world
  28360. */
  28361. get rayToWorld(): Vector3;
  28362. /**
  28363. * Sets the hit data (normal & point in world space)
  28364. * @param hitNormalWorld defines the normal in world space
  28365. * @param hitPointWorld defines the point in world space
  28366. */
  28367. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28368. /**
  28369. * Sets the distance from the start point to the hit point
  28370. * @param distance
  28371. */
  28372. setHitDistance(distance: number): void;
  28373. /**
  28374. * Calculates the distance manually
  28375. */
  28376. calculateHitDistance(): void;
  28377. /**
  28378. * Resets all the values to default
  28379. * @param from The from point on world space
  28380. * @param to The to point on world space
  28381. */
  28382. reset(from?: Vector3, to?: Vector3): void;
  28383. }
  28384. /**
  28385. * Interface for the size containing width and height
  28386. */
  28387. interface IXYZ {
  28388. /**
  28389. * X
  28390. */
  28391. x: number;
  28392. /**
  28393. * Y
  28394. */
  28395. y: number;
  28396. /**
  28397. * Z
  28398. */
  28399. z: number;
  28400. }
  28401. }
  28402. declare module "babylonjs/Physics/IPhysicsEngine" {
  28403. import { Nullable } from "babylonjs/types";
  28404. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28406. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28407. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28408. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28409. /**
  28410. * Interface used to describe a physics joint
  28411. */
  28412. export interface PhysicsImpostorJoint {
  28413. /** Defines the main impostor to which the joint is linked */
  28414. mainImpostor: PhysicsImpostor;
  28415. /** Defines the impostor that is connected to the main impostor using this joint */
  28416. connectedImpostor: PhysicsImpostor;
  28417. /** Defines the joint itself */
  28418. joint: PhysicsJoint;
  28419. }
  28420. /** @hidden */
  28421. export interface IPhysicsEnginePlugin {
  28422. world: any;
  28423. name: string;
  28424. setGravity(gravity: Vector3): void;
  28425. setTimeStep(timeStep: number): void;
  28426. getTimeStep(): number;
  28427. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28428. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28429. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28430. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28431. removePhysicsBody(impostor: PhysicsImpostor): void;
  28432. generateJoint(joint: PhysicsImpostorJoint): void;
  28433. removeJoint(joint: PhysicsImpostorJoint): void;
  28434. isSupported(): boolean;
  28435. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28436. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28437. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28438. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28439. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28440. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28441. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28442. getBodyMass(impostor: PhysicsImpostor): number;
  28443. getBodyFriction(impostor: PhysicsImpostor): number;
  28444. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28445. getBodyRestitution(impostor: PhysicsImpostor): number;
  28446. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28447. getBodyPressure?(impostor: PhysicsImpostor): number;
  28448. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28449. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28450. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28451. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28452. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28453. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28454. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28455. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28456. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28457. sleepBody(impostor: PhysicsImpostor): void;
  28458. wakeUpBody(impostor: PhysicsImpostor): void;
  28459. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28460. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28461. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28462. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28463. getRadius(impostor: PhysicsImpostor): number;
  28464. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28465. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28466. dispose(): void;
  28467. }
  28468. /**
  28469. * Interface used to define a physics engine
  28470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28471. */
  28472. export interface IPhysicsEngine {
  28473. /**
  28474. * Gets the gravity vector used by the simulation
  28475. */
  28476. gravity: Vector3;
  28477. /**
  28478. * Sets the gravity vector used by the simulation
  28479. * @param gravity defines the gravity vector to use
  28480. */
  28481. setGravity(gravity: Vector3): void;
  28482. /**
  28483. * Set the time step of the physics engine.
  28484. * Default is 1/60.
  28485. * To slow it down, enter 1/600 for example.
  28486. * To speed it up, 1/30
  28487. * @param newTimeStep the new timestep to apply to this world.
  28488. */
  28489. setTimeStep(newTimeStep: number): void;
  28490. /**
  28491. * Get the time step of the physics engine.
  28492. * @returns the current time step
  28493. */
  28494. getTimeStep(): number;
  28495. /**
  28496. * Set the sub time step of the physics engine.
  28497. * Default is 0 meaning there is no sub steps
  28498. * To increase physics resolution precision, set a small value (like 1 ms)
  28499. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28500. */
  28501. setSubTimeStep(subTimeStep: number): void;
  28502. /**
  28503. * Get the sub time step of the physics engine.
  28504. * @returns the current sub time step
  28505. */
  28506. getSubTimeStep(): number;
  28507. /**
  28508. * Release all resources
  28509. */
  28510. dispose(): void;
  28511. /**
  28512. * Gets the name of the current physics plugin
  28513. * @returns the name of the plugin
  28514. */
  28515. getPhysicsPluginName(): string;
  28516. /**
  28517. * Adding a new impostor for the impostor tracking.
  28518. * This will be done by the impostor itself.
  28519. * @param impostor the impostor to add
  28520. */
  28521. addImpostor(impostor: PhysicsImpostor): void;
  28522. /**
  28523. * Remove an impostor from the engine.
  28524. * This impostor and its mesh will not longer be updated by the physics engine.
  28525. * @param impostor the impostor to remove
  28526. */
  28527. removeImpostor(impostor: PhysicsImpostor): void;
  28528. /**
  28529. * Add a joint to the physics engine
  28530. * @param mainImpostor defines the main impostor to which the joint is added.
  28531. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28532. * @param joint defines the joint that will connect both impostors.
  28533. */
  28534. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28535. /**
  28536. * Removes a joint from the simulation
  28537. * @param mainImpostor defines the impostor used with the joint
  28538. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28539. * @param joint defines the joint to remove
  28540. */
  28541. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28542. /**
  28543. * Gets the current plugin used to run the simulation
  28544. * @returns current plugin
  28545. */
  28546. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28547. /**
  28548. * Gets the list of physic impostors
  28549. * @returns an array of PhysicsImpostor
  28550. */
  28551. getImpostors(): Array<PhysicsImpostor>;
  28552. /**
  28553. * Gets the impostor for a physics enabled object
  28554. * @param object defines the object impersonated by the impostor
  28555. * @returns the PhysicsImpostor or null if not found
  28556. */
  28557. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28558. /**
  28559. * Gets the impostor for a physics body object
  28560. * @param body defines physics body used by the impostor
  28561. * @returns the PhysicsImpostor or null if not found
  28562. */
  28563. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28564. /**
  28565. * Does a raycast in the physics world
  28566. * @param from when should the ray start?
  28567. * @param to when should the ray end?
  28568. * @returns PhysicsRaycastResult
  28569. */
  28570. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28571. /**
  28572. * Called by the scene. No need to call it.
  28573. * @param delta defines the timespam between frames
  28574. */
  28575. _step(delta: number): void;
  28576. }
  28577. }
  28578. declare module "babylonjs/Physics/physicsImpostor" {
  28579. import { Nullable, IndicesArray } from "babylonjs/types";
  28580. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28581. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28583. import { Scene } from "babylonjs/scene";
  28584. import { Bone } from "babylonjs/Bones/bone";
  28585. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28586. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28587. import { Space } from "babylonjs/Maths/math.axis";
  28588. /**
  28589. * The interface for the physics imposter parameters
  28590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28591. */
  28592. export interface PhysicsImpostorParameters {
  28593. /**
  28594. * The mass of the physics imposter
  28595. */
  28596. mass: number;
  28597. /**
  28598. * The friction of the physics imposter
  28599. */
  28600. friction?: number;
  28601. /**
  28602. * The coefficient of restitution of the physics imposter
  28603. */
  28604. restitution?: number;
  28605. /**
  28606. * The native options of the physics imposter
  28607. */
  28608. nativeOptions?: any;
  28609. /**
  28610. * Specifies if the parent should be ignored
  28611. */
  28612. ignoreParent?: boolean;
  28613. /**
  28614. * Specifies if bi-directional transformations should be disabled
  28615. */
  28616. disableBidirectionalTransformation?: boolean;
  28617. /**
  28618. * The pressure inside the physics imposter, soft object only
  28619. */
  28620. pressure?: number;
  28621. /**
  28622. * The stiffness the physics imposter, soft object only
  28623. */
  28624. stiffness?: number;
  28625. /**
  28626. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28627. */
  28628. velocityIterations?: number;
  28629. /**
  28630. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28631. */
  28632. positionIterations?: number;
  28633. /**
  28634. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28635. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28636. * Add to fix multiple points
  28637. */
  28638. fixedPoints?: number;
  28639. /**
  28640. * The collision margin around a soft object
  28641. */
  28642. margin?: number;
  28643. /**
  28644. * The collision margin around a soft object
  28645. */
  28646. damping?: number;
  28647. /**
  28648. * The path for a rope based on an extrusion
  28649. */
  28650. path?: any;
  28651. /**
  28652. * The shape of an extrusion used for a rope based on an extrusion
  28653. */
  28654. shape?: any;
  28655. }
  28656. /**
  28657. * Interface for a physics-enabled object
  28658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28659. */
  28660. export interface IPhysicsEnabledObject {
  28661. /**
  28662. * The position of the physics-enabled object
  28663. */
  28664. position: Vector3;
  28665. /**
  28666. * The rotation of the physics-enabled object
  28667. */
  28668. rotationQuaternion: Nullable<Quaternion>;
  28669. /**
  28670. * The scale of the physics-enabled object
  28671. */
  28672. scaling: Vector3;
  28673. /**
  28674. * The rotation of the physics-enabled object
  28675. */
  28676. rotation?: Vector3;
  28677. /**
  28678. * The parent of the physics-enabled object
  28679. */
  28680. parent?: any;
  28681. /**
  28682. * The bounding info of the physics-enabled object
  28683. * @returns The bounding info of the physics-enabled object
  28684. */
  28685. getBoundingInfo(): BoundingInfo;
  28686. /**
  28687. * Computes the world matrix
  28688. * @param force Specifies if the world matrix should be computed by force
  28689. * @returns A world matrix
  28690. */
  28691. computeWorldMatrix(force: boolean): Matrix;
  28692. /**
  28693. * Gets the world matrix
  28694. * @returns A world matrix
  28695. */
  28696. getWorldMatrix?(): Matrix;
  28697. /**
  28698. * Gets the child meshes
  28699. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28700. * @returns An array of abstract meshes
  28701. */
  28702. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28703. /**
  28704. * Gets the vertex data
  28705. * @param kind The type of vertex data
  28706. * @returns A nullable array of numbers, or a float32 array
  28707. */
  28708. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28709. /**
  28710. * Gets the indices from the mesh
  28711. * @returns A nullable array of index arrays
  28712. */
  28713. getIndices?(): Nullable<IndicesArray>;
  28714. /**
  28715. * Gets the scene from the mesh
  28716. * @returns the indices array or null
  28717. */
  28718. getScene?(): Scene;
  28719. /**
  28720. * Gets the absolute position from the mesh
  28721. * @returns the absolute position
  28722. */
  28723. getAbsolutePosition(): Vector3;
  28724. /**
  28725. * Gets the absolute pivot point from the mesh
  28726. * @returns the absolute pivot point
  28727. */
  28728. getAbsolutePivotPoint(): Vector3;
  28729. /**
  28730. * Rotates the mesh
  28731. * @param axis The axis of rotation
  28732. * @param amount The amount of rotation
  28733. * @param space The space of the rotation
  28734. * @returns The rotation transform node
  28735. */
  28736. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28737. /**
  28738. * Translates the mesh
  28739. * @param axis The axis of translation
  28740. * @param distance The distance of translation
  28741. * @param space The space of the translation
  28742. * @returns The transform node
  28743. */
  28744. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28745. /**
  28746. * Sets the absolute position of the mesh
  28747. * @param absolutePosition The absolute position of the mesh
  28748. * @returns The transform node
  28749. */
  28750. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28751. /**
  28752. * Gets the class name of the mesh
  28753. * @returns The class name
  28754. */
  28755. getClassName(): string;
  28756. }
  28757. /**
  28758. * Represents a physics imposter
  28759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28760. */
  28761. export class PhysicsImpostor {
  28762. /**
  28763. * The physics-enabled object used as the physics imposter
  28764. */
  28765. object: IPhysicsEnabledObject;
  28766. /**
  28767. * The type of the physics imposter
  28768. */
  28769. type: number;
  28770. private _options;
  28771. private _scene?;
  28772. /**
  28773. * The default object size of the imposter
  28774. */
  28775. static DEFAULT_OBJECT_SIZE: Vector3;
  28776. /**
  28777. * The identity quaternion of the imposter
  28778. */
  28779. static IDENTITY_QUATERNION: Quaternion;
  28780. /** @hidden */
  28781. _pluginData: any;
  28782. private _physicsEngine;
  28783. private _physicsBody;
  28784. private _bodyUpdateRequired;
  28785. private _onBeforePhysicsStepCallbacks;
  28786. private _onAfterPhysicsStepCallbacks;
  28787. /** @hidden */
  28788. _onPhysicsCollideCallbacks: Array<{
  28789. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28790. otherImpostors: Array<PhysicsImpostor>;
  28791. }>;
  28792. private _deltaPosition;
  28793. private _deltaRotation;
  28794. private _deltaRotationConjugated;
  28795. /** @hidden */
  28796. _isFromLine: boolean;
  28797. private _parent;
  28798. private _isDisposed;
  28799. private static _tmpVecs;
  28800. private static _tmpQuat;
  28801. /**
  28802. * Specifies if the physics imposter is disposed
  28803. */
  28804. get isDisposed(): boolean;
  28805. /**
  28806. * Gets the mass of the physics imposter
  28807. */
  28808. get mass(): number;
  28809. set mass(value: number);
  28810. /**
  28811. * Gets the coefficient of friction
  28812. */
  28813. get friction(): number;
  28814. /**
  28815. * Sets the coefficient of friction
  28816. */
  28817. set friction(value: number);
  28818. /**
  28819. * Gets the coefficient of restitution
  28820. */
  28821. get restitution(): number;
  28822. /**
  28823. * Sets the coefficient of restitution
  28824. */
  28825. set restitution(value: number);
  28826. /**
  28827. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28828. */
  28829. get pressure(): number;
  28830. /**
  28831. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28832. */
  28833. set pressure(value: number);
  28834. /**
  28835. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28836. */
  28837. get stiffness(): number;
  28838. /**
  28839. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28840. */
  28841. set stiffness(value: number);
  28842. /**
  28843. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28844. */
  28845. get velocityIterations(): number;
  28846. /**
  28847. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28848. */
  28849. set velocityIterations(value: number);
  28850. /**
  28851. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28852. */
  28853. get positionIterations(): number;
  28854. /**
  28855. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28856. */
  28857. set positionIterations(value: number);
  28858. /**
  28859. * The unique id of the physics imposter
  28860. * set by the physics engine when adding this impostor to the array
  28861. */
  28862. uniqueId: number;
  28863. /**
  28864. * @hidden
  28865. */
  28866. soft: boolean;
  28867. /**
  28868. * @hidden
  28869. */
  28870. segments: number;
  28871. private _joints;
  28872. /**
  28873. * Initializes the physics imposter
  28874. * @param object The physics-enabled object used as the physics imposter
  28875. * @param type The type of the physics imposter
  28876. * @param _options The options for the physics imposter
  28877. * @param _scene The Babylon scene
  28878. */
  28879. constructor(
  28880. /**
  28881. * The physics-enabled object used as the physics imposter
  28882. */
  28883. object: IPhysicsEnabledObject,
  28884. /**
  28885. * The type of the physics imposter
  28886. */
  28887. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28888. /**
  28889. * This function will completly initialize this impostor.
  28890. * It will create a new body - but only if this mesh has no parent.
  28891. * If it has, this impostor will not be used other than to define the impostor
  28892. * of the child mesh.
  28893. * @hidden
  28894. */
  28895. _init(): void;
  28896. private _getPhysicsParent;
  28897. /**
  28898. * Should a new body be generated.
  28899. * @returns boolean specifying if body initialization is required
  28900. */
  28901. isBodyInitRequired(): boolean;
  28902. /**
  28903. * Sets the updated scaling
  28904. * @param updated Specifies if the scaling is updated
  28905. */
  28906. setScalingUpdated(): void;
  28907. /**
  28908. * Force a regeneration of this or the parent's impostor's body.
  28909. * Use under cautious - This will remove all joints already implemented.
  28910. */
  28911. forceUpdate(): void;
  28912. /**
  28913. * Gets the body that holds this impostor. Either its own, or its parent.
  28914. */
  28915. get physicsBody(): any;
  28916. /**
  28917. * Get the parent of the physics imposter
  28918. * @returns Physics imposter or null
  28919. */
  28920. get parent(): Nullable<PhysicsImpostor>;
  28921. /**
  28922. * Sets the parent of the physics imposter
  28923. */
  28924. set parent(value: Nullable<PhysicsImpostor>);
  28925. /**
  28926. * Set the physics body. Used mainly by the physics engine/plugin
  28927. */
  28928. set physicsBody(physicsBody: any);
  28929. /**
  28930. * Resets the update flags
  28931. */
  28932. resetUpdateFlags(): void;
  28933. /**
  28934. * Gets the object extend size
  28935. * @returns the object extend size
  28936. */
  28937. getObjectExtendSize(): Vector3;
  28938. /**
  28939. * Gets the object center
  28940. * @returns The object center
  28941. */
  28942. getObjectCenter(): Vector3;
  28943. /**
  28944. * Get a specific parameter from the options parameters
  28945. * @param paramName The object parameter name
  28946. * @returns The object parameter
  28947. */
  28948. getParam(paramName: string): any;
  28949. /**
  28950. * Sets a specific parameter in the options given to the physics plugin
  28951. * @param paramName The parameter name
  28952. * @param value The value of the parameter
  28953. */
  28954. setParam(paramName: string, value: number): void;
  28955. /**
  28956. * Specifically change the body's mass option. Won't recreate the physics body object
  28957. * @param mass The mass of the physics imposter
  28958. */
  28959. setMass(mass: number): void;
  28960. /**
  28961. * Gets the linear velocity
  28962. * @returns linear velocity or null
  28963. */
  28964. getLinearVelocity(): Nullable<Vector3>;
  28965. /**
  28966. * Sets the linear velocity
  28967. * @param velocity linear velocity or null
  28968. */
  28969. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28970. /**
  28971. * Gets the angular velocity
  28972. * @returns angular velocity or null
  28973. */
  28974. getAngularVelocity(): Nullable<Vector3>;
  28975. /**
  28976. * Sets the angular velocity
  28977. * @param velocity The velocity or null
  28978. */
  28979. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28980. /**
  28981. * Execute a function with the physics plugin native code
  28982. * Provide a function the will have two variables - the world object and the physics body object
  28983. * @param func The function to execute with the physics plugin native code
  28984. */
  28985. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28986. /**
  28987. * Register a function that will be executed before the physics world is stepping forward
  28988. * @param func The function to execute before the physics world is stepped forward
  28989. */
  28990. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28991. /**
  28992. * Unregister a function that will be executed before the physics world is stepping forward
  28993. * @param func The function to execute before the physics world is stepped forward
  28994. */
  28995. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28996. /**
  28997. * Register a function that will be executed after the physics step
  28998. * @param func The function to execute after physics step
  28999. */
  29000. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  29001. /**
  29002. * Unregisters a function that will be executed after the physics step
  29003. * @param func The function to execute after physics step
  29004. */
  29005. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  29006. /**
  29007. * register a function that will be executed when this impostor collides against a different body
  29008. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  29009. * @param func Callback that is executed on collision
  29010. */
  29011. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  29012. /**
  29013. * Unregisters the physics imposter on contact
  29014. * @param collideAgainst The physics object to collide against
  29015. * @param func Callback to execute on collision
  29016. */
  29017. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  29018. private _tmpQuat;
  29019. private _tmpQuat2;
  29020. /**
  29021. * Get the parent rotation
  29022. * @returns The parent rotation
  29023. */
  29024. getParentsRotation(): Quaternion;
  29025. /**
  29026. * this function is executed by the physics engine.
  29027. */
  29028. beforeStep: () => void;
  29029. /**
  29030. * this function is executed by the physics engine
  29031. */
  29032. afterStep: () => void;
  29033. /**
  29034. * Legacy collision detection event support
  29035. */
  29036. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  29037. /**
  29038. * event and body object due to cannon's event-based architecture.
  29039. */
  29040. onCollide: (e: {
  29041. body: any;
  29042. }) => void;
  29043. /**
  29044. * Apply a force
  29045. * @param force The force to apply
  29046. * @param contactPoint The contact point for the force
  29047. * @returns The physics imposter
  29048. */
  29049. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29050. /**
  29051. * Apply an impulse
  29052. * @param force The impulse force
  29053. * @param contactPoint The contact point for the impulse force
  29054. * @returns The physics imposter
  29055. */
  29056. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29057. /**
  29058. * A help function to create a joint
  29059. * @param otherImpostor A physics imposter used to create a joint
  29060. * @param jointType The type of joint
  29061. * @param jointData The data for the joint
  29062. * @returns The physics imposter
  29063. */
  29064. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  29065. /**
  29066. * Add a joint to this impostor with a different impostor
  29067. * @param otherImpostor A physics imposter used to add a joint
  29068. * @param joint The joint to add
  29069. * @returns The physics imposter
  29070. */
  29071. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  29072. /**
  29073. * Add an anchor to a cloth impostor
  29074. * @param otherImpostor rigid impostor to anchor to
  29075. * @param width ratio across width from 0 to 1
  29076. * @param height ratio up height from 0 to 1
  29077. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  29078. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  29079. * @returns impostor the soft imposter
  29080. */
  29081. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29082. /**
  29083. * Add a hook to a rope impostor
  29084. * @param otherImpostor rigid impostor to anchor to
  29085. * @param length ratio across rope from 0 to 1
  29086. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  29087. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  29088. * @returns impostor the rope imposter
  29089. */
  29090. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29091. /**
  29092. * Will keep this body still, in a sleep mode.
  29093. * @returns the physics imposter
  29094. */
  29095. sleep(): PhysicsImpostor;
  29096. /**
  29097. * Wake the body up.
  29098. * @returns The physics imposter
  29099. */
  29100. wakeUp(): PhysicsImpostor;
  29101. /**
  29102. * Clones the physics imposter
  29103. * @param newObject The physics imposter clones to this physics-enabled object
  29104. * @returns A nullable physics imposter
  29105. */
  29106. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29107. /**
  29108. * Disposes the physics imposter
  29109. */
  29110. dispose(): void;
  29111. /**
  29112. * Sets the delta position
  29113. * @param position The delta position amount
  29114. */
  29115. setDeltaPosition(position: Vector3): void;
  29116. /**
  29117. * Sets the delta rotation
  29118. * @param rotation The delta rotation amount
  29119. */
  29120. setDeltaRotation(rotation: Quaternion): void;
  29121. /**
  29122. * Gets the box size of the physics imposter and stores the result in the input parameter
  29123. * @param result Stores the box size
  29124. * @returns The physics imposter
  29125. */
  29126. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29127. /**
  29128. * Gets the radius of the physics imposter
  29129. * @returns Radius of the physics imposter
  29130. */
  29131. getRadius(): number;
  29132. /**
  29133. * Sync a bone with this impostor
  29134. * @param bone The bone to sync to the impostor.
  29135. * @param boneMesh The mesh that the bone is influencing.
  29136. * @param jointPivot The pivot of the joint / bone in local space.
  29137. * @param distToJoint Optional distance from the impostor to the joint.
  29138. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29139. */
  29140. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29141. /**
  29142. * Sync impostor to a bone
  29143. * @param bone The bone that the impostor will be synced to.
  29144. * @param boneMesh The mesh that the bone is influencing.
  29145. * @param jointPivot The pivot of the joint / bone in local space.
  29146. * @param distToJoint Optional distance from the impostor to the joint.
  29147. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29148. * @param boneAxis Optional vector3 axis the bone is aligned with
  29149. */
  29150. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29151. /**
  29152. * No-Imposter type
  29153. */
  29154. static NoImpostor: number;
  29155. /**
  29156. * Sphere-Imposter type
  29157. */
  29158. static SphereImpostor: number;
  29159. /**
  29160. * Box-Imposter type
  29161. */
  29162. static BoxImpostor: number;
  29163. /**
  29164. * Plane-Imposter type
  29165. */
  29166. static PlaneImpostor: number;
  29167. /**
  29168. * Mesh-imposter type
  29169. */
  29170. static MeshImpostor: number;
  29171. /**
  29172. * Capsule-Impostor type (Ammo.js plugin only)
  29173. */
  29174. static CapsuleImpostor: number;
  29175. /**
  29176. * Cylinder-Imposter type
  29177. */
  29178. static CylinderImpostor: number;
  29179. /**
  29180. * Particle-Imposter type
  29181. */
  29182. static ParticleImpostor: number;
  29183. /**
  29184. * Heightmap-Imposter type
  29185. */
  29186. static HeightmapImpostor: number;
  29187. /**
  29188. * ConvexHull-Impostor type (Ammo.js plugin only)
  29189. */
  29190. static ConvexHullImpostor: number;
  29191. /**
  29192. * Custom-Imposter type (Ammo.js plugin only)
  29193. */
  29194. static CustomImpostor: number;
  29195. /**
  29196. * Rope-Imposter type
  29197. */
  29198. static RopeImpostor: number;
  29199. /**
  29200. * Cloth-Imposter type
  29201. */
  29202. static ClothImpostor: number;
  29203. /**
  29204. * Softbody-Imposter type
  29205. */
  29206. static SoftbodyImpostor: number;
  29207. }
  29208. }
  29209. declare module "babylonjs/Meshes/mesh" {
  29210. import { Observable } from "babylonjs/Misc/observable";
  29211. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29212. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29213. import { Camera } from "babylonjs/Cameras/camera";
  29214. import { Scene } from "babylonjs/scene";
  29215. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29216. import { Color4 } from "babylonjs/Maths/math.color";
  29217. import { Engine } from "babylonjs/Engines/engine";
  29218. import { Node } from "babylonjs/node";
  29219. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29220. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29221. import { Buffer } from "babylonjs/Meshes/buffer";
  29222. import { Geometry } from "babylonjs/Meshes/geometry";
  29223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29225. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29226. import { Effect } from "babylonjs/Materials/effect";
  29227. import { Material } from "babylonjs/Materials/material";
  29228. import { Skeleton } from "babylonjs/Bones/skeleton";
  29229. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29230. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29231. import { Path3D } from "babylonjs/Maths/math.path";
  29232. import { Plane } from "babylonjs/Maths/math.plane";
  29233. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29234. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29235. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29236. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29237. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29238. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29239. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29240. /**
  29241. * @hidden
  29242. **/
  29243. export class _CreationDataStorage {
  29244. closePath?: boolean;
  29245. closeArray?: boolean;
  29246. idx: number[];
  29247. dashSize: number;
  29248. gapSize: number;
  29249. path3D: Path3D;
  29250. pathArray: Vector3[][];
  29251. arc: number;
  29252. radius: number;
  29253. cap: number;
  29254. tessellation: number;
  29255. }
  29256. /**
  29257. * @hidden
  29258. **/
  29259. class _InstanceDataStorage {
  29260. visibleInstances: any;
  29261. batchCache: _InstancesBatch;
  29262. instancesBufferSize: number;
  29263. instancesBuffer: Nullable<Buffer>;
  29264. instancesData: Float32Array;
  29265. overridenInstanceCount: number;
  29266. isFrozen: boolean;
  29267. previousBatch: Nullable<_InstancesBatch>;
  29268. hardwareInstancedRendering: boolean;
  29269. sideOrientation: number;
  29270. manualUpdate: boolean;
  29271. previousRenderId: number;
  29272. }
  29273. /**
  29274. * @hidden
  29275. **/
  29276. export class _InstancesBatch {
  29277. mustReturn: boolean;
  29278. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29279. renderSelf: boolean[];
  29280. hardwareInstancedRendering: boolean[];
  29281. }
  29282. /**
  29283. * @hidden
  29284. **/
  29285. class _ThinInstanceDataStorage {
  29286. instancesCount: number;
  29287. matrixBuffer: Nullable<Buffer>;
  29288. matrixBufferSize: number;
  29289. matrixData: Nullable<Float32Array>;
  29290. boundingVectors: Array<Vector3>;
  29291. worldMatrices: Nullable<Matrix[]>;
  29292. }
  29293. /**
  29294. * Class used to represent renderable models
  29295. */
  29296. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29297. /**
  29298. * Mesh side orientation : usually the external or front surface
  29299. */
  29300. static readonly FRONTSIDE: number;
  29301. /**
  29302. * Mesh side orientation : usually the internal or back surface
  29303. */
  29304. static readonly BACKSIDE: number;
  29305. /**
  29306. * Mesh side orientation : both internal and external or front and back surfaces
  29307. */
  29308. static readonly DOUBLESIDE: number;
  29309. /**
  29310. * Mesh side orientation : by default, `FRONTSIDE`
  29311. */
  29312. static readonly DEFAULTSIDE: number;
  29313. /**
  29314. * Mesh cap setting : no cap
  29315. */
  29316. static readonly NO_CAP: number;
  29317. /**
  29318. * Mesh cap setting : one cap at the beginning of the mesh
  29319. */
  29320. static readonly CAP_START: number;
  29321. /**
  29322. * Mesh cap setting : one cap at the end of the mesh
  29323. */
  29324. static readonly CAP_END: number;
  29325. /**
  29326. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29327. */
  29328. static readonly CAP_ALL: number;
  29329. /**
  29330. * Mesh pattern setting : no flip or rotate
  29331. */
  29332. static readonly NO_FLIP: number;
  29333. /**
  29334. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29335. */
  29336. static readonly FLIP_TILE: number;
  29337. /**
  29338. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29339. */
  29340. static readonly ROTATE_TILE: number;
  29341. /**
  29342. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29343. */
  29344. static readonly FLIP_ROW: number;
  29345. /**
  29346. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29347. */
  29348. static readonly ROTATE_ROW: number;
  29349. /**
  29350. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29351. */
  29352. static readonly FLIP_N_ROTATE_TILE: number;
  29353. /**
  29354. * Mesh pattern setting : rotate pattern and rotate
  29355. */
  29356. static readonly FLIP_N_ROTATE_ROW: number;
  29357. /**
  29358. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29359. */
  29360. static readonly CENTER: number;
  29361. /**
  29362. * Mesh tile positioning : part tiles on left
  29363. */
  29364. static readonly LEFT: number;
  29365. /**
  29366. * Mesh tile positioning : part tiles on right
  29367. */
  29368. static readonly RIGHT: number;
  29369. /**
  29370. * Mesh tile positioning : part tiles on top
  29371. */
  29372. static readonly TOP: number;
  29373. /**
  29374. * Mesh tile positioning : part tiles on bottom
  29375. */
  29376. static readonly BOTTOM: number;
  29377. /**
  29378. * Gets the default side orientation.
  29379. * @param orientation the orientation to value to attempt to get
  29380. * @returns the default orientation
  29381. * @hidden
  29382. */
  29383. static _GetDefaultSideOrientation(orientation?: number): number;
  29384. private _internalMeshDataInfo;
  29385. get computeBonesUsingShaders(): boolean;
  29386. set computeBonesUsingShaders(value: boolean);
  29387. /**
  29388. * An event triggered before rendering the mesh
  29389. */
  29390. get onBeforeRenderObservable(): Observable<Mesh>;
  29391. /**
  29392. * An event triggered before binding the mesh
  29393. */
  29394. get onBeforeBindObservable(): Observable<Mesh>;
  29395. /**
  29396. * An event triggered after rendering the mesh
  29397. */
  29398. get onAfterRenderObservable(): Observable<Mesh>;
  29399. /**
  29400. * An event triggered before drawing the mesh
  29401. */
  29402. get onBeforeDrawObservable(): Observable<Mesh>;
  29403. private _onBeforeDrawObserver;
  29404. /**
  29405. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29406. */
  29407. set onBeforeDraw(callback: () => void);
  29408. get hasInstances(): boolean;
  29409. get hasThinInstances(): boolean;
  29410. /**
  29411. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29412. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29413. */
  29414. delayLoadState: number;
  29415. /**
  29416. * Gets the list of instances created from this mesh
  29417. * it is not supposed to be modified manually.
  29418. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29419. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29420. */
  29421. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29422. /**
  29423. * Gets the file containing delay loading data for this mesh
  29424. */
  29425. delayLoadingFile: string;
  29426. /** @hidden */
  29427. _binaryInfo: any;
  29428. /**
  29429. * User defined function used to change how LOD level selection is done
  29430. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29431. */
  29432. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29433. /**
  29434. * Gets or sets the morph target manager
  29435. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29436. */
  29437. get morphTargetManager(): Nullable<MorphTargetManager>;
  29438. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29439. /** @hidden */
  29440. _creationDataStorage: Nullable<_CreationDataStorage>;
  29441. /** @hidden */
  29442. _geometry: Nullable<Geometry>;
  29443. /** @hidden */
  29444. _delayInfo: Array<string>;
  29445. /** @hidden */
  29446. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29447. /** @hidden */
  29448. _instanceDataStorage: _InstanceDataStorage;
  29449. /** @hidden */
  29450. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29451. private _effectiveMaterial;
  29452. /** @hidden */
  29453. _shouldGenerateFlatShading: boolean;
  29454. /** @hidden */
  29455. _originalBuilderSideOrientation: number;
  29456. /**
  29457. * Use this property to change the original side orientation defined at construction time
  29458. */
  29459. overrideMaterialSideOrientation: Nullable<number>;
  29460. /**
  29461. * Gets the source mesh (the one used to clone this one from)
  29462. */
  29463. get source(): Nullable<Mesh>;
  29464. /**
  29465. * Gets the list of clones of this mesh
  29466. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29467. * Note that useClonedMeshMap=true is the default setting
  29468. */
  29469. get cloneMeshMap(): Nullable<{
  29470. [id: string]: Mesh | undefined;
  29471. }>;
  29472. /**
  29473. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29474. */
  29475. get isUnIndexed(): boolean;
  29476. set isUnIndexed(value: boolean);
  29477. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29478. get worldMatrixInstancedBuffer(): Float32Array;
  29479. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29480. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29481. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29482. /**
  29483. * @constructor
  29484. * @param name The value used by scene.getMeshByName() to do a lookup.
  29485. * @param scene The scene to add this mesh to.
  29486. * @param parent The parent of this mesh, if it has one
  29487. * @param source An optional Mesh from which geometry is shared, cloned.
  29488. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29489. * When false, achieved by calling a clone(), also passing False.
  29490. * This will make creation of children, recursive.
  29491. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29492. */
  29493. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29494. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29495. doNotInstantiate: boolean;
  29496. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29497. /**
  29498. * Gets the class name
  29499. * @returns the string "Mesh".
  29500. */
  29501. getClassName(): string;
  29502. /** @hidden */
  29503. get _isMesh(): boolean;
  29504. /**
  29505. * Returns a description of this mesh
  29506. * @param fullDetails define if full details about this mesh must be used
  29507. * @returns a descriptive string representing this mesh
  29508. */
  29509. toString(fullDetails?: boolean): string;
  29510. /** @hidden */
  29511. _unBindEffect(): void;
  29512. /**
  29513. * Gets a boolean indicating if this mesh has LOD
  29514. */
  29515. get hasLODLevels(): boolean;
  29516. /**
  29517. * Gets the list of MeshLODLevel associated with the current mesh
  29518. * @returns an array of MeshLODLevel
  29519. */
  29520. getLODLevels(): MeshLODLevel[];
  29521. private _sortLODLevels;
  29522. /**
  29523. * Add a mesh as LOD level triggered at the given distance.
  29524. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29525. * @param distance The distance from the center of the object to show this level
  29526. * @param mesh The mesh to be added as LOD level (can be null)
  29527. * @return This mesh (for chaining)
  29528. */
  29529. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29530. /**
  29531. * Returns the LOD level mesh at the passed distance or null if not found.
  29532. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29533. * @param distance The distance from the center of the object to show this level
  29534. * @returns a Mesh or `null`
  29535. */
  29536. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29537. /**
  29538. * Remove a mesh from the LOD array
  29539. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29540. * @param mesh defines the mesh to be removed
  29541. * @return This mesh (for chaining)
  29542. */
  29543. removeLODLevel(mesh: Mesh): Mesh;
  29544. /**
  29545. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29546. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29547. * @param camera defines the camera to use to compute distance
  29548. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29549. * @return This mesh (for chaining)
  29550. */
  29551. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29552. /**
  29553. * Gets the mesh internal Geometry object
  29554. */
  29555. get geometry(): Nullable<Geometry>;
  29556. /**
  29557. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29558. * @returns the total number of vertices
  29559. */
  29560. getTotalVertices(): number;
  29561. /**
  29562. * Returns the content of an associated vertex buffer
  29563. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29564. * - VertexBuffer.PositionKind
  29565. * - VertexBuffer.UVKind
  29566. * - VertexBuffer.UV2Kind
  29567. * - VertexBuffer.UV3Kind
  29568. * - VertexBuffer.UV4Kind
  29569. * - VertexBuffer.UV5Kind
  29570. * - VertexBuffer.UV6Kind
  29571. * - VertexBuffer.ColorKind
  29572. * - VertexBuffer.MatricesIndicesKind
  29573. * - VertexBuffer.MatricesIndicesExtraKind
  29574. * - VertexBuffer.MatricesWeightsKind
  29575. * - VertexBuffer.MatricesWeightsExtraKind
  29576. * @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
  29577. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29578. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29579. */
  29580. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29581. /**
  29582. * Returns the mesh VertexBuffer object from the requested `kind`
  29583. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29584. * - VertexBuffer.PositionKind
  29585. * - VertexBuffer.NormalKind
  29586. * - VertexBuffer.UVKind
  29587. * - VertexBuffer.UV2Kind
  29588. * - VertexBuffer.UV3Kind
  29589. * - VertexBuffer.UV4Kind
  29590. * - VertexBuffer.UV5Kind
  29591. * - VertexBuffer.UV6Kind
  29592. * - VertexBuffer.ColorKind
  29593. * - VertexBuffer.MatricesIndicesKind
  29594. * - VertexBuffer.MatricesIndicesExtraKind
  29595. * - VertexBuffer.MatricesWeightsKind
  29596. * - VertexBuffer.MatricesWeightsExtraKind
  29597. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29598. */
  29599. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29600. /**
  29601. * Tests if a specific vertex buffer is associated with this mesh
  29602. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29603. * - VertexBuffer.PositionKind
  29604. * - VertexBuffer.NormalKind
  29605. * - VertexBuffer.UVKind
  29606. * - VertexBuffer.UV2Kind
  29607. * - VertexBuffer.UV3Kind
  29608. * - VertexBuffer.UV4Kind
  29609. * - VertexBuffer.UV5Kind
  29610. * - VertexBuffer.UV6Kind
  29611. * - VertexBuffer.ColorKind
  29612. * - VertexBuffer.MatricesIndicesKind
  29613. * - VertexBuffer.MatricesIndicesExtraKind
  29614. * - VertexBuffer.MatricesWeightsKind
  29615. * - VertexBuffer.MatricesWeightsExtraKind
  29616. * @returns a boolean
  29617. */
  29618. isVerticesDataPresent(kind: string): boolean;
  29619. /**
  29620. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29621. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29622. * - VertexBuffer.PositionKind
  29623. * - VertexBuffer.UVKind
  29624. * - VertexBuffer.UV2Kind
  29625. * - VertexBuffer.UV3Kind
  29626. * - VertexBuffer.UV4Kind
  29627. * - VertexBuffer.UV5Kind
  29628. * - VertexBuffer.UV6Kind
  29629. * - VertexBuffer.ColorKind
  29630. * - VertexBuffer.MatricesIndicesKind
  29631. * - VertexBuffer.MatricesIndicesExtraKind
  29632. * - VertexBuffer.MatricesWeightsKind
  29633. * - VertexBuffer.MatricesWeightsExtraKind
  29634. * @returns a boolean
  29635. */
  29636. isVertexBufferUpdatable(kind: string): boolean;
  29637. /**
  29638. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29639. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29640. * - VertexBuffer.PositionKind
  29641. * - VertexBuffer.NormalKind
  29642. * - VertexBuffer.UVKind
  29643. * - VertexBuffer.UV2Kind
  29644. * - VertexBuffer.UV3Kind
  29645. * - VertexBuffer.UV4Kind
  29646. * - VertexBuffer.UV5Kind
  29647. * - VertexBuffer.UV6Kind
  29648. * - VertexBuffer.ColorKind
  29649. * - VertexBuffer.MatricesIndicesKind
  29650. * - VertexBuffer.MatricesIndicesExtraKind
  29651. * - VertexBuffer.MatricesWeightsKind
  29652. * - VertexBuffer.MatricesWeightsExtraKind
  29653. * @returns an array of strings
  29654. */
  29655. getVerticesDataKinds(): string[];
  29656. /**
  29657. * Returns a positive integer : the total number of indices in this mesh geometry.
  29658. * @returns the numner of indices or zero if the mesh has no geometry.
  29659. */
  29660. getTotalIndices(): number;
  29661. /**
  29662. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29663. * @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.
  29664. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29665. * @returns the indices array or an empty array if the mesh has no geometry
  29666. */
  29667. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29668. get isBlocked(): boolean;
  29669. /**
  29670. * Determine if the current mesh is ready to be rendered
  29671. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29672. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29673. * @returns true if all associated assets are ready (material, textures, shaders)
  29674. */
  29675. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29676. /**
  29677. * 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.
  29678. */
  29679. get areNormalsFrozen(): boolean;
  29680. /**
  29681. * 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.
  29682. * @returns the current mesh
  29683. */
  29684. freezeNormals(): Mesh;
  29685. /**
  29686. * 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
  29687. * @returns the current mesh
  29688. */
  29689. unfreezeNormals(): Mesh;
  29690. /**
  29691. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29692. */
  29693. set overridenInstanceCount(count: number);
  29694. /** @hidden */
  29695. _preActivate(): Mesh;
  29696. /** @hidden */
  29697. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29698. /** @hidden */
  29699. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29700. protected _afterComputeWorldMatrix(): void;
  29701. /** @hidden */
  29702. _postActivate(): void;
  29703. /**
  29704. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29705. * This means the mesh underlying bounding box and sphere are recomputed.
  29706. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29707. * @returns the current mesh
  29708. */
  29709. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29710. /** @hidden */
  29711. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29712. /**
  29713. * This function will subdivide the mesh into multiple submeshes
  29714. * @param count defines the expected number of submeshes
  29715. */
  29716. subdivide(count: number): void;
  29717. /**
  29718. * Copy a FloatArray into a specific associated vertex buffer
  29719. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29720. * - VertexBuffer.PositionKind
  29721. * - VertexBuffer.UVKind
  29722. * - VertexBuffer.UV2Kind
  29723. * - VertexBuffer.UV3Kind
  29724. * - VertexBuffer.UV4Kind
  29725. * - VertexBuffer.UV5Kind
  29726. * - VertexBuffer.UV6Kind
  29727. * - VertexBuffer.ColorKind
  29728. * - VertexBuffer.MatricesIndicesKind
  29729. * - VertexBuffer.MatricesIndicesExtraKind
  29730. * - VertexBuffer.MatricesWeightsKind
  29731. * - VertexBuffer.MatricesWeightsExtraKind
  29732. * @param data defines the data source
  29733. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29734. * @param stride defines the data stride size (can be null)
  29735. * @returns the current mesh
  29736. */
  29737. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29738. /**
  29739. * Delete a vertex buffer associated with this mesh
  29740. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29741. * - VertexBuffer.PositionKind
  29742. * - VertexBuffer.UVKind
  29743. * - VertexBuffer.UV2Kind
  29744. * - VertexBuffer.UV3Kind
  29745. * - VertexBuffer.UV4Kind
  29746. * - VertexBuffer.UV5Kind
  29747. * - VertexBuffer.UV6Kind
  29748. * - VertexBuffer.ColorKind
  29749. * - VertexBuffer.MatricesIndicesKind
  29750. * - VertexBuffer.MatricesIndicesExtraKind
  29751. * - VertexBuffer.MatricesWeightsKind
  29752. * - VertexBuffer.MatricesWeightsExtraKind
  29753. */
  29754. removeVerticesData(kind: string): void;
  29755. /**
  29756. * Flags an associated vertex buffer as updatable
  29757. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29758. * - VertexBuffer.PositionKind
  29759. * - VertexBuffer.UVKind
  29760. * - VertexBuffer.UV2Kind
  29761. * - VertexBuffer.UV3Kind
  29762. * - VertexBuffer.UV4Kind
  29763. * - VertexBuffer.UV5Kind
  29764. * - VertexBuffer.UV6Kind
  29765. * - VertexBuffer.ColorKind
  29766. * - VertexBuffer.MatricesIndicesKind
  29767. * - VertexBuffer.MatricesIndicesExtraKind
  29768. * - VertexBuffer.MatricesWeightsKind
  29769. * - VertexBuffer.MatricesWeightsExtraKind
  29770. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29771. */
  29772. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29773. /**
  29774. * Sets the mesh global Vertex Buffer
  29775. * @param buffer defines the buffer to use
  29776. * @returns the current mesh
  29777. */
  29778. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29779. /**
  29780. * Update a specific associated vertex buffer
  29781. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29782. * - VertexBuffer.PositionKind
  29783. * - VertexBuffer.UVKind
  29784. * - VertexBuffer.UV2Kind
  29785. * - VertexBuffer.UV3Kind
  29786. * - VertexBuffer.UV4Kind
  29787. * - VertexBuffer.UV5Kind
  29788. * - VertexBuffer.UV6Kind
  29789. * - VertexBuffer.ColorKind
  29790. * - VertexBuffer.MatricesIndicesKind
  29791. * - VertexBuffer.MatricesIndicesExtraKind
  29792. * - VertexBuffer.MatricesWeightsKind
  29793. * - VertexBuffer.MatricesWeightsExtraKind
  29794. * @param data defines the data source
  29795. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29796. * @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)
  29797. * @returns the current mesh
  29798. */
  29799. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29800. /**
  29801. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29802. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29803. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29804. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29805. * @returns the current mesh
  29806. */
  29807. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29808. /**
  29809. * Creates a un-shared specific occurence of the geometry for the mesh.
  29810. * @returns the current mesh
  29811. */
  29812. makeGeometryUnique(): Mesh;
  29813. /**
  29814. * Set the index buffer of this mesh
  29815. * @param indices defines the source data
  29816. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29817. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29818. * @returns the current mesh
  29819. */
  29820. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29821. /**
  29822. * Update the current index buffer
  29823. * @param indices defines the source data
  29824. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29825. * @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)
  29826. * @returns the current mesh
  29827. */
  29828. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29829. /**
  29830. * Invert the geometry to move from a right handed system to a left handed one.
  29831. * @returns the current mesh
  29832. */
  29833. toLeftHanded(): Mesh;
  29834. /** @hidden */
  29835. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29836. /** @hidden */
  29837. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29838. /**
  29839. * Registers for this mesh a javascript function called just before the rendering process
  29840. * @param func defines the function to call before rendering this mesh
  29841. * @returns the current mesh
  29842. */
  29843. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29844. /**
  29845. * Disposes a previously registered javascript function called before the rendering
  29846. * @param func defines the function to remove
  29847. * @returns the current mesh
  29848. */
  29849. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29850. /**
  29851. * Registers for this mesh a javascript function called just after the rendering is complete
  29852. * @param func defines the function to call after rendering this mesh
  29853. * @returns the current mesh
  29854. */
  29855. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29856. /**
  29857. * Disposes a previously registered javascript function called after the rendering.
  29858. * @param func defines the function to remove
  29859. * @returns the current mesh
  29860. */
  29861. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29862. /** @hidden */
  29863. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29864. /** @hidden */
  29865. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29866. /** @hidden */
  29867. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29868. /** @hidden */
  29869. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29870. /** @hidden */
  29871. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29872. /** @hidden */
  29873. _rebuild(): void;
  29874. /** @hidden */
  29875. _freeze(): void;
  29876. /** @hidden */
  29877. _unFreeze(): void;
  29878. /**
  29879. * 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
  29880. * @param subMesh defines the subMesh to render
  29881. * @param enableAlphaMode defines if alpha mode can be changed
  29882. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29883. * @returns the current mesh
  29884. */
  29885. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29886. private _onBeforeDraw;
  29887. /**
  29888. * Renormalize the mesh and patch it up if there are no weights
  29889. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29890. * However in the case of zero weights then we set just a single influence to 1.
  29891. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29892. */
  29893. cleanMatrixWeights(): void;
  29894. private normalizeSkinFourWeights;
  29895. private normalizeSkinWeightsAndExtra;
  29896. /**
  29897. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29898. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29899. * the user know there was an issue with importing the mesh
  29900. * @returns a validation object with skinned, valid and report string
  29901. */
  29902. validateSkinning(): {
  29903. skinned: boolean;
  29904. valid: boolean;
  29905. report: string;
  29906. };
  29907. /** @hidden */
  29908. _checkDelayState(): Mesh;
  29909. private _queueLoad;
  29910. /**
  29911. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29912. * A mesh is in the frustum if its bounding box intersects the frustum
  29913. * @param frustumPlanes defines the frustum to test
  29914. * @returns true if the mesh is in the frustum planes
  29915. */
  29916. isInFrustum(frustumPlanes: Plane[]): boolean;
  29917. /**
  29918. * Sets the mesh material by the material or multiMaterial `id` property
  29919. * @param id is a string identifying the material or the multiMaterial
  29920. * @returns the current mesh
  29921. */
  29922. setMaterialByID(id: string): Mesh;
  29923. /**
  29924. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29925. * @returns an array of IAnimatable
  29926. */
  29927. getAnimatables(): IAnimatable[];
  29928. /**
  29929. * Modifies the mesh geometry according to the passed transformation matrix.
  29930. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29931. * The mesh normals are modified using the same transformation.
  29932. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29933. * @param transform defines the transform matrix to use
  29934. * @see https://doc.babylonjs.com/resources/baking_transformations
  29935. * @returns the current mesh
  29936. */
  29937. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29938. /**
  29939. * Modifies the mesh geometry according to its own current World Matrix.
  29940. * The mesh World Matrix is then reset.
  29941. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29942. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29943. * @see https://doc.babylonjs.com/resources/baking_transformations
  29944. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29945. * @returns the current mesh
  29946. */
  29947. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29948. /** @hidden */
  29949. get _positions(): Nullable<Vector3[]>;
  29950. /** @hidden */
  29951. _resetPointsArrayCache(): Mesh;
  29952. /** @hidden */
  29953. _generatePointsArray(): boolean;
  29954. /**
  29955. * Returns a new Mesh object generated from the current mesh properties.
  29956. * This method must not get confused with createInstance()
  29957. * @param name is a string, the name given to the new mesh
  29958. * @param newParent can be any Node object (default `null`)
  29959. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29960. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29961. * @returns a new mesh
  29962. */
  29963. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29964. /**
  29965. * Releases resources associated with this mesh.
  29966. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29967. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29968. */
  29969. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29970. /** @hidden */
  29971. _disposeInstanceSpecificData(): void;
  29972. /** @hidden */
  29973. _disposeThinInstanceSpecificData(): void;
  29974. /**
  29975. * Modifies the mesh geometry according to a displacement map.
  29976. * 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.
  29977. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29978. * @param url is a string, the URL from the image file is to be downloaded.
  29979. * @param minHeight is the lower limit of the displacement.
  29980. * @param maxHeight is the upper limit of the displacement.
  29981. * @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.
  29982. * @param uvOffset is an optional vector2 used to offset UV.
  29983. * @param uvScale is an optional vector2 used to scale UV.
  29984. * @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.
  29985. * @returns the Mesh.
  29986. */
  29987. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29988. /**
  29989. * Modifies the mesh geometry according to a displacementMap buffer.
  29990. * 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.
  29991. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29992. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29993. * @param heightMapWidth is the width of the buffer image.
  29994. * @param heightMapHeight is the height of the buffer image.
  29995. * @param minHeight is the lower limit of the displacement.
  29996. * @param maxHeight is the upper limit of the displacement.
  29997. * @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.
  29998. * @param uvOffset is an optional vector2 used to offset UV.
  29999. * @param uvScale is an optional vector2 used to scale UV.
  30000. * @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.
  30001. * @returns the Mesh.
  30002. */
  30003. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  30004. /**
  30005. * Modify the mesh to get a flat shading rendering.
  30006. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  30007. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  30008. * @returns current mesh
  30009. */
  30010. convertToFlatShadedMesh(): Mesh;
  30011. /**
  30012. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  30013. * In other words, more vertices, no more indices and a single bigger VBO.
  30014. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  30015. * @returns current mesh
  30016. */
  30017. convertToUnIndexedMesh(): Mesh;
  30018. /**
  30019. * Inverses facet orientations.
  30020. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30021. * @param flipNormals will also inverts the normals
  30022. * @returns current mesh
  30023. */
  30024. flipFaces(flipNormals?: boolean): Mesh;
  30025. /**
  30026. * Increase the number of facets and hence vertices in a mesh
  30027. * Vertex normals are interpolated from existing vertex normals
  30028. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30029. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  30030. */
  30031. increaseVertices(numberPerEdge: number): void;
  30032. /**
  30033. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  30034. * This will undo any application of covertToFlatShadedMesh
  30035. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30036. */
  30037. forceSharedVertices(): void;
  30038. /** @hidden */
  30039. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  30040. /** @hidden */
  30041. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  30042. /**
  30043. * Creates a new InstancedMesh object from the mesh model.
  30044. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  30045. * @param name defines the name of the new instance
  30046. * @returns a new InstancedMesh
  30047. */
  30048. createInstance(name: string): InstancedMesh;
  30049. /**
  30050. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  30051. * After this call, all the mesh instances have the same submeshes than the current mesh.
  30052. * @returns the current mesh
  30053. */
  30054. synchronizeInstances(): Mesh;
  30055. /**
  30056. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  30057. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  30058. * This should be used together with the simplification to avoid disappearing triangles.
  30059. * @param successCallback an optional success callback to be called after the optimization finished.
  30060. * @returns the current mesh
  30061. */
  30062. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  30063. /**
  30064. * Serialize current mesh
  30065. * @param serializationObject defines the object which will receive the serialization data
  30066. */
  30067. serialize(serializationObject: any): void;
  30068. /** @hidden */
  30069. _syncGeometryWithMorphTargetManager(): void;
  30070. /** @hidden */
  30071. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  30072. /**
  30073. * Returns a new Mesh object parsed from the source provided.
  30074. * @param parsedMesh is the source
  30075. * @param scene defines the hosting scene
  30076. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  30077. * @returns a new Mesh
  30078. */
  30079. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  30080. /**
  30081. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  30082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30083. * @param name defines the name of the mesh to create
  30084. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  30085. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  30086. * @param closePath creates a seam between the first and the last points of each path of the path array
  30087. * @param offset is taken in account only if the `pathArray` is containing a single path
  30088. * @param scene defines the hosting scene
  30089. * @param updatable defines if the mesh must be flagged as updatable
  30090. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30091. * @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)
  30092. * @returns a new Mesh
  30093. */
  30094. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30095. /**
  30096. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30097. * @param name defines the name of the mesh to create
  30098. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30099. * @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
  30100. * @param scene defines the hosting scene
  30101. * @param updatable defines if the mesh must be flagged as updatable
  30102. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30103. * @returns a new Mesh
  30104. */
  30105. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30106. /**
  30107. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30108. * @param name defines the name of the mesh to create
  30109. * @param size sets the size (float) of each box side (default 1)
  30110. * @param scene defines the hosting scene
  30111. * @param updatable defines if the mesh must be flagged as updatable
  30112. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30113. * @returns a new Mesh
  30114. */
  30115. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30116. /**
  30117. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30118. * @param name defines the name of the mesh to create
  30119. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30120. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30121. * @param scene defines the hosting scene
  30122. * @param updatable defines if the mesh must be flagged as updatable
  30123. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30124. * @returns a new Mesh
  30125. */
  30126. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30127. /**
  30128. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30129. * @param name defines the name of the mesh to create
  30130. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30131. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30132. * @param scene defines the hosting scene
  30133. * @returns a new Mesh
  30134. */
  30135. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30136. /**
  30137. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30138. * @param name defines the name of the mesh to create
  30139. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30140. * @param diameterTop set the top cap diameter (floats, default 1)
  30141. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30142. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30143. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30144. * @param scene defines the hosting scene
  30145. * @param updatable defines if the mesh must be flagged as updatable
  30146. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30147. * @returns a new Mesh
  30148. */
  30149. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30150. /**
  30151. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30152. * @param name defines the name of the mesh to create
  30153. * @param diameter sets the diameter size (float) of the torus (default 1)
  30154. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30155. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30156. * @param scene defines the hosting scene
  30157. * @param updatable defines if the mesh must be flagged as updatable
  30158. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30159. * @returns a new Mesh
  30160. */
  30161. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30162. /**
  30163. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30164. * @param name defines the name of the mesh to create
  30165. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30166. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30167. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30168. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30169. * @param p the number of windings on X axis (positive integers, default 2)
  30170. * @param q the number of windings on Y axis (positive integers, default 3)
  30171. * @param scene defines the hosting scene
  30172. * @param updatable defines if the mesh must be flagged as updatable
  30173. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30174. * @returns a new Mesh
  30175. */
  30176. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30177. /**
  30178. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30179. * @param name defines the name of the mesh to create
  30180. * @param points is an array successive Vector3
  30181. * @param scene defines the hosting scene
  30182. * @param updatable defines if the mesh must be flagged as updatable
  30183. * @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).
  30184. * @returns a new Mesh
  30185. */
  30186. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30187. /**
  30188. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30189. * @param name defines the name of the mesh to create
  30190. * @param points is an array successive Vector3
  30191. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30192. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30193. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30194. * @param scene defines the hosting scene
  30195. * @param updatable defines if the mesh must be flagged as updatable
  30196. * @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)
  30197. * @returns a new Mesh
  30198. */
  30199. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30200. /**
  30201. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30202. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30203. * 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.
  30204. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30205. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30206. * Remember you can only change the shape positions, not their number when updating a polygon.
  30207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30208. * @param name defines the name of the mesh to create
  30209. * @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
  30210. * @param scene defines the hosting scene
  30211. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30212. * @param updatable defines if the mesh must be flagged as updatable
  30213. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30214. * @param earcutInjection can be used to inject your own earcut reference
  30215. * @returns a new Mesh
  30216. */
  30217. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30218. /**
  30219. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30221. * @param name defines the name of the mesh to create
  30222. * @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
  30223. * @param depth defines the height of extrusion
  30224. * @param scene defines the hosting scene
  30225. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30226. * @param updatable defines if the mesh must be flagged as updatable
  30227. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30228. * @param earcutInjection can be used to inject your own earcut reference
  30229. * @returns a new Mesh
  30230. */
  30231. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30232. /**
  30233. * Creates an extruded shape mesh.
  30234. * 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
  30235. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30236. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30237. * @param name defines the name of the mesh to create
  30238. * @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
  30239. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30240. * @param scale is the value to scale the shape
  30241. * @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
  30242. * @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
  30243. * @param scene defines the hosting scene
  30244. * @param updatable defines if the mesh must be flagged as updatable
  30245. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30246. * @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)
  30247. * @returns a new Mesh
  30248. */
  30249. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30250. /**
  30251. * Creates an custom extruded shape mesh.
  30252. * The custom extrusion is a parametric shape.
  30253. * It has no predefined shape. Its final shape will depend on the input parameters.
  30254. * Please consider using the same method from the MeshBuilder class instead
  30255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30256. * @param name defines the name of the mesh to create
  30257. * @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
  30258. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30259. * @param scaleFunction is a custom Javascript function called on each path point
  30260. * @param rotationFunction is a custom Javascript function called on each path point
  30261. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30262. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30263. * @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
  30264. * @param scene defines the hosting scene
  30265. * @param updatable defines if the mesh must be flagged as updatable
  30266. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30267. * @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)
  30268. * @returns a new Mesh
  30269. */
  30270. 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;
  30271. /**
  30272. * Creates lathe mesh.
  30273. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30274. * Please consider using the same method from the MeshBuilder class instead
  30275. * @param name defines the name of the mesh to create
  30276. * @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
  30277. * @param radius is the radius value of the lathe
  30278. * @param tessellation is the side number of the lathe.
  30279. * @param scene defines the hosting scene
  30280. * @param updatable defines if the mesh must be flagged as updatable
  30281. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30282. * @returns a new Mesh
  30283. */
  30284. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30285. /**
  30286. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30287. * @param name defines the name of the mesh to create
  30288. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30289. * @param scene defines the hosting scene
  30290. * @param updatable defines if the mesh must be flagged as updatable
  30291. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30292. * @returns a new Mesh
  30293. */
  30294. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30295. /**
  30296. * Creates a ground mesh.
  30297. * Please consider using the same method from the MeshBuilder class instead
  30298. * @param name defines the name of the mesh to create
  30299. * @param width set the width of the ground
  30300. * @param height set the height of the ground
  30301. * @param subdivisions sets the number of subdivisions per side
  30302. * @param scene defines the hosting scene
  30303. * @param updatable defines if the mesh must be flagged as updatable
  30304. * @returns a new Mesh
  30305. */
  30306. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30307. /**
  30308. * Creates a tiled ground mesh.
  30309. * Please consider using the same method from the MeshBuilder class instead
  30310. * @param name defines the name of the mesh to create
  30311. * @param xmin set the ground minimum X coordinate
  30312. * @param zmin set the ground minimum Y coordinate
  30313. * @param xmax set the ground maximum X coordinate
  30314. * @param zmax set the ground maximum Z coordinate
  30315. * @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
  30316. * @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
  30317. * @param scene defines the hosting scene
  30318. * @param updatable defines if the mesh must be flagged as updatable
  30319. * @returns a new Mesh
  30320. */
  30321. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30322. w: number;
  30323. h: number;
  30324. }, precision: {
  30325. w: number;
  30326. h: number;
  30327. }, scene: Scene, updatable?: boolean): Mesh;
  30328. /**
  30329. * Creates a ground mesh from a height map.
  30330. * Please consider using the same method from the MeshBuilder class instead
  30331. * @see https://doc.babylonjs.com/babylon101/height_map
  30332. * @param name defines the name of the mesh to create
  30333. * @param url sets the URL of the height map image resource
  30334. * @param width set the ground width size
  30335. * @param height set the ground height size
  30336. * @param subdivisions sets the number of subdivision per side
  30337. * @param minHeight is the minimum altitude on the ground
  30338. * @param maxHeight is the maximum altitude on the ground
  30339. * @param scene defines the hosting scene
  30340. * @param updatable defines if the mesh must be flagged as updatable
  30341. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30342. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30343. * @returns a new Mesh
  30344. */
  30345. 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;
  30346. /**
  30347. * Creates a tube mesh.
  30348. * The tube is a parametric shape.
  30349. * It has no predefined shape. Its final shape will depend on the input parameters.
  30350. * Please consider using the same method from the MeshBuilder class instead
  30351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30352. * @param name defines the name of the mesh to create
  30353. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30354. * @param radius sets the tube radius size
  30355. * @param tessellation is the number of sides on the tubular surface
  30356. * @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
  30357. * @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
  30358. * @param scene defines the hosting scene
  30359. * @param updatable defines if the mesh must be flagged as updatable
  30360. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30361. * @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)
  30362. * @returns a new Mesh
  30363. */
  30364. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30365. (i: number, distance: number): number;
  30366. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30367. /**
  30368. * Creates a polyhedron mesh.
  30369. * Please consider using the same method from the MeshBuilder class instead.
  30370. * * 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
  30371. * * The parameter `size` (positive float, default 1) sets the polygon size
  30372. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30373. * * 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`
  30374. * * 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
  30375. * * 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)`)
  30376. * * 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
  30377. * * 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
  30378. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30381. * @param name defines the name of the mesh to create
  30382. * @param options defines the options used to create the mesh
  30383. * @param scene defines the hosting scene
  30384. * @returns a new Mesh
  30385. */
  30386. static CreatePolyhedron(name: string, options: {
  30387. type?: number;
  30388. size?: number;
  30389. sizeX?: number;
  30390. sizeY?: number;
  30391. sizeZ?: number;
  30392. custom?: any;
  30393. faceUV?: Vector4[];
  30394. faceColors?: Color4[];
  30395. updatable?: boolean;
  30396. sideOrientation?: number;
  30397. }, scene: Scene): Mesh;
  30398. /**
  30399. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30400. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30401. * * 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`)
  30402. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30403. * * 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
  30404. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30407. * @param name defines the name of the mesh
  30408. * @param options defines the options used to create the mesh
  30409. * @param scene defines the hosting scene
  30410. * @returns a new Mesh
  30411. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30412. */
  30413. static CreateIcoSphere(name: string, options: {
  30414. radius?: number;
  30415. flat?: boolean;
  30416. subdivisions?: number;
  30417. sideOrientation?: number;
  30418. updatable?: boolean;
  30419. }, scene: Scene): Mesh;
  30420. /**
  30421. * Creates a decal mesh.
  30422. * Please consider using the same method from the MeshBuilder class instead.
  30423. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30424. * @param name defines the name of the mesh
  30425. * @param sourceMesh defines the mesh receiving the decal
  30426. * @param position sets the position of the decal in world coordinates
  30427. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30428. * @param size sets the decal scaling
  30429. * @param angle sets the angle to rotate the decal
  30430. * @returns a new Mesh
  30431. */
  30432. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30433. /** Creates a Capsule Mesh
  30434. * @param name defines the name of the mesh.
  30435. * @param options the constructors options used to shape the mesh.
  30436. * @param scene defines the scene the mesh is scoped to.
  30437. * @returns the capsule mesh
  30438. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30439. */
  30440. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30441. /**
  30442. * Prepare internal position array for software CPU skinning
  30443. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30444. */
  30445. setPositionsForCPUSkinning(): Float32Array;
  30446. /**
  30447. * Prepare internal normal array for software CPU skinning
  30448. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30449. */
  30450. setNormalsForCPUSkinning(): Float32Array;
  30451. /**
  30452. * Updates the vertex buffer by applying transformation from the bones
  30453. * @param skeleton defines the skeleton to apply to current mesh
  30454. * @returns the current mesh
  30455. */
  30456. applySkeleton(skeleton: Skeleton): Mesh;
  30457. /**
  30458. * 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
  30459. * @param meshes defines the list of meshes to scan
  30460. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30461. */
  30462. static MinMax(meshes: AbstractMesh[]): {
  30463. min: Vector3;
  30464. max: Vector3;
  30465. };
  30466. /**
  30467. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30468. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30469. * @returns a vector3
  30470. */
  30471. static Center(meshesOrMinMaxVector: {
  30472. min: Vector3;
  30473. max: Vector3;
  30474. } | AbstractMesh[]): Vector3;
  30475. /**
  30476. * Merge the array of meshes into a single mesh for performance reasons.
  30477. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30478. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30479. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30480. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30481. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30482. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30483. * @returns a new mesh
  30484. */
  30485. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30486. /** @hidden */
  30487. addInstance(instance: InstancedMesh): void;
  30488. /** @hidden */
  30489. removeInstance(instance: InstancedMesh): void;
  30490. }
  30491. }
  30492. declare module "babylonjs/Cameras/camera" {
  30493. import { SmartArray } from "babylonjs/Misc/smartArray";
  30494. import { Observable } from "babylonjs/Misc/observable";
  30495. import { Nullable } from "babylonjs/types";
  30496. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30497. import { Scene } from "babylonjs/scene";
  30498. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30499. import { Node } from "babylonjs/node";
  30500. import { Mesh } from "babylonjs/Meshes/mesh";
  30501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30502. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30503. import { Viewport } from "babylonjs/Maths/math.viewport";
  30504. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30506. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30507. import { Ray } from "babylonjs/Culling/ray";
  30508. /**
  30509. * This is the base class of all the camera used in the application.
  30510. * @see https://doc.babylonjs.com/features/cameras
  30511. */
  30512. export class Camera extends Node {
  30513. /** @hidden */
  30514. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30515. /**
  30516. * This is the default projection mode used by the cameras.
  30517. * It helps recreating a feeling of perspective and better appreciate depth.
  30518. * This is the best way to simulate real life cameras.
  30519. */
  30520. static readonly PERSPECTIVE_CAMERA: number;
  30521. /**
  30522. * This helps creating camera with an orthographic mode.
  30523. * 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.
  30524. */
  30525. static readonly ORTHOGRAPHIC_CAMERA: number;
  30526. /**
  30527. * This is the default FOV mode for perspective cameras.
  30528. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30529. */
  30530. static readonly FOVMODE_VERTICAL_FIXED: number;
  30531. /**
  30532. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30533. */
  30534. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30535. /**
  30536. * This specifies ther is no need for a camera rig.
  30537. * Basically only one eye is rendered corresponding to the camera.
  30538. */
  30539. static readonly RIG_MODE_NONE: number;
  30540. /**
  30541. * Simulates a camera Rig with one blue eye and one red eye.
  30542. * This can be use with 3d blue and red glasses.
  30543. */
  30544. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30545. /**
  30546. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30547. */
  30548. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30549. /**
  30550. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30551. */
  30552. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30553. /**
  30554. * Defines that both eyes of the camera will be rendered over under each other.
  30555. */
  30556. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30557. /**
  30558. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30559. */
  30560. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30561. /**
  30562. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30563. */
  30564. static readonly RIG_MODE_VR: number;
  30565. /**
  30566. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30567. */
  30568. static readonly RIG_MODE_WEBVR: number;
  30569. /**
  30570. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30571. */
  30572. static readonly RIG_MODE_CUSTOM: number;
  30573. /**
  30574. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30575. */
  30576. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30577. /**
  30578. * Define the input manager associated with the camera.
  30579. */
  30580. inputs: CameraInputsManager<Camera>;
  30581. /** @hidden */
  30582. _position: Vector3;
  30583. /**
  30584. * Define the current local position of the camera in the scene
  30585. */
  30586. get position(): Vector3;
  30587. set position(newPosition: Vector3);
  30588. protected _upVector: Vector3;
  30589. /**
  30590. * The vector the camera should consider as up.
  30591. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30592. */
  30593. set upVector(vec: Vector3);
  30594. get upVector(): Vector3;
  30595. /**
  30596. * Define the current limit on the left side for an orthographic camera
  30597. * In scene unit
  30598. */
  30599. orthoLeft: Nullable<number>;
  30600. /**
  30601. * Define the current limit on the right side for an orthographic camera
  30602. * In scene unit
  30603. */
  30604. orthoRight: Nullable<number>;
  30605. /**
  30606. * Define the current limit on the bottom side for an orthographic camera
  30607. * In scene unit
  30608. */
  30609. orthoBottom: Nullable<number>;
  30610. /**
  30611. * Define the current limit on the top side for an orthographic camera
  30612. * In scene unit
  30613. */
  30614. orthoTop: Nullable<number>;
  30615. /**
  30616. * Field Of View is set in Radians. (default is 0.8)
  30617. */
  30618. fov: number;
  30619. /**
  30620. * Define the minimum distance the camera can see from.
  30621. * This is important to note that the depth buffer are not infinite and the closer it starts
  30622. * the more your scene might encounter depth fighting issue.
  30623. */
  30624. minZ: number;
  30625. /**
  30626. * Define the maximum distance the camera can see to.
  30627. * This is important to note that the depth buffer are not infinite and the further it end
  30628. * the more your scene might encounter depth fighting issue.
  30629. */
  30630. maxZ: number;
  30631. /**
  30632. * Define the default inertia of the camera.
  30633. * This helps giving a smooth feeling to the camera movement.
  30634. */
  30635. inertia: number;
  30636. /**
  30637. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30638. */
  30639. mode: number;
  30640. /**
  30641. * Define whether the camera is intermediate.
  30642. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30643. */
  30644. isIntermediate: boolean;
  30645. /**
  30646. * Define the viewport of the camera.
  30647. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30648. */
  30649. viewport: Viewport;
  30650. /**
  30651. * Restricts the camera to viewing objects with the same layerMask.
  30652. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30653. */
  30654. layerMask: number;
  30655. /**
  30656. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30657. */
  30658. fovMode: number;
  30659. /**
  30660. * Rig mode of the camera.
  30661. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30662. * This is normally controlled byt the camera themselves as internal use.
  30663. */
  30664. cameraRigMode: number;
  30665. /**
  30666. * Defines the distance between both "eyes" in case of a RIG
  30667. */
  30668. interaxialDistance: number;
  30669. /**
  30670. * Defines if stereoscopic rendering is done side by side or over under.
  30671. */
  30672. isStereoscopicSideBySide: boolean;
  30673. /**
  30674. * 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
  30675. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30676. * else in the scene. (Eg. security camera)
  30677. *
  30678. * 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)
  30679. */
  30680. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30681. /**
  30682. * When set, the camera will render to this render target instead of the default canvas
  30683. *
  30684. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30685. */
  30686. outputRenderTarget: Nullable<RenderTargetTexture>;
  30687. /**
  30688. * Observable triggered when the camera view matrix has changed.
  30689. */
  30690. onViewMatrixChangedObservable: Observable<Camera>;
  30691. /**
  30692. * Observable triggered when the camera Projection matrix has changed.
  30693. */
  30694. onProjectionMatrixChangedObservable: Observable<Camera>;
  30695. /**
  30696. * Observable triggered when the inputs have been processed.
  30697. */
  30698. onAfterCheckInputsObservable: Observable<Camera>;
  30699. /**
  30700. * Observable triggered when reset has been called and applied to the camera.
  30701. */
  30702. onRestoreStateObservable: Observable<Camera>;
  30703. /**
  30704. * Is this camera a part of a rig system?
  30705. */
  30706. isRigCamera: boolean;
  30707. /**
  30708. * If isRigCamera set to true this will be set with the parent camera.
  30709. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30710. */
  30711. rigParent?: Camera;
  30712. /** @hidden */
  30713. _cameraRigParams: any;
  30714. /** @hidden */
  30715. _rigCameras: Camera[];
  30716. /** @hidden */
  30717. _rigPostProcess: Nullable<PostProcess>;
  30718. protected _webvrViewMatrix: Matrix;
  30719. /** @hidden */
  30720. _skipRendering: boolean;
  30721. /** @hidden */
  30722. _projectionMatrix: Matrix;
  30723. /** @hidden */
  30724. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30725. /** @hidden */
  30726. _activeMeshes: SmartArray<AbstractMesh>;
  30727. protected _globalPosition: Vector3;
  30728. /** @hidden */
  30729. _computedViewMatrix: Matrix;
  30730. private _doNotComputeProjectionMatrix;
  30731. private _transformMatrix;
  30732. private _frustumPlanes;
  30733. private _refreshFrustumPlanes;
  30734. private _storedFov;
  30735. private _stateStored;
  30736. /**
  30737. * Instantiates a new camera object.
  30738. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30739. * @see https://doc.babylonjs.com/features/cameras
  30740. * @param name Defines the name of the camera in the scene
  30741. * @param position Defines the position of the camera
  30742. * @param scene Defines the scene the camera belongs too
  30743. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30744. */
  30745. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30746. /**
  30747. * Store current camera state (fov, position, etc..)
  30748. * @returns the camera
  30749. */
  30750. storeState(): Camera;
  30751. /**
  30752. * Restores the camera state values if it has been stored. You must call storeState() first
  30753. */
  30754. protected _restoreStateValues(): boolean;
  30755. /**
  30756. * Restored camera state. You must call storeState() first.
  30757. * @returns true if restored and false otherwise
  30758. */
  30759. restoreState(): boolean;
  30760. /**
  30761. * Gets the class name of the camera.
  30762. * @returns the class name
  30763. */
  30764. getClassName(): string;
  30765. /** @hidden */
  30766. readonly _isCamera: boolean;
  30767. /**
  30768. * Gets a string representation of the camera useful for debug purpose.
  30769. * @param fullDetails Defines that a more verboe level of logging is required
  30770. * @returns the string representation
  30771. */
  30772. toString(fullDetails?: boolean): string;
  30773. /**
  30774. * Gets the current world space position of the camera.
  30775. */
  30776. get globalPosition(): Vector3;
  30777. /**
  30778. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30779. * @returns the active meshe list
  30780. */
  30781. getActiveMeshes(): SmartArray<AbstractMesh>;
  30782. /**
  30783. * Check whether a mesh is part of the current active mesh list of the camera
  30784. * @param mesh Defines the mesh to check
  30785. * @returns true if active, false otherwise
  30786. */
  30787. isActiveMesh(mesh: Mesh): boolean;
  30788. /**
  30789. * Is this camera ready to be used/rendered
  30790. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30791. * @return true if the camera is ready
  30792. */
  30793. isReady(completeCheck?: boolean): boolean;
  30794. /** @hidden */
  30795. _initCache(): void;
  30796. /** @hidden */
  30797. _updateCache(ignoreParentClass?: boolean): void;
  30798. /** @hidden */
  30799. _isSynchronized(): boolean;
  30800. /** @hidden */
  30801. _isSynchronizedViewMatrix(): boolean;
  30802. /** @hidden */
  30803. _isSynchronizedProjectionMatrix(): boolean;
  30804. /**
  30805. * Attach the input controls to a specific dom element to get the input from.
  30806. * @param element Defines the element the controls should be listened from
  30807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30808. */
  30809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30810. /**
  30811. * Detach the current controls from the specified dom element.
  30812. * @param element Defines the element to stop listening the inputs from
  30813. */
  30814. detachControl(element: HTMLElement): void;
  30815. /**
  30816. * Update the camera state according to the different inputs gathered during the frame.
  30817. */
  30818. update(): void;
  30819. /** @hidden */
  30820. _checkInputs(): void;
  30821. /** @hidden */
  30822. get rigCameras(): Camera[];
  30823. /**
  30824. * Gets the post process used by the rig cameras
  30825. */
  30826. get rigPostProcess(): Nullable<PostProcess>;
  30827. /**
  30828. * Internal, gets the first post proces.
  30829. * @returns the first post process to be run on this camera.
  30830. */
  30831. _getFirstPostProcess(): Nullable<PostProcess>;
  30832. private _cascadePostProcessesToRigCams;
  30833. /**
  30834. * Attach a post process to the camera.
  30835. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30836. * @param postProcess The post process to attach to the camera
  30837. * @param insertAt The position of the post process in case several of them are in use in the scene
  30838. * @returns the position the post process has been inserted at
  30839. */
  30840. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30841. /**
  30842. * Detach a post process to the camera.
  30843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30844. * @param postProcess The post process to detach from the camera
  30845. */
  30846. detachPostProcess(postProcess: PostProcess): void;
  30847. /**
  30848. * Gets the current world matrix of the camera
  30849. */
  30850. getWorldMatrix(): Matrix;
  30851. /** @hidden */
  30852. _getViewMatrix(): Matrix;
  30853. /**
  30854. * Gets the current view matrix of the camera.
  30855. * @param force forces the camera to recompute the matrix without looking at the cached state
  30856. * @returns the view matrix
  30857. */
  30858. getViewMatrix(force?: boolean): Matrix;
  30859. /**
  30860. * Freeze the projection matrix.
  30861. * It will prevent the cache check of the camera projection compute and can speed up perf
  30862. * if no parameter of the camera are meant to change
  30863. * @param projection Defines manually a projection if necessary
  30864. */
  30865. freezeProjectionMatrix(projection?: Matrix): void;
  30866. /**
  30867. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30868. */
  30869. unfreezeProjectionMatrix(): void;
  30870. /**
  30871. * Gets the current projection matrix of the camera.
  30872. * @param force forces the camera to recompute the matrix without looking at the cached state
  30873. * @returns the projection matrix
  30874. */
  30875. getProjectionMatrix(force?: boolean): Matrix;
  30876. /**
  30877. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30878. * @returns a Matrix
  30879. */
  30880. getTransformationMatrix(): Matrix;
  30881. private _updateFrustumPlanes;
  30882. /**
  30883. * Checks if a cullable object (mesh...) is in the camera frustum
  30884. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30885. * @param target The object to check
  30886. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30887. * @returns true if the object is in frustum otherwise false
  30888. */
  30889. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30890. /**
  30891. * Checks if a cullable object (mesh...) is in the camera frustum
  30892. * Unlike isInFrustum this cheks the full bounding box
  30893. * @param target The object to check
  30894. * @returns true if the object is in frustum otherwise false
  30895. */
  30896. isCompletelyInFrustum(target: ICullable): boolean;
  30897. /**
  30898. * Gets a ray in the forward direction from the camera.
  30899. * @param length Defines the length of the ray to create
  30900. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30901. * @param origin Defines the start point of the ray which defaults to the camera position
  30902. * @returns the forward ray
  30903. */
  30904. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30905. /**
  30906. * Gets a ray in the forward direction from the camera.
  30907. * @param refRay the ray to (re)use when setting the values
  30908. * @param length Defines the length of the ray to create
  30909. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30910. * @param origin Defines the start point of the ray which defaults to the camera position
  30911. * @returns the forward ray
  30912. */
  30913. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30914. /**
  30915. * Releases resources associated with this node.
  30916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30918. */
  30919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30920. /** @hidden */
  30921. _isLeftCamera: boolean;
  30922. /**
  30923. * Gets the left camera of a rig setup in case of Rigged Camera
  30924. */
  30925. get isLeftCamera(): boolean;
  30926. /** @hidden */
  30927. _isRightCamera: boolean;
  30928. /**
  30929. * Gets the right camera of a rig setup in case of Rigged Camera
  30930. */
  30931. get isRightCamera(): boolean;
  30932. /**
  30933. * Gets the left camera of a rig setup in case of Rigged Camera
  30934. */
  30935. get leftCamera(): Nullable<FreeCamera>;
  30936. /**
  30937. * Gets the right camera of a rig setup in case of Rigged Camera
  30938. */
  30939. get rightCamera(): Nullable<FreeCamera>;
  30940. /**
  30941. * Gets the left camera target of a rig setup in case of Rigged Camera
  30942. * @returns the target position
  30943. */
  30944. getLeftTarget(): Nullable<Vector3>;
  30945. /**
  30946. * Gets the right camera target of a rig setup in case of Rigged Camera
  30947. * @returns the target position
  30948. */
  30949. getRightTarget(): Nullable<Vector3>;
  30950. /**
  30951. * @hidden
  30952. */
  30953. setCameraRigMode(mode: number, rigParams: any): void;
  30954. /** @hidden */
  30955. static _setStereoscopicRigMode(camera: Camera): void;
  30956. /** @hidden */
  30957. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30958. /** @hidden */
  30959. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30960. /** @hidden */
  30961. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30962. /** @hidden */
  30963. _getVRProjectionMatrix(): Matrix;
  30964. protected _updateCameraRotationMatrix(): void;
  30965. protected _updateWebVRCameraRotationMatrix(): void;
  30966. /**
  30967. * This function MUST be overwritten by the different WebVR cameras available.
  30968. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30969. * @hidden
  30970. */
  30971. _getWebVRProjectionMatrix(): Matrix;
  30972. /**
  30973. * This function MUST be overwritten by the different WebVR cameras available.
  30974. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30975. * @hidden
  30976. */
  30977. _getWebVRViewMatrix(): Matrix;
  30978. /** @hidden */
  30979. setCameraRigParameter(name: string, value: any): void;
  30980. /**
  30981. * needs to be overridden by children so sub has required properties to be copied
  30982. * @hidden
  30983. */
  30984. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30985. /**
  30986. * May need to be overridden by children
  30987. * @hidden
  30988. */
  30989. _updateRigCameras(): void;
  30990. /** @hidden */
  30991. _setupInputs(): void;
  30992. /**
  30993. * Serialiaze the camera setup to a json represention
  30994. * @returns the JSON representation
  30995. */
  30996. serialize(): any;
  30997. /**
  30998. * Clones the current camera.
  30999. * @param name The cloned camera name
  31000. * @returns the cloned camera
  31001. */
  31002. clone(name: string): Camera;
  31003. /**
  31004. * Gets the direction of the camera relative to a given local axis.
  31005. * @param localAxis Defines the reference axis to provide a relative direction.
  31006. * @return the direction
  31007. */
  31008. getDirection(localAxis: Vector3): Vector3;
  31009. /**
  31010. * Returns the current camera absolute rotation
  31011. */
  31012. get absoluteRotation(): Quaternion;
  31013. /**
  31014. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31015. * @param localAxis Defines the reference axis to provide a relative direction.
  31016. * @param result Defines the vector to store the result in
  31017. */
  31018. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31019. /**
  31020. * Gets a camera constructor for a given camera type
  31021. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31022. * @param name The name of the camera the result will be able to instantiate
  31023. * @param scene The scene the result will construct the camera in
  31024. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31025. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31026. * @returns a factory method to construc the camera
  31027. */
  31028. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31029. /**
  31030. * Compute the world matrix of the camera.
  31031. * @returns the camera world matrix
  31032. */
  31033. computeWorldMatrix(): Matrix;
  31034. /**
  31035. * Parse a JSON and creates the camera from the parsed information
  31036. * @param parsedCamera The JSON to parse
  31037. * @param scene The scene to instantiate the camera in
  31038. * @returns the newly constructed camera
  31039. */
  31040. static Parse(parsedCamera: any, scene: Scene): Camera;
  31041. }
  31042. }
  31043. declare module "babylonjs/Meshes/Builders/discBuilder" {
  31044. import { Nullable } from "babylonjs/types";
  31045. import { Scene } from "babylonjs/scene";
  31046. import { Vector4 } from "babylonjs/Maths/math.vector";
  31047. import { Mesh } from "babylonjs/Meshes/mesh";
  31048. /**
  31049. * Class containing static functions to help procedurally build meshes
  31050. */
  31051. export class DiscBuilder {
  31052. /**
  31053. * Creates a plane polygonal mesh. By default, this is a disc
  31054. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  31055. * * 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
  31056. * * 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
  31057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  31058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  31059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  31060. * @param name defines the name of the mesh
  31061. * @param options defines the options used to create the mesh
  31062. * @param scene defines the hosting scene
  31063. * @returns the plane polygonal mesh
  31064. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  31065. */
  31066. static CreateDisc(name: string, options: {
  31067. radius?: number;
  31068. tessellation?: number;
  31069. arc?: number;
  31070. updatable?: boolean;
  31071. sideOrientation?: number;
  31072. frontUVs?: Vector4;
  31073. backUVs?: Vector4;
  31074. }, scene?: Nullable<Scene>): Mesh;
  31075. }
  31076. }
  31077. declare module "babylonjs/Materials/fresnelParameters" {
  31078. import { DeepImmutable } from "babylonjs/types";
  31079. import { Color3 } from "babylonjs/Maths/math.color";
  31080. /**
  31081. * Options to be used when creating a FresnelParameters.
  31082. */
  31083. export type IFresnelParametersCreationOptions = {
  31084. /**
  31085. * Define the color used on edges (grazing angle)
  31086. */
  31087. leftColor?: Color3;
  31088. /**
  31089. * Define the color used on center
  31090. */
  31091. rightColor?: Color3;
  31092. /**
  31093. * Define bias applied to computed fresnel term
  31094. */
  31095. bias?: number;
  31096. /**
  31097. * Defined the power exponent applied to fresnel term
  31098. */
  31099. power?: number;
  31100. /**
  31101. * Define if the fresnel effect is enable or not.
  31102. */
  31103. isEnabled?: boolean;
  31104. };
  31105. /**
  31106. * Serialized format for FresnelParameters.
  31107. */
  31108. export type IFresnelParametersSerialized = {
  31109. /**
  31110. * Define the color used on edges (grazing angle) [as an array]
  31111. */
  31112. leftColor: number[];
  31113. /**
  31114. * Define the color used on center [as an array]
  31115. */
  31116. rightColor: number[];
  31117. /**
  31118. * Define bias applied to computed fresnel term
  31119. */
  31120. bias: number;
  31121. /**
  31122. * Defined the power exponent applied to fresnel term
  31123. */
  31124. power?: number;
  31125. /**
  31126. * Define if the fresnel effect is enable or not.
  31127. */
  31128. isEnabled: boolean;
  31129. };
  31130. /**
  31131. * This represents all the required information to add a fresnel effect on a material:
  31132. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31133. */
  31134. export class FresnelParameters {
  31135. private _isEnabled;
  31136. /**
  31137. * Define if the fresnel effect is enable or not.
  31138. */
  31139. get isEnabled(): boolean;
  31140. set isEnabled(value: boolean);
  31141. /**
  31142. * Define the color used on edges (grazing angle)
  31143. */
  31144. leftColor: Color3;
  31145. /**
  31146. * Define the color used on center
  31147. */
  31148. rightColor: Color3;
  31149. /**
  31150. * Define bias applied to computed fresnel term
  31151. */
  31152. bias: number;
  31153. /**
  31154. * Defined the power exponent applied to fresnel term
  31155. */
  31156. power: number;
  31157. /**
  31158. * Creates a new FresnelParameters object.
  31159. *
  31160. * @param options provide your own settings to optionally to override defaults
  31161. */
  31162. constructor(options?: IFresnelParametersCreationOptions);
  31163. /**
  31164. * Clones the current fresnel and its valuues
  31165. * @returns a clone fresnel configuration
  31166. */
  31167. clone(): FresnelParameters;
  31168. /**
  31169. * Determines equality between FresnelParameters objects
  31170. * @param otherFresnelParameters defines the second operand
  31171. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31172. */
  31173. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31174. /**
  31175. * Serializes the current fresnel parameters to a JSON representation.
  31176. * @return the JSON serialization
  31177. */
  31178. serialize(): IFresnelParametersSerialized;
  31179. /**
  31180. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31181. * @param parsedFresnelParameters Define the JSON representation
  31182. * @returns the parsed parameters
  31183. */
  31184. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31185. }
  31186. }
  31187. declare module "babylonjs/Materials/materialFlags" {
  31188. /**
  31189. * This groups all the flags used to control the materials channel.
  31190. */
  31191. export class MaterialFlags {
  31192. private static _DiffuseTextureEnabled;
  31193. /**
  31194. * Are diffuse textures enabled in the application.
  31195. */
  31196. static get DiffuseTextureEnabled(): boolean;
  31197. static set DiffuseTextureEnabled(value: boolean);
  31198. private static _DetailTextureEnabled;
  31199. /**
  31200. * Are detail textures enabled in the application.
  31201. */
  31202. static get DetailTextureEnabled(): boolean;
  31203. static set DetailTextureEnabled(value: boolean);
  31204. private static _AmbientTextureEnabled;
  31205. /**
  31206. * Are ambient textures enabled in the application.
  31207. */
  31208. static get AmbientTextureEnabled(): boolean;
  31209. static set AmbientTextureEnabled(value: boolean);
  31210. private static _OpacityTextureEnabled;
  31211. /**
  31212. * Are opacity textures enabled in the application.
  31213. */
  31214. static get OpacityTextureEnabled(): boolean;
  31215. static set OpacityTextureEnabled(value: boolean);
  31216. private static _ReflectionTextureEnabled;
  31217. /**
  31218. * Are reflection textures enabled in the application.
  31219. */
  31220. static get ReflectionTextureEnabled(): boolean;
  31221. static set ReflectionTextureEnabled(value: boolean);
  31222. private static _EmissiveTextureEnabled;
  31223. /**
  31224. * Are emissive textures enabled in the application.
  31225. */
  31226. static get EmissiveTextureEnabled(): boolean;
  31227. static set EmissiveTextureEnabled(value: boolean);
  31228. private static _SpecularTextureEnabled;
  31229. /**
  31230. * Are specular textures enabled in the application.
  31231. */
  31232. static get SpecularTextureEnabled(): boolean;
  31233. static set SpecularTextureEnabled(value: boolean);
  31234. private static _BumpTextureEnabled;
  31235. /**
  31236. * Are bump textures enabled in the application.
  31237. */
  31238. static get BumpTextureEnabled(): boolean;
  31239. static set BumpTextureEnabled(value: boolean);
  31240. private static _LightmapTextureEnabled;
  31241. /**
  31242. * Are lightmap textures enabled in the application.
  31243. */
  31244. static get LightmapTextureEnabled(): boolean;
  31245. static set LightmapTextureEnabled(value: boolean);
  31246. private static _RefractionTextureEnabled;
  31247. /**
  31248. * Are refraction textures enabled in the application.
  31249. */
  31250. static get RefractionTextureEnabled(): boolean;
  31251. static set RefractionTextureEnabled(value: boolean);
  31252. private static _ColorGradingTextureEnabled;
  31253. /**
  31254. * Are color grading textures enabled in the application.
  31255. */
  31256. static get ColorGradingTextureEnabled(): boolean;
  31257. static set ColorGradingTextureEnabled(value: boolean);
  31258. private static _FresnelEnabled;
  31259. /**
  31260. * Are fresnels enabled in the application.
  31261. */
  31262. static get FresnelEnabled(): boolean;
  31263. static set FresnelEnabled(value: boolean);
  31264. private static _ClearCoatTextureEnabled;
  31265. /**
  31266. * Are clear coat textures enabled in the application.
  31267. */
  31268. static get ClearCoatTextureEnabled(): boolean;
  31269. static set ClearCoatTextureEnabled(value: boolean);
  31270. private static _ClearCoatBumpTextureEnabled;
  31271. /**
  31272. * Are clear coat bump textures enabled in the application.
  31273. */
  31274. static get ClearCoatBumpTextureEnabled(): boolean;
  31275. static set ClearCoatBumpTextureEnabled(value: boolean);
  31276. private static _ClearCoatTintTextureEnabled;
  31277. /**
  31278. * Are clear coat tint textures enabled in the application.
  31279. */
  31280. static get ClearCoatTintTextureEnabled(): boolean;
  31281. static set ClearCoatTintTextureEnabled(value: boolean);
  31282. private static _SheenTextureEnabled;
  31283. /**
  31284. * Are sheen textures enabled in the application.
  31285. */
  31286. static get SheenTextureEnabled(): boolean;
  31287. static set SheenTextureEnabled(value: boolean);
  31288. private static _AnisotropicTextureEnabled;
  31289. /**
  31290. * Are anisotropic textures enabled in the application.
  31291. */
  31292. static get AnisotropicTextureEnabled(): boolean;
  31293. static set AnisotropicTextureEnabled(value: boolean);
  31294. private static _ThicknessTextureEnabled;
  31295. /**
  31296. * Are thickness textures enabled in the application.
  31297. */
  31298. static get ThicknessTextureEnabled(): boolean;
  31299. static set ThicknessTextureEnabled(value: boolean);
  31300. }
  31301. }
  31302. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31303. /** @hidden */
  31304. export var defaultFragmentDeclaration: {
  31305. name: string;
  31306. shader: string;
  31307. };
  31308. }
  31309. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31310. /** @hidden */
  31311. export var defaultUboDeclaration: {
  31312. name: string;
  31313. shader: string;
  31314. };
  31315. }
  31316. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31317. /** @hidden */
  31318. export var prePassDeclaration: {
  31319. name: string;
  31320. shader: string;
  31321. };
  31322. }
  31323. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31324. /** @hidden */
  31325. export var lightFragmentDeclaration: {
  31326. name: string;
  31327. shader: string;
  31328. };
  31329. }
  31330. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31331. /** @hidden */
  31332. export var lightUboDeclaration: {
  31333. name: string;
  31334. shader: string;
  31335. };
  31336. }
  31337. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31338. /** @hidden */
  31339. export var lightsFragmentFunctions: {
  31340. name: string;
  31341. shader: string;
  31342. };
  31343. }
  31344. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31345. /** @hidden */
  31346. export var shadowsFragmentFunctions: {
  31347. name: string;
  31348. shader: string;
  31349. };
  31350. }
  31351. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31352. /** @hidden */
  31353. export var fresnelFunction: {
  31354. name: string;
  31355. shader: string;
  31356. };
  31357. }
  31358. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31359. /** @hidden */
  31360. export var bumpFragmentMainFunctions: {
  31361. name: string;
  31362. shader: string;
  31363. };
  31364. }
  31365. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31366. /** @hidden */
  31367. export var bumpFragmentFunctions: {
  31368. name: string;
  31369. shader: string;
  31370. };
  31371. }
  31372. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31373. /** @hidden */
  31374. export var logDepthDeclaration: {
  31375. name: string;
  31376. shader: string;
  31377. };
  31378. }
  31379. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31380. /** @hidden */
  31381. export var bumpFragment: {
  31382. name: string;
  31383. shader: string;
  31384. };
  31385. }
  31386. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31387. /** @hidden */
  31388. export var depthPrePass: {
  31389. name: string;
  31390. shader: string;
  31391. };
  31392. }
  31393. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31394. /** @hidden */
  31395. export var lightFragment: {
  31396. name: string;
  31397. shader: string;
  31398. };
  31399. }
  31400. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31401. /** @hidden */
  31402. export var logDepthFragment: {
  31403. name: string;
  31404. shader: string;
  31405. };
  31406. }
  31407. declare module "babylonjs/Shaders/default.fragment" {
  31408. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31409. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31412. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31413. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31414. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31415. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31416. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31417. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31418. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31419. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31420. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31421. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31422. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31423. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31424. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31425. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31426. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31427. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31428. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31429. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31430. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31431. /** @hidden */
  31432. export var defaultPixelShader: {
  31433. name: string;
  31434. shader: string;
  31435. };
  31436. }
  31437. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31438. /** @hidden */
  31439. export var defaultVertexDeclaration: {
  31440. name: string;
  31441. shader: string;
  31442. };
  31443. }
  31444. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31445. /** @hidden */
  31446. export var bumpVertexDeclaration: {
  31447. name: string;
  31448. shader: string;
  31449. };
  31450. }
  31451. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31452. /** @hidden */
  31453. export var bumpVertex: {
  31454. name: string;
  31455. shader: string;
  31456. };
  31457. }
  31458. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31459. /** @hidden */
  31460. export var fogVertex: {
  31461. name: string;
  31462. shader: string;
  31463. };
  31464. }
  31465. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31466. /** @hidden */
  31467. export var shadowsVertex: {
  31468. name: string;
  31469. shader: string;
  31470. };
  31471. }
  31472. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31473. /** @hidden */
  31474. export var pointCloudVertex: {
  31475. name: string;
  31476. shader: string;
  31477. };
  31478. }
  31479. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31480. /** @hidden */
  31481. export var logDepthVertex: {
  31482. name: string;
  31483. shader: string;
  31484. };
  31485. }
  31486. declare module "babylonjs/Shaders/default.vertex" {
  31487. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31488. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31489. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31490. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31491. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31492. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31493. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31494. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31495. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31496. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31497. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31498. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31499. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31500. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31501. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31502. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31503. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31504. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31505. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31506. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31507. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31508. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31509. /** @hidden */
  31510. export var defaultVertexShader: {
  31511. name: string;
  31512. shader: string;
  31513. };
  31514. }
  31515. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31516. import { Nullable } from "babylonjs/types";
  31517. import { Scene } from "babylonjs/scene";
  31518. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31519. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31520. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31521. /**
  31522. * @hidden
  31523. */
  31524. export interface IMaterialDetailMapDefines {
  31525. DETAIL: boolean;
  31526. DETAILDIRECTUV: number;
  31527. DETAIL_NORMALBLENDMETHOD: number;
  31528. /** @hidden */
  31529. _areTexturesDirty: boolean;
  31530. }
  31531. /**
  31532. * Define the code related to the detail map parameters of a material
  31533. *
  31534. * Inspired from:
  31535. * 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
  31536. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31537. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31538. */
  31539. export class DetailMapConfiguration {
  31540. private _texture;
  31541. /**
  31542. * The detail texture of the material.
  31543. */
  31544. texture: Nullable<BaseTexture>;
  31545. /**
  31546. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31547. * Bigger values mean stronger blending
  31548. */
  31549. diffuseBlendLevel: number;
  31550. /**
  31551. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31552. * Bigger values mean stronger blending. Only used with PBR materials
  31553. */
  31554. roughnessBlendLevel: number;
  31555. /**
  31556. * Defines how strong the bump effect from the detail map is
  31557. * Bigger values mean stronger effect
  31558. */
  31559. bumpLevel: number;
  31560. private _normalBlendMethod;
  31561. /**
  31562. * The method used to blend the bump and detail normals together
  31563. */
  31564. normalBlendMethod: number;
  31565. private _isEnabled;
  31566. /**
  31567. * Enable or disable the detail map on this material
  31568. */
  31569. isEnabled: boolean;
  31570. /** @hidden */
  31571. private _internalMarkAllSubMeshesAsTexturesDirty;
  31572. /** @hidden */
  31573. _markAllSubMeshesAsTexturesDirty(): void;
  31574. /**
  31575. * Instantiate a new detail map
  31576. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31577. */
  31578. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31579. /**
  31580. * Gets whether the submesh is ready to be used or not.
  31581. * @param defines the list of "defines" to update.
  31582. * @param scene defines the scene the material belongs to.
  31583. * @returns - boolean indicating that the submesh is ready or not.
  31584. */
  31585. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31586. /**
  31587. * Update the defines for detail map usage
  31588. * @param defines the list of "defines" to update.
  31589. * @param scene defines the scene the material belongs to.
  31590. */
  31591. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31592. /**
  31593. * Binds the material data.
  31594. * @param uniformBuffer defines the Uniform buffer to fill in.
  31595. * @param scene defines the scene the material belongs to.
  31596. * @param isFrozen defines whether the material is frozen or not.
  31597. */
  31598. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31599. /**
  31600. * Checks to see if a texture is used in the material.
  31601. * @param texture - Base texture to use.
  31602. * @returns - Boolean specifying if a texture is used in the material.
  31603. */
  31604. hasTexture(texture: BaseTexture): boolean;
  31605. /**
  31606. * Returns an array of the actively used textures.
  31607. * @param activeTextures Array of BaseTextures
  31608. */
  31609. getActiveTextures(activeTextures: BaseTexture[]): void;
  31610. /**
  31611. * Returns the animatable textures.
  31612. * @param animatables Array of animatable textures.
  31613. */
  31614. getAnimatables(animatables: IAnimatable[]): void;
  31615. /**
  31616. * Disposes the resources of the material.
  31617. * @param forceDisposeTextures - Forces the disposal of all textures.
  31618. */
  31619. dispose(forceDisposeTextures?: boolean): void;
  31620. /**
  31621. * Get the current class name useful for serialization or dynamic coding.
  31622. * @returns "DetailMap"
  31623. */
  31624. getClassName(): string;
  31625. /**
  31626. * Add the required uniforms to the current list.
  31627. * @param uniforms defines the current uniform list.
  31628. */
  31629. static AddUniforms(uniforms: string[]): void;
  31630. /**
  31631. * Add the required samplers to the current list.
  31632. * @param samplers defines the current sampler list.
  31633. */
  31634. static AddSamplers(samplers: string[]): void;
  31635. /**
  31636. * Add the required uniforms to the current buffer.
  31637. * @param uniformBuffer defines the current uniform buffer.
  31638. */
  31639. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31640. /**
  31641. * Makes a duplicate of the current instance into another one.
  31642. * @param detailMap define the instance where to copy the info
  31643. */
  31644. copyTo(detailMap: DetailMapConfiguration): void;
  31645. /**
  31646. * Serializes this detail map instance
  31647. * @returns - An object with the serialized instance.
  31648. */
  31649. serialize(): any;
  31650. /**
  31651. * Parses a detail map setting from a serialized object.
  31652. * @param source - Serialized object.
  31653. * @param scene Defines the scene we are parsing for
  31654. * @param rootUrl Defines the rootUrl to load from
  31655. */
  31656. parse(source: any, scene: Scene, rootUrl: string): void;
  31657. }
  31658. }
  31659. declare module "babylonjs/Materials/standardMaterial" {
  31660. import { SmartArray } from "babylonjs/Misc/smartArray";
  31661. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31662. import { Nullable } from "babylonjs/types";
  31663. import { Scene } from "babylonjs/scene";
  31664. import { Matrix } from "babylonjs/Maths/math.vector";
  31665. import { Color3 } from "babylonjs/Maths/math.color";
  31666. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31668. import { Mesh } from "babylonjs/Meshes/mesh";
  31669. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31670. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31671. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31672. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31673. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31675. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31676. import "babylonjs/Shaders/default.fragment";
  31677. import "babylonjs/Shaders/default.vertex";
  31678. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31679. /** @hidden */
  31680. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31681. MAINUV1: boolean;
  31682. MAINUV2: boolean;
  31683. DIFFUSE: boolean;
  31684. DIFFUSEDIRECTUV: number;
  31685. DETAIL: boolean;
  31686. DETAILDIRECTUV: number;
  31687. DETAIL_NORMALBLENDMETHOD: number;
  31688. AMBIENT: boolean;
  31689. AMBIENTDIRECTUV: number;
  31690. OPACITY: boolean;
  31691. OPACITYDIRECTUV: number;
  31692. OPACITYRGB: boolean;
  31693. REFLECTION: boolean;
  31694. EMISSIVE: boolean;
  31695. EMISSIVEDIRECTUV: number;
  31696. SPECULAR: boolean;
  31697. SPECULARDIRECTUV: number;
  31698. BUMP: boolean;
  31699. BUMPDIRECTUV: number;
  31700. PARALLAX: boolean;
  31701. PARALLAXOCCLUSION: boolean;
  31702. SPECULAROVERALPHA: boolean;
  31703. CLIPPLANE: boolean;
  31704. CLIPPLANE2: boolean;
  31705. CLIPPLANE3: boolean;
  31706. CLIPPLANE4: boolean;
  31707. CLIPPLANE5: boolean;
  31708. CLIPPLANE6: boolean;
  31709. ALPHATEST: boolean;
  31710. DEPTHPREPASS: boolean;
  31711. ALPHAFROMDIFFUSE: boolean;
  31712. POINTSIZE: boolean;
  31713. FOG: boolean;
  31714. SPECULARTERM: boolean;
  31715. DIFFUSEFRESNEL: boolean;
  31716. OPACITYFRESNEL: boolean;
  31717. REFLECTIONFRESNEL: boolean;
  31718. REFRACTIONFRESNEL: boolean;
  31719. EMISSIVEFRESNEL: boolean;
  31720. FRESNEL: boolean;
  31721. NORMAL: boolean;
  31722. UV1: boolean;
  31723. UV2: boolean;
  31724. VERTEXCOLOR: boolean;
  31725. VERTEXALPHA: boolean;
  31726. NUM_BONE_INFLUENCERS: number;
  31727. BonesPerMesh: number;
  31728. BONETEXTURE: boolean;
  31729. INSTANCES: boolean;
  31730. THIN_INSTANCES: boolean;
  31731. GLOSSINESS: boolean;
  31732. ROUGHNESS: boolean;
  31733. EMISSIVEASILLUMINATION: boolean;
  31734. LINKEMISSIVEWITHDIFFUSE: boolean;
  31735. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31736. LIGHTMAP: boolean;
  31737. LIGHTMAPDIRECTUV: number;
  31738. OBJECTSPACE_NORMALMAP: boolean;
  31739. USELIGHTMAPASSHADOWMAP: boolean;
  31740. REFLECTIONMAP_3D: boolean;
  31741. REFLECTIONMAP_SPHERICAL: boolean;
  31742. REFLECTIONMAP_PLANAR: boolean;
  31743. REFLECTIONMAP_CUBIC: boolean;
  31744. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31745. REFLECTIONMAP_PROJECTION: boolean;
  31746. REFLECTIONMAP_SKYBOX: boolean;
  31747. REFLECTIONMAP_EXPLICIT: boolean;
  31748. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31749. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31750. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31751. INVERTCUBICMAP: boolean;
  31752. LOGARITHMICDEPTH: boolean;
  31753. REFRACTION: boolean;
  31754. REFRACTIONMAP_3D: boolean;
  31755. REFLECTIONOVERALPHA: boolean;
  31756. TWOSIDEDLIGHTING: boolean;
  31757. SHADOWFLOAT: boolean;
  31758. MORPHTARGETS: boolean;
  31759. MORPHTARGETS_NORMAL: boolean;
  31760. MORPHTARGETS_TANGENT: boolean;
  31761. MORPHTARGETS_UV: boolean;
  31762. NUM_MORPH_INFLUENCERS: number;
  31763. NONUNIFORMSCALING: boolean;
  31764. PREMULTIPLYALPHA: boolean;
  31765. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31766. ALPHABLEND: boolean;
  31767. PREPASS: boolean;
  31768. SCENE_MRT_COUNT: number;
  31769. RGBDLIGHTMAP: boolean;
  31770. RGBDREFLECTION: boolean;
  31771. RGBDREFRACTION: boolean;
  31772. IMAGEPROCESSING: boolean;
  31773. VIGNETTE: boolean;
  31774. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31775. VIGNETTEBLENDMODEOPAQUE: boolean;
  31776. TONEMAPPING: boolean;
  31777. TONEMAPPING_ACES: boolean;
  31778. CONTRAST: boolean;
  31779. COLORCURVES: boolean;
  31780. COLORGRADING: boolean;
  31781. COLORGRADING3D: boolean;
  31782. SAMPLER3DGREENDEPTH: boolean;
  31783. SAMPLER3DBGRMAP: boolean;
  31784. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31785. MULTIVIEW: boolean;
  31786. /**
  31787. * If the reflection texture on this material is in linear color space
  31788. * @hidden
  31789. */
  31790. IS_REFLECTION_LINEAR: boolean;
  31791. /**
  31792. * If the refraction texture on this material is in linear color space
  31793. * @hidden
  31794. */
  31795. IS_REFRACTION_LINEAR: boolean;
  31796. EXPOSURE: boolean;
  31797. constructor();
  31798. setReflectionMode(modeToEnable: string): void;
  31799. }
  31800. /**
  31801. * This is the default material used in Babylon. It is the best trade off between quality
  31802. * and performances.
  31803. * @see https://doc.babylonjs.com/babylon101/materials
  31804. */
  31805. export class StandardMaterial extends PushMaterial {
  31806. private _diffuseTexture;
  31807. /**
  31808. * The basic texture of the material as viewed under a light.
  31809. */
  31810. diffuseTexture: Nullable<BaseTexture>;
  31811. private _ambientTexture;
  31812. /**
  31813. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31814. */
  31815. ambientTexture: Nullable<BaseTexture>;
  31816. private _opacityTexture;
  31817. /**
  31818. * Define the transparency of the material from a texture.
  31819. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31820. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31821. */
  31822. opacityTexture: Nullable<BaseTexture>;
  31823. private _reflectionTexture;
  31824. /**
  31825. * Define the texture used to display the reflection.
  31826. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31827. */
  31828. reflectionTexture: Nullable<BaseTexture>;
  31829. private _emissiveTexture;
  31830. /**
  31831. * Define texture of the material as if self lit.
  31832. * This will be mixed in the final result even in the absence of light.
  31833. */
  31834. emissiveTexture: Nullable<BaseTexture>;
  31835. private _specularTexture;
  31836. /**
  31837. * Define how the color and intensity of the highlight given by the light in the material.
  31838. */
  31839. specularTexture: Nullable<BaseTexture>;
  31840. private _bumpTexture;
  31841. /**
  31842. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31843. * 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.
  31844. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31845. */
  31846. bumpTexture: Nullable<BaseTexture>;
  31847. private _lightmapTexture;
  31848. /**
  31849. * Complex lighting can be computationally expensive to compute at runtime.
  31850. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31851. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31852. */
  31853. lightmapTexture: Nullable<BaseTexture>;
  31854. private _refractionTexture;
  31855. /**
  31856. * Define the texture used to display the refraction.
  31857. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31858. */
  31859. refractionTexture: Nullable<BaseTexture>;
  31860. /**
  31861. * The color of the material lit by the environmental background lighting.
  31862. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31863. */
  31864. ambientColor: Color3;
  31865. /**
  31866. * The basic color of the material as viewed under a light.
  31867. */
  31868. diffuseColor: Color3;
  31869. /**
  31870. * Define how the color and intensity of the highlight given by the light in the material.
  31871. */
  31872. specularColor: Color3;
  31873. /**
  31874. * Define the color of the material as if self lit.
  31875. * This will be mixed in the final result even in the absence of light.
  31876. */
  31877. emissiveColor: Color3;
  31878. /**
  31879. * Defines how sharp are the highlights in the material.
  31880. * The bigger the value the sharper giving a more glossy feeling to the result.
  31881. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31882. */
  31883. specularPower: number;
  31884. private _useAlphaFromDiffuseTexture;
  31885. /**
  31886. * Does the transparency come from the diffuse texture alpha channel.
  31887. */
  31888. useAlphaFromDiffuseTexture: boolean;
  31889. private _useEmissiveAsIllumination;
  31890. /**
  31891. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31892. */
  31893. useEmissiveAsIllumination: boolean;
  31894. private _linkEmissiveWithDiffuse;
  31895. /**
  31896. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31897. * the emissive level when the final color is close to one.
  31898. */
  31899. linkEmissiveWithDiffuse: boolean;
  31900. private _useSpecularOverAlpha;
  31901. /**
  31902. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31903. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31904. */
  31905. useSpecularOverAlpha: boolean;
  31906. private _useReflectionOverAlpha;
  31907. /**
  31908. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31909. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31910. */
  31911. useReflectionOverAlpha: boolean;
  31912. private _disableLighting;
  31913. /**
  31914. * Does lights from the scene impacts this material.
  31915. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31916. */
  31917. disableLighting: boolean;
  31918. private _useObjectSpaceNormalMap;
  31919. /**
  31920. * Allows using an object space normal map (instead of tangent space).
  31921. */
  31922. useObjectSpaceNormalMap: boolean;
  31923. private _useParallax;
  31924. /**
  31925. * Is parallax enabled or not.
  31926. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31927. */
  31928. useParallax: boolean;
  31929. private _useParallaxOcclusion;
  31930. /**
  31931. * Is parallax occlusion enabled or not.
  31932. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31933. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31934. */
  31935. useParallaxOcclusion: boolean;
  31936. /**
  31937. * 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.
  31938. */
  31939. parallaxScaleBias: number;
  31940. private _roughness;
  31941. /**
  31942. * Helps to define how blurry the reflections should appears in the material.
  31943. */
  31944. roughness: number;
  31945. /**
  31946. * In case of refraction, define the value of the index of refraction.
  31947. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31948. */
  31949. indexOfRefraction: number;
  31950. /**
  31951. * Invert the refraction texture alongside the y axis.
  31952. * It can be useful with procedural textures or probe for instance.
  31953. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31954. */
  31955. invertRefractionY: boolean;
  31956. /**
  31957. * Defines the alpha limits in alpha test mode.
  31958. */
  31959. alphaCutOff: number;
  31960. private _useLightmapAsShadowmap;
  31961. /**
  31962. * In case of light mapping, define whether the map contains light or shadow informations.
  31963. */
  31964. useLightmapAsShadowmap: boolean;
  31965. private _diffuseFresnelParameters;
  31966. /**
  31967. * Define the diffuse fresnel parameters of the material.
  31968. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31969. */
  31970. diffuseFresnelParameters: FresnelParameters;
  31971. private _opacityFresnelParameters;
  31972. /**
  31973. * Define the opacity fresnel parameters of the material.
  31974. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31975. */
  31976. opacityFresnelParameters: FresnelParameters;
  31977. private _reflectionFresnelParameters;
  31978. /**
  31979. * Define the reflection fresnel parameters of the material.
  31980. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31981. */
  31982. reflectionFresnelParameters: FresnelParameters;
  31983. private _refractionFresnelParameters;
  31984. /**
  31985. * Define the refraction fresnel parameters of the material.
  31986. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31987. */
  31988. refractionFresnelParameters: FresnelParameters;
  31989. private _emissiveFresnelParameters;
  31990. /**
  31991. * Define the emissive fresnel parameters of the material.
  31992. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31993. */
  31994. emissiveFresnelParameters: FresnelParameters;
  31995. private _useReflectionFresnelFromSpecular;
  31996. /**
  31997. * If true automatically deducts the fresnels values from the material specularity.
  31998. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31999. */
  32000. useReflectionFresnelFromSpecular: boolean;
  32001. private _useGlossinessFromSpecularMapAlpha;
  32002. /**
  32003. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  32004. */
  32005. useGlossinessFromSpecularMapAlpha: boolean;
  32006. private _maxSimultaneousLights;
  32007. /**
  32008. * Defines the maximum number of lights that can be used in the material
  32009. */
  32010. maxSimultaneousLights: number;
  32011. private _invertNormalMapX;
  32012. /**
  32013. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32014. */
  32015. invertNormalMapX: boolean;
  32016. private _invertNormalMapY;
  32017. /**
  32018. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32019. */
  32020. invertNormalMapY: boolean;
  32021. private _twoSidedLighting;
  32022. /**
  32023. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32024. */
  32025. twoSidedLighting: boolean;
  32026. /**
  32027. * Default configuration related to image processing available in the standard Material.
  32028. */
  32029. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32030. /**
  32031. * Gets the image processing configuration used either in this material.
  32032. */
  32033. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  32034. /**
  32035. * Sets the Default image processing configuration used either in the this material.
  32036. *
  32037. * If sets to null, the scene one is in use.
  32038. */
  32039. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  32040. /**
  32041. * Keep track of the image processing observer to allow dispose and replace.
  32042. */
  32043. private _imageProcessingObserver;
  32044. /**
  32045. * Attaches a new image processing configuration to the Standard Material.
  32046. * @param configuration
  32047. */
  32048. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32049. /**
  32050. * Gets wether the color curves effect is enabled.
  32051. */
  32052. get cameraColorCurvesEnabled(): boolean;
  32053. /**
  32054. * Sets wether the color curves effect is enabled.
  32055. */
  32056. set cameraColorCurvesEnabled(value: boolean);
  32057. /**
  32058. * Gets wether the color grading effect is enabled.
  32059. */
  32060. get cameraColorGradingEnabled(): boolean;
  32061. /**
  32062. * Gets wether the color grading effect is enabled.
  32063. */
  32064. set cameraColorGradingEnabled(value: boolean);
  32065. /**
  32066. * Gets wether tonemapping is enabled or not.
  32067. */
  32068. get cameraToneMappingEnabled(): boolean;
  32069. /**
  32070. * Sets wether tonemapping is enabled or not
  32071. */
  32072. set cameraToneMappingEnabled(value: boolean);
  32073. /**
  32074. * The camera exposure used on this material.
  32075. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32076. * This corresponds to a photographic exposure.
  32077. */
  32078. get cameraExposure(): number;
  32079. /**
  32080. * The camera exposure used on this material.
  32081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32082. * This corresponds to a photographic exposure.
  32083. */
  32084. set cameraExposure(value: number);
  32085. /**
  32086. * Gets The camera contrast used on this material.
  32087. */
  32088. get cameraContrast(): number;
  32089. /**
  32090. * Sets The camera contrast used on this material.
  32091. */
  32092. set cameraContrast(value: number);
  32093. /**
  32094. * Gets the Color Grading 2D Lookup Texture.
  32095. */
  32096. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32097. /**
  32098. * Sets the Color Grading 2D Lookup Texture.
  32099. */
  32100. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32101. /**
  32102. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32103. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32104. * 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;
  32105. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32106. */
  32107. get cameraColorCurves(): Nullable<ColorCurves>;
  32108. /**
  32109. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32110. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32111. * 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;
  32112. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32113. */
  32114. set cameraColorCurves(value: Nullable<ColorCurves>);
  32115. /**
  32116. * Can this material render to several textures at once
  32117. */
  32118. get canRenderToMRT(): boolean;
  32119. /**
  32120. * Defines the detail map parameters for the material.
  32121. */
  32122. readonly detailMap: DetailMapConfiguration;
  32123. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32124. protected _worldViewProjectionMatrix: Matrix;
  32125. protected _globalAmbientColor: Color3;
  32126. protected _useLogarithmicDepth: boolean;
  32127. protected _rebuildInParallel: boolean;
  32128. /**
  32129. * Instantiates a new standard material.
  32130. * This is the default material used in Babylon. It is the best trade off between quality
  32131. * and performances.
  32132. * @see https://doc.babylonjs.com/babylon101/materials
  32133. * @param name Define the name of the material in the scene
  32134. * @param scene Define the scene the material belong to
  32135. */
  32136. constructor(name: string, scene: Scene);
  32137. /**
  32138. * Gets a boolean indicating that current material needs to register RTT
  32139. */
  32140. get hasRenderTargetTextures(): boolean;
  32141. /**
  32142. * Gets the current class name of the material e.g. "StandardMaterial"
  32143. * Mainly use in serialization.
  32144. * @returns the class name
  32145. */
  32146. getClassName(): string;
  32147. /**
  32148. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32149. * You can try switching to logarithmic depth.
  32150. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32151. */
  32152. get useLogarithmicDepth(): boolean;
  32153. set useLogarithmicDepth(value: boolean);
  32154. /**
  32155. * Specifies if the material will require alpha blending
  32156. * @returns a boolean specifying if alpha blending is needed
  32157. */
  32158. needAlphaBlending(): boolean;
  32159. /**
  32160. * Specifies if this material should be rendered in alpha test mode
  32161. * @returns a boolean specifying if an alpha test is needed.
  32162. */
  32163. needAlphaTesting(): boolean;
  32164. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32165. /**
  32166. * Get the texture used for alpha test purpose.
  32167. * @returns the diffuse texture in case of the standard material.
  32168. */
  32169. getAlphaTestTexture(): Nullable<BaseTexture>;
  32170. /**
  32171. * Get if the submesh is ready to be used and all its information available.
  32172. * Child classes can use it to update shaders
  32173. * @param mesh defines the mesh to check
  32174. * @param subMesh defines which submesh to check
  32175. * @param useInstances specifies that instances should be used
  32176. * @returns a boolean indicating that the submesh is ready or not
  32177. */
  32178. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32179. /**
  32180. * Builds the material UBO layouts.
  32181. * Used internally during the effect preparation.
  32182. */
  32183. buildUniformLayout(): void;
  32184. /**
  32185. * Unbinds the material from the mesh
  32186. */
  32187. unbind(): void;
  32188. /**
  32189. * Binds the submesh to this material by preparing the effect and shader to draw
  32190. * @param world defines the world transformation matrix
  32191. * @param mesh defines the mesh containing the submesh
  32192. * @param subMesh defines the submesh to bind the material to
  32193. */
  32194. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32195. /**
  32196. * Get the list of animatables in the material.
  32197. * @returns the list of animatables object used in the material
  32198. */
  32199. getAnimatables(): IAnimatable[];
  32200. /**
  32201. * Gets the active textures from the material
  32202. * @returns an array of textures
  32203. */
  32204. getActiveTextures(): BaseTexture[];
  32205. /**
  32206. * Specifies if the material uses a texture
  32207. * @param texture defines the texture to check against the material
  32208. * @returns a boolean specifying if the material uses the texture
  32209. */
  32210. hasTexture(texture: BaseTexture): boolean;
  32211. /**
  32212. * Disposes the material
  32213. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32214. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32215. */
  32216. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32217. /**
  32218. * Makes a duplicate of the material, and gives it a new name
  32219. * @param name defines the new name for the duplicated material
  32220. * @returns the cloned material
  32221. */
  32222. clone(name: string): StandardMaterial;
  32223. /**
  32224. * Serializes this material in a JSON representation
  32225. * @returns the serialized material object
  32226. */
  32227. serialize(): any;
  32228. /**
  32229. * Creates a standard material from parsed material data
  32230. * @param source defines the JSON representation of the material
  32231. * @param scene defines the hosting scene
  32232. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32233. * @returns a new standard material
  32234. */
  32235. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32236. /**
  32237. * Are diffuse textures enabled in the application.
  32238. */
  32239. static get DiffuseTextureEnabled(): boolean;
  32240. static set DiffuseTextureEnabled(value: boolean);
  32241. /**
  32242. * Are detail textures enabled in the application.
  32243. */
  32244. static get DetailTextureEnabled(): boolean;
  32245. static set DetailTextureEnabled(value: boolean);
  32246. /**
  32247. * Are ambient textures enabled in the application.
  32248. */
  32249. static get AmbientTextureEnabled(): boolean;
  32250. static set AmbientTextureEnabled(value: boolean);
  32251. /**
  32252. * Are opacity textures enabled in the application.
  32253. */
  32254. static get OpacityTextureEnabled(): boolean;
  32255. static set OpacityTextureEnabled(value: boolean);
  32256. /**
  32257. * Are reflection textures enabled in the application.
  32258. */
  32259. static get ReflectionTextureEnabled(): boolean;
  32260. static set ReflectionTextureEnabled(value: boolean);
  32261. /**
  32262. * Are emissive textures enabled in the application.
  32263. */
  32264. static get EmissiveTextureEnabled(): boolean;
  32265. static set EmissiveTextureEnabled(value: boolean);
  32266. /**
  32267. * Are specular textures enabled in the application.
  32268. */
  32269. static get SpecularTextureEnabled(): boolean;
  32270. static set SpecularTextureEnabled(value: boolean);
  32271. /**
  32272. * Are bump textures enabled in the application.
  32273. */
  32274. static get BumpTextureEnabled(): boolean;
  32275. static set BumpTextureEnabled(value: boolean);
  32276. /**
  32277. * Are lightmap textures enabled in the application.
  32278. */
  32279. static get LightmapTextureEnabled(): boolean;
  32280. static set LightmapTextureEnabled(value: boolean);
  32281. /**
  32282. * Are refraction textures enabled in the application.
  32283. */
  32284. static get RefractionTextureEnabled(): boolean;
  32285. static set RefractionTextureEnabled(value: boolean);
  32286. /**
  32287. * Are color grading textures enabled in the application.
  32288. */
  32289. static get ColorGradingTextureEnabled(): boolean;
  32290. static set ColorGradingTextureEnabled(value: boolean);
  32291. /**
  32292. * Are fresnels enabled in the application.
  32293. */
  32294. static get FresnelEnabled(): boolean;
  32295. static set FresnelEnabled(value: boolean);
  32296. }
  32297. }
  32298. declare module "babylonjs/Particles/solidParticleSystem" {
  32299. import { Nullable } from "babylonjs/types";
  32300. import { Mesh } from "babylonjs/Meshes/mesh";
  32301. import { Scene, IDisposable } from "babylonjs/scene";
  32302. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32303. import { Material } from "babylonjs/Materials/material";
  32304. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32305. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32306. /**
  32307. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32308. *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.
  32309. * The SPS is also a particle system. It provides some methods to manage the particles.
  32310. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32311. *
  32312. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32313. */
  32314. export class SolidParticleSystem implements IDisposable {
  32315. /**
  32316. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32317. * Example : var p = SPS.particles[i];
  32318. */
  32319. particles: SolidParticle[];
  32320. /**
  32321. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32322. */
  32323. nbParticles: number;
  32324. /**
  32325. * If the particles must ever face the camera (default false). Useful for planar particles.
  32326. */
  32327. billboard: boolean;
  32328. /**
  32329. * Recompute normals when adding a shape
  32330. */
  32331. recomputeNormals: boolean;
  32332. /**
  32333. * This a counter ofr your own usage. It's not set by any SPS functions.
  32334. */
  32335. counter: number;
  32336. /**
  32337. * The SPS name. This name is also given to the underlying mesh.
  32338. */
  32339. name: string;
  32340. /**
  32341. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32342. */
  32343. mesh: Mesh;
  32344. /**
  32345. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32346. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32347. */
  32348. vars: any;
  32349. /**
  32350. * This array is populated when the SPS is set as 'pickable'.
  32351. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32352. * Each element of this array is an object `{idx: int, faceId: int}`.
  32353. * `idx` is the picked particle index in the `SPS.particles` array
  32354. * `faceId` is the picked face index counted within this particle.
  32355. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32356. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32357. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32358. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32359. */
  32360. pickedParticles: {
  32361. idx: number;
  32362. faceId: number;
  32363. }[];
  32364. /**
  32365. * This array is populated when the SPS is set as 'pickable'
  32366. * Each key of this array is a submesh index.
  32367. * Each element of this array is a second array defined like this :
  32368. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32369. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32370. * `idx` is the picked particle index in the `SPS.particles` array
  32371. * `faceId` is the picked face index counted within this particle.
  32372. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32373. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32374. */
  32375. pickedBySubMesh: {
  32376. idx: number;
  32377. faceId: number;
  32378. }[][];
  32379. /**
  32380. * This array is populated when `enableDepthSort` is set to true.
  32381. * Each element of this array is an instance of the class DepthSortedParticle.
  32382. */
  32383. depthSortedParticles: DepthSortedParticle[];
  32384. /**
  32385. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32386. * @hidden
  32387. */
  32388. _bSphereOnly: boolean;
  32389. /**
  32390. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32391. * @hidden
  32392. */
  32393. _bSphereRadiusFactor: number;
  32394. private _scene;
  32395. private _positions;
  32396. private _indices;
  32397. private _normals;
  32398. private _colors;
  32399. private _uvs;
  32400. private _indices32;
  32401. private _positions32;
  32402. private _normals32;
  32403. private _fixedNormal32;
  32404. private _colors32;
  32405. private _uvs32;
  32406. private _index;
  32407. private _updatable;
  32408. private _pickable;
  32409. private _isVisibilityBoxLocked;
  32410. private _alwaysVisible;
  32411. private _depthSort;
  32412. private _expandable;
  32413. private _shapeCounter;
  32414. private _copy;
  32415. private _color;
  32416. private _computeParticleColor;
  32417. private _computeParticleTexture;
  32418. private _computeParticleRotation;
  32419. private _computeParticleVertex;
  32420. private _computeBoundingBox;
  32421. private _depthSortParticles;
  32422. private _camera;
  32423. private _mustUnrotateFixedNormals;
  32424. private _particlesIntersect;
  32425. private _needs32Bits;
  32426. private _isNotBuilt;
  32427. private _lastParticleId;
  32428. private _idxOfId;
  32429. private _multimaterialEnabled;
  32430. private _useModelMaterial;
  32431. private _indicesByMaterial;
  32432. private _materialIndexes;
  32433. private _depthSortFunction;
  32434. private _materialSortFunction;
  32435. private _materials;
  32436. private _multimaterial;
  32437. private _materialIndexesById;
  32438. private _defaultMaterial;
  32439. private _autoUpdateSubMeshes;
  32440. private _tmpVertex;
  32441. /**
  32442. * Creates a SPS (Solid Particle System) object.
  32443. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32444. * @param scene (Scene) is the scene in which the SPS is added.
  32445. * @param options defines the options of the sps e.g.
  32446. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32447. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32448. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32449. * * 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.
  32450. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32451. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32452. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32453. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32454. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32455. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32456. */
  32457. constructor(name: string, scene: Scene, options?: {
  32458. updatable?: boolean;
  32459. isPickable?: boolean;
  32460. enableDepthSort?: boolean;
  32461. particleIntersection?: boolean;
  32462. boundingSphereOnly?: boolean;
  32463. bSphereRadiusFactor?: number;
  32464. expandable?: boolean;
  32465. useModelMaterial?: boolean;
  32466. enableMultiMaterial?: boolean;
  32467. });
  32468. /**
  32469. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32470. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32471. * @returns the created mesh
  32472. */
  32473. buildMesh(): Mesh;
  32474. /**
  32475. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32476. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32477. * Thus the particles generated from `digest()` have their property `position` set yet.
  32478. * @param mesh ( Mesh ) is the mesh to be digested
  32479. * @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
  32480. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32481. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32482. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32483. * @returns the current SPS
  32484. */
  32485. digest(mesh: Mesh, options?: {
  32486. facetNb?: number;
  32487. number?: number;
  32488. delta?: number;
  32489. storage?: [];
  32490. }): SolidParticleSystem;
  32491. /**
  32492. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32493. * @hidden
  32494. */
  32495. private _unrotateFixedNormals;
  32496. /**
  32497. * Resets the temporary working copy particle
  32498. * @hidden
  32499. */
  32500. private _resetCopy;
  32501. /**
  32502. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32503. * @param p the current index in the positions array to be updated
  32504. * @param ind the current index in the indices array
  32505. * @param shape a Vector3 array, the shape geometry
  32506. * @param positions the positions array to be updated
  32507. * @param meshInd the shape indices array
  32508. * @param indices the indices array to be updated
  32509. * @param meshUV the shape uv array
  32510. * @param uvs the uv array to be updated
  32511. * @param meshCol the shape color array
  32512. * @param colors the color array to be updated
  32513. * @param meshNor the shape normals array
  32514. * @param normals the normals array to be updated
  32515. * @param idx the particle index
  32516. * @param idxInShape the particle index in its shape
  32517. * @param options the addShape() method passed options
  32518. * @model the particle model
  32519. * @hidden
  32520. */
  32521. private _meshBuilder;
  32522. /**
  32523. * Returns a shape Vector3 array from positions float array
  32524. * @param positions float array
  32525. * @returns a vector3 array
  32526. * @hidden
  32527. */
  32528. private _posToShape;
  32529. /**
  32530. * Returns a shapeUV array from a float uvs (array deep copy)
  32531. * @param uvs as a float array
  32532. * @returns a shapeUV array
  32533. * @hidden
  32534. */
  32535. private _uvsToShapeUV;
  32536. /**
  32537. * Adds a new particle object in the particles array
  32538. * @param idx particle index in particles array
  32539. * @param id particle id
  32540. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32541. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32542. * @param model particle ModelShape object
  32543. * @param shapeId model shape identifier
  32544. * @param idxInShape index of the particle in the current model
  32545. * @param bInfo model bounding info object
  32546. * @param storage target storage array, if any
  32547. * @hidden
  32548. */
  32549. private _addParticle;
  32550. /**
  32551. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32552. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32553. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32554. * @param nb (positive integer) the number of particles to be created from this model
  32555. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32556. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32557. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32558. * @returns the number of shapes in the system
  32559. */
  32560. addShape(mesh: Mesh, nb: number, options?: {
  32561. positionFunction?: any;
  32562. vertexFunction?: any;
  32563. storage?: [];
  32564. }): number;
  32565. /**
  32566. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32567. * @hidden
  32568. */
  32569. private _rebuildParticle;
  32570. /**
  32571. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32572. * @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.
  32573. * @returns the SPS.
  32574. */
  32575. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32576. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32577. * Returns an array with the removed particles.
  32578. * 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.
  32579. * The SPS can't be empty so at least one particle needs to remain in place.
  32580. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32581. * @param start index of the first particle to remove
  32582. * @param end index of the last particle to remove (included)
  32583. * @returns an array populated with the removed particles
  32584. */
  32585. removeParticles(start: number, end: number): SolidParticle[];
  32586. /**
  32587. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32588. * @param solidParticleArray an array populated with Solid Particles objects
  32589. * @returns the SPS
  32590. */
  32591. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32592. /**
  32593. * Creates a new particle and modifies the SPS mesh geometry :
  32594. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32595. * - calls _addParticle() to populate the particle array
  32596. * factorized code from addShape() and insertParticlesFromArray()
  32597. * @param idx particle index in the particles array
  32598. * @param i particle index in its shape
  32599. * @param modelShape particle ModelShape object
  32600. * @param shape shape vertex array
  32601. * @param meshInd shape indices array
  32602. * @param meshUV shape uv array
  32603. * @param meshCol shape color array
  32604. * @param meshNor shape normals array
  32605. * @param bbInfo shape bounding info
  32606. * @param storage target particle storage
  32607. * @options addShape() passed options
  32608. * @hidden
  32609. */
  32610. private _insertNewParticle;
  32611. /**
  32612. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32613. * This method calls `updateParticle()` for each particle of the SPS.
  32614. * For an animated SPS, it is usually called within the render loop.
  32615. * 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.
  32616. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32617. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32618. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32619. * @returns the SPS.
  32620. */
  32621. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32622. /**
  32623. * Disposes the SPS.
  32624. */
  32625. dispose(): void;
  32626. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32627. * idx is the particle index in the SPS
  32628. * faceId is the picked face index counted within this particle.
  32629. * Returns null if the pickInfo can't identify a picked particle.
  32630. * @param pickingInfo (PickingInfo object)
  32631. * @returns {idx: number, faceId: number} or null
  32632. */
  32633. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32634. idx: number;
  32635. faceId: number;
  32636. }>;
  32637. /**
  32638. * Returns a SolidParticle object from its identifier : particle.id
  32639. * @param id (integer) the particle Id
  32640. * @returns the searched particle or null if not found in the SPS.
  32641. */
  32642. getParticleById(id: number): Nullable<SolidParticle>;
  32643. /**
  32644. * Returns a new array populated with the particles having the passed shapeId.
  32645. * @param shapeId (integer) the shape identifier
  32646. * @returns a new solid particle array
  32647. */
  32648. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32649. /**
  32650. * Populates the passed array "ref" with the particles having the passed shapeId.
  32651. * @param shapeId the shape identifier
  32652. * @returns the SPS
  32653. * @param ref
  32654. */
  32655. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32656. /**
  32657. * Computes the required SubMeshes according the materials assigned to the particles.
  32658. * @returns the solid particle system.
  32659. * Does nothing if called before the SPS mesh is built.
  32660. */
  32661. computeSubMeshes(): SolidParticleSystem;
  32662. /**
  32663. * Sorts the solid particles by material when MultiMaterial is enabled.
  32664. * Updates the indices32 array.
  32665. * Updates the indicesByMaterial array.
  32666. * Updates the mesh indices array.
  32667. * @returns the SPS
  32668. * @hidden
  32669. */
  32670. private _sortParticlesByMaterial;
  32671. /**
  32672. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32673. * @hidden
  32674. */
  32675. private _setMaterialIndexesById;
  32676. /**
  32677. * Returns an array with unique values of Materials from the passed array
  32678. * @param array the material array to be checked and filtered
  32679. * @hidden
  32680. */
  32681. private _filterUniqueMaterialId;
  32682. /**
  32683. * Sets a new Standard Material as _defaultMaterial if not already set.
  32684. * @hidden
  32685. */
  32686. private _setDefaultMaterial;
  32687. /**
  32688. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32689. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32690. * @returns the SPS.
  32691. */
  32692. refreshVisibleSize(): SolidParticleSystem;
  32693. /**
  32694. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32695. * @param size the size (float) of the visibility box
  32696. * note : this doesn't lock the SPS mesh bounding box.
  32697. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32698. */
  32699. setVisibilityBox(size: number): void;
  32700. /**
  32701. * Gets whether the SPS as always visible or not
  32702. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32703. */
  32704. get isAlwaysVisible(): boolean;
  32705. /**
  32706. * Sets the SPS as always visible or not
  32707. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32708. */
  32709. set isAlwaysVisible(val: boolean);
  32710. /**
  32711. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32712. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32713. */
  32714. set isVisibilityBoxLocked(val: boolean);
  32715. /**
  32716. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32717. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32718. */
  32719. get isVisibilityBoxLocked(): boolean;
  32720. /**
  32721. * Tells to `setParticles()` to compute the particle rotations or not.
  32722. * Default value : true. The SPS is faster when it's set to false.
  32723. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32724. */
  32725. set computeParticleRotation(val: boolean);
  32726. /**
  32727. * Tells to `setParticles()` to compute the particle colors or not.
  32728. * Default value : true. The SPS is faster when it's set to false.
  32729. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32730. */
  32731. set computeParticleColor(val: boolean);
  32732. set computeParticleTexture(val: boolean);
  32733. /**
  32734. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32735. * Default value : false. The SPS is faster when it's set to false.
  32736. * Note : the particle custom vertex positions aren't stored values.
  32737. */
  32738. set computeParticleVertex(val: boolean);
  32739. /**
  32740. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32741. */
  32742. set computeBoundingBox(val: boolean);
  32743. /**
  32744. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32745. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32746. * Default : `true`
  32747. */
  32748. set depthSortParticles(val: boolean);
  32749. /**
  32750. * Gets if `setParticles()` computes the particle rotations or not.
  32751. * Default value : true. The SPS is faster when it's set to false.
  32752. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32753. */
  32754. get computeParticleRotation(): boolean;
  32755. /**
  32756. * Gets if `setParticles()` computes the particle colors or not.
  32757. * Default value : true. The SPS is faster when it's set to false.
  32758. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32759. */
  32760. get computeParticleColor(): boolean;
  32761. /**
  32762. * Gets if `setParticles()` computes the particle textures or not.
  32763. * Default value : true. The SPS is faster when it's set to false.
  32764. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32765. */
  32766. get computeParticleTexture(): boolean;
  32767. /**
  32768. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32769. * Default value : false. The SPS is faster when it's set to false.
  32770. * Note : the particle custom vertex positions aren't stored values.
  32771. */
  32772. get computeParticleVertex(): boolean;
  32773. /**
  32774. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32775. */
  32776. get computeBoundingBox(): boolean;
  32777. /**
  32778. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32779. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32780. * Default : `true`
  32781. */
  32782. get depthSortParticles(): boolean;
  32783. /**
  32784. * Gets if the SPS is created as expandable at construction time.
  32785. * Default : `false`
  32786. */
  32787. get expandable(): boolean;
  32788. /**
  32789. * Gets if the SPS supports the Multi Materials
  32790. */
  32791. get multimaterialEnabled(): boolean;
  32792. /**
  32793. * Gets if the SPS uses the model materials for its own multimaterial.
  32794. */
  32795. get useModelMaterial(): boolean;
  32796. /**
  32797. * The SPS used material array.
  32798. */
  32799. get materials(): Material[];
  32800. /**
  32801. * Sets the SPS MultiMaterial from the passed materials.
  32802. * Note : the passed array is internally copied and not used then by reference.
  32803. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32804. */
  32805. setMultiMaterial(materials: Material[]): void;
  32806. /**
  32807. * The SPS computed multimaterial object
  32808. */
  32809. get multimaterial(): MultiMaterial;
  32810. set multimaterial(mm: MultiMaterial);
  32811. /**
  32812. * If the subMeshes must be updated on the next call to setParticles()
  32813. */
  32814. get autoUpdateSubMeshes(): boolean;
  32815. set autoUpdateSubMeshes(val: boolean);
  32816. /**
  32817. * This function does nothing. It may be overwritten to set all the particle first values.
  32818. * The SPS doesn't call this function, you may have to call it by your own.
  32819. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32820. */
  32821. initParticles(): void;
  32822. /**
  32823. * This function does nothing. It may be overwritten to recycle a particle.
  32824. * The SPS doesn't call this function, you may have to call it by your own.
  32825. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32826. * @param particle The particle to recycle
  32827. * @returns the recycled particle
  32828. */
  32829. recycleParticle(particle: SolidParticle): SolidParticle;
  32830. /**
  32831. * Updates a particle : this function should be overwritten by the user.
  32832. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32833. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32834. * @example : just set a particle position or velocity and recycle conditions
  32835. * @param particle The particle to update
  32836. * @returns the updated particle
  32837. */
  32838. updateParticle(particle: SolidParticle): SolidParticle;
  32839. /**
  32840. * Updates a vertex of a particle : it can be overwritten by the user.
  32841. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32842. * @param particle the current particle
  32843. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32844. * @param pt the index of the current vertex in the particle shape
  32845. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32846. * @example : just set a vertex particle position or color
  32847. * @returns the sps
  32848. */
  32849. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32850. /**
  32851. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32852. * This does nothing and may be overwritten by the user.
  32853. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32854. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32855. * @param update the boolean update value actually passed to setParticles()
  32856. */
  32857. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32858. /**
  32859. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32860. * This will be passed three parameters.
  32861. * This does nothing and may be overwritten by the user.
  32862. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32863. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32864. * @param update the boolean update value actually passed to setParticles()
  32865. */
  32866. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32867. }
  32868. }
  32869. declare module "babylonjs/Particles/solidParticle" {
  32870. import { Nullable } from "babylonjs/types";
  32871. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32872. import { Color4 } from "babylonjs/Maths/math.color";
  32873. import { Mesh } from "babylonjs/Meshes/mesh";
  32874. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32875. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32876. import { Plane } from "babylonjs/Maths/math.plane";
  32877. import { Material } from "babylonjs/Materials/material";
  32878. /**
  32879. * Represents one particle of a solid particle system.
  32880. */
  32881. export class SolidParticle {
  32882. /**
  32883. * particle global index
  32884. */
  32885. idx: number;
  32886. /**
  32887. * particle identifier
  32888. */
  32889. id: number;
  32890. /**
  32891. * The color of the particle
  32892. */
  32893. color: Nullable<Color4>;
  32894. /**
  32895. * The world space position of the particle.
  32896. */
  32897. position: Vector3;
  32898. /**
  32899. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32900. */
  32901. rotation: Vector3;
  32902. /**
  32903. * The world space rotation quaternion of the particle.
  32904. */
  32905. rotationQuaternion: Nullable<Quaternion>;
  32906. /**
  32907. * The scaling of the particle.
  32908. */
  32909. scaling: Vector3;
  32910. /**
  32911. * The uvs of the particle.
  32912. */
  32913. uvs: Vector4;
  32914. /**
  32915. * The current speed of the particle.
  32916. */
  32917. velocity: Vector3;
  32918. /**
  32919. * The pivot point in the particle local space.
  32920. */
  32921. pivot: Vector3;
  32922. /**
  32923. * Must the particle be translated from its pivot point in its local space ?
  32924. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32925. * Default : false
  32926. */
  32927. translateFromPivot: boolean;
  32928. /**
  32929. * Is the particle active or not ?
  32930. */
  32931. alive: boolean;
  32932. /**
  32933. * Is the particle visible or not ?
  32934. */
  32935. isVisible: boolean;
  32936. /**
  32937. * Index of this particle in the global "positions" array (Internal use)
  32938. * @hidden
  32939. */
  32940. _pos: number;
  32941. /**
  32942. * @hidden Index of this particle in the global "indices" array (Internal use)
  32943. */
  32944. _ind: number;
  32945. /**
  32946. * @hidden ModelShape of this particle (Internal use)
  32947. */
  32948. _model: ModelShape;
  32949. /**
  32950. * ModelShape id of this particle
  32951. */
  32952. shapeId: number;
  32953. /**
  32954. * Index of the particle in its shape id
  32955. */
  32956. idxInShape: number;
  32957. /**
  32958. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32959. */
  32960. _modelBoundingInfo: BoundingInfo;
  32961. /**
  32962. * @hidden Particle BoundingInfo object (Internal use)
  32963. */
  32964. _boundingInfo: BoundingInfo;
  32965. /**
  32966. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32967. */
  32968. _sps: SolidParticleSystem;
  32969. /**
  32970. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32971. */
  32972. _stillInvisible: boolean;
  32973. /**
  32974. * @hidden Last computed particle rotation matrix
  32975. */
  32976. _rotationMatrix: number[];
  32977. /**
  32978. * Parent particle Id, if any.
  32979. * Default null.
  32980. */
  32981. parentId: Nullable<number>;
  32982. /**
  32983. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32984. */
  32985. materialIndex: Nullable<number>;
  32986. /**
  32987. * Custom object or properties.
  32988. */
  32989. props: Nullable<any>;
  32990. /**
  32991. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32992. * The possible values are :
  32993. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32994. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32995. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32996. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32997. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32998. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32999. * */
  33000. cullingStrategy: number;
  33001. /**
  33002. * @hidden Internal global position in the SPS.
  33003. */
  33004. _globalPosition: Vector3;
  33005. /**
  33006. * Creates a Solid Particle object.
  33007. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33008. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  33009. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  33010. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33011. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33012. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33013. * @param shapeId (integer) is the model shape identifier in the SPS.
  33014. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33015. * @param sps defines the sps it is associated to
  33016. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33017. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  33018. */
  33019. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  33020. /**
  33021. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  33022. * @param target the particle target
  33023. * @returns the current particle
  33024. */
  33025. copyToRef(target: SolidParticle): SolidParticle;
  33026. /**
  33027. * Legacy support, changed scale to scaling
  33028. */
  33029. get scale(): Vector3;
  33030. /**
  33031. * Legacy support, changed scale to scaling
  33032. */
  33033. set scale(scale: Vector3);
  33034. /**
  33035. * Legacy support, changed quaternion to rotationQuaternion
  33036. */
  33037. get quaternion(): Nullable<Quaternion>;
  33038. /**
  33039. * Legacy support, changed quaternion to rotationQuaternion
  33040. */
  33041. set quaternion(q: Nullable<Quaternion>);
  33042. /**
  33043. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33044. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33045. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33046. * @returns true if it intersects
  33047. */
  33048. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33049. /**
  33050. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  33051. * A particle is in the frustum if its bounding box intersects the frustum
  33052. * @param frustumPlanes defines the frustum to test
  33053. * @returns true if the particle is in the frustum planes
  33054. */
  33055. isInFrustum(frustumPlanes: Plane[]): boolean;
  33056. /**
  33057. * get the rotation matrix of the particle
  33058. * @hidden
  33059. */
  33060. getRotationMatrix(m: Matrix): void;
  33061. }
  33062. /**
  33063. * Represents the shape of the model used by one particle of a solid particle system.
  33064. * SPS internal tool, don't use it manually.
  33065. */
  33066. export class ModelShape {
  33067. /**
  33068. * The shape id
  33069. * @hidden
  33070. */
  33071. shapeID: number;
  33072. /**
  33073. * flat array of model positions (internal use)
  33074. * @hidden
  33075. */
  33076. _shape: Vector3[];
  33077. /**
  33078. * flat array of model UVs (internal use)
  33079. * @hidden
  33080. */
  33081. _shapeUV: number[];
  33082. /**
  33083. * color array of the model
  33084. * @hidden
  33085. */
  33086. _shapeColors: number[];
  33087. /**
  33088. * indices array of the model
  33089. * @hidden
  33090. */
  33091. _indices: number[];
  33092. /**
  33093. * normals array of the model
  33094. * @hidden
  33095. */
  33096. _normals: number[];
  33097. /**
  33098. * length of the shape in the model indices array (internal use)
  33099. * @hidden
  33100. */
  33101. _indicesLength: number;
  33102. /**
  33103. * Custom position function (internal use)
  33104. * @hidden
  33105. */
  33106. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33107. /**
  33108. * Custom vertex function (internal use)
  33109. * @hidden
  33110. */
  33111. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33112. /**
  33113. * Model material (internal use)
  33114. * @hidden
  33115. */
  33116. _material: Nullable<Material>;
  33117. /**
  33118. * 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.
  33119. * SPS internal tool, don't use it manually.
  33120. * @hidden
  33121. */
  33122. 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>);
  33123. }
  33124. /**
  33125. * Represents a Depth Sorted Particle in the solid particle system.
  33126. * @hidden
  33127. */
  33128. export class DepthSortedParticle {
  33129. /**
  33130. * Particle index
  33131. */
  33132. idx: number;
  33133. /**
  33134. * Index of the particle in the "indices" array
  33135. */
  33136. ind: number;
  33137. /**
  33138. * Length of the particle shape in the "indices" array
  33139. */
  33140. indicesLength: number;
  33141. /**
  33142. * Squared distance from the particle to the camera
  33143. */
  33144. sqDistance: number;
  33145. /**
  33146. * Material index when used with MultiMaterials
  33147. */
  33148. materialIndex: number;
  33149. /**
  33150. * Creates a new sorted particle
  33151. * @param materialIndex
  33152. */
  33153. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33154. }
  33155. /**
  33156. * Represents a solid particle vertex
  33157. */
  33158. export class SolidParticleVertex {
  33159. /**
  33160. * Vertex position
  33161. */
  33162. position: Vector3;
  33163. /**
  33164. * Vertex color
  33165. */
  33166. color: Color4;
  33167. /**
  33168. * Vertex UV
  33169. */
  33170. uv: Vector2;
  33171. /**
  33172. * Creates a new solid particle vertex
  33173. */
  33174. constructor();
  33175. /** Vertex x coordinate */
  33176. get x(): number;
  33177. set x(val: number);
  33178. /** Vertex y coordinate */
  33179. get y(): number;
  33180. set y(val: number);
  33181. /** Vertex z coordinate */
  33182. get z(): number;
  33183. set z(val: number);
  33184. }
  33185. }
  33186. declare module "babylonjs/Collisions/meshCollisionData" {
  33187. import { Collider } from "babylonjs/Collisions/collider";
  33188. import { Vector3 } from "babylonjs/Maths/math.vector";
  33189. import { Nullable } from "babylonjs/types";
  33190. import { Observer } from "babylonjs/Misc/observable";
  33191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33192. /**
  33193. * @hidden
  33194. */
  33195. export class _MeshCollisionData {
  33196. _checkCollisions: boolean;
  33197. _collisionMask: number;
  33198. _collisionGroup: number;
  33199. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33200. _collider: Nullable<Collider>;
  33201. _oldPositionForCollisions: Vector3;
  33202. _diffPositionForCollisions: Vector3;
  33203. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33204. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33205. _collisionResponse: boolean;
  33206. }
  33207. }
  33208. declare module "babylonjs/Meshes/abstractMesh" {
  33209. import { Observable } from "babylonjs/Misc/observable";
  33210. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33211. import { Camera } from "babylonjs/Cameras/camera";
  33212. import { Scene, IDisposable } from "babylonjs/scene";
  33213. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33214. import { Node } from "babylonjs/node";
  33215. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33216. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33217. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33218. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33219. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33220. import { Material } from "babylonjs/Materials/material";
  33221. import { Light } from "babylonjs/Lights/light";
  33222. import { Skeleton } from "babylonjs/Bones/skeleton";
  33223. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33224. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33225. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33226. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33227. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33228. import { Plane } from "babylonjs/Maths/math.plane";
  33229. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33230. import { Ray } from "babylonjs/Culling/ray";
  33231. import { Collider } from "babylonjs/Collisions/collider";
  33232. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33233. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33234. /** @hidden */
  33235. class _FacetDataStorage {
  33236. facetPositions: Vector3[];
  33237. facetNormals: Vector3[];
  33238. facetPartitioning: number[][];
  33239. facetNb: number;
  33240. partitioningSubdivisions: number;
  33241. partitioningBBoxRatio: number;
  33242. facetDataEnabled: boolean;
  33243. facetParameters: any;
  33244. bbSize: Vector3;
  33245. subDiv: {
  33246. max: number;
  33247. X: number;
  33248. Y: number;
  33249. Z: number;
  33250. };
  33251. facetDepthSort: boolean;
  33252. facetDepthSortEnabled: boolean;
  33253. depthSortedIndices: IndicesArray;
  33254. depthSortedFacets: {
  33255. ind: number;
  33256. sqDistance: number;
  33257. }[];
  33258. facetDepthSortFunction: (f1: {
  33259. ind: number;
  33260. sqDistance: number;
  33261. }, f2: {
  33262. ind: number;
  33263. sqDistance: number;
  33264. }) => number;
  33265. facetDepthSortFrom: Vector3;
  33266. facetDepthSortOrigin: Vector3;
  33267. invertedMatrix: Matrix;
  33268. }
  33269. /**
  33270. * @hidden
  33271. **/
  33272. class _InternalAbstractMeshDataInfo {
  33273. _hasVertexAlpha: boolean;
  33274. _useVertexColors: boolean;
  33275. _numBoneInfluencers: number;
  33276. _applyFog: boolean;
  33277. _receiveShadows: boolean;
  33278. _facetData: _FacetDataStorage;
  33279. _visibility: number;
  33280. _skeleton: Nullable<Skeleton>;
  33281. _layerMask: number;
  33282. _computeBonesUsingShaders: boolean;
  33283. _isActive: boolean;
  33284. _onlyForInstances: boolean;
  33285. _isActiveIntermediate: boolean;
  33286. _onlyForInstancesIntermediate: boolean;
  33287. _actAsRegularMesh: boolean;
  33288. }
  33289. /**
  33290. * Class used to store all common mesh properties
  33291. */
  33292. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33293. /** No occlusion */
  33294. static OCCLUSION_TYPE_NONE: number;
  33295. /** Occlusion set to optimisitic */
  33296. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33297. /** Occlusion set to strict */
  33298. static OCCLUSION_TYPE_STRICT: number;
  33299. /** Use an accurante occlusion algorithm */
  33300. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33301. /** Use a conservative occlusion algorithm */
  33302. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33303. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33304. * Test order :
  33305. * Is the bounding sphere outside the frustum ?
  33306. * If not, are the bounding box vertices outside the frustum ?
  33307. * It not, then the cullable object is in the frustum.
  33308. */
  33309. static readonly CULLINGSTRATEGY_STANDARD: number;
  33310. /** Culling strategy : Bounding Sphere Only.
  33311. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33312. * It's also less accurate than the standard because some not visible objects can still be selected.
  33313. * Test : is the bounding sphere outside the frustum ?
  33314. * If not, then the cullable object is in the frustum.
  33315. */
  33316. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33317. /** Culling strategy : Optimistic Inclusion.
  33318. * This in an inclusion test first, then the standard exclusion test.
  33319. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33320. * 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.
  33321. * Anyway, it's as accurate as the standard strategy.
  33322. * Test :
  33323. * Is the cullable object bounding sphere center in the frustum ?
  33324. * If not, apply the default culling strategy.
  33325. */
  33326. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33327. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33328. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33329. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33330. * 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.
  33331. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33332. * Test :
  33333. * Is the cullable object bounding sphere center in the frustum ?
  33334. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33335. */
  33336. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33337. /**
  33338. * No billboard
  33339. */
  33340. static get BILLBOARDMODE_NONE(): number;
  33341. /** Billboard on X axis */
  33342. static get BILLBOARDMODE_X(): number;
  33343. /** Billboard on Y axis */
  33344. static get BILLBOARDMODE_Y(): number;
  33345. /** Billboard on Z axis */
  33346. static get BILLBOARDMODE_Z(): number;
  33347. /** Billboard on all axes */
  33348. static get BILLBOARDMODE_ALL(): number;
  33349. /** Billboard on using position instead of orientation */
  33350. static get BILLBOARDMODE_USE_POSITION(): number;
  33351. /** @hidden */
  33352. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33353. /**
  33354. * The culling strategy to use to check whether the mesh must be rendered or not.
  33355. * This value can be changed at any time and will be used on the next render mesh selection.
  33356. * The possible values are :
  33357. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33358. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33359. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33360. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33361. * Please read each static variable documentation to get details about the culling process.
  33362. * */
  33363. cullingStrategy: number;
  33364. /**
  33365. * Gets the number of facets in the mesh
  33366. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33367. */
  33368. get facetNb(): number;
  33369. /**
  33370. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33371. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33372. */
  33373. get partitioningSubdivisions(): number;
  33374. set partitioningSubdivisions(nb: number);
  33375. /**
  33376. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33377. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33378. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33379. */
  33380. get partitioningBBoxRatio(): number;
  33381. set partitioningBBoxRatio(ratio: number);
  33382. /**
  33383. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33384. * Works only for updatable meshes.
  33385. * Doesn't work with multi-materials
  33386. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33387. */
  33388. get mustDepthSortFacets(): boolean;
  33389. set mustDepthSortFacets(sort: boolean);
  33390. /**
  33391. * The location (Vector3) where the facet depth sort must be computed from.
  33392. * By default, the active camera position.
  33393. * Used only when facet depth sort is enabled
  33394. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33395. */
  33396. get facetDepthSortFrom(): Vector3;
  33397. set facetDepthSortFrom(location: Vector3);
  33398. /**
  33399. * gets a boolean indicating if facetData is enabled
  33400. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33401. */
  33402. get isFacetDataEnabled(): boolean;
  33403. /** @hidden */
  33404. _updateNonUniformScalingState(value: boolean): boolean;
  33405. /**
  33406. * An event triggered when this mesh collides with another one
  33407. */
  33408. onCollideObservable: Observable<AbstractMesh>;
  33409. /** Set a function to call when this mesh collides with another one */
  33410. set onCollide(callback: () => void);
  33411. /**
  33412. * An event triggered when the collision's position changes
  33413. */
  33414. onCollisionPositionChangeObservable: Observable<Vector3>;
  33415. /** Set a function to call when the collision's position changes */
  33416. set onCollisionPositionChange(callback: () => void);
  33417. /**
  33418. * An event triggered when material is changed
  33419. */
  33420. onMaterialChangedObservable: Observable<AbstractMesh>;
  33421. /**
  33422. * Gets or sets the orientation for POV movement & rotation
  33423. */
  33424. definedFacingForward: boolean;
  33425. /** @hidden */
  33426. _occlusionQuery: Nullable<WebGLQuery>;
  33427. /** @hidden */
  33428. _renderingGroup: Nullable<RenderingGroup>;
  33429. /**
  33430. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33431. */
  33432. get visibility(): number;
  33433. /**
  33434. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33435. */
  33436. set visibility(value: number);
  33437. /** Gets or sets the alpha index used to sort transparent meshes
  33438. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33439. */
  33440. alphaIndex: number;
  33441. /**
  33442. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33443. */
  33444. isVisible: boolean;
  33445. /**
  33446. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33447. */
  33448. isPickable: boolean;
  33449. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33450. showSubMeshesBoundingBox: boolean;
  33451. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33452. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33453. */
  33454. isBlocker: boolean;
  33455. /**
  33456. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33457. */
  33458. enablePointerMoveEvents: boolean;
  33459. private _renderingGroupId;
  33460. /**
  33461. * Specifies the rendering group id for this mesh (0 by default)
  33462. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33463. */
  33464. get renderingGroupId(): number;
  33465. set renderingGroupId(value: number);
  33466. private _material;
  33467. /** Gets or sets current material */
  33468. get material(): Nullable<Material>;
  33469. set material(value: Nullable<Material>);
  33470. /**
  33471. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33472. * @see https://doc.babylonjs.com/babylon101/shadows
  33473. */
  33474. get receiveShadows(): boolean;
  33475. set receiveShadows(value: boolean);
  33476. /** Defines color to use when rendering outline */
  33477. outlineColor: Color3;
  33478. /** Define width to use when rendering outline */
  33479. outlineWidth: number;
  33480. /** Defines color to use when rendering overlay */
  33481. overlayColor: Color3;
  33482. /** Defines alpha to use when rendering overlay */
  33483. overlayAlpha: number;
  33484. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33485. get hasVertexAlpha(): boolean;
  33486. set hasVertexAlpha(value: boolean);
  33487. /** 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) */
  33488. get useVertexColors(): boolean;
  33489. set useVertexColors(value: boolean);
  33490. /**
  33491. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33492. */
  33493. get computeBonesUsingShaders(): boolean;
  33494. set computeBonesUsingShaders(value: boolean);
  33495. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33496. get numBoneInfluencers(): number;
  33497. set numBoneInfluencers(value: number);
  33498. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33499. get applyFog(): boolean;
  33500. set applyFog(value: boolean);
  33501. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33502. useOctreeForRenderingSelection: boolean;
  33503. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33504. useOctreeForPicking: boolean;
  33505. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33506. useOctreeForCollisions: boolean;
  33507. /**
  33508. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33509. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33510. */
  33511. get layerMask(): number;
  33512. set layerMask(value: number);
  33513. /**
  33514. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33515. */
  33516. alwaysSelectAsActiveMesh: boolean;
  33517. /**
  33518. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33519. */
  33520. doNotSyncBoundingInfo: boolean;
  33521. /**
  33522. * Gets or sets the current action manager
  33523. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33524. */
  33525. actionManager: Nullable<AbstractActionManager>;
  33526. private _meshCollisionData;
  33527. /**
  33528. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33529. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33530. */
  33531. ellipsoid: Vector3;
  33532. /**
  33533. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33534. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33535. */
  33536. ellipsoidOffset: Vector3;
  33537. /**
  33538. * Gets or sets a collision mask used to mask collisions (default is -1).
  33539. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33540. */
  33541. get collisionMask(): number;
  33542. set collisionMask(mask: number);
  33543. /**
  33544. * Gets or sets a collision response flag (default is true).
  33545. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33546. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33547. * to respond to the collision.
  33548. */
  33549. get collisionResponse(): boolean;
  33550. set collisionResponse(response: boolean);
  33551. /**
  33552. * Gets or sets the current collision group mask (-1 by default).
  33553. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33554. */
  33555. get collisionGroup(): number;
  33556. set collisionGroup(mask: number);
  33557. /**
  33558. * Gets or sets current surrounding meshes (null by default).
  33559. *
  33560. * By default collision detection is tested against every mesh in the scene.
  33561. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33562. * meshes will be tested for the collision.
  33563. *
  33564. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33565. */
  33566. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33567. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33568. /**
  33569. * Defines edge width used when edgesRenderer is enabled
  33570. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33571. */
  33572. edgesWidth: number;
  33573. /**
  33574. * Defines edge color used when edgesRenderer is enabled
  33575. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33576. */
  33577. edgesColor: Color4;
  33578. /** @hidden */
  33579. _edgesRenderer: Nullable<IEdgesRenderer>;
  33580. /** @hidden */
  33581. _masterMesh: Nullable<AbstractMesh>;
  33582. /** @hidden */
  33583. _boundingInfo: Nullable<BoundingInfo>;
  33584. /** @hidden */
  33585. _renderId: number;
  33586. /**
  33587. * Gets or sets the list of subMeshes
  33588. * @see https://doc.babylonjs.com/how_to/multi_materials
  33589. */
  33590. subMeshes: SubMesh[];
  33591. /** @hidden */
  33592. _intersectionsInProgress: AbstractMesh[];
  33593. /** @hidden */
  33594. _unIndexed: boolean;
  33595. /** @hidden */
  33596. _lightSources: Light[];
  33597. /** Gets the list of lights affecting that mesh */
  33598. get lightSources(): Light[];
  33599. /** @hidden */
  33600. get _positions(): Nullable<Vector3[]>;
  33601. /** @hidden */
  33602. _waitingData: {
  33603. lods: Nullable<any>;
  33604. actions: Nullable<any>;
  33605. freezeWorldMatrix: Nullable<boolean>;
  33606. };
  33607. /** @hidden */
  33608. _bonesTransformMatrices: Nullable<Float32Array>;
  33609. /** @hidden */
  33610. _transformMatrixTexture: Nullable<RawTexture>;
  33611. /**
  33612. * Gets or sets a skeleton to apply skining transformations
  33613. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33614. */
  33615. set skeleton(value: Nullable<Skeleton>);
  33616. get skeleton(): Nullable<Skeleton>;
  33617. /**
  33618. * An event triggered when the mesh is rebuilt.
  33619. */
  33620. onRebuildObservable: Observable<AbstractMesh>;
  33621. /**
  33622. * Creates a new AbstractMesh
  33623. * @param name defines the name of the mesh
  33624. * @param scene defines the hosting scene
  33625. */
  33626. constructor(name: string, scene?: Nullable<Scene>);
  33627. /**
  33628. * Returns the string "AbstractMesh"
  33629. * @returns "AbstractMesh"
  33630. */
  33631. getClassName(): string;
  33632. /**
  33633. * Gets a string representation of the current mesh
  33634. * @param fullDetails defines a boolean indicating if full details must be included
  33635. * @returns a string representation of the current mesh
  33636. */
  33637. toString(fullDetails?: boolean): string;
  33638. /**
  33639. * @hidden
  33640. */
  33641. protected _getEffectiveParent(): Nullable<Node>;
  33642. /** @hidden */
  33643. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33644. /** @hidden */
  33645. _rebuild(): void;
  33646. /** @hidden */
  33647. _resyncLightSources(): void;
  33648. /** @hidden */
  33649. _resyncLightSource(light: Light): void;
  33650. /** @hidden */
  33651. _unBindEffect(): void;
  33652. /** @hidden */
  33653. _removeLightSource(light: Light, dispose: boolean): void;
  33654. private _markSubMeshesAsDirty;
  33655. /** @hidden */
  33656. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33657. /** @hidden */
  33658. _markSubMeshesAsAttributesDirty(): void;
  33659. /** @hidden */
  33660. _markSubMeshesAsMiscDirty(): void;
  33661. /**
  33662. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33663. */
  33664. get scaling(): Vector3;
  33665. set scaling(newScaling: Vector3);
  33666. /**
  33667. * Returns true if the mesh is blocked. Implemented by child classes
  33668. */
  33669. get isBlocked(): boolean;
  33670. /**
  33671. * Returns the mesh itself by default. Implemented by child classes
  33672. * @param camera defines the camera to use to pick the right LOD level
  33673. * @returns the currentAbstractMesh
  33674. */
  33675. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33676. /**
  33677. * Returns 0 by default. Implemented by child classes
  33678. * @returns an integer
  33679. */
  33680. getTotalVertices(): number;
  33681. /**
  33682. * Returns a positive integer : the total number of indices in this mesh geometry.
  33683. * @returns the numner of indices or zero if the mesh has no geometry.
  33684. */
  33685. getTotalIndices(): number;
  33686. /**
  33687. * Returns null by default. Implemented by child classes
  33688. * @returns null
  33689. */
  33690. getIndices(): Nullable<IndicesArray>;
  33691. /**
  33692. * Returns the array of the requested vertex data kind. Implemented by child classes
  33693. * @param kind defines the vertex data kind to use
  33694. * @returns null
  33695. */
  33696. getVerticesData(kind: string): Nullable<FloatArray>;
  33697. /**
  33698. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33699. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33700. * Note that a new underlying VertexBuffer object is created each call.
  33701. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33702. * @param kind defines vertex data kind:
  33703. * * VertexBuffer.PositionKind
  33704. * * VertexBuffer.UVKind
  33705. * * VertexBuffer.UV2Kind
  33706. * * VertexBuffer.UV3Kind
  33707. * * VertexBuffer.UV4Kind
  33708. * * VertexBuffer.UV5Kind
  33709. * * VertexBuffer.UV6Kind
  33710. * * VertexBuffer.ColorKind
  33711. * * VertexBuffer.MatricesIndicesKind
  33712. * * VertexBuffer.MatricesIndicesExtraKind
  33713. * * VertexBuffer.MatricesWeightsKind
  33714. * * VertexBuffer.MatricesWeightsExtraKind
  33715. * @param data defines the data source
  33716. * @param updatable defines if the data must be flagged as updatable (or static)
  33717. * @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
  33718. * @returns the current mesh
  33719. */
  33720. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33721. /**
  33722. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33723. * If the mesh has no geometry, it is simply returned as it is.
  33724. * @param kind defines vertex data kind:
  33725. * * VertexBuffer.PositionKind
  33726. * * VertexBuffer.UVKind
  33727. * * VertexBuffer.UV2Kind
  33728. * * VertexBuffer.UV3Kind
  33729. * * VertexBuffer.UV4Kind
  33730. * * VertexBuffer.UV5Kind
  33731. * * VertexBuffer.UV6Kind
  33732. * * VertexBuffer.ColorKind
  33733. * * VertexBuffer.MatricesIndicesKind
  33734. * * VertexBuffer.MatricesIndicesExtraKind
  33735. * * VertexBuffer.MatricesWeightsKind
  33736. * * VertexBuffer.MatricesWeightsExtraKind
  33737. * @param data defines the data source
  33738. * @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
  33739. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33740. * @returns the current mesh
  33741. */
  33742. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33743. /**
  33744. * Sets the mesh indices,
  33745. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33746. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33747. * @param totalVertices Defines the total number of vertices
  33748. * @returns the current mesh
  33749. */
  33750. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33751. /**
  33752. * Gets a boolean indicating if specific vertex data is present
  33753. * @param kind defines the vertex data kind to use
  33754. * @returns true is data kind is present
  33755. */
  33756. isVerticesDataPresent(kind: string): boolean;
  33757. /**
  33758. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33759. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33760. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33761. * @returns a BoundingInfo
  33762. */
  33763. getBoundingInfo(): BoundingInfo;
  33764. /**
  33765. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33766. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33767. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33768. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33769. * @returns the current mesh
  33770. */
  33771. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33772. /**
  33773. * Overwrite the current bounding info
  33774. * @param boundingInfo defines the new bounding info
  33775. * @returns the current mesh
  33776. */
  33777. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33778. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33779. get useBones(): boolean;
  33780. /** @hidden */
  33781. _preActivate(): void;
  33782. /** @hidden */
  33783. _preActivateForIntermediateRendering(renderId: number): void;
  33784. /** @hidden */
  33785. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33786. /** @hidden */
  33787. _postActivate(): void;
  33788. /** @hidden */
  33789. _freeze(): void;
  33790. /** @hidden */
  33791. _unFreeze(): void;
  33792. /**
  33793. * Gets the current world matrix
  33794. * @returns a Matrix
  33795. */
  33796. getWorldMatrix(): Matrix;
  33797. /** @hidden */
  33798. _getWorldMatrixDeterminant(): number;
  33799. /**
  33800. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33801. */
  33802. get isAnInstance(): boolean;
  33803. /**
  33804. * Gets a boolean indicating if this mesh has instances
  33805. */
  33806. get hasInstances(): boolean;
  33807. /**
  33808. * Gets a boolean indicating if this mesh has thin instances
  33809. */
  33810. get hasThinInstances(): boolean;
  33811. /**
  33812. * Perform relative position change from the point of view of behind the front of the mesh.
  33813. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33814. * Supports definition of mesh facing forward or backward
  33815. * @param amountRight defines the distance on the right axis
  33816. * @param amountUp defines the distance on the up axis
  33817. * @param amountForward defines the distance on the forward axis
  33818. * @returns the current mesh
  33819. */
  33820. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33821. /**
  33822. * Calculate relative position change from the point of view of behind the front of the mesh.
  33823. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33824. * Supports definition of mesh facing forward or backward
  33825. * @param amountRight defines the distance on the right axis
  33826. * @param amountUp defines the distance on the up axis
  33827. * @param amountForward defines the distance on the forward axis
  33828. * @returns the new displacement vector
  33829. */
  33830. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33831. /**
  33832. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33833. * Supports definition of mesh facing forward or backward
  33834. * @param flipBack defines the flip
  33835. * @param twirlClockwise defines the twirl
  33836. * @param tiltRight defines the tilt
  33837. * @returns the current mesh
  33838. */
  33839. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33840. /**
  33841. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33842. * Supports definition of mesh facing forward or backward.
  33843. * @param flipBack defines the flip
  33844. * @param twirlClockwise defines the twirl
  33845. * @param tiltRight defines the tilt
  33846. * @returns the new rotation vector
  33847. */
  33848. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33849. /**
  33850. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33851. * This means the mesh underlying bounding box and sphere are recomputed.
  33852. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33853. * @returns the current mesh
  33854. */
  33855. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33856. /** @hidden */
  33857. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33858. /** @hidden */
  33859. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33860. /** @hidden */
  33861. _updateBoundingInfo(): AbstractMesh;
  33862. /** @hidden */
  33863. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33864. /** @hidden */
  33865. protected _afterComputeWorldMatrix(): void;
  33866. /** @hidden */
  33867. get _effectiveMesh(): AbstractMesh;
  33868. /**
  33869. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33870. * A mesh is in the frustum if its bounding box intersects the frustum
  33871. * @param frustumPlanes defines the frustum to test
  33872. * @returns true if the mesh is in the frustum planes
  33873. */
  33874. isInFrustum(frustumPlanes: Plane[]): boolean;
  33875. /**
  33876. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33877. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33878. * @param frustumPlanes defines the frustum to test
  33879. * @returns true if the mesh is completely in the frustum planes
  33880. */
  33881. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33882. /**
  33883. * True if the mesh intersects another mesh or a SolidParticle object
  33884. * @param mesh defines a target mesh or SolidParticle to test
  33885. * @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)
  33886. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33887. * @returns true if there is an intersection
  33888. */
  33889. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33890. /**
  33891. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33892. * @param point defines the point to test
  33893. * @returns true if there is an intersection
  33894. */
  33895. intersectsPoint(point: Vector3): boolean;
  33896. /**
  33897. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33898. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33899. */
  33900. get checkCollisions(): boolean;
  33901. set checkCollisions(collisionEnabled: boolean);
  33902. /**
  33903. * Gets Collider object used to compute collisions (not physics)
  33904. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33905. */
  33906. get collider(): Nullable<Collider>;
  33907. /**
  33908. * Move the mesh using collision engine
  33909. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33910. * @param displacement defines the requested displacement vector
  33911. * @returns the current mesh
  33912. */
  33913. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33914. private _onCollisionPositionChange;
  33915. /** @hidden */
  33916. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33917. /** @hidden */
  33918. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33919. /** @hidden */
  33920. _checkCollision(collider: Collider): AbstractMesh;
  33921. /** @hidden */
  33922. _generatePointsArray(): boolean;
  33923. /**
  33924. * Checks if the passed Ray intersects with the mesh
  33925. * @param ray defines the ray to use
  33926. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33927. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33928. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33929. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33930. * @returns the picking info
  33931. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33932. */
  33933. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33934. /**
  33935. * Clones the current mesh
  33936. * @param name defines the mesh name
  33937. * @param newParent defines the new mesh parent
  33938. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33939. * @returns the new mesh
  33940. */
  33941. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33942. /**
  33943. * Disposes all the submeshes of the current meshnp
  33944. * @returns the current mesh
  33945. */
  33946. releaseSubMeshes(): AbstractMesh;
  33947. /**
  33948. * Releases resources associated with this abstract mesh.
  33949. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33950. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33951. */
  33952. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33953. /**
  33954. * Adds the passed mesh as a child to the current mesh
  33955. * @param mesh defines the child mesh
  33956. * @returns the current mesh
  33957. */
  33958. addChild(mesh: AbstractMesh): AbstractMesh;
  33959. /**
  33960. * Removes the passed mesh from the current mesh children list
  33961. * @param mesh defines the child mesh
  33962. * @returns the current mesh
  33963. */
  33964. removeChild(mesh: AbstractMesh): AbstractMesh;
  33965. /** @hidden */
  33966. private _initFacetData;
  33967. /**
  33968. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33969. * This method can be called within the render loop.
  33970. * 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
  33971. * @returns the current mesh
  33972. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33973. */
  33974. updateFacetData(): AbstractMesh;
  33975. /**
  33976. * Returns the facetLocalNormals array.
  33977. * The normals are expressed in the mesh local spac
  33978. * @returns an array of Vector3
  33979. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33980. */
  33981. getFacetLocalNormals(): Vector3[];
  33982. /**
  33983. * Returns the facetLocalPositions array.
  33984. * The facet positions are expressed in the mesh local space
  33985. * @returns an array of Vector3
  33986. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33987. */
  33988. getFacetLocalPositions(): Vector3[];
  33989. /**
  33990. * Returns the facetLocalPartioning array
  33991. * @returns an array of array of numbers
  33992. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33993. */
  33994. getFacetLocalPartitioning(): number[][];
  33995. /**
  33996. * Returns the i-th facet position in the world system.
  33997. * This method allocates a new Vector3 per call
  33998. * @param i defines the facet index
  33999. * @returns a new Vector3
  34000. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34001. */
  34002. getFacetPosition(i: number): Vector3;
  34003. /**
  34004. * Sets the reference Vector3 with the i-th facet position in the world system
  34005. * @param i defines the facet index
  34006. * @param ref defines the target vector
  34007. * @returns the current mesh
  34008. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34009. */
  34010. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  34011. /**
  34012. * Returns the i-th facet normal in the world system.
  34013. * This method allocates a new Vector3 per call
  34014. * @param i defines the facet index
  34015. * @returns a new Vector3
  34016. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34017. */
  34018. getFacetNormal(i: number): Vector3;
  34019. /**
  34020. * Sets the reference Vector3 with the i-th facet normal in the world system
  34021. * @param i defines the facet index
  34022. * @param ref defines the target vector
  34023. * @returns the current mesh
  34024. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34025. */
  34026. getFacetNormalToRef(i: number, ref: Vector3): this;
  34027. /**
  34028. * 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)
  34029. * @param x defines x coordinate
  34030. * @param y defines y coordinate
  34031. * @param z defines z coordinate
  34032. * @returns the array of facet indexes
  34033. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34034. */
  34035. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  34036. /**
  34037. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  34038. * @param projected sets as the (x,y,z) world projection on the facet
  34039. * @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
  34040. * @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
  34041. * @param x defines x coordinate
  34042. * @param y defines y coordinate
  34043. * @param z defines z coordinate
  34044. * @returns the face index if found (or null instead)
  34045. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34046. */
  34047. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34048. /**
  34049. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  34050. * @param projected sets as the (x,y,z) local projection on the facet
  34051. * @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
  34052. * @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
  34053. * @param x defines x coordinate
  34054. * @param y defines y coordinate
  34055. * @param z defines z coordinate
  34056. * @returns the face index if found (or null instead)
  34057. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34058. */
  34059. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34060. /**
  34061. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  34062. * @returns the parameters
  34063. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34064. */
  34065. getFacetDataParameters(): any;
  34066. /**
  34067. * Disables the feature FacetData and frees the related memory
  34068. * @returns the current mesh
  34069. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34070. */
  34071. disableFacetData(): AbstractMesh;
  34072. /**
  34073. * Updates the AbstractMesh indices array
  34074. * @param indices defines the data source
  34075. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34076. * @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)
  34077. * @returns the current mesh
  34078. */
  34079. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34080. /**
  34081. * Creates new normals data for the mesh
  34082. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34083. * @returns the current mesh
  34084. */
  34085. createNormals(updatable: boolean): AbstractMesh;
  34086. /**
  34087. * Align the mesh with a normal
  34088. * @param normal defines the normal to use
  34089. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34090. * @returns the current mesh
  34091. */
  34092. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34093. /** @hidden */
  34094. _checkOcclusionQuery(): boolean;
  34095. /**
  34096. * Disables the mesh edge rendering mode
  34097. * @returns the currentAbstractMesh
  34098. */
  34099. disableEdgesRendering(): AbstractMesh;
  34100. /**
  34101. * Enables the edge rendering mode on the mesh.
  34102. * This mode makes the mesh edges visible
  34103. * @param epsilon defines the maximal distance between two angles to detect a face
  34104. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34105. * @returns the currentAbstractMesh
  34106. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34107. */
  34108. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34109. /**
  34110. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34111. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34112. */
  34113. getConnectedParticleSystems(): IParticleSystem[];
  34114. }
  34115. }
  34116. declare module "babylonjs/Actions/actionEvent" {
  34117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34118. import { Nullable } from "babylonjs/types";
  34119. import { Sprite } from "babylonjs/Sprites/sprite";
  34120. import { Scene } from "babylonjs/scene";
  34121. import { Vector2 } from "babylonjs/Maths/math.vector";
  34122. /**
  34123. * Interface used to define ActionEvent
  34124. */
  34125. export interface IActionEvent {
  34126. /** The mesh or sprite that triggered the action */
  34127. source: any;
  34128. /** The X mouse cursor position at the time of the event */
  34129. pointerX: number;
  34130. /** The Y mouse cursor position at the time of the event */
  34131. pointerY: number;
  34132. /** The mesh that is currently pointed at (can be null) */
  34133. meshUnderPointer: Nullable<AbstractMesh>;
  34134. /** the original (browser) event that triggered the ActionEvent */
  34135. sourceEvent?: any;
  34136. /** additional data for the event */
  34137. additionalData?: any;
  34138. }
  34139. /**
  34140. * ActionEvent is the event being sent when an action is triggered.
  34141. */
  34142. export class ActionEvent implements IActionEvent {
  34143. /** The mesh or sprite that triggered the action */
  34144. source: any;
  34145. /** The X mouse cursor position at the time of the event */
  34146. pointerX: number;
  34147. /** The Y mouse cursor position at the time of the event */
  34148. pointerY: number;
  34149. /** The mesh that is currently pointed at (can be null) */
  34150. meshUnderPointer: Nullable<AbstractMesh>;
  34151. /** the original (browser) event that triggered the ActionEvent */
  34152. sourceEvent?: any;
  34153. /** additional data for the event */
  34154. additionalData?: any;
  34155. /**
  34156. * Creates a new ActionEvent
  34157. * @param source The mesh or sprite that triggered the action
  34158. * @param pointerX The X mouse cursor position at the time of the event
  34159. * @param pointerY The Y mouse cursor position at the time of the event
  34160. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34161. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34162. * @param additionalData additional data for the event
  34163. */
  34164. constructor(
  34165. /** The mesh or sprite that triggered the action */
  34166. source: any,
  34167. /** The X mouse cursor position at the time of the event */
  34168. pointerX: number,
  34169. /** The Y mouse cursor position at the time of the event */
  34170. pointerY: number,
  34171. /** The mesh that is currently pointed at (can be null) */
  34172. meshUnderPointer: Nullable<AbstractMesh>,
  34173. /** the original (browser) event that triggered the ActionEvent */
  34174. sourceEvent?: any,
  34175. /** additional data for the event */
  34176. additionalData?: any);
  34177. /**
  34178. * Helper function to auto-create an ActionEvent from a source mesh.
  34179. * @param source The source mesh that triggered the event
  34180. * @param evt The original (browser) event
  34181. * @param additionalData additional data for the event
  34182. * @returns the new ActionEvent
  34183. */
  34184. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34185. /**
  34186. * Helper function to auto-create an ActionEvent from a source sprite
  34187. * @param source The source sprite that triggered the event
  34188. * @param scene Scene associated with the sprite
  34189. * @param evt The original (browser) event
  34190. * @param additionalData additional data for the event
  34191. * @returns the new ActionEvent
  34192. */
  34193. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34194. /**
  34195. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34196. * @param scene the scene where the event occurred
  34197. * @param evt The original (browser) event
  34198. * @returns the new ActionEvent
  34199. */
  34200. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34201. /**
  34202. * Helper function to auto-create an ActionEvent from a primitive
  34203. * @param prim defines the target primitive
  34204. * @param pointerPos defines the pointer position
  34205. * @param evt The original (browser) event
  34206. * @param additionalData additional data for the event
  34207. * @returns the new ActionEvent
  34208. */
  34209. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34210. }
  34211. }
  34212. declare module "babylonjs/Actions/abstractActionManager" {
  34213. import { IDisposable } from "babylonjs/scene";
  34214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34215. import { IAction } from "babylonjs/Actions/action";
  34216. import { Nullable } from "babylonjs/types";
  34217. /**
  34218. * Abstract class used to decouple action Manager from scene and meshes.
  34219. * Do not instantiate.
  34220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34221. */
  34222. export abstract class AbstractActionManager implements IDisposable {
  34223. /** Gets the list of active triggers */
  34224. static Triggers: {
  34225. [key: string]: number;
  34226. };
  34227. /** Gets the cursor to use when hovering items */
  34228. hoverCursor: string;
  34229. /** Gets the list of actions */
  34230. actions: IAction[];
  34231. /**
  34232. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34233. */
  34234. isRecursive: boolean;
  34235. /**
  34236. * Releases all associated resources
  34237. */
  34238. abstract dispose(): void;
  34239. /**
  34240. * Does this action manager has pointer triggers
  34241. */
  34242. abstract get hasPointerTriggers(): boolean;
  34243. /**
  34244. * Does this action manager has pick triggers
  34245. */
  34246. abstract get hasPickTriggers(): boolean;
  34247. /**
  34248. * Process a specific trigger
  34249. * @param trigger defines the trigger to process
  34250. * @param evt defines the event details to be processed
  34251. */
  34252. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34253. /**
  34254. * Does this action manager handles actions of any of the given triggers
  34255. * @param triggers defines the triggers to be tested
  34256. * @return a boolean indicating whether one (or more) of the triggers is handled
  34257. */
  34258. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34259. /**
  34260. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34261. * speed.
  34262. * @param triggerA defines the trigger to be tested
  34263. * @param triggerB defines the trigger to be tested
  34264. * @return a boolean indicating whether one (or more) of the triggers is handled
  34265. */
  34266. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34267. /**
  34268. * Does this action manager handles actions of a given trigger
  34269. * @param trigger defines the trigger to be tested
  34270. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34271. * @return whether the trigger is handled
  34272. */
  34273. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34274. /**
  34275. * Serialize this manager to a JSON object
  34276. * @param name defines the property name to store this manager
  34277. * @returns a JSON representation of this manager
  34278. */
  34279. abstract serialize(name: string): any;
  34280. /**
  34281. * Registers an action to this action manager
  34282. * @param action defines the action to be registered
  34283. * @return the action amended (prepared) after registration
  34284. */
  34285. abstract registerAction(action: IAction): Nullable<IAction>;
  34286. /**
  34287. * Unregisters an action to this action manager
  34288. * @param action defines the action to be unregistered
  34289. * @return a boolean indicating whether the action has been unregistered
  34290. */
  34291. abstract unregisterAction(action: IAction): Boolean;
  34292. /**
  34293. * Does exist one action manager with at least one trigger
  34294. **/
  34295. static get HasTriggers(): boolean;
  34296. /**
  34297. * Does exist one action manager with at least one pick trigger
  34298. **/
  34299. static get HasPickTriggers(): boolean;
  34300. /**
  34301. * Does exist one action manager that handles actions of a given trigger
  34302. * @param trigger defines the trigger to be tested
  34303. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34304. **/
  34305. static HasSpecificTrigger(trigger: number): boolean;
  34306. }
  34307. }
  34308. declare module "babylonjs/node" {
  34309. import { Scene } from "babylonjs/scene";
  34310. import { Nullable } from "babylonjs/types";
  34311. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34312. import { Engine } from "babylonjs/Engines/engine";
  34313. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34314. import { Observable } from "babylonjs/Misc/observable";
  34315. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34316. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34317. import { Animatable } from "babylonjs/Animations/animatable";
  34318. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34319. import { Animation } from "babylonjs/Animations/animation";
  34320. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34322. /**
  34323. * Defines how a node can be built from a string name.
  34324. */
  34325. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34326. /**
  34327. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34328. */
  34329. export class Node implements IBehaviorAware<Node> {
  34330. /** @hidden */
  34331. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34332. private static _NodeConstructors;
  34333. /**
  34334. * Add a new node constructor
  34335. * @param type defines the type name of the node to construct
  34336. * @param constructorFunc defines the constructor function
  34337. */
  34338. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34339. /**
  34340. * Returns a node constructor based on type name
  34341. * @param type defines the type name
  34342. * @param name defines the new node name
  34343. * @param scene defines the hosting scene
  34344. * @param options defines optional options to transmit to constructors
  34345. * @returns the new constructor or null
  34346. */
  34347. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34348. /**
  34349. * Gets or sets the name of the node
  34350. */
  34351. name: string;
  34352. /**
  34353. * Gets or sets the id of the node
  34354. */
  34355. id: string;
  34356. /**
  34357. * Gets or sets the unique id of the node
  34358. */
  34359. uniqueId: number;
  34360. /**
  34361. * Gets or sets a string used to store user defined state for the node
  34362. */
  34363. state: string;
  34364. /**
  34365. * Gets or sets an object used to store user defined information for the node
  34366. */
  34367. metadata: any;
  34368. /**
  34369. * For internal use only. Please do not use.
  34370. */
  34371. reservedDataStore: any;
  34372. /**
  34373. * List of inspectable custom properties (used by the Inspector)
  34374. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34375. */
  34376. inspectableCustomProperties: IInspectable[];
  34377. private _doNotSerialize;
  34378. /**
  34379. * Gets or sets a boolean used to define if the node must be serialized
  34380. */
  34381. get doNotSerialize(): boolean;
  34382. set doNotSerialize(value: boolean);
  34383. /** @hidden */
  34384. _isDisposed: boolean;
  34385. /**
  34386. * Gets a list of Animations associated with the node
  34387. */
  34388. animations: import("babylonjs/Animations/animation").Animation[];
  34389. protected _ranges: {
  34390. [name: string]: Nullable<AnimationRange>;
  34391. };
  34392. /**
  34393. * Callback raised when the node is ready to be used
  34394. */
  34395. onReady: Nullable<(node: Node) => void>;
  34396. private _isEnabled;
  34397. private _isParentEnabled;
  34398. private _isReady;
  34399. /** @hidden */
  34400. _currentRenderId: number;
  34401. private _parentUpdateId;
  34402. /** @hidden */
  34403. _childUpdateId: number;
  34404. /** @hidden */
  34405. _waitingParentId: Nullable<string>;
  34406. /** @hidden */
  34407. _scene: Scene;
  34408. /** @hidden */
  34409. _cache: any;
  34410. private _parentNode;
  34411. private _children;
  34412. /** @hidden */
  34413. _worldMatrix: Matrix;
  34414. /** @hidden */
  34415. _worldMatrixDeterminant: number;
  34416. /** @hidden */
  34417. _worldMatrixDeterminantIsDirty: boolean;
  34418. /** @hidden */
  34419. private _sceneRootNodesIndex;
  34420. /**
  34421. * Gets a boolean indicating if the node has been disposed
  34422. * @returns true if the node was disposed
  34423. */
  34424. isDisposed(): boolean;
  34425. /**
  34426. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34427. * @see https://doc.babylonjs.com/how_to/parenting
  34428. */
  34429. set parent(parent: Nullable<Node>);
  34430. get parent(): Nullable<Node>;
  34431. /** @hidden */
  34432. _addToSceneRootNodes(): void;
  34433. /** @hidden */
  34434. _removeFromSceneRootNodes(): void;
  34435. private _animationPropertiesOverride;
  34436. /**
  34437. * Gets or sets the animation properties override
  34438. */
  34439. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34440. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34441. /**
  34442. * Gets a string identifying the name of the class
  34443. * @returns "Node" string
  34444. */
  34445. getClassName(): string;
  34446. /** @hidden */
  34447. readonly _isNode: boolean;
  34448. /**
  34449. * An event triggered when the mesh is disposed
  34450. */
  34451. onDisposeObservable: Observable<Node>;
  34452. private _onDisposeObserver;
  34453. /**
  34454. * Sets a callback that will be raised when the node will be disposed
  34455. */
  34456. set onDispose(callback: () => void);
  34457. /**
  34458. * Creates a new Node
  34459. * @param name the name and id to be given to this node
  34460. * @param scene the scene this node will be added to
  34461. */
  34462. constructor(name: string, scene?: Nullable<Scene>);
  34463. /**
  34464. * Gets the scene of the node
  34465. * @returns a scene
  34466. */
  34467. getScene(): Scene;
  34468. /**
  34469. * Gets the engine of the node
  34470. * @returns a Engine
  34471. */
  34472. getEngine(): Engine;
  34473. private _behaviors;
  34474. /**
  34475. * Attach a behavior to the node
  34476. * @see https://doc.babylonjs.com/features/behaviour
  34477. * @param behavior defines the behavior to attach
  34478. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34479. * @returns the current Node
  34480. */
  34481. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34482. /**
  34483. * Remove an attached behavior
  34484. * @see https://doc.babylonjs.com/features/behaviour
  34485. * @param behavior defines the behavior to attach
  34486. * @returns the current Node
  34487. */
  34488. removeBehavior(behavior: Behavior<Node>): Node;
  34489. /**
  34490. * Gets the list of attached behaviors
  34491. * @see https://doc.babylonjs.com/features/behaviour
  34492. */
  34493. get behaviors(): Behavior<Node>[];
  34494. /**
  34495. * Gets an attached behavior by name
  34496. * @param name defines the name of the behavior to look for
  34497. * @see https://doc.babylonjs.com/features/behaviour
  34498. * @returns null if behavior was not found else the requested behavior
  34499. */
  34500. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34501. /**
  34502. * Returns the latest update of the World matrix
  34503. * @returns a Matrix
  34504. */
  34505. getWorldMatrix(): Matrix;
  34506. /** @hidden */
  34507. _getWorldMatrixDeterminant(): number;
  34508. /**
  34509. * Returns directly the latest state of the mesh World matrix.
  34510. * A Matrix is returned.
  34511. */
  34512. get worldMatrixFromCache(): Matrix;
  34513. /** @hidden */
  34514. _initCache(): void;
  34515. /** @hidden */
  34516. updateCache(force?: boolean): void;
  34517. /** @hidden */
  34518. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34519. /** @hidden */
  34520. _updateCache(ignoreParentClass?: boolean): void;
  34521. /** @hidden */
  34522. _isSynchronized(): boolean;
  34523. /** @hidden */
  34524. _markSyncedWithParent(): void;
  34525. /** @hidden */
  34526. isSynchronizedWithParent(): boolean;
  34527. /** @hidden */
  34528. isSynchronized(): boolean;
  34529. /**
  34530. * Is this node ready to be used/rendered
  34531. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34532. * @return true if the node is ready
  34533. */
  34534. isReady(completeCheck?: boolean): boolean;
  34535. /**
  34536. * Is this node enabled?
  34537. * 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
  34538. * @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
  34539. * @return whether this node (and its parent) is enabled
  34540. */
  34541. isEnabled(checkAncestors?: boolean): boolean;
  34542. /** @hidden */
  34543. protected _syncParentEnabledState(): void;
  34544. /**
  34545. * Set the enabled state of this node
  34546. * @param value defines the new enabled state
  34547. */
  34548. setEnabled(value: boolean): void;
  34549. /**
  34550. * Is this node a descendant of the given node?
  34551. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34552. * @param ancestor defines the parent node to inspect
  34553. * @returns a boolean indicating if this node is a descendant of the given node
  34554. */
  34555. isDescendantOf(ancestor: Node): boolean;
  34556. /** @hidden */
  34557. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34558. /**
  34559. * Will return all nodes that have this node as ascendant
  34560. * @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
  34561. * @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
  34562. * @return all children nodes of all types
  34563. */
  34564. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34565. /**
  34566. * Get all child-meshes of this node
  34567. * @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)
  34568. * @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
  34569. * @returns an array of AbstractMesh
  34570. */
  34571. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34572. /**
  34573. * Get all direct children of this node
  34574. * @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
  34575. * @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)
  34576. * @returns an array of Node
  34577. */
  34578. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34579. /** @hidden */
  34580. _setReady(state: boolean): void;
  34581. /**
  34582. * Get an animation by name
  34583. * @param name defines the name of the animation to look for
  34584. * @returns null if not found else the requested animation
  34585. */
  34586. getAnimationByName(name: string): Nullable<Animation>;
  34587. /**
  34588. * Creates an animation range for this node
  34589. * @param name defines the name of the range
  34590. * @param from defines the starting key
  34591. * @param to defines the end key
  34592. */
  34593. createAnimationRange(name: string, from: number, to: number): void;
  34594. /**
  34595. * Delete a specific animation range
  34596. * @param name defines the name of the range to delete
  34597. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34598. */
  34599. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34600. /**
  34601. * Get an animation range by name
  34602. * @param name defines the name of the animation range to look for
  34603. * @returns null if not found else the requested animation range
  34604. */
  34605. getAnimationRange(name: string): Nullable<AnimationRange>;
  34606. /**
  34607. * Gets the list of all animation ranges defined on this node
  34608. * @returns an array
  34609. */
  34610. getAnimationRanges(): Nullable<AnimationRange>[];
  34611. /**
  34612. * Will start the animation sequence
  34613. * @param name defines the range frames for animation sequence
  34614. * @param loop defines if the animation should loop (false by default)
  34615. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34616. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34617. * @returns the object created for this animation. If range does not exist, it will return null
  34618. */
  34619. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34620. /**
  34621. * Serialize animation ranges into a JSON compatible object
  34622. * @returns serialization object
  34623. */
  34624. serializeAnimationRanges(): any;
  34625. /**
  34626. * Computes the world matrix of the node
  34627. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34628. * @returns the world matrix
  34629. */
  34630. computeWorldMatrix(force?: boolean): Matrix;
  34631. /**
  34632. * Releases resources associated with this node.
  34633. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34634. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34635. */
  34636. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34637. /**
  34638. * Parse animation range data from a serialization object and store them into a given node
  34639. * @param node defines where to store the animation ranges
  34640. * @param parsedNode defines the serialization object to read data from
  34641. * @param scene defines the hosting scene
  34642. */
  34643. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34644. /**
  34645. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34646. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34647. * @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
  34648. * @returns the new bounding vectors
  34649. */
  34650. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34651. min: Vector3;
  34652. max: Vector3;
  34653. };
  34654. }
  34655. }
  34656. declare module "babylonjs/Animations/animation" {
  34657. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34658. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34659. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34660. import { Nullable } from "babylonjs/types";
  34661. import { Scene } from "babylonjs/scene";
  34662. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34663. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34664. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34665. import { Node } from "babylonjs/node";
  34666. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34667. import { Size } from "babylonjs/Maths/math.size";
  34668. import { Animatable } from "babylonjs/Animations/animatable";
  34669. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34670. /**
  34671. * @hidden
  34672. */
  34673. export class _IAnimationState {
  34674. key: number;
  34675. repeatCount: number;
  34676. workValue?: any;
  34677. loopMode?: number;
  34678. offsetValue?: any;
  34679. highLimitValue?: any;
  34680. }
  34681. /**
  34682. * Class used to store any kind of animation
  34683. */
  34684. export class Animation {
  34685. /**Name of the animation */
  34686. name: string;
  34687. /**Property to animate */
  34688. targetProperty: string;
  34689. /**The frames per second of the animation */
  34690. framePerSecond: number;
  34691. /**The data type of the animation */
  34692. dataType: number;
  34693. /**The loop mode of the animation */
  34694. loopMode?: number | undefined;
  34695. /**Specifies if blending should be enabled */
  34696. enableBlending?: boolean | undefined;
  34697. /**
  34698. * Use matrix interpolation instead of using direct key value when animating matrices
  34699. */
  34700. static AllowMatricesInterpolation: boolean;
  34701. /**
  34702. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34703. */
  34704. static AllowMatrixDecomposeForInterpolation: boolean;
  34705. /** Define the Url to load snippets */
  34706. static SnippetUrl: string;
  34707. /** Snippet ID if the animation was created from the snippet server */
  34708. snippetId: string;
  34709. /**
  34710. * Stores the key frames of the animation
  34711. */
  34712. private _keys;
  34713. /**
  34714. * Stores the easing function of the animation
  34715. */
  34716. private _easingFunction;
  34717. /**
  34718. * @hidden Internal use only
  34719. */
  34720. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34721. /**
  34722. * The set of event that will be linked to this animation
  34723. */
  34724. private _events;
  34725. /**
  34726. * Stores an array of target property paths
  34727. */
  34728. targetPropertyPath: string[];
  34729. /**
  34730. * Stores the blending speed of the animation
  34731. */
  34732. blendingSpeed: number;
  34733. /**
  34734. * Stores the animation ranges for the animation
  34735. */
  34736. private _ranges;
  34737. /**
  34738. * @hidden Internal use
  34739. */
  34740. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34741. /**
  34742. * Sets up an animation
  34743. * @param property The property to animate
  34744. * @param animationType The animation type to apply
  34745. * @param framePerSecond The frames per second of the animation
  34746. * @param easingFunction The easing function used in the animation
  34747. * @returns The created animation
  34748. */
  34749. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34750. /**
  34751. * Create and start an animation on a node
  34752. * @param name defines the name of the global animation that will be run on all nodes
  34753. * @param node defines the root node where the animation will take place
  34754. * @param targetProperty defines property to animate
  34755. * @param framePerSecond defines the number of frame per second yo use
  34756. * @param totalFrame defines the number of frames in total
  34757. * @param from defines the initial value
  34758. * @param to defines the final value
  34759. * @param loopMode defines which loop mode you want to use (off by default)
  34760. * @param easingFunction defines the easing function to use (linear by default)
  34761. * @param onAnimationEnd defines the callback to call when animation end
  34762. * @returns the animatable created for this animation
  34763. */
  34764. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34765. /**
  34766. * Create and start an animation on a node and its descendants
  34767. * @param name defines the name of the global animation that will be run on all nodes
  34768. * @param node defines the root node where the animation will take place
  34769. * @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
  34770. * @param targetProperty defines property to animate
  34771. * @param framePerSecond defines the number of frame per second to use
  34772. * @param totalFrame defines the number of frames in total
  34773. * @param from defines the initial value
  34774. * @param to defines the final value
  34775. * @param loopMode defines which loop mode you want to use (off by default)
  34776. * @param easingFunction defines the easing function to use (linear by default)
  34777. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34778. * @returns the list of animatables created for all nodes
  34779. * @example https://www.babylonjs-playground.com/#MH0VLI
  34780. */
  34781. 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[]>;
  34782. /**
  34783. * Creates a new animation, merges it with the existing animations and starts it
  34784. * @param name Name of the animation
  34785. * @param node Node which contains the scene that begins the animations
  34786. * @param targetProperty Specifies which property to animate
  34787. * @param framePerSecond The frames per second of the animation
  34788. * @param totalFrame The total number of frames
  34789. * @param from The frame at the beginning of the animation
  34790. * @param to The frame at the end of the animation
  34791. * @param loopMode Specifies the loop mode of the animation
  34792. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34793. * @param onAnimationEnd Callback to run once the animation is complete
  34794. * @returns Nullable animation
  34795. */
  34796. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34797. /**
  34798. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34799. * @param sourceAnimation defines the Animation containing keyframes to convert
  34800. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34801. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34802. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34803. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34804. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34805. */
  34806. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34807. /**
  34808. * Transition property of an host to the target Value
  34809. * @param property The property to transition
  34810. * @param targetValue The target Value of the property
  34811. * @param host The object where the property to animate belongs
  34812. * @param scene Scene used to run the animation
  34813. * @param frameRate Framerate (in frame/s) to use
  34814. * @param transition The transition type we want to use
  34815. * @param duration The duration of the animation, in milliseconds
  34816. * @param onAnimationEnd Callback trigger at the end of the animation
  34817. * @returns Nullable animation
  34818. */
  34819. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34820. /**
  34821. * Return the array of runtime animations currently using this animation
  34822. */
  34823. get runtimeAnimations(): RuntimeAnimation[];
  34824. /**
  34825. * Specifies if any of the runtime animations are currently running
  34826. */
  34827. get hasRunningRuntimeAnimations(): boolean;
  34828. /**
  34829. * Initializes the animation
  34830. * @param name Name of the animation
  34831. * @param targetProperty Property to animate
  34832. * @param framePerSecond The frames per second of the animation
  34833. * @param dataType The data type of the animation
  34834. * @param loopMode The loop mode of the animation
  34835. * @param enableBlending Specifies if blending should be enabled
  34836. */
  34837. constructor(
  34838. /**Name of the animation */
  34839. name: string,
  34840. /**Property to animate */
  34841. targetProperty: string,
  34842. /**The frames per second of the animation */
  34843. framePerSecond: number,
  34844. /**The data type of the animation */
  34845. dataType: number,
  34846. /**The loop mode of the animation */
  34847. loopMode?: number | undefined,
  34848. /**Specifies if blending should be enabled */
  34849. enableBlending?: boolean | undefined);
  34850. /**
  34851. * Converts the animation to a string
  34852. * @param fullDetails support for multiple levels of logging within scene loading
  34853. * @returns String form of the animation
  34854. */
  34855. toString(fullDetails?: boolean): string;
  34856. /**
  34857. * Add an event to this animation
  34858. * @param event Event to add
  34859. */
  34860. addEvent(event: AnimationEvent): void;
  34861. /**
  34862. * Remove all events found at the given frame
  34863. * @param frame The frame to remove events from
  34864. */
  34865. removeEvents(frame: number): void;
  34866. /**
  34867. * Retrieves all the events from the animation
  34868. * @returns Events from the animation
  34869. */
  34870. getEvents(): AnimationEvent[];
  34871. /**
  34872. * Creates an animation range
  34873. * @param name Name of the animation range
  34874. * @param from Starting frame of the animation range
  34875. * @param to Ending frame of the animation
  34876. */
  34877. createRange(name: string, from: number, to: number): void;
  34878. /**
  34879. * Deletes an animation range by name
  34880. * @param name Name of the animation range to delete
  34881. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34882. */
  34883. deleteRange(name: string, deleteFrames?: boolean): void;
  34884. /**
  34885. * Gets the animation range by name, or null if not defined
  34886. * @param name Name of the animation range
  34887. * @returns Nullable animation range
  34888. */
  34889. getRange(name: string): Nullable<AnimationRange>;
  34890. /**
  34891. * Gets the key frames from the animation
  34892. * @returns The key frames of the animation
  34893. */
  34894. getKeys(): Array<IAnimationKey>;
  34895. /**
  34896. * Gets the highest frame rate of the animation
  34897. * @returns Highest frame rate of the animation
  34898. */
  34899. getHighestFrame(): number;
  34900. /**
  34901. * Gets the easing function of the animation
  34902. * @returns Easing function of the animation
  34903. */
  34904. getEasingFunction(): IEasingFunction;
  34905. /**
  34906. * Sets the easing function of the animation
  34907. * @param easingFunction A custom mathematical formula for animation
  34908. */
  34909. setEasingFunction(easingFunction: EasingFunction): void;
  34910. /**
  34911. * Interpolates a scalar linearly
  34912. * @param startValue Start value of the animation curve
  34913. * @param endValue End value of the animation curve
  34914. * @param gradient Scalar amount to interpolate
  34915. * @returns Interpolated scalar value
  34916. */
  34917. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34918. /**
  34919. * Interpolates a scalar cubically
  34920. * @param startValue Start value of the animation curve
  34921. * @param outTangent End tangent of the animation
  34922. * @param endValue End value of the animation curve
  34923. * @param inTangent Start tangent of the animation curve
  34924. * @param gradient Scalar amount to interpolate
  34925. * @returns Interpolated scalar value
  34926. */
  34927. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34928. /**
  34929. * Interpolates a quaternion using a spherical linear interpolation
  34930. * @param startValue Start value of the animation curve
  34931. * @param endValue End value of the animation curve
  34932. * @param gradient Scalar amount to interpolate
  34933. * @returns Interpolated quaternion value
  34934. */
  34935. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34936. /**
  34937. * Interpolates a quaternion cubically
  34938. * @param startValue Start value of the animation curve
  34939. * @param outTangent End tangent of the animation curve
  34940. * @param endValue End value of the animation curve
  34941. * @param inTangent Start tangent of the animation curve
  34942. * @param gradient Scalar amount to interpolate
  34943. * @returns Interpolated quaternion value
  34944. */
  34945. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34946. /**
  34947. * Interpolates a Vector3 linearl
  34948. * @param startValue Start value of the animation curve
  34949. * @param endValue End value of the animation curve
  34950. * @param gradient Scalar amount to interpolate
  34951. * @returns Interpolated scalar value
  34952. */
  34953. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34954. /**
  34955. * Interpolates a Vector3 cubically
  34956. * @param startValue Start value of the animation curve
  34957. * @param outTangent End tangent of the animation
  34958. * @param endValue End value of the animation curve
  34959. * @param inTangent Start tangent of the animation curve
  34960. * @param gradient Scalar amount to interpolate
  34961. * @returns InterpolatedVector3 value
  34962. */
  34963. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34964. /**
  34965. * Interpolates a Vector2 linearly
  34966. * @param startValue Start value of the animation curve
  34967. * @param endValue End value of the animation curve
  34968. * @param gradient Scalar amount to interpolate
  34969. * @returns Interpolated Vector2 value
  34970. */
  34971. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34972. /**
  34973. * Interpolates a Vector2 cubically
  34974. * @param startValue Start value of the animation curve
  34975. * @param outTangent End tangent of the animation
  34976. * @param endValue End value of the animation curve
  34977. * @param inTangent Start tangent of the animation curve
  34978. * @param gradient Scalar amount to interpolate
  34979. * @returns Interpolated Vector2 value
  34980. */
  34981. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34982. /**
  34983. * Interpolates a size linearly
  34984. * @param startValue Start value of the animation curve
  34985. * @param endValue End value of the animation curve
  34986. * @param gradient Scalar amount to interpolate
  34987. * @returns Interpolated Size value
  34988. */
  34989. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34990. /**
  34991. * Interpolates a Color3 linearly
  34992. * @param startValue Start value of the animation curve
  34993. * @param endValue End value of the animation curve
  34994. * @param gradient Scalar amount to interpolate
  34995. * @returns Interpolated Color3 value
  34996. */
  34997. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34998. /**
  34999. * Interpolates a Color4 linearly
  35000. * @param startValue Start value of the animation curve
  35001. * @param endValue End value of the animation curve
  35002. * @param gradient Scalar amount to interpolate
  35003. * @returns Interpolated Color3 value
  35004. */
  35005. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  35006. /**
  35007. * @hidden Internal use only
  35008. */
  35009. _getKeyValue(value: any): any;
  35010. /**
  35011. * @hidden Internal use only
  35012. */
  35013. _interpolate(currentFrame: number, state: _IAnimationState): any;
  35014. /**
  35015. * Defines the function to use to interpolate matrices
  35016. * @param startValue defines the start matrix
  35017. * @param endValue defines the end matrix
  35018. * @param gradient defines the gradient between both matrices
  35019. * @param result defines an optional target matrix where to store the interpolation
  35020. * @returns the interpolated matrix
  35021. */
  35022. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  35023. /**
  35024. * Makes a copy of the animation
  35025. * @returns Cloned animation
  35026. */
  35027. clone(): Animation;
  35028. /**
  35029. * Sets the key frames of the animation
  35030. * @param values The animation key frames to set
  35031. */
  35032. setKeys(values: Array<IAnimationKey>): void;
  35033. /**
  35034. * Serializes the animation to an object
  35035. * @returns Serialized object
  35036. */
  35037. serialize(): any;
  35038. /**
  35039. * Float animation type
  35040. */
  35041. static readonly ANIMATIONTYPE_FLOAT: number;
  35042. /**
  35043. * Vector3 animation type
  35044. */
  35045. static readonly ANIMATIONTYPE_VECTOR3: number;
  35046. /**
  35047. * Quaternion animation type
  35048. */
  35049. static readonly ANIMATIONTYPE_QUATERNION: number;
  35050. /**
  35051. * Matrix animation type
  35052. */
  35053. static readonly ANIMATIONTYPE_MATRIX: number;
  35054. /**
  35055. * Color3 animation type
  35056. */
  35057. static readonly ANIMATIONTYPE_COLOR3: number;
  35058. /**
  35059. * Color3 animation type
  35060. */
  35061. static readonly ANIMATIONTYPE_COLOR4: number;
  35062. /**
  35063. * Vector2 animation type
  35064. */
  35065. static readonly ANIMATIONTYPE_VECTOR2: number;
  35066. /**
  35067. * Size animation type
  35068. */
  35069. static readonly ANIMATIONTYPE_SIZE: number;
  35070. /**
  35071. * Relative Loop Mode
  35072. */
  35073. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  35074. /**
  35075. * Cycle Loop Mode
  35076. */
  35077. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  35078. /**
  35079. * Constant Loop Mode
  35080. */
  35081. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  35082. /** @hidden */
  35083. static _UniversalLerp(left: any, right: any, amount: number): any;
  35084. /**
  35085. * Parses an animation object and creates an animation
  35086. * @param parsedAnimation Parsed animation object
  35087. * @returns Animation object
  35088. */
  35089. static Parse(parsedAnimation: any): Animation;
  35090. /**
  35091. * Appends the serialized animations from the source animations
  35092. * @param source Source containing the animations
  35093. * @param destination Target to store the animations
  35094. */
  35095. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35096. /**
  35097. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35098. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35099. * @param url defines the url to load from
  35100. * @returns a promise that will resolve to the new animation or an array of animations
  35101. */
  35102. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35103. /**
  35104. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35105. * @param snippetId defines the snippet to load
  35106. * @returns a promise that will resolve to the new animation or a new array of animations
  35107. */
  35108. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35109. }
  35110. }
  35111. declare module "babylonjs/Animations/animatable.interface" {
  35112. import { Nullable } from "babylonjs/types";
  35113. import { Animation } from "babylonjs/Animations/animation";
  35114. /**
  35115. * Interface containing an array of animations
  35116. */
  35117. export interface IAnimatable {
  35118. /**
  35119. * Array of animations
  35120. */
  35121. animations: Nullable<Array<Animation>>;
  35122. }
  35123. }
  35124. declare module "babylonjs/Misc/decorators" {
  35125. import { Nullable } from "babylonjs/types";
  35126. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35127. import { Scene } from "babylonjs/scene";
  35128. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35129. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35130. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35132. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35133. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35134. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35135. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35136. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35137. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35138. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35139. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35140. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35141. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35142. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35143. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35144. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35145. /**
  35146. * Decorator used to define property that can be serialized as reference to a camera
  35147. * @param sourceName defines the name of the property to decorate
  35148. */
  35149. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35150. /**
  35151. * Class used to help serialization objects
  35152. */
  35153. export class SerializationHelper {
  35154. /** @hidden */
  35155. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35156. /** @hidden */
  35157. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35158. /** @hidden */
  35159. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35160. /** @hidden */
  35161. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35162. /**
  35163. * Appends the serialized animations from the source animations
  35164. * @param source Source containing the animations
  35165. * @param destination Target to store the animations
  35166. */
  35167. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35168. /**
  35169. * Static function used to serialized a specific entity
  35170. * @param entity defines the entity to serialize
  35171. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35172. * @returns a JSON compatible object representing the serialization of the entity
  35173. */
  35174. static Serialize<T>(entity: T, serializationObject?: any): any;
  35175. /**
  35176. * Creates a new entity from a serialization data object
  35177. * @param creationFunction defines a function used to instanciated the new entity
  35178. * @param source defines the source serialization data
  35179. * @param scene defines the hosting scene
  35180. * @param rootUrl defines the root url for resources
  35181. * @returns a new entity
  35182. */
  35183. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35184. /**
  35185. * Clones an object
  35186. * @param creationFunction defines the function used to instanciate the new object
  35187. * @param source defines the source object
  35188. * @returns the cloned object
  35189. */
  35190. static Clone<T>(creationFunction: () => T, source: T): T;
  35191. /**
  35192. * Instanciates a new object based on a source one (some data will be shared between both object)
  35193. * @param creationFunction defines the function used to instanciate the new object
  35194. * @param source defines the source object
  35195. * @returns the new object
  35196. */
  35197. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35198. }
  35199. }
  35200. declare module "babylonjs/Materials/Textures/baseTexture" {
  35201. import { Observable } from "babylonjs/Misc/observable";
  35202. import { Nullable } from "babylonjs/types";
  35203. import { Scene } from "babylonjs/scene";
  35204. import { Matrix } from "babylonjs/Maths/math.vector";
  35205. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35206. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35207. import { ISize } from "babylonjs/Maths/math.size";
  35208. import "babylonjs/Misc/fileTools";
  35209. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35210. /**
  35211. * Base class of all the textures in babylon.
  35212. * It groups all the common properties the materials, post process, lights... might need
  35213. * in order to make a correct use of the texture.
  35214. */
  35215. export class BaseTexture implements IAnimatable {
  35216. /**
  35217. * Default anisotropic filtering level for the application.
  35218. * It is set to 4 as a good tradeoff between perf and quality.
  35219. */
  35220. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35221. /**
  35222. * Gets or sets the unique id of the texture
  35223. */
  35224. uniqueId: number;
  35225. /**
  35226. * Define the name of the texture.
  35227. */
  35228. name: string;
  35229. /**
  35230. * Gets or sets an object used to store user defined information.
  35231. */
  35232. metadata: any;
  35233. /**
  35234. * For internal use only. Please do not use.
  35235. */
  35236. reservedDataStore: any;
  35237. private _hasAlpha;
  35238. /**
  35239. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35240. */
  35241. set hasAlpha(value: boolean);
  35242. get hasAlpha(): boolean;
  35243. /**
  35244. * Defines if the alpha value should be determined via the rgb values.
  35245. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35246. */
  35247. getAlphaFromRGB: boolean;
  35248. /**
  35249. * Intensity or strength of the texture.
  35250. * It is commonly used by materials to fine tune the intensity of the texture
  35251. */
  35252. level: number;
  35253. /**
  35254. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35255. * This is part of the texture as textures usually maps to one uv set.
  35256. */
  35257. coordinatesIndex: number;
  35258. protected _coordinatesMode: number;
  35259. /**
  35260. * How a texture is mapped.
  35261. *
  35262. * | Value | Type | Description |
  35263. * | ----- | ----------------------------------- | ----------- |
  35264. * | 0 | EXPLICIT_MODE | |
  35265. * | 1 | SPHERICAL_MODE | |
  35266. * | 2 | PLANAR_MODE | |
  35267. * | 3 | CUBIC_MODE | |
  35268. * | 4 | PROJECTION_MODE | |
  35269. * | 5 | SKYBOX_MODE | |
  35270. * | 6 | INVCUBIC_MODE | |
  35271. * | 7 | EQUIRECTANGULAR_MODE | |
  35272. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35273. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35274. */
  35275. set coordinatesMode(value: number);
  35276. get coordinatesMode(): number;
  35277. private _wrapU;
  35278. /**
  35279. * | Value | Type | Description |
  35280. * | ----- | ------------------ | ----------- |
  35281. * | 0 | CLAMP_ADDRESSMODE | |
  35282. * | 1 | WRAP_ADDRESSMODE | |
  35283. * | 2 | MIRROR_ADDRESSMODE | |
  35284. */
  35285. get wrapU(): number;
  35286. set wrapU(value: number);
  35287. private _wrapV;
  35288. /**
  35289. * | Value | Type | Description |
  35290. * | ----- | ------------------ | ----------- |
  35291. * | 0 | CLAMP_ADDRESSMODE | |
  35292. * | 1 | WRAP_ADDRESSMODE | |
  35293. * | 2 | MIRROR_ADDRESSMODE | |
  35294. */
  35295. get wrapV(): number;
  35296. set wrapV(value: number);
  35297. /**
  35298. * | Value | Type | Description |
  35299. * | ----- | ------------------ | ----------- |
  35300. * | 0 | CLAMP_ADDRESSMODE | |
  35301. * | 1 | WRAP_ADDRESSMODE | |
  35302. * | 2 | MIRROR_ADDRESSMODE | |
  35303. */
  35304. wrapR: number;
  35305. /**
  35306. * With compliant hardware and browser (supporting anisotropic filtering)
  35307. * this defines the level of anisotropic filtering in the texture.
  35308. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35309. */
  35310. anisotropicFilteringLevel: number;
  35311. /**
  35312. * Define if the texture is a cube texture or if false a 2d texture.
  35313. */
  35314. get isCube(): boolean;
  35315. set isCube(value: boolean);
  35316. /**
  35317. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35318. */
  35319. get is3D(): boolean;
  35320. set is3D(value: boolean);
  35321. /**
  35322. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35323. */
  35324. get is2DArray(): boolean;
  35325. set is2DArray(value: boolean);
  35326. private _gammaSpace;
  35327. /**
  35328. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35329. * HDR texture are usually stored in linear space.
  35330. * This only impacts the PBR and Background materials
  35331. */
  35332. get gammaSpace(): boolean;
  35333. set gammaSpace(gamma: boolean);
  35334. /**
  35335. * Gets or sets whether or not the texture contains RGBD data.
  35336. */
  35337. get isRGBD(): boolean;
  35338. set isRGBD(value: boolean);
  35339. /**
  35340. * Is Z inverted in the texture (useful in a cube texture).
  35341. */
  35342. invertZ: boolean;
  35343. /**
  35344. * Are mip maps generated for this texture or not.
  35345. */
  35346. get noMipmap(): boolean;
  35347. /**
  35348. * @hidden
  35349. */
  35350. lodLevelInAlpha: boolean;
  35351. /**
  35352. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35353. */
  35354. get lodGenerationOffset(): number;
  35355. set lodGenerationOffset(value: number);
  35356. /**
  35357. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35358. */
  35359. get lodGenerationScale(): number;
  35360. set lodGenerationScale(value: number);
  35361. /**
  35362. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35363. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35364. * average roughness values.
  35365. */
  35366. get linearSpecularLOD(): boolean;
  35367. set linearSpecularLOD(value: boolean);
  35368. /**
  35369. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35370. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35371. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35372. */
  35373. get irradianceTexture(): Nullable<BaseTexture>;
  35374. set irradianceTexture(value: Nullable<BaseTexture>);
  35375. /**
  35376. * Define if the texture is a render target.
  35377. */
  35378. isRenderTarget: boolean;
  35379. /**
  35380. * Define the unique id of the texture in the scene.
  35381. */
  35382. get uid(): string;
  35383. /** @hidden */
  35384. _prefiltered: boolean;
  35385. /**
  35386. * Return a string representation of the texture.
  35387. * @returns the texture as a string
  35388. */
  35389. toString(): string;
  35390. /**
  35391. * Get the class name of the texture.
  35392. * @returns "BaseTexture"
  35393. */
  35394. getClassName(): string;
  35395. /**
  35396. * Define the list of animation attached to the texture.
  35397. */
  35398. animations: import("babylonjs/Animations/animation").Animation[];
  35399. /**
  35400. * An event triggered when the texture is disposed.
  35401. */
  35402. onDisposeObservable: Observable<BaseTexture>;
  35403. private _onDisposeObserver;
  35404. /**
  35405. * Callback triggered when the texture has been disposed.
  35406. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35407. */
  35408. set onDispose(callback: () => void);
  35409. /**
  35410. * Define the current state of the loading sequence when in delayed load mode.
  35411. */
  35412. delayLoadState: number;
  35413. protected _scene: Nullable<Scene>;
  35414. protected _engine: Nullable<ThinEngine>;
  35415. /** @hidden */
  35416. _texture: Nullable<InternalTexture>;
  35417. private _uid;
  35418. /**
  35419. * Define if the texture is preventinga material to render or not.
  35420. * If not and the texture is not ready, the engine will use a default black texture instead.
  35421. */
  35422. get isBlocking(): boolean;
  35423. /**
  35424. * Instantiates a new BaseTexture.
  35425. * Base class of all the textures in babylon.
  35426. * It groups all the common properties the materials, post process, lights... might need
  35427. * in order to make a correct use of the texture.
  35428. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35429. */
  35430. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35431. /**
  35432. * Get the scene the texture belongs to.
  35433. * @returns the scene or null if undefined
  35434. */
  35435. getScene(): Nullable<Scene>;
  35436. /** @hidden */
  35437. protected _getEngine(): Nullable<ThinEngine>;
  35438. /**
  35439. * Get the texture transform matrix used to offset tile the texture for istance.
  35440. * @returns the transformation matrix
  35441. */
  35442. getTextureMatrix(): Matrix;
  35443. /**
  35444. * Get the texture reflection matrix used to rotate/transform the reflection.
  35445. * @returns the reflection matrix
  35446. */
  35447. getReflectionTextureMatrix(): Matrix;
  35448. /**
  35449. * Get the underlying lower level texture from Babylon.
  35450. * @returns the insternal texture
  35451. */
  35452. getInternalTexture(): Nullable<InternalTexture>;
  35453. /**
  35454. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35455. * @returns true if ready or not blocking
  35456. */
  35457. isReadyOrNotBlocking(): boolean;
  35458. /**
  35459. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35460. * @returns true if fully ready
  35461. */
  35462. isReady(): boolean;
  35463. private _cachedSize;
  35464. /**
  35465. * Get the size of the texture.
  35466. * @returns the texture size.
  35467. */
  35468. getSize(): ISize;
  35469. /**
  35470. * Get the base size of the texture.
  35471. * It can be different from the size if the texture has been resized for POT for instance
  35472. * @returns the base size
  35473. */
  35474. getBaseSize(): ISize;
  35475. /**
  35476. * Update the sampling mode of the texture.
  35477. * Default is Trilinear mode.
  35478. *
  35479. * | Value | Type | Description |
  35480. * | ----- | ------------------ | ----------- |
  35481. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35482. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35483. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35484. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35485. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35486. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35487. * | 7 | NEAREST_LINEAR | |
  35488. * | 8 | NEAREST_NEAREST | |
  35489. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35490. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35491. * | 11 | LINEAR_LINEAR | |
  35492. * | 12 | LINEAR_NEAREST | |
  35493. *
  35494. * > _mag_: magnification filter (close to the viewer)
  35495. * > _min_: minification filter (far from the viewer)
  35496. * > _mip_: filter used between mip map levels
  35497. *@param samplingMode Define the new sampling mode of the texture
  35498. */
  35499. updateSamplingMode(samplingMode: number): void;
  35500. /**
  35501. * Scales the texture if is `canRescale()`
  35502. * @param ratio the resize factor we want to use to rescale
  35503. */
  35504. scale(ratio: number): void;
  35505. /**
  35506. * Get if the texture can rescale.
  35507. */
  35508. get canRescale(): boolean;
  35509. /** @hidden */
  35510. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35511. /** @hidden */
  35512. _rebuild(): void;
  35513. /**
  35514. * Triggers the load sequence in delayed load mode.
  35515. */
  35516. delayLoad(): void;
  35517. /**
  35518. * Clones the texture.
  35519. * @returns the cloned texture
  35520. */
  35521. clone(): Nullable<BaseTexture>;
  35522. /**
  35523. * Get the texture underlying type (INT, FLOAT...)
  35524. */
  35525. get textureType(): number;
  35526. /**
  35527. * Get the texture underlying format (RGB, RGBA...)
  35528. */
  35529. get textureFormat(): number;
  35530. /**
  35531. * Indicates that textures need to be re-calculated for all materials
  35532. */
  35533. protected _markAllSubMeshesAsTexturesDirty(): void;
  35534. /**
  35535. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35536. * This will returns an RGBA array buffer containing either in values (0-255) or
  35537. * float values (0-1) depending of the underlying buffer type.
  35538. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35539. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35540. * @param buffer defines a user defined buffer to fill with data (can be null)
  35541. * @returns The Array buffer containing the pixels data.
  35542. */
  35543. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35544. /**
  35545. * Release and destroy the underlying lower level texture aka internalTexture.
  35546. */
  35547. releaseInternalTexture(): void;
  35548. /** @hidden */
  35549. get _lodTextureHigh(): Nullable<BaseTexture>;
  35550. /** @hidden */
  35551. get _lodTextureMid(): Nullable<BaseTexture>;
  35552. /** @hidden */
  35553. get _lodTextureLow(): Nullable<BaseTexture>;
  35554. /**
  35555. * Dispose the texture and release its associated resources.
  35556. */
  35557. dispose(): void;
  35558. /**
  35559. * Serialize the texture into a JSON representation that can be parsed later on.
  35560. * @returns the JSON representation of the texture
  35561. */
  35562. serialize(): any;
  35563. /**
  35564. * Helper function to be called back once a list of texture contains only ready textures.
  35565. * @param textures Define the list of textures to wait for
  35566. * @param callback Define the callback triggered once the entire list will be ready
  35567. */
  35568. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35569. private static _isScene;
  35570. }
  35571. }
  35572. declare module "babylonjs/Materials/effect" {
  35573. import { Observable } from "babylonjs/Misc/observable";
  35574. import { Nullable } from "babylonjs/types";
  35575. import { IDisposable } from "babylonjs/scene";
  35576. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35577. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35578. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35579. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35580. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35581. import { Engine } from "babylonjs/Engines/engine";
  35582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35584. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35585. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35586. /**
  35587. * Options to be used when creating an effect.
  35588. */
  35589. export interface IEffectCreationOptions {
  35590. /**
  35591. * Atrributes that will be used in the shader.
  35592. */
  35593. attributes: string[];
  35594. /**
  35595. * Uniform varible names that will be set in the shader.
  35596. */
  35597. uniformsNames: string[];
  35598. /**
  35599. * Uniform buffer variable names that will be set in the shader.
  35600. */
  35601. uniformBuffersNames: string[];
  35602. /**
  35603. * Sampler texture variable names that will be set in the shader.
  35604. */
  35605. samplers: string[];
  35606. /**
  35607. * Define statements that will be set in the shader.
  35608. */
  35609. defines: any;
  35610. /**
  35611. * Possible fallbacks for this effect to improve performance when needed.
  35612. */
  35613. fallbacks: Nullable<IEffectFallbacks>;
  35614. /**
  35615. * Callback that will be called when the shader is compiled.
  35616. */
  35617. onCompiled: Nullable<(effect: Effect) => void>;
  35618. /**
  35619. * Callback that will be called if an error occurs during shader compilation.
  35620. */
  35621. onError: Nullable<(effect: Effect, errors: string) => void>;
  35622. /**
  35623. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35624. */
  35625. indexParameters?: any;
  35626. /**
  35627. * Max number of lights that can be used in the shader.
  35628. */
  35629. maxSimultaneousLights?: number;
  35630. /**
  35631. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35632. */
  35633. transformFeedbackVaryings?: Nullable<string[]>;
  35634. /**
  35635. * 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
  35636. */
  35637. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35638. /**
  35639. * Is this effect rendering to several color attachments ?
  35640. */
  35641. multiTarget?: boolean;
  35642. }
  35643. /**
  35644. * Effect containing vertex and fragment shader that can be executed on an object.
  35645. */
  35646. export class Effect implements IDisposable {
  35647. /**
  35648. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35649. */
  35650. static ShadersRepository: string;
  35651. /**
  35652. * Enable logging of the shader code when a compilation error occurs
  35653. */
  35654. static LogShaderCodeOnCompilationError: boolean;
  35655. /**
  35656. * Name of the effect.
  35657. */
  35658. name: any;
  35659. /**
  35660. * String container all the define statements that should be set on the shader.
  35661. */
  35662. defines: string;
  35663. /**
  35664. * Callback that will be called when the shader is compiled.
  35665. */
  35666. onCompiled: Nullable<(effect: Effect) => void>;
  35667. /**
  35668. * Callback that will be called if an error occurs during shader compilation.
  35669. */
  35670. onError: Nullable<(effect: Effect, errors: string) => void>;
  35671. /**
  35672. * Callback that will be called when effect is bound.
  35673. */
  35674. onBind: Nullable<(effect: Effect) => void>;
  35675. /**
  35676. * Unique ID of the effect.
  35677. */
  35678. uniqueId: number;
  35679. /**
  35680. * Observable that will be called when the shader is compiled.
  35681. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35682. */
  35683. onCompileObservable: Observable<Effect>;
  35684. /**
  35685. * Observable that will be called if an error occurs during shader compilation.
  35686. */
  35687. onErrorObservable: Observable<Effect>;
  35688. /** @hidden */
  35689. _onBindObservable: Nullable<Observable<Effect>>;
  35690. /**
  35691. * @hidden
  35692. * Specifies if the effect was previously ready
  35693. */
  35694. _wasPreviouslyReady: boolean;
  35695. /**
  35696. * Observable that will be called when effect is bound.
  35697. */
  35698. get onBindObservable(): Observable<Effect>;
  35699. /** @hidden */
  35700. _bonesComputationForcedToCPU: boolean;
  35701. /** @hidden */
  35702. _multiTarget: boolean;
  35703. private static _uniqueIdSeed;
  35704. private _engine;
  35705. private _uniformBuffersNames;
  35706. private _uniformBuffersNamesList;
  35707. private _uniformsNames;
  35708. private _samplerList;
  35709. private _samplers;
  35710. private _isReady;
  35711. private _compilationError;
  35712. private _allFallbacksProcessed;
  35713. private _attributesNames;
  35714. private _attributes;
  35715. private _attributeLocationByName;
  35716. private _uniforms;
  35717. /**
  35718. * Key for the effect.
  35719. * @hidden
  35720. */
  35721. _key: string;
  35722. private _indexParameters;
  35723. private _fallbacks;
  35724. private _vertexSourceCode;
  35725. private _fragmentSourceCode;
  35726. private _vertexSourceCodeOverride;
  35727. private _fragmentSourceCodeOverride;
  35728. private _transformFeedbackVaryings;
  35729. /**
  35730. * Compiled shader to webGL program.
  35731. * @hidden
  35732. */
  35733. _pipelineContext: Nullable<IPipelineContext>;
  35734. private _valueCache;
  35735. private static _baseCache;
  35736. /**
  35737. * Instantiates an effect.
  35738. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35739. * @param baseName Name of the effect.
  35740. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35741. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35742. * @param samplers List of sampler variables that will be passed to the shader.
  35743. * @param engine Engine to be used to render the effect
  35744. * @param defines Define statements to be added to the shader.
  35745. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35746. * @param onCompiled Callback that will be called when the shader is compiled.
  35747. * @param onError Callback that will be called if an error occurs during shader compilation.
  35748. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35749. */
  35750. 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);
  35751. private _useFinalCode;
  35752. /**
  35753. * Unique key for this effect
  35754. */
  35755. get key(): string;
  35756. /**
  35757. * If the effect has been compiled and prepared.
  35758. * @returns if the effect is compiled and prepared.
  35759. */
  35760. isReady(): boolean;
  35761. private _isReadyInternal;
  35762. /**
  35763. * The engine the effect was initialized with.
  35764. * @returns the engine.
  35765. */
  35766. getEngine(): Engine;
  35767. /**
  35768. * The pipeline context for this effect
  35769. * @returns the associated pipeline context
  35770. */
  35771. getPipelineContext(): Nullable<IPipelineContext>;
  35772. /**
  35773. * The set of names of attribute variables for the shader.
  35774. * @returns An array of attribute names.
  35775. */
  35776. getAttributesNames(): string[];
  35777. /**
  35778. * Returns the attribute at the given index.
  35779. * @param index The index of the attribute.
  35780. * @returns The location of the attribute.
  35781. */
  35782. getAttributeLocation(index: number): number;
  35783. /**
  35784. * Returns the attribute based on the name of the variable.
  35785. * @param name of the attribute to look up.
  35786. * @returns the attribute location.
  35787. */
  35788. getAttributeLocationByName(name: string): number;
  35789. /**
  35790. * The number of attributes.
  35791. * @returns the numnber of attributes.
  35792. */
  35793. getAttributesCount(): number;
  35794. /**
  35795. * Gets the index of a uniform variable.
  35796. * @param uniformName of the uniform to look up.
  35797. * @returns the index.
  35798. */
  35799. getUniformIndex(uniformName: string): number;
  35800. /**
  35801. * Returns the attribute based on the name of the variable.
  35802. * @param uniformName of the uniform to look up.
  35803. * @returns the location of the uniform.
  35804. */
  35805. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35806. /**
  35807. * Returns an array of sampler variable names
  35808. * @returns The array of sampler variable names.
  35809. */
  35810. getSamplers(): string[];
  35811. /**
  35812. * Returns an array of uniform variable names
  35813. * @returns The array of uniform variable names.
  35814. */
  35815. getUniformNames(): string[];
  35816. /**
  35817. * Returns an array of uniform buffer variable names
  35818. * @returns The array of uniform buffer variable names.
  35819. */
  35820. getUniformBuffersNames(): string[];
  35821. /**
  35822. * Returns the index parameters used to create the effect
  35823. * @returns The index parameters object
  35824. */
  35825. getIndexParameters(): any;
  35826. /**
  35827. * The error from the last compilation.
  35828. * @returns the error string.
  35829. */
  35830. getCompilationError(): string;
  35831. /**
  35832. * Gets a boolean indicating that all fallbacks were used during compilation
  35833. * @returns true if all fallbacks were used
  35834. */
  35835. allFallbacksProcessed(): boolean;
  35836. /**
  35837. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35838. * @param func The callback to be used.
  35839. */
  35840. executeWhenCompiled(func: (effect: Effect) => void): void;
  35841. private _checkIsReady;
  35842. private _loadShader;
  35843. /**
  35844. * Gets the vertex shader source code of this effect
  35845. */
  35846. get vertexSourceCode(): string;
  35847. /**
  35848. * Gets the fragment shader source code of this effect
  35849. */
  35850. get fragmentSourceCode(): string;
  35851. /**
  35852. * Recompiles the webGL program
  35853. * @param vertexSourceCode The source code for the vertex shader.
  35854. * @param fragmentSourceCode The source code for the fragment shader.
  35855. * @param onCompiled Callback called when completed.
  35856. * @param onError Callback called on error.
  35857. * @hidden
  35858. */
  35859. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35860. /**
  35861. * Prepares the effect
  35862. * @hidden
  35863. */
  35864. _prepareEffect(): void;
  35865. private _getShaderCodeAndErrorLine;
  35866. private _processCompilationErrors;
  35867. /**
  35868. * Checks if the effect is supported. (Must be called after compilation)
  35869. */
  35870. get isSupported(): boolean;
  35871. /**
  35872. * Binds a texture to the engine to be used as output of the shader.
  35873. * @param channel Name of the output variable.
  35874. * @param texture Texture to bind.
  35875. * @hidden
  35876. */
  35877. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35878. /**
  35879. * Sets a texture on the engine to be used in the shader.
  35880. * @param channel Name of the sampler variable.
  35881. * @param texture Texture to set.
  35882. */
  35883. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35884. /**
  35885. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35886. * @param channel Name of the sampler variable.
  35887. * @param texture Texture to set.
  35888. */
  35889. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35890. /**
  35891. * Sets an array of textures on the engine to be used in the shader.
  35892. * @param channel Name of the variable.
  35893. * @param textures Textures to set.
  35894. */
  35895. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35896. /**
  35897. * 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)
  35898. * @param channel Name of the sampler variable.
  35899. * @param postProcess Post process to get the input texture from.
  35900. */
  35901. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35902. /**
  35903. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35904. * 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)
  35905. * @param channel Name of the sampler variable.
  35906. * @param postProcess Post process to get the output texture from.
  35907. */
  35908. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35909. /** @hidden */
  35910. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35911. /** @hidden */
  35912. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35913. /** @hidden */
  35914. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35915. /** @hidden */
  35916. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35917. /**
  35918. * Binds a buffer to a uniform.
  35919. * @param buffer Buffer to bind.
  35920. * @param name Name of the uniform variable to bind to.
  35921. */
  35922. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35923. /**
  35924. * Binds block to a uniform.
  35925. * @param blockName Name of the block to bind.
  35926. * @param index Index to bind.
  35927. */
  35928. bindUniformBlock(blockName: string, index: number): void;
  35929. /**
  35930. * Sets an interger value on a uniform variable.
  35931. * @param uniformName Name of the variable.
  35932. * @param value Value to be set.
  35933. * @returns this effect.
  35934. */
  35935. setInt(uniformName: string, value: number): Effect;
  35936. /**
  35937. * Sets an int array on a uniform variable.
  35938. * @param uniformName Name of the variable.
  35939. * @param array array to be set.
  35940. * @returns this effect.
  35941. */
  35942. setIntArray(uniformName: string, array: Int32Array): Effect;
  35943. /**
  35944. * 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)
  35945. * @param uniformName Name of the variable.
  35946. * @param array array to be set.
  35947. * @returns this effect.
  35948. */
  35949. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35950. /**
  35951. * 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)
  35952. * @param uniformName Name of the variable.
  35953. * @param array array to be set.
  35954. * @returns this effect.
  35955. */
  35956. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35957. /**
  35958. * 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)
  35959. * @param uniformName Name of the variable.
  35960. * @param array array to be set.
  35961. * @returns this effect.
  35962. */
  35963. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35964. /**
  35965. * Sets an float array on a uniform variable.
  35966. * @param uniformName Name of the variable.
  35967. * @param array array to be set.
  35968. * @returns this effect.
  35969. */
  35970. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35971. /**
  35972. * 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)
  35973. * @param uniformName Name of the variable.
  35974. * @param array array to be set.
  35975. * @returns this effect.
  35976. */
  35977. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35978. /**
  35979. * 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)
  35980. * @param uniformName Name of the variable.
  35981. * @param array array to be set.
  35982. * @returns this effect.
  35983. */
  35984. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35985. /**
  35986. * 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)
  35987. * @param uniformName Name of the variable.
  35988. * @param array array to be set.
  35989. * @returns this effect.
  35990. */
  35991. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35992. /**
  35993. * Sets an array on a uniform variable.
  35994. * @param uniformName Name of the variable.
  35995. * @param array array to be set.
  35996. * @returns this effect.
  35997. */
  35998. setArray(uniformName: string, array: number[]): Effect;
  35999. /**
  36000. * 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)
  36001. * @param uniformName Name of the variable.
  36002. * @param array array to be set.
  36003. * @returns this effect.
  36004. */
  36005. setArray2(uniformName: string, array: number[]): Effect;
  36006. /**
  36007. * 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)
  36008. * @param uniformName Name of the variable.
  36009. * @param array array to be set.
  36010. * @returns this effect.
  36011. */
  36012. setArray3(uniformName: string, array: number[]): Effect;
  36013. /**
  36014. * 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)
  36015. * @param uniformName Name of the variable.
  36016. * @param array array to be set.
  36017. * @returns this effect.
  36018. */
  36019. setArray4(uniformName: string, array: number[]): Effect;
  36020. /**
  36021. * Sets matrices on a uniform variable.
  36022. * @param uniformName Name of the variable.
  36023. * @param matrices matrices to be set.
  36024. * @returns this effect.
  36025. */
  36026. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  36027. /**
  36028. * Sets matrix on a uniform variable.
  36029. * @param uniformName Name of the variable.
  36030. * @param matrix matrix to be set.
  36031. * @returns this effect.
  36032. */
  36033. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  36034. /**
  36035. * 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)
  36036. * @param uniformName Name of the variable.
  36037. * @param matrix matrix to be set.
  36038. * @returns this effect.
  36039. */
  36040. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36041. /**
  36042. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  36043. * @param uniformName Name of the variable.
  36044. * @param matrix matrix to be set.
  36045. * @returns this effect.
  36046. */
  36047. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36048. /**
  36049. * Sets a float on a uniform variable.
  36050. * @param uniformName Name of the variable.
  36051. * @param value value to be set.
  36052. * @returns this effect.
  36053. */
  36054. setFloat(uniformName: string, value: number): Effect;
  36055. /**
  36056. * Sets a boolean on a uniform variable.
  36057. * @param uniformName Name of the variable.
  36058. * @param bool value to be set.
  36059. * @returns this effect.
  36060. */
  36061. setBool(uniformName: string, bool: boolean): Effect;
  36062. /**
  36063. * Sets a Vector2 on a uniform variable.
  36064. * @param uniformName Name of the variable.
  36065. * @param vector2 vector2 to be set.
  36066. * @returns this effect.
  36067. */
  36068. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  36069. /**
  36070. * Sets a float2 on a uniform variable.
  36071. * @param uniformName Name of the variable.
  36072. * @param x First float in float2.
  36073. * @param y Second float in float2.
  36074. * @returns this effect.
  36075. */
  36076. setFloat2(uniformName: string, x: number, y: number): Effect;
  36077. /**
  36078. * Sets a Vector3 on a uniform variable.
  36079. * @param uniformName Name of the variable.
  36080. * @param vector3 Value to be set.
  36081. * @returns this effect.
  36082. */
  36083. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36084. /**
  36085. * Sets a float3 on a uniform variable.
  36086. * @param uniformName Name of the variable.
  36087. * @param x First float in float3.
  36088. * @param y Second float in float3.
  36089. * @param z Third float in float3.
  36090. * @returns this effect.
  36091. */
  36092. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36093. /**
  36094. * Sets a Vector4 on a uniform variable.
  36095. * @param uniformName Name of the variable.
  36096. * @param vector4 Value to be set.
  36097. * @returns this effect.
  36098. */
  36099. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36100. /**
  36101. * Sets a float4 on a uniform variable.
  36102. * @param uniformName Name of the variable.
  36103. * @param x First float in float4.
  36104. * @param y Second float in float4.
  36105. * @param z Third float in float4.
  36106. * @param w Fourth float in float4.
  36107. * @returns this effect.
  36108. */
  36109. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36110. /**
  36111. * Sets a Color3 on a uniform variable.
  36112. * @param uniformName Name of the variable.
  36113. * @param color3 Value to be set.
  36114. * @returns this effect.
  36115. */
  36116. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36117. /**
  36118. * Sets a Color4 on a uniform variable.
  36119. * @param uniformName Name of the variable.
  36120. * @param color3 Value to be set.
  36121. * @param alpha Alpha value to be set.
  36122. * @returns this effect.
  36123. */
  36124. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36125. /**
  36126. * Sets a Color4 on a uniform variable
  36127. * @param uniformName defines the name of the variable
  36128. * @param color4 defines the value to be set
  36129. * @returns this effect.
  36130. */
  36131. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36132. /** Release all associated resources */
  36133. dispose(): void;
  36134. /**
  36135. * This function will add a new shader to the shader store
  36136. * @param name the name of the shader
  36137. * @param pixelShader optional pixel shader content
  36138. * @param vertexShader optional vertex shader content
  36139. */
  36140. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36141. /**
  36142. * Store of each shader (The can be looked up using effect.key)
  36143. */
  36144. static ShadersStore: {
  36145. [key: string]: string;
  36146. };
  36147. /**
  36148. * Store of each included file for a shader (The can be looked up using effect.key)
  36149. */
  36150. static IncludesShadersStore: {
  36151. [key: string]: string;
  36152. };
  36153. /**
  36154. * Resets the cache of effects.
  36155. */
  36156. static ResetCache(): void;
  36157. }
  36158. }
  36159. declare module "babylonjs/Engines/engineCapabilities" {
  36160. /**
  36161. * Interface used to describe the capabilities of the engine relatively to the current browser
  36162. */
  36163. export interface EngineCapabilities {
  36164. /** Maximum textures units per fragment shader */
  36165. maxTexturesImageUnits: number;
  36166. /** Maximum texture units per vertex shader */
  36167. maxVertexTextureImageUnits: number;
  36168. /** Maximum textures units in the entire pipeline */
  36169. maxCombinedTexturesImageUnits: number;
  36170. /** Maximum texture size */
  36171. maxTextureSize: number;
  36172. /** Maximum texture samples */
  36173. maxSamples?: number;
  36174. /** Maximum cube texture size */
  36175. maxCubemapTextureSize: number;
  36176. /** Maximum render texture size */
  36177. maxRenderTextureSize: number;
  36178. /** Maximum number of vertex attributes */
  36179. maxVertexAttribs: number;
  36180. /** Maximum number of varyings */
  36181. maxVaryingVectors: number;
  36182. /** Maximum number of uniforms per vertex shader */
  36183. maxVertexUniformVectors: number;
  36184. /** Maximum number of uniforms per fragment shader */
  36185. maxFragmentUniformVectors: number;
  36186. /** Defines if standard derivates (dx/dy) are supported */
  36187. standardDerivatives: boolean;
  36188. /** Defines if s3tc texture compression is supported */
  36189. s3tc?: WEBGL_compressed_texture_s3tc;
  36190. /** Defines if pvrtc texture compression is supported */
  36191. pvrtc: any;
  36192. /** Defines if etc1 texture compression is supported */
  36193. etc1: any;
  36194. /** Defines if etc2 texture compression is supported */
  36195. etc2: any;
  36196. /** Defines if astc texture compression is supported */
  36197. astc: any;
  36198. /** Defines if bptc texture compression is supported */
  36199. bptc: any;
  36200. /** Defines if float textures are supported */
  36201. textureFloat: boolean;
  36202. /** Defines if vertex array objects are supported */
  36203. vertexArrayObject: boolean;
  36204. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36205. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36206. /** Gets the maximum level of anisotropy supported */
  36207. maxAnisotropy: number;
  36208. /** Defines if instancing is supported */
  36209. instancedArrays: boolean;
  36210. /** Defines if 32 bits indices are supported */
  36211. uintIndices: boolean;
  36212. /** Defines if high precision shaders are supported */
  36213. highPrecisionShaderSupported: boolean;
  36214. /** Defines if depth reading in the fragment shader is supported */
  36215. fragmentDepthSupported: boolean;
  36216. /** Defines if float texture linear filtering is supported*/
  36217. textureFloatLinearFiltering: boolean;
  36218. /** Defines if rendering to float textures is supported */
  36219. textureFloatRender: boolean;
  36220. /** Defines if half float textures are supported*/
  36221. textureHalfFloat: boolean;
  36222. /** Defines if half float texture linear filtering is supported*/
  36223. textureHalfFloatLinearFiltering: boolean;
  36224. /** Defines if rendering to half float textures is supported */
  36225. textureHalfFloatRender: boolean;
  36226. /** Defines if textureLOD shader command is supported */
  36227. textureLOD: boolean;
  36228. /** Defines if draw buffers extension is supported */
  36229. drawBuffersExtension: boolean;
  36230. /** Defines if depth textures are supported */
  36231. depthTextureExtension: boolean;
  36232. /** Defines if float color buffer are supported */
  36233. colorBufferFloat: boolean;
  36234. /** Gets disjoint timer query extension (null if not supported) */
  36235. timerQuery?: EXT_disjoint_timer_query;
  36236. /** Defines if timestamp can be used with timer query */
  36237. canUseTimestampForTimerQuery: boolean;
  36238. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36239. multiview?: any;
  36240. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36241. oculusMultiview?: any;
  36242. /** Function used to let the system compiles shaders in background */
  36243. parallelShaderCompile?: {
  36244. COMPLETION_STATUS_KHR: number;
  36245. };
  36246. /** Max number of texture samples for MSAA */
  36247. maxMSAASamples: number;
  36248. /** Defines if the blend min max extension is supported */
  36249. blendMinMax: boolean;
  36250. }
  36251. }
  36252. declare module "babylonjs/States/depthCullingState" {
  36253. import { Nullable } from "babylonjs/types";
  36254. /**
  36255. * @hidden
  36256. **/
  36257. export class DepthCullingState {
  36258. private _isDepthTestDirty;
  36259. private _isDepthMaskDirty;
  36260. private _isDepthFuncDirty;
  36261. private _isCullFaceDirty;
  36262. private _isCullDirty;
  36263. private _isZOffsetDirty;
  36264. private _isFrontFaceDirty;
  36265. private _depthTest;
  36266. private _depthMask;
  36267. private _depthFunc;
  36268. private _cull;
  36269. private _cullFace;
  36270. private _zOffset;
  36271. private _frontFace;
  36272. /**
  36273. * Initializes the state.
  36274. */
  36275. constructor();
  36276. get isDirty(): boolean;
  36277. get zOffset(): number;
  36278. set zOffset(value: number);
  36279. get cullFace(): Nullable<number>;
  36280. set cullFace(value: Nullable<number>);
  36281. get cull(): Nullable<boolean>;
  36282. set cull(value: Nullable<boolean>);
  36283. get depthFunc(): Nullable<number>;
  36284. set depthFunc(value: Nullable<number>);
  36285. get depthMask(): boolean;
  36286. set depthMask(value: boolean);
  36287. get depthTest(): boolean;
  36288. set depthTest(value: boolean);
  36289. get frontFace(): Nullable<number>;
  36290. set frontFace(value: Nullable<number>);
  36291. reset(): void;
  36292. apply(gl: WebGLRenderingContext): void;
  36293. }
  36294. }
  36295. declare module "babylonjs/States/stencilState" {
  36296. /**
  36297. * @hidden
  36298. **/
  36299. export class StencilState {
  36300. /** 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 */
  36301. static readonly ALWAYS: number;
  36302. /** Passed to stencilOperation to specify that stencil value must be kept */
  36303. static readonly KEEP: number;
  36304. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36305. static readonly REPLACE: number;
  36306. private _isStencilTestDirty;
  36307. private _isStencilMaskDirty;
  36308. private _isStencilFuncDirty;
  36309. private _isStencilOpDirty;
  36310. private _stencilTest;
  36311. private _stencilMask;
  36312. private _stencilFunc;
  36313. private _stencilFuncRef;
  36314. private _stencilFuncMask;
  36315. private _stencilOpStencilFail;
  36316. private _stencilOpDepthFail;
  36317. private _stencilOpStencilDepthPass;
  36318. get isDirty(): boolean;
  36319. get stencilFunc(): number;
  36320. set stencilFunc(value: number);
  36321. get stencilFuncRef(): number;
  36322. set stencilFuncRef(value: number);
  36323. get stencilFuncMask(): number;
  36324. set stencilFuncMask(value: number);
  36325. get stencilOpStencilFail(): number;
  36326. set stencilOpStencilFail(value: number);
  36327. get stencilOpDepthFail(): number;
  36328. set stencilOpDepthFail(value: number);
  36329. get stencilOpStencilDepthPass(): number;
  36330. set stencilOpStencilDepthPass(value: number);
  36331. get stencilMask(): number;
  36332. set stencilMask(value: number);
  36333. get stencilTest(): boolean;
  36334. set stencilTest(value: boolean);
  36335. constructor();
  36336. reset(): void;
  36337. apply(gl: WebGLRenderingContext): void;
  36338. }
  36339. }
  36340. declare module "babylonjs/States/alphaCullingState" {
  36341. /**
  36342. * @hidden
  36343. **/
  36344. export class AlphaState {
  36345. private _isAlphaBlendDirty;
  36346. private _isBlendFunctionParametersDirty;
  36347. private _isBlendEquationParametersDirty;
  36348. private _isBlendConstantsDirty;
  36349. private _alphaBlend;
  36350. private _blendFunctionParameters;
  36351. private _blendEquationParameters;
  36352. private _blendConstants;
  36353. /**
  36354. * Initializes the state.
  36355. */
  36356. constructor();
  36357. get isDirty(): boolean;
  36358. get alphaBlend(): boolean;
  36359. set alphaBlend(value: boolean);
  36360. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36361. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36362. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36363. reset(): void;
  36364. apply(gl: WebGLRenderingContext): void;
  36365. }
  36366. }
  36367. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36368. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36369. /** @hidden */
  36370. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36371. attributeProcessor(attribute: string): string;
  36372. varyingProcessor(varying: string, isFragment: boolean): string;
  36373. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36374. }
  36375. }
  36376. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36377. /**
  36378. * Interface for attribute information associated with buffer instanciation
  36379. */
  36380. export interface InstancingAttributeInfo {
  36381. /**
  36382. * Name of the GLSL attribute
  36383. * if attribute index is not specified, this is used to retrieve the index from the effect
  36384. */
  36385. attributeName: string;
  36386. /**
  36387. * Index/offset of the attribute in the vertex shader
  36388. * if not specified, this will be computes from the name.
  36389. */
  36390. index?: number;
  36391. /**
  36392. * size of the attribute, 1, 2, 3 or 4
  36393. */
  36394. attributeSize: number;
  36395. /**
  36396. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36397. */
  36398. offset: number;
  36399. /**
  36400. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36401. * default to 1
  36402. */
  36403. divisor?: number;
  36404. /**
  36405. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36406. * default is FLOAT
  36407. */
  36408. attributeType?: number;
  36409. /**
  36410. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36411. */
  36412. normalized?: boolean;
  36413. }
  36414. }
  36415. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36416. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36417. import { Nullable } from "babylonjs/types";
  36418. module "babylonjs/Engines/thinEngine" {
  36419. interface ThinEngine {
  36420. /**
  36421. * Update a video texture
  36422. * @param texture defines the texture to update
  36423. * @param video defines the video element to use
  36424. * @param invertY defines if data must be stored with Y axis inverted
  36425. */
  36426. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36427. }
  36428. }
  36429. }
  36430. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36432. import { Nullable } from "babylonjs/types";
  36433. module "babylonjs/Engines/thinEngine" {
  36434. interface ThinEngine {
  36435. /**
  36436. * Creates a dynamic texture
  36437. * @param width defines the width of the texture
  36438. * @param height defines the height of the texture
  36439. * @param generateMipMaps defines if the engine should generate the mip levels
  36440. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36441. * @returns the dynamic texture inside an InternalTexture
  36442. */
  36443. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36444. /**
  36445. * Update the content of a dynamic texture
  36446. * @param texture defines the texture to update
  36447. * @param canvas defines the canvas containing the source
  36448. * @param invertY defines if data must be stored with Y axis inverted
  36449. * @param premulAlpha defines if alpha is stored as premultiplied
  36450. * @param format defines the format of the data
  36451. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36452. */
  36453. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36454. }
  36455. }
  36456. }
  36457. declare module "babylonjs/Materials/Textures/videoTexture" {
  36458. import { Observable } from "babylonjs/Misc/observable";
  36459. import { Nullable } from "babylonjs/types";
  36460. import { Scene } from "babylonjs/scene";
  36461. import { Texture } from "babylonjs/Materials/Textures/texture";
  36462. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36463. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36464. /**
  36465. * Settings for finer control over video usage
  36466. */
  36467. export interface VideoTextureSettings {
  36468. /**
  36469. * Applies `autoplay` to video, if specified
  36470. */
  36471. autoPlay?: boolean;
  36472. /**
  36473. * Applies `loop` to video, if specified
  36474. */
  36475. loop?: boolean;
  36476. /**
  36477. * Automatically updates internal texture from video at every frame in the render loop
  36478. */
  36479. autoUpdateTexture: boolean;
  36480. /**
  36481. * Image src displayed during the video loading or until the user interacts with the video.
  36482. */
  36483. poster?: string;
  36484. }
  36485. /**
  36486. * If you want to display a video in your scene, this is the special texture for that.
  36487. * This special texture works similar to other textures, with the exception of a few parameters.
  36488. * @see https://doc.babylonjs.com/how_to/video_texture
  36489. */
  36490. export class VideoTexture extends Texture {
  36491. /**
  36492. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36493. */
  36494. readonly autoUpdateTexture: boolean;
  36495. /**
  36496. * The video instance used by the texture internally
  36497. */
  36498. readonly video: HTMLVideoElement;
  36499. private _onUserActionRequestedObservable;
  36500. /**
  36501. * Event triggerd when a dom action is required by the user to play the video.
  36502. * This happens due to recent changes in browser policies preventing video to auto start.
  36503. */
  36504. get onUserActionRequestedObservable(): Observable<Texture>;
  36505. private _generateMipMaps;
  36506. private _stillImageCaptured;
  36507. private _displayingPosterTexture;
  36508. private _settings;
  36509. private _createInternalTextureOnEvent;
  36510. private _frameId;
  36511. private _currentSrc;
  36512. /**
  36513. * Creates a video texture.
  36514. * If you want to display a video in your scene, this is the special texture for that.
  36515. * This special texture works similar to other textures, with the exception of a few parameters.
  36516. * @see https://doc.babylonjs.com/how_to/video_texture
  36517. * @param name optional name, will detect from video source, if not defined
  36518. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36519. * @param scene is obviously the current scene.
  36520. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36521. * @param invertY is false by default but can be used to invert video on Y axis
  36522. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36523. * @param settings allows finer control over video usage
  36524. */
  36525. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36526. private _getName;
  36527. private _getVideo;
  36528. private _createInternalTexture;
  36529. private reset;
  36530. /**
  36531. * @hidden Internal method to initiate `update`.
  36532. */
  36533. _rebuild(): void;
  36534. /**
  36535. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36536. */
  36537. update(): void;
  36538. /**
  36539. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36540. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36541. */
  36542. updateTexture(isVisible: boolean): void;
  36543. protected _updateInternalTexture: () => void;
  36544. /**
  36545. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36546. * @param url New url.
  36547. */
  36548. updateURL(url: string): void;
  36549. /**
  36550. * Clones the texture.
  36551. * @returns the cloned texture
  36552. */
  36553. clone(): VideoTexture;
  36554. /**
  36555. * Dispose the texture and release its associated resources.
  36556. */
  36557. dispose(): void;
  36558. /**
  36559. * Creates a video texture straight from a stream.
  36560. * @param scene Define the scene the texture should be created in
  36561. * @param stream Define the stream the texture should be created from
  36562. * @returns The created video texture as a promise
  36563. */
  36564. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36565. /**
  36566. * Creates a video texture straight from your WebCam video feed.
  36567. * @param scene Define the scene the texture should be created in
  36568. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36569. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36570. * @returns The created video texture as a promise
  36571. */
  36572. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36573. minWidth: number;
  36574. maxWidth: number;
  36575. minHeight: number;
  36576. maxHeight: number;
  36577. deviceId: string;
  36578. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36579. /**
  36580. * Creates a video texture straight from your WebCam video feed.
  36581. * @param scene Define the scene the texture should be created in
  36582. * @param onReady Define a callback to triggered once the texture will be ready
  36583. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36584. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36585. */
  36586. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36587. minWidth: number;
  36588. maxWidth: number;
  36589. minHeight: number;
  36590. maxHeight: number;
  36591. deviceId: string;
  36592. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36593. }
  36594. }
  36595. declare module "babylonjs/Engines/thinEngine" {
  36596. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36597. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36598. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36599. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36600. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36601. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36602. import { Observable } from "babylonjs/Misc/observable";
  36603. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36604. import { StencilState } from "babylonjs/States/stencilState";
  36605. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36607. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36608. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36609. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36610. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36611. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36612. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36613. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36615. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36616. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36617. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36618. import { WebRequest } from "babylonjs/Misc/webRequest";
  36619. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36620. /**
  36621. * Defines the interface used by objects working like Scene
  36622. * @hidden
  36623. */
  36624. export interface ISceneLike {
  36625. _addPendingData(data: any): void;
  36626. _removePendingData(data: any): void;
  36627. offlineProvider: IOfflineProvider;
  36628. }
  36629. /**
  36630. * Information about the current host
  36631. */
  36632. export interface HostInformation {
  36633. /**
  36634. * Defines if the current host is a mobile
  36635. */
  36636. isMobile: boolean;
  36637. }
  36638. /** Interface defining initialization parameters for Engine class */
  36639. export interface EngineOptions extends WebGLContextAttributes {
  36640. /**
  36641. * Defines if the engine should no exceed a specified device ratio
  36642. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36643. */
  36644. limitDeviceRatio?: number;
  36645. /**
  36646. * Defines if webvr should be enabled automatically
  36647. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36648. */
  36649. autoEnableWebVR?: boolean;
  36650. /**
  36651. * Defines if webgl2 should be turned off even if supported
  36652. * @see https://doc.babylonjs.com/features/webgl2
  36653. */
  36654. disableWebGL2Support?: boolean;
  36655. /**
  36656. * Defines if webaudio should be initialized as well
  36657. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36658. */
  36659. audioEngine?: boolean;
  36660. /**
  36661. * Defines if animations should run using a deterministic lock step
  36662. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36663. */
  36664. deterministicLockstep?: boolean;
  36665. /** Defines the maximum steps to use with deterministic lock step mode */
  36666. lockstepMaxSteps?: number;
  36667. /** Defines the seconds between each deterministic lock step */
  36668. timeStep?: number;
  36669. /**
  36670. * Defines that engine should ignore context lost events
  36671. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36672. */
  36673. doNotHandleContextLost?: boolean;
  36674. /**
  36675. * Defines that engine should ignore modifying touch action attribute and style
  36676. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36677. */
  36678. doNotHandleTouchAction?: boolean;
  36679. /**
  36680. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36681. */
  36682. useHighPrecisionFloats?: boolean;
  36683. /**
  36684. * Make the canvas XR Compatible for XR sessions
  36685. */
  36686. xrCompatible?: boolean;
  36687. /**
  36688. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36689. */
  36690. useHighPrecisionMatrix?: boolean;
  36691. }
  36692. /**
  36693. * The base engine class (root of all engines)
  36694. */
  36695. export class ThinEngine {
  36696. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36697. static ExceptionList: ({
  36698. key: string;
  36699. capture: string;
  36700. captureConstraint: number;
  36701. targets: string[];
  36702. } | {
  36703. key: string;
  36704. capture: null;
  36705. captureConstraint: null;
  36706. targets: string[];
  36707. })[];
  36708. /** @hidden */
  36709. static _TextureLoaders: IInternalTextureLoader[];
  36710. /**
  36711. * Returns the current npm package of the sdk
  36712. */
  36713. static get NpmPackage(): string;
  36714. /**
  36715. * Returns the current version of the framework
  36716. */
  36717. static get Version(): string;
  36718. /**
  36719. * Returns a string describing the current engine
  36720. */
  36721. get description(): string;
  36722. /**
  36723. * Gets or sets the epsilon value used by collision engine
  36724. */
  36725. static CollisionsEpsilon: number;
  36726. /**
  36727. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36728. */
  36729. static get ShadersRepository(): string;
  36730. static set ShadersRepository(value: string);
  36731. /** @hidden */
  36732. _shaderProcessor: IShaderProcessor;
  36733. /**
  36734. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36735. */
  36736. forcePOTTextures: boolean;
  36737. /**
  36738. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36739. */
  36740. isFullscreen: boolean;
  36741. /**
  36742. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36743. */
  36744. cullBackFaces: boolean;
  36745. /**
  36746. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36747. */
  36748. renderEvenInBackground: boolean;
  36749. /**
  36750. * Gets or sets a boolean indicating that cache can be kept between frames
  36751. */
  36752. preventCacheWipeBetweenFrames: boolean;
  36753. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36754. validateShaderPrograms: boolean;
  36755. /**
  36756. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36757. * This can provide greater z depth for distant objects.
  36758. */
  36759. useReverseDepthBuffer: boolean;
  36760. /**
  36761. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36762. */
  36763. disableUniformBuffers: boolean;
  36764. /** @hidden */
  36765. _uniformBuffers: UniformBuffer[];
  36766. /**
  36767. * Gets a boolean indicating that the engine supports uniform buffers
  36768. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36769. */
  36770. get supportsUniformBuffers(): boolean;
  36771. /** @hidden */
  36772. _gl: WebGLRenderingContext;
  36773. /** @hidden */
  36774. _webGLVersion: number;
  36775. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36776. protected _windowIsBackground: boolean;
  36777. protected _creationOptions: EngineOptions;
  36778. protected _highPrecisionShadersAllowed: boolean;
  36779. /** @hidden */
  36780. get _shouldUseHighPrecisionShader(): boolean;
  36781. /**
  36782. * Gets a boolean indicating that only power of 2 textures are supported
  36783. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36784. */
  36785. get needPOTTextures(): boolean;
  36786. /** @hidden */
  36787. _badOS: boolean;
  36788. /** @hidden */
  36789. _badDesktopOS: boolean;
  36790. private _hardwareScalingLevel;
  36791. /** @hidden */
  36792. _caps: EngineCapabilities;
  36793. private _isStencilEnable;
  36794. private _glVersion;
  36795. private _glRenderer;
  36796. private _glVendor;
  36797. /** @hidden */
  36798. _videoTextureSupported: boolean;
  36799. protected _renderingQueueLaunched: boolean;
  36800. protected _activeRenderLoops: (() => void)[];
  36801. /**
  36802. * Observable signaled when a context lost event is raised
  36803. */
  36804. onContextLostObservable: Observable<ThinEngine>;
  36805. /**
  36806. * Observable signaled when a context restored event is raised
  36807. */
  36808. onContextRestoredObservable: Observable<ThinEngine>;
  36809. private _onContextLost;
  36810. private _onContextRestored;
  36811. protected _contextWasLost: boolean;
  36812. /** @hidden */
  36813. _doNotHandleContextLost: boolean;
  36814. /**
  36815. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36816. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36817. */
  36818. get doNotHandleContextLost(): boolean;
  36819. set doNotHandleContextLost(value: boolean);
  36820. /**
  36821. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36822. */
  36823. disableVertexArrayObjects: boolean;
  36824. /** @hidden */
  36825. protected _colorWrite: boolean;
  36826. /** @hidden */
  36827. protected _colorWriteChanged: boolean;
  36828. /** @hidden */
  36829. protected _depthCullingState: DepthCullingState;
  36830. /** @hidden */
  36831. protected _stencilState: StencilState;
  36832. /** @hidden */
  36833. _alphaState: AlphaState;
  36834. /** @hidden */
  36835. _alphaMode: number;
  36836. /** @hidden */
  36837. _alphaEquation: number;
  36838. /** @hidden */
  36839. _internalTexturesCache: InternalTexture[];
  36840. /** @hidden */
  36841. protected _activeChannel: number;
  36842. private _currentTextureChannel;
  36843. /** @hidden */
  36844. protected _boundTexturesCache: {
  36845. [key: string]: Nullable<InternalTexture>;
  36846. };
  36847. /** @hidden */
  36848. protected _currentEffect: Nullable<Effect>;
  36849. /** @hidden */
  36850. protected _currentProgram: Nullable<WebGLProgram>;
  36851. private _compiledEffects;
  36852. private _vertexAttribArraysEnabled;
  36853. /** @hidden */
  36854. protected _cachedViewport: Nullable<IViewportLike>;
  36855. private _cachedVertexArrayObject;
  36856. /** @hidden */
  36857. protected _cachedVertexBuffers: any;
  36858. /** @hidden */
  36859. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36860. /** @hidden */
  36861. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36862. /** @hidden */
  36863. _currentRenderTarget: Nullable<InternalTexture>;
  36864. private _uintIndicesCurrentlySet;
  36865. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36866. /** @hidden */
  36867. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36868. /** @hidden */
  36869. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36870. private _currentBufferPointers;
  36871. private _currentInstanceLocations;
  36872. private _currentInstanceBuffers;
  36873. private _textureUnits;
  36874. /** @hidden */
  36875. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36876. /** @hidden */
  36877. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36878. /** @hidden */
  36879. _boundRenderFunction: any;
  36880. private _vaoRecordInProgress;
  36881. private _mustWipeVertexAttributes;
  36882. private _emptyTexture;
  36883. private _emptyCubeTexture;
  36884. private _emptyTexture3D;
  36885. private _emptyTexture2DArray;
  36886. /** @hidden */
  36887. _frameHandler: number;
  36888. private _nextFreeTextureSlots;
  36889. private _maxSimultaneousTextures;
  36890. private _activeRequests;
  36891. /** @hidden */
  36892. _transformTextureUrl: Nullable<(url: string) => string>;
  36893. /**
  36894. * Gets information about the current host
  36895. */
  36896. hostInformation: HostInformation;
  36897. protected get _supportsHardwareTextureRescaling(): boolean;
  36898. private _framebufferDimensionsObject;
  36899. /**
  36900. * sets the object from which width and height will be taken from when getting render width and height
  36901. * Will fallback to the gl object
  36902. * @param dimensions the framebuffer width and height that will be used.
  36903. */
  36904. set framebufferDimensionsObject(dimensions: Nullable<{
  36905. framebufferWidth: number;
  36906. framebufferHeight: number;
  36907. }>);
  36908. /**
  36909. * Gets the current viewport
  36910. */
  36911. get currentViewport(): Nullable<IViewportLike>;
  36912. /**
  36913. * Gets the default empty texture
  36914. */
  36915. get emptyTexture(): InternalTexture;
  36916. /**
  36917. * Gets the default empty 3D texture
  36918. */
  36919. get emptyTexture3D(): InternalTexture;
  36920. /**
  36921. * Gets the default empty 2D array texture
  36922. */
  36923. get emptyTexture2DArray(): InternalTexture;
  36924. /**
  36925. * Gets the default empty cube texture
  36926. */
  36927. get emptyCubeTexture(): InternalTexture;
  36928. /**
  36929. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36930. */
  36931. readonly premultipliedAlpha: boolean;
  36932. /**
  36933. * Observable event triggered before each texture is initialized
  36934. */
  36935. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36936. /**
  36937. * Creates a new engine
  36938. * @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
  36939. * @param antialias defines enable antialiasing (default: false)
  36940. * @param options defines further options to be sent to the getContext() function
  36941. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36942. */
  36943. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36944. private _rebuildInternalTextures;
  36945. private _rebuildEffects;
  36946. /**
  36947. * Gets a boolean indicating if all created effects are ready
  36948. * @returns true if all effects are ready
  36949. */
  36950. areAllEffectsReady(): boolean;
  36951. protected _rebuildBuffers(): void;
  36952. protected _initGLContext(): void;
  36953. /**
  36954. * Gets version of the current webGL context
  36955. */
  36956. get webGLVersion(): number;
  36957. /**
  36958. * Gets a string identifying the name of the class
  36959. * @returns "Engine" string
  36960. */
  36961. getClassName(): string;
  36962. /**
  36963. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36964. */
  36965. get isStencilEnable(): boolean;
  36966. /** @hidden */
  36967. _prepareWorkingCanvas(): void;
  36968. /**
  36969. * Reset the texture cache to empty state
  36970. */
  36971. resetTextureCache(): void;
  36972. /**
  36973. * Gets an object containing information about the current webGL context
  36974. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36975. */
  36976. getGlInfo(): {
  36977. vendor: string;
  36978. renderer: string;
  36979. version: string;
  36980. };
  36981. /**
  36982. * Defines the hardware scaling level.
  36983. * By default the hardware scaling level is computed from the window device ratio.
  36984. * 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.
  36985. * @param level defines the level to use
  36986. */
  36987. setHardwareScalingLevel(level: number): void;
  36988. /**
  36989. * Gets the current hardware scaling level.
  36990. * By default the hardware scaling level is computed from the window device ratio.
  36991. * 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.
  36992. * @returns a number indicating the current hardware scaling level
  36993. */
  36994. getHardwareScalingLevel(): number;
  36995. /**
  36996. * Gets the list of loaded textures
  36997. * @returns an array containing all loaded textures
  36998. */
  36999. getLoadedTexturesCache(): InternalTexture[];
  37000. /**
  37001. * Gets the object containing all engine capabilities
  37002. * @returns the EngineCapabilities object
  37003. */
  37004. getCaps(): EngineCapabilities;
  37005. /**
  37006. * stop executing a render loop function and remove it from the execution array
  37007. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  37008. */
  37009. stopRenderLoop(renderFunction?: () => void): void;
  37010. /** @hidden */
  37011. _renderLoop(): void;
  37012. /**
  37013. * Gets the HTML canvas attached with the current webGL context
  37014. * @returns a HTML canvas
  37015. */
  37016. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  37017. /**
  37018. * Gets host window
  37019. * @returns the host window object
  37020. */
  37021. getHostWindow(): Nullable<Window>;
  37022. /**
  37023. * Gets the current render width
  37024. * @param useScreen defines if screen size must be used (or the current render target if any)
  37025. * @returns a number defining the current render width
  37026. */
  37027. getRenderWidth(useScreen?: boolean): number;
  37028. /**
  37029. * Gets the current render height
  37030. * @param useScreen defines if screen size must be used (or the current render target if any)
  37031. * @returns a number defining the current render height
  37032. */
  37033. getRenderHeight(useScreen?: boolean): number;
  37034. /**
  37035. * Can be used to override the current requestAnimationFrame requester.
  37036. * @hidden
  37037. */
  37038. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  37039. /**
  37040. * Register and execute a render loop. The engine can have more than one render function
  37041. * @param renderFunction defines the function to continuously execute
  37042. */
  37043. runRenderLoop(renderFunction: () => void): void;
  37044. /**
  37045. * Clear the current render buffer or the current render target (if any is set up)
  37046. * @param color defines the color to use
  37047. * @param backBuffer defines if the back buffer must be cleared
  37048. * @param depth defines if the depth buffer must be cleared
  37049. * @param stencil defines if the stencil buffer must be cleared
  37050. */
  37051. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  37052. private _viewportCached;
  37053. /** @hidden */
  37054. _viewport(x: number, y: number, width: number, height: number): void;
  37055. /**
  37056. * Set the WebGL's viewport
  37057. * @param viewport defines the viewport element to be used
  37058. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  37059. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  37060. */
  37061. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  37062. /**
  37063. * Begin a new frame
  37064. */
  37065. beginFrame(): void;
  37066. /**
  37067. * Enf the current frame
  37068. */
  37069. endFrame(): void;
  37070. /**
  37071. * Resize the view according to the canvas' size
  37072. */
  37073. resize(): void;
  37074. /**
  37075. * Force a specific size of the canvas
  37076. * @param width defines the new canvas' width
  37077. * @param height defines the new canvas' height
  37078. * @returns true if the size was changed
  37079. */
  37080. setSize(width: number, height: number): boolean;
  37081. /**
  37082. * Binds the frame buffer to the specified texture.
  37083. * @param texture The texture to render to or null for the default canvas
  37084. * @param faceIndex The face of the texture to render to in case of cube texture
  37085. * @param requiredWidth The width of the target to render to
  37086. * @param requiredHeight The height of the target to render to
  37087. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37088. * @param lodLevel defines the lod level to bind to the frame buffer
  37089. * @param layer defines the 2d array index to bind to frame buffer to
  37090. */
  37091. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37092. /** @hidden */
  37093. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37094. /**
  37095. * Unbind the current render target texture from the webGL context
  37096. * @param texture defines the render target texture to unbind
  37097. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37098. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37099. */
  37100. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37101. /**
  37102. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37103. */
  37104. flushFramebuffer(): void;
  37105. /**
  37106. * Unbind the current render target and bind the default framebuffer
  37107. */
  37108. restoreDefaultFramebuffer(): void;
  37109. /** @hidden */
  37110. protected _resetVertexBufferBinding(): void;
  37111. /**
  37112. * Creates a vertex buffer
  37113. * @param data the data for the vertex buffer
  37114. * @returns the new WebGL static buffer
  37115. */
  37116. createVertexBuffer(data: DataArray): DataBuffer;
  37117. private _createVertexBuffer;
  37118. /**
  37119. * Creates a dynamic vertex buffer
  37120. * @param data the data for the dynamic vertex buffer
  37121. * @returns the new WebGL dynamic buffer
  37122. */
  37123. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37124. protected _resetIndexBufferBinding(): void;
  37125. /**
  37126. * Creates a new index buffer
  37127. * @param indices defines the content of the index buffer
  37128. * @param updatable defines if the index buffer must be updatable
  37129. * @returns a new webGL buffer
  37130. */
  37131. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37132. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37133. /**
  37134. * Bind a webGL buffer to the webGL context
  37135. * @param buffer defines the buffer to bind
  37136. */
  37137. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37138. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37139. private bindBuffer;
  37140. /**
  37141. * update the bound buffer with the given data
  37142. * @param data defines the data to update
  37143. */
  37144. updateArrayBuffer(data: Float32Array): void;
  37145. private _vertexAttribPointer;
  37146. /** @hidden */
  37147. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37148. private _bindVertexBuffersAttributes;
  37149. /**
  37150. * Records a vertex array object
  37151. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37152. * @param vertexBuffers defines the list of vertex buffers to store
  37153. * @param indexBuffer defines the index buffer to store
  37154. * @param effect defines the effect to store
  37155. * @returns the new vertex array object
  37156. */
  37157. recordVertexArrayObject(vertexBuffers: {
  37158. [key: string]: VertexBuffer;
  37159. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37160. /**
  37161. * Bind a specific vertex array object
  37162. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37163. * @param vertexArrayObject defines the vertex array object to bind
  37164. * @param indexBuffer defines the index buffer to bind
  37165. */
  37166. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37167. /**
  37168. * Bind webGl buffers directly to the webGL context
  37169. * @param vertexBuffer defines the vertex buffer to bind
  37170. * @param indexBuffer defines the index buffer to bind
  37171. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37172. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37173. * @param effect defines the effect associated with the vertex buffer
  37174. */
  37175. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37176. private _unbindVertexArrayObject;
  37177. /**
  37178. * Bind a list of vertex buffers to the webGL context
  37179. * @param vertexBuffers defines the list of vertex buffers to bind
  37180. * @param indexBuffer defines the index buffer to bind
  37181. * @param effect defines the effect associated with the vertex buffers
  37182. */
  37183. bindBuffers(vertexBuffers: {
  37184. [key: string]: Nullable<VertexBuffer>;
  37185. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37186. /**
  37187. * Unbind all instance attributes
  37188. */
  37189. unbindInstanceAttributes(): void;
  37190. /**
  37191. * Release and free the memory of a vertex array object
  37192. * @param vao defines the vertex array object to delete
  37193. */
  37194. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37195. /** @hidden */
  37196. _releaseBuffer(buffer: DataBuffer): boolean;
  37197. protected _deleteBuffer(buffer: DataBuffer): void;
  37198. /**
  37199. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37200. * @param instancesBuffer defines the webGL buffer to update and bind
  37201. * @param data defines the data to store in the buffer
  37202. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37203. */
  37204. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37205. /**
  37206. * Bind the content of a webGL buffer used with instantiation
  37207. * @param instancesBuffer defines the webGL buffer to bind
  37208. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37209. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37210. */
  37211. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37212. /**
  37213. * Disable the instance attribute corresponding to the name in parameter
  37214. * @param name defines the name of the attribute to disable
  37215. */
  37216. disableInstanceAttributeByName(name: string): void;
  37217. /**
  37218. * Disable the instance attribute corresponding to the location in parameter
  37219. * @param attributeLocation defines the attribute location of the attribute to disable
  37220. */
  37221. disableInstanceAttribute(attributeLocation: number): void;
  37222. /**
  37223. * Disable the attribute corresponding to the location in parameter
  37224. * @param attributeLocation defines the attribute location of the attribute to disable
  37225. */
  37226. disableAttributeByIndex(attributeLocation: number): void;
  37227. /**
  37228. * Send a draw order
  37229. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37230. * @param indexStart defines the starting index
  37231. * @param indexCount defines the number of index to draw
  37232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37233. */
  37234. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37235. /**
  37236. * Draw a list of points
  37237. * @param verticesStart defines the index of first vertex to draw
  37238. * @param verticesCount defines the count of vertices to draw
  37239. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37240. */
  37241. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37242. /**
  37243. * Draw a list of unindexed primitives
  37244. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37245. * @param verticesStart defines the index of first vertex to draw
  37246. * @param verticesCount defines the count of vertices to draw
  37247. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37248. */
  37249. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37250. /**
  37251. * Draw a list of indexed primitives
  37252. * @param fillMode defines the primitive to use
  37253. * @param indexStart defines the starting index
  37254. * @param indexCount defines the number of index to draw
  37255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37256. */
  37257. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37258. /**
  37259. * Draw a list of unindexed primitives
  37260. * @param fillMode defines the primitive to use
  37261. * @param verticesStart defines the index of first vertex to draw
  37262. * @param verticesCount defines the count of vertices to draw
  37263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37264. */
  37265. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37266. private _drawMode;
  37267. /** @hidden */
  37268. protected _reportDrawCall(): void;
  37269. /** @hidden */
  37270. _releaseEffect(effect: Effect): void;
  37271. /** @hidden */
  37272. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37273. /**
  37274. * Create a new effect (used to store vertex/fragment shaders)
  37275. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37276. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37277. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37278. * @param samplers defines an array of string used to represent textures
  37279. * @param defines defines the string containing the defines to use to compile the shaders
  37280. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37281. * @param onCompiled defines a function to call when the effect creation is successful
  37282. * @param onError defines a function to call when the effect creation has failed
  37283. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37284. * @returns the new Effect
  37285. */
  37286. 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;
  37287. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37288. private _compileShader;
  37289. private _compileRawShader;
  37290. /** @hidden */
  37291. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37292. /**
  37293. * Directly creates a webGL program
  37294. * @param pipelineContext defines the pipeline context to attach to
  37295. * @param vertexCode defines the vertex shader code to use
  37296. * @param fragmentCode defines the fragment shader code to use
  37297. * @param context defines the webGL context to use (if not set, the current one will be used)
  37298. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37299. * @returns the new webGL program
  37300. */
  37301. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37302. /**
  37303. * Creates a webGL program
  37304. * @param pipelineContext defines the pipeline context to attach to
  37305. * @param vertexCode defines the vertex shader code to use
  37306. * @param fragmentCode defines the fragment shader code to use
  37307. * @param defines defines the string containing the defines to use to compile the shaders
  37308. * @param context defines the webGL context to use (if not set, the current one will be used)
  37309. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37310. * @returns the new webGL program
  37311. */
  37312. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37313. /**
  37314. * Creates a new pipeline context
  37315. * @returns the new pipeline
  37316. */
  37317. createPipelineContext(): IPipelineContext;
  37318. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37319. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37320. /** @hidden */
  37321. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37322. /** @hidden */
  37323. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37324. /** @hidden */
  37325. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37326. /**
  37327. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37328. * @param pipelineContext defines the pipeline context to use
  37329. * @param uniformsNames defines the list of uniform names
  37330. * @returns an array of webGL uniform locations
  37331. */
  37332. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37333. /**
  37334. * Gets the lsit of active attributes for a given webGL program
  37335. * @param pipelineContext defines the pipeline context to use
  37336. * @param attributesNames defines the list of attribute names to get
  37337. * @returns an array of indices indicating the offset of each attribute
  37338. */
  37339. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37340. /**
  37341. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37342. * @param effect defines the effect to activate
  37343. */
  37344. enableEffect(effect: Nullable<Effect>): void;
  37345. /**
  37346. * Set the value of an uniform to a number (int)
  37347. * @param uniform defines the webGL uniform location where to store the value
  37348. * @param value defines the int number to store
  37349. */
  37350. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37351. /**
  37352. * Set the value of an uniform to an array of int32
  37353. * @param uniform defines the webGL uniform location where to store the value
  37354. * @param array defines the array of int32 to store
  37355. */
  37356. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37357. /**
  37358. * Set the value of an uniform to an array of int32 (stored as vec2)
  37359. * @param uniform defines the webGL uniform location where to store the value
  37360. * @param array defines the array of int32 to store
  37361. */
  37362. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37363. /**
  37364. * Set the value of an uniform to an array of int32 (stored as vec3)
  37365. * @param uniform defines the webGL uniform location where to store the value
  37366. * @param array defines the array of int32 to store
  37367. */
  37368. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37369. /**
  37370. * Set the value of an uniform to an array of int32 (stored as vec4)
  37371. * @param uniform defines the webGL uniform location where to store the value
  37372. * @param array defines the array of int32 to store
  37373. */
  37374. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37375. /**
  37376. * Set the value of an uniform to an array of number
  37377. * @param uniform defines the webGL uniform location where to store the value
  37378. * @param array defines the array of number to store
  37379. */
  37380. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37381. /**
  37382. * Set the value of an uniform to an array of number (stored as vec2)
  37383. * @param uniform defines the webGL uniform location where to store the value
  37384. * @param array defines the array of number to store
  37385. */
  37386. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37387. /**
  37388. * Set the value of an uniform to an array of number (stored as vec3)
  37389. * @param uniform defines the webGL uniform location where to store the value
  37390. * @param array defines the array of number to store
  37391. */
  37392. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37393. /**
  37394. * Set the value of an uniform to an array of number (stored as vec4)
  37395. * @param uniform defines the webGL uniform location where to store the value
  37396. * @param array defines the array of number to store
  37397. */
  37398. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37399. /**
  37400. * Set the value of an uniform to an array of float32 (stored as matrices)
  37401. * @param uniform defines the webGL uniform location where to store the value
  37402. * @param matrices defines the array of float32 to store
  37403. */
  37404. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37405. /**
  37406. * Set the value of an uniform to a matrix (3x3)
  37407. * @param uniform defines the webGL uniform location where to store the value
  37408. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37409. */
  37410. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37411. /**
  37412. * Set the value of an uniform to a matrix (2x2)
  37413. * @param uniform defines the webGL uniform location where to store the value
  37414. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37415. */
  37416. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37417. /**
  37418. * Set the value of an uniform to a number (float)
  37419. * @param uniform defines the webGL uniform location where to store the value
  37420. * @param value defines the float number to store
  37421. */
  37422. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37423. /**
  37424. * Set the value of an uniform to a vec2
  37425. * @param uniform defines the webGL uniform location where to store the value
  37426. * @param x defines the 1st component of the value
  37427. * @param y defines the 2nd component of the value
  37428. */
  37429. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37430. /**
  37431. * Set the value of an uniform to a vec3
  37432. * @param uniform defines the webGL uniform location where to store the value
  37433. * @param x defines the 1st component of the value
  37434. * @param y defines the 2nd component of the value
  37435. * @param z defines the 3rd component of the value
  37436. */
  37437. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37438. /**
  37439. * Set the value of an uniform to a vec4
  37440. * @param uniform defines the webGL uniform location where to store the value
  37441. * @param x defines the 1st component of the value
  37442. * @param y defines the 2nd component of the value
  37443. * @param z defines the 3rd component of the value
  37444. * @param w defines the 4th component of the value
  37445. */
  37446. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37447. /**
  37448. * Apply all cached states (depth, culling, stencil and alpha)
  37449. */
  37450. applyStates(): void;
  37451. /**
  37452. * Enable or disable color writing
  37453. * @param enable defines the state to set
  37454. */
  37455. setColorWrite(enable: boolean): void;
  37456. /**
  37457. * Gets a boolean indicating if color writing is enabled
  37458. * @returns the current color writing state
  37459. */
  37460. getColorWrite(): boolean;
  37461. /**
  37462. * Gets the depth culling state manager
  37463. */
  37464. get depthCullingState(): DepthCullingState;
  37465. /**
  37466. * Gets the alpha state manager
  37467. */
  37468. get alphaState(): AlphaState;
  37469. /**
  37470. * Gets the stencil state manager
  37471. */
  37472. get stencilState(): StencilState;
  37473. /**
  37474. * Clears the list of texture accessible through engine.
  37475. * This can help preventing texture load conflict due to name collision.
  37476. */
  37477. clearInternalTexturesCache(): void;
  37478. /**
  37479. * Force the entire cache to be cleared
  37480. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37481. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37482. */
  37483. wipeCaches(bruteForce?: boolean): void;
  37484. /** @hidden */
  37485. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37486. min: number;
  37487. mag: number;
  37488. };
  37489. /** @hidden */
  37490. _createTexture(): WebGLTexture;
  37491. /**
  37492. * Usually called from Texture.ts.
  37493. * Passed information to create a WebGLTexture
  37494. * @param url defines a value which contains one of the following:
  37495. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37496. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37497. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37498. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37499. * @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)
  37500. * @param scene needed for loading to the correct scene
  37501. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37502. * @param onLoad optional callback to be called upon successful completion
  37503. * @param onError optional callback to be called upon failure
  37504. * @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
  37505. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37506. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37507. * @param forcedExtension defines the extension to use to pick the right loader
  37508. * @param mimeType defines an optional mime type
  37509. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37510. */
  37511. 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;
  37512. /**
  37513. * Loads an image as an HTMLImageElement.
  37514. * @param input url string, ArrayBuffer, or Blob to load
  37515. * @param onLoad callback called when the image successfully loads
  37516. * @param onError callback called when the image fails to load
  37517. * @param offlineProvider offline provider for caching
  37518. * @param mimeType optional mime type
  37519. * @returns the HTMLImageElement of the loaded image
  37520. * @hidden
  37521. */
  37522. 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>;
  37523. /**
  37524. * @hidden
  37525. */
  37526. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37527. private _unpackFlipYCached;
  37528. /**
  37529. * In case you are sharing the context with other applications, it might
  37530. * be interested to not cache the unpack flip y state to ensure a consistent
  37531. * value would be set.
  37532. */
  37533. enableUnpackFlipYCached: boolean;
  37534. /** @hidden */
  37535. _unpackFlipY(value: boolean): void;
  37536. /** @hidden */
  37537. _getUnpackAlignement(): number;
  37538. private _getTextureTarget;
  37539. /**
  37540. * Update the sampling mode of a given texture
  37541. * @param samplingMode defines the required sampling mode
  37542. * @param texture defines the texture to update
  37543. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37544. */
  37545. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37546. /**
  37547. * Update the sampling mode of a given texture
  37548. * @param texture defines the texture to update
  37549. * @param wrapU defines the texture wrap mode of the u coordinates
  37550. * @param wrapV defines the texture wrap mode of the v coordinates
  37551. * @param wrapR defines the texture wrap mode of the r coordinates
  37552. */
  37553. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37554. /** @hidden */
  37555. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37556. width: number;
  37557. height: number;
  37558. layers?: number;
  37559. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37560. /** @hidden */
  37561. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37562. /** @hidden */
  37563. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37564. /**
  37565. * Update a portion of an internal texture
  37566. * @param texture defines the texture to update
  37567. * @param imageData defines the data to store into the texture
  37568. * @param xOffset defines the x coordinates of the update rectangle
  37569. * @param yOffset defines the y coordinates of the update rectangle
  37570. * @param width defines the width of the update rectangle
  37571. * @param height defines the height of the update rectangle
  37572. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37573. * @param lod defines the lod level to update (0 by default)
  37574. */
  37575. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37576. /** @hidden */
  37577. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37578. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37579. private _prepareWebGLTexture;
  37580. /** @hidden */
  37581. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37582. private _getDepthStencilBuffer;
  37583. /** @hidden */
  37584. _releaseFramebufferObjects(texture: InternalTexture): void;
  37585. /** @hidden */
  37586. _releaseTexture(texture: InternalTexture): void;
  37587. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37588. protected _setProgram(program: WebGLProgram): void;
  37589. protected _boundUniforms: {
  37590. [key: number]: WebGLUniformLocation;
  37591. };
  37592. /**
  37593. * Binds an effect to the webGL context
  37594. * @param effect defines the effect to bind
  37595. */
  37596. bindSamplers(effect: Effect): void;
  37597. private _activateCurrentTexture;
  37598. /** @hidden */
  37599. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37600. /** @hidden */
  37601. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37602. /**
  37603. * Unbind all textures from the webGL context
  37604. */
  37605. unbindAllTextures(): void;
  37606. /**
  37607. * Sets a texture to the according uniform.
  37608. * @param channel The texture channel
  37609. * @param uniform The uniform to set
  37610. * @param texture The texture to apply
  37611. */
  37612. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37613. private _bindSamplerUniformToChannel;
  37614. private _getTextureWrapMode;
  37615. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37616. /**
  37617. * Sets an array of texture to the webGL context
  37618. * @param channel defines the channel where the texture array must be set
  37619. * @param uniform defines the associated uniform location
  37620. * @param textures defines the array of textures to bind
  37621. */
  37622. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37623. /** @hidden */
  37624. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37625. private _setTextureParameterFloat;
  37626. private _setTextureParameterInteger;
  37627. /**
  37628. * Unbind all vertex attributes from the webGL context
  37629. */
  37630. unbindAllAttributes(): void;
  37631. /**
  37632. * 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
  37633. */
  37634. releaseEffects(): void;
  37635. /**
  37636. * Dispose and release all associated resources
  37637. */
  37638. dispose(): void;
  37639. /**
  37640. * Attach a new callback raised when context lost event is fired
  37641. * @param callback defines the callback to call
  37642. */
  37643. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37644. /**
  37645. * Attach a new callback raised when context restored event is fired
  37646. * @param callback defines the callback to call
  37647. */
  37648. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37649. /**
  37650. * Get the current error code of the webGL context
  37651. * @returns the error code
  37652. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37653. */
  37654. getError(): number;
  37655. private _canRenderToFloatFramebuffer;
  37656. private _canRenderToHalfFloatFramebuffer;
  37657. private _canRenderToFramebuffer;
  37658. /** @hidden */
  37659. _getWebGLTextureType(type: number): number;
  37660. /** @hidden */
  37661. _getInternalFormat(format: number): number;
  37662. /** @hidden */
  37663. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37664. /** @hidden */
  37665. _getRGBAMultiSampleBufferFormat(type: number): number;
  37666. /** @hidden */
  37667. _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;
  37668. /**
  37669. * Loads a file from a url
  37670. * @param url url to load
  37671. * @param onSuccess callback called when the file successfully loads
  37672. * @param onProgress callback called while file is loading (if the server supports this mode)
  37673. * @param offlineProvider defines the offline provider for caching
  37674. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37675. * @param onError callback called when the file fails to load
  37676. * @returns a file request object
  37677. * @hidden
  37678. */
  37679. 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;
  37680. /**
  37681. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37682. * @param x defines the x coordinate of the rectangle where pixels must be read
  37683. * @param y defines the y coordinate of the rectangle where pixels must be read
  37684. * @param width defines the width of the rectangle where pixels must be read
  37685. * @param height defines the height of the rectangle where pixels must be read
  37686. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37687. * @returns a Uint8Array containing RGBA colors
  37688. */
  37689. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37690. private static _isSupported;
  37691. /**
  37692. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37693. * @returns true if the engine can be created
  37694. * @ignorenaming
  37695. */
  37696. static isSupported(): boolean;
  37697. /**
  37698. * Find the next highest power of two.
  37699. * @param x Number to start search from.
  37700. * @return Next highest power of two.
  37701. */
  37702. static CeilingPOT(x: number): number;
  37703. /**
  37704. * Find the next lowest power of two.
  37705. * @param x Number to start search from.
  37706. * @return Next lowest power of two.
  37707. */
  37708. static FloorPOT(x: number): number;
  37709. /**
  37710. * Find the nearest power of two.
  37711. * @param x Number to start search from.
  37712. * @return Next nearest power of two.
  37713. */
  37714. static NearestPOT(x: number): number;
  37715. /**
  37716. * Get the closest exponent of two
  37717. * @param value defines the value to approximate
  37718. * @param max defines the maximum value to return
  37719. * @param mode defines how to define the closest value
  37720. * @returns closest exponent of two of the given value
  37721. */
  37722. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37723. /**
  37724. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37725. * @param func - the function to be called
  37726. * @param requester - the object that will request the next frame. Falls back to window.
  37727. * @returns frame number
  37728. */
  37729. static QueueNewFrame(func: () => void, requester?: any): number;
  37730. /**
  37731. * Gets host document
  37732. * @returns the host document object
  37733. */
  37734. getHostDocument(): Nullable<Document>;
  37735. }
  37736. }
  37737. declare module "babylonjs/Maths/sphericalPolynomial" {
  37738. import { Vector3 } from "babylonjs/Maths/math.vector";
  37739. import { Color3 } from "babylonjs/Maths/math.color";
  37740. /**
  37741. * Class representing spherical harmonics coefficients to the 3rd degree
  37742. */
  37743. export class SphericalHarmonics {
  37744. /**
  37745. * Defines whether or not the harmonics have been prescaled for rendering.
  37746. */
  37747. preScaled: boolean;
  37748. /**
  37749. * The l0,0 coefficients of the spherical harmonics
  37750. */
  37751. l00: Vector3;
  37752. /**
  37753. * The l1,-1 coefficients of the spherical harmonics
  37754. */
  37755. l1_1: Vector3;
  37756. /**
  37757. * The l1,0 coefficients of the spherical harmonics
  37758. */
  37759. l10: Vector3;
  37760. /**
  37761. * The l1,1 coefficients of the spherical harmonics
  37762. */
  37763. l11: Vector3;
  37764. /**
  37765. * The l2,-2 coefficients of the spherical harmonics
  37766. */
  37767. l2_2: Vector3;
  37768. /**
  37769. * The l2,-1 coefficients of the spherical harmonics
  37770. */
  37771. l2_1: Vector3;
  37772. /**
  37773. * The l2,0 coefficients of the spherical harmonics
  37774. */
  37775. l20: Vector3;
  37776. /**
  37777. * The l2,1 coefficients of the spherical harmonics
  37778. */
  37779. l21: Vector3;
  37780. /**
  37781. * The l2,2 coefficients of the spherical harmonics
  37782. */
  37783. l22: Vector3;
  37784. /**
  37785. * Adds a light to the spherical harmonics
  37786. * @param direction the direction of the light
  37787. * @param color the color of the light
  37788. * @param deltaSolidAngle the delta solid angle of the light
  37789. */
  37790. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37791. /**
  37792. * Scales the spherical harmonics by the given amount
  37793. * @param scale the amount to scale
  37794. */
  37795. scaleInPlace(scale: number): void;
  37796. /**
  37797. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37798. *
  37799. * ```
  37800. * E_lm = A_l * L_lm
  37801. * ```
  37802. *
  37803. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37804. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37805. * the scaling factors are given in equation 9.
  37806. */
  37807. convertIncidentRadianceToIrradiance(): void;
  37808. /**
  37809. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37810. *
  37811. * ```
  37812. * L = (1/pi) * E * rho
  37813. * ```
  37814. *
  37815. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37816. */
  37817. convertIrradianceToLambertianRadiance(): void;
  37818. /**
  37819. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37820. * required operations at run time.
  37821. *
  37822. * This is simply done by scaling back the SH with Ylm constants parameter.
  37823. * The trigonometric part being applied by the shader at run time.
  37824. */
  37825. preScaleForRendering(): void;
  37826. /**
  37827. * Constructs a spherical harmonics from an array.
  37828. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37829. * @returns the spherical harmonics
  37830. */
  37831. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37832. /**
  37833. * Gets the spherical harmonics from polynomial
  37834. * @param polynomial the spherical polynomial
  37835. * @returns the spherical harmonics
  37836. */
  37837. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37838. }
  37839. /**
  37840. * Class representing spherical polynomial coefficients to the 3rd degree
  37841. */
  37842. export class SphericalPolynomial {
  37843. private _harmonics;
  37844. /**
  37845. * The spherical harmonics used to create the polynomials.
  37846. */
  37847. get preScaledHarmonics(): SphericalHarmonics;
  37848. /**
  37849. * The x coefficients of the spherical polynomial
  37850. */
  37851. x: Vector3;
  37852. /**
  37853. * The y coefficients of the spherical polynomial
  37854. */
  37855. y: Vector3;
  37856. /**
  37857. * The z coefficients of the spherical polynomial
  37858. */
  37859. z: Vector3;
  37860. /**
  37861. * The xx coefficients of the spherical polynomial
  37862. */
  37863. xx: Vector3;
  37864. /**
  37865. * The yy coefficients of the spherical polynomial
  37866. */
  37867. yy: Vector3;
  37868. /**
  37869. * The zz coefficients of the spherical polynomial
  37870. */
  37871. zz: Vector3;
  37872. /**
  37873. * The xy coefficients of the spherical polynomial
  37874. */
  37875. xy: Vector3;
  37876. /**
  37877. * The yz coefficients of the spherical polynomial
  37878. */
  37879. yz: Vector3;
  37880. /**
  37881. * The zx coefficients of the spherical polynomial
  37882. */
  37883. zx: Vector3;
  37884. /**
  37885. * Adds an ambient color to the spherical polynomial
  37886. * @param color the color to add
  37887. */
  37888. addAmbient(color: Color3): void;
  37889. /**
  37890. * Scales the spherical polynomial by the given amount
  37891. * @param scale the amount to scale
  37892. */
  37893. scaleInPlace(scale: number): void;
  37894. /**
  37895. * Gets the spherical polynomial from harmonics
  37896. * @param harmonics the spherical harmonics
  37897. * @returns the spherical polynomial
  37898. */
  37899. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37900. /**
  37901. * Constructs a spherical polynomial from an array.
  37902. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37903. * @returns the spherical polynomial
  37904. */
  37905. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37906. }
  37907. }
  37908. declare module "babylonjs/Materials/Textures/internalTexture" {
  37909. import { Observable } from "babylonjs/Misc/observable";
  37910. import { Nullable, int } from "babylonjs/types";
  37911. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37912. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37913. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37914. /**
  37915. * Defines the source of the internal texture
  37916. */
  37917. export enum InternalTextureSource {
  37918. /**
  37919. * The source of the texture data is unknown
  37920. */
  37921. Unknown = 0,
  37922. /**
  37923. * Texture data comes from an URL
  37924. */
  37925. Url = 1,
  37926. /**
  37927. * Texture data is only used for temporary storage
  37928. */
  37929. Temp = 2,
  37930. /**
  37931. * Texture data comes from raw data (ArrayBuffer)
  37932. */
  37933. Raw = 3,
  37934. /**
  37935. * Texture content is dynamic (video or dynamic texture)
  37936. */
  37937. Dynamic = 4,
  37938. /**
  37939. * Texture content is generated by rendering to it
  37940. */
  37941. RenderTarget = 5,
  37942. /**
  37943. * Texture content is part of a multi render target process
  37944. */
  37945. MultiRenderTarget = 6,
  37946. /**
  37947. * Texture data comes from a cube data file
  37948. */
  37949. Cube = 7,
  37950. /**
  37951. * Texture data comes from a raw cube data
  37952. */
  37953. CubeRaw = 8,
  37954. /**
  37955. * Texture data come from a prefiltered cube data file
  37956. */
  37957. CubePrefiltered = 9,
  37958. /**
  37959. * Texture content is raw 3D data
  37960. */
  37961. Raw3D = 10,
  37962. /**
  37963. * Texture content is raw 2D array data
  37964. */
  37965. Raw2DArray = 11,
  37966. /**
  37967. * Texture content is a depth texture
  37968. */
  37969. Depth = 12,
  37970. /**
  37971. * Texture data comes from a raw cube data encoded with RGBD
  37972. */
  37973. CubeRawRGBD = 13
  37974. }
  37975. /**
  37976. * Class used to store data associated with WebGL texture data for the engine
  37977. * This class should not be used directly
  37978. */
  37979. export class InternalTexture {
  37980. /** @hidden */
  37981. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37982. /**
  37983. * Defines if the texture is ready
  37984. */
  37985. isReady: boolean;
  37986. /**
  37987. * Defines if the texture is a cube texture
  37988. */
  37989. isCube: boolean;
  37990. /**
  37991. * Defines if the texture contains 3D data
  37992. */
  37993. is3D: boolean;
  37994. /**
  37995. * Defines if the texture contains 2D array data
  37996. */
  37997. is2DArray: boolean;
  37998. /**
  37999. * Defines if the texture contains multiview data
  38000. */
  38001. isMultiview: boolean;
  38002. /**
  38003. * Gets the URL used to load this texture
  38004. */
  38005. url: string;
  38006. /**
  38007. * Gets the sampling mode of the texture
  38008. */
  38009. samplingMode: number;
  38010. /**
  38011. * Gets a boolean indicating if the texture needs mipmaps generation
  38012. */
  38013. generateMipMaps: boolean;
  38014. /**
  38015. * Gets the number of samples used by the texture (WebGL2+ only)
  38016. */
  38017. samples: number;
  38018. /**
  38019. * Gets the type of the texture (int, float...)
  38020. */
  38021. type: number;
  38022. /**
  38023. * Gets the format of the texture (RGB, RGBA...)
  38024. */
  38025. format: number;
  38026. /**
  38027. * Observable called when the texture is loaded
  38028. */
  38029. onLoadedObservable: Observable<InternalTexture>;
  38030. /**
  38031. * Gets the width of the texture
  38032. */
  38033. width: number;
  38034. /**
  38035. * Gets the height of the texture
  38036. */
  38037. height: number;
  38038. /**
  38039. * Gets the depth of the texture
  38040. */
  38041. depth: number;
  38042. /**
  38043. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  38044. */
  38045. baseWidth: number;
  38046. /**
  38047. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  38048. */
  38049. baseHeight: number;
  38050. /**
  38051. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  38052. */
  38053. baseDepth: number;
  38054. /**
  38055. * Gets a boolean indicating if the texture is inverted on Y axis
  38056. */
  38057. invertY: boolean;
  38058. /** @hidden */
  38059. _invertVScale: boolean;
  38060. /** @hidden */
  38061. _associatedChannel: number;
  38062. /** @hidden */
  38063. _source: InternalTextureSource;
  38064. /** @hidden */
  38065. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  38066. /** @hidden */
  38067. _bufferView: Nullable<ArrayBufferView>;
  38068. /** @hidden */
  38069. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38070. /** @hidden */
  38071. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38072. /** @hidden */
  38073. _size: number;
  38074. /** @hidden */
  38075. _extension: string;
  38076. /** @hidden */
  38077. _files: Nullable<string[]>;
  38078. /** @hidden */
  38079. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38080. /** @hidden */
  38081. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38082. /** @hidden */
  38083. _framebuffer: Nullable<WebGLFramebuffer>;
  38084. /** @hidden */
  38085. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38086. /** @hidden */
  38087. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38088. /** @hidden */
  38089. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38090. /** @hidden */
  38091. _attachments: Nullable<number[]>;
  38092. /** @hidden */
  38093. _textureArray: Nullable<InternalTexture[]>;
  38094. /** @hidden */
  38095. _cachedCoordinatesMode: Nullable<number>;
  38096. /** @hidden */
  38097. _cachedWrapU: Nullable<number>;
  38098. /** @hidden */
  38099. _cachedWrapV: Nullable<number>;
  38100. /** @hidden */
  38101. _cachedWrapR: Nullable<number>;
  38102. /** @hidden */
  38103. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38104. /** @hidden */
  38105. _isDisabled: boolean;
  38106. /** @hidden */
  38107. _compression: Nullable<string>;
  38108. /** @hidden */
  38109. _generateStencilBuffer: boolean;
  38110. /** @hidden */
  38111. _generateDepthBuffer: boolean;
  38112. /** @hidden */
  38113. _comparisonFunction: number;
  38114. /** @hidden */
  38115. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38116. /** @hidden */
  38117. _lodGenerationScale: number;
  38118. /** @hidden */
  38119. _lodGenerationOffset: number;
  38120. /** @hidden */
  38121. _depthStencilTexture: Nullable<InternalTexture>;
  38122. /** @hidden */
  38123. _colorTextureArray: Nullable<WebGLTexture>;
  38124. /** @hidden */
  38125. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38126. /** @hidden */
  38127. _lodTextureHigh: Nullable<BaseTexture>;
  38128. /** @hidden */
  38129. _lodTextureMid: Nullable<BaseTexture>;
  38130. /** @hidden */
  38131. _lodTextureLow: Nullable<BaseTexture>;
  38132. /** @hidden */
  38133. _isRGBD: boolean;
  38134. /** @hidden */
  38135. _linearSpecularLOD: boolean;
  38136. /** @hidden */
  38137. _irradianceTexture: Nullable<BaseTexture>;
  38138. /** @hidden */
  38139. _webGLTexture: Nullable<WebGLTexture>;
  38140. /** @hidden */
  38141. _references: number;
  38142. /** @hidden */
  38143. _gammaSpace: Nullable<boolean>;
  38144. private _engine;
  38145. /**
  38146. * Gets the Engine the texture belongs to.
  38147. * @returns The babylon engine
  38148. */
  38149. getEngine(): ThinEngine;
  38150. /**
  38151. * Gets the data source type of the texture
  38152. */
  38153. get source(): InternalTextureSource;
  38154. /**
  38155. * Creates a new InternalTexture
  38156. * @param engine defines the engine to use
  38157. * @param source defines the type of data that will be used
  38158. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38159. */
  38160. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38161. /**
  38162. * Increments the number of references (ie. the number of Texture that point to it)
  38163. */
  38164. incrementReferences(): void;
  38165. /**
  38166. * Change the size of the texture (not the size of the content)
  38167. * @param width defines the new width
  38168. * @param height defines the new height
  38169. * @param depth defines the new depth (1 by default)
  38170. */
  38171. updateSize(width: int, height: int, depth?: int): void;
  38172. /** @hidden */
  38173. _rebuild(): void;
  38174. /** @hidden */
  38175. _swapAndDie(target: InternalTexture): void;
  38176. /**
  38177. * Dispose the current allocated resources
  38178. */
  38179. dispose(): void;
  38180. }
  38181. }
  38182. declare module "babylonjs/Audio/analyser" {
  38183. import { Scene } from "babylonjs/scene";
  38184. /**
  38185. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38186. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38187. */
  38188. export class Analyser {
  38189. /**
  38190. * Gets or sets the smoothing
  38191. * @ignorenaming
  38192. */
  38193. SMOOTHING: number;
  38194. /**
  38195. * Gets or sets the FFT table size
  38196. * @ignorenaming
  38197. */
  38198. FFT_SIZE: number;
  38199. /**
  38200. * Gets or sets the bar graph amplitude
  38201. * @ignorenaming
  38202. */
  38203. BARGRAPHAMPLITUDE: number;
  38204. /**
  38205. * Gets or sets the position of the debug canvas
  38206. * @ignorenaming
  38207. */
  38208. DEBUGCANVASPOS: {
  38209. x: number;
  38210. y: number;
  38211. };
  38212. /**
  38213. * Gets or sets the debug canvas size
  38214. * @ignorenaming
  38215. */
  38216. DEBUGCANVASSIZE: {
  38217. width: number;
  38218. height: number;
  38219. };
  38220. private _byteFreqs;
  38221. private _byteTime;
  38222. private _floatFreqs;
  38223. private _webAudioAnalyser;
  38224. private _debugCanvas;
  38225. private _debugCanvasContext;
  38226. private _scene;
  38227. private _registerFunc;
  38228. private _audioEngine;
  38229. /**
  38230. * Creates a new analyser
  38231. * @param scene defines hosting scene
  38232. */
  38233. constructor(scene: Scene);
  38234. /**
  38235. * Get the number of data values you will have to play with for the visualization
  38236. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38237. * @returns a number
  38238. */
  38239. getFrequencyBinCount(): number;
  38240. /**
  38241. * Gets the current frequency data as a byte array
  38242. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38243. * @returns a Uint8Array
  38244. */
  38245. getByteFrequencyData(): Uint8Array;
  38246. /**
  38247. * Gets the current waveform as a byte array
  38248. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38249. * @returns a Uint8Array
  38250. */
  38251. getByteTimeDomainData(): Uint8Array;
  38252. /**
  38253. * Gets the current frequency data as a float array
  38254. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38255. * @returns a Float32Array
  38256. */
  38257. getFloatFrequencyData(): Float32Array;
  38258. /**
  38259. * Renders the debug canvas
  38260. */
  38261. drawDebugCanvas(): void;
  38262. /**
  38263. * Stops rendering the debug canvas and removes it
  38264. */
  38265. stopDebugCanvas(): void;
  38266. /**
  38267. * Connects two audio nodes
  38268. * @param inputAudioNode defines first node to connect
  38269. * @param outputAudioNode defines second node to connect
  38270. */
  38271. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38272. /**
  38273. * Releases all associated resources
  38274. */
  38275. dispose(): void;
  38276. }
  38277. }
  38278. declare module "babylonjs/Audio/audioEngine" {
  38279. import { IDisposable } from "babylonjs/scene";
  38280. import { Analyser } from "babylonjs/Audio/analyser";
  38281. import { Nullable } from "babylonjs/types";
  38282. import { Observable } from "babylonjs/Misc/observable";
  38283. /**
  38284. * This represents an audio engine and it is responsible
  38285. * to play, synchronize and analyse sounds throughout the application.
  38286. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38287. */
  38288. export interface IAudioEngine extends IDisposable {
  38289. /**
  38290. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38291. */
  38292. readonly canUseWebAudio: boolean;
  38293. /**
  38294. * Gets the current AudioContext if available.
  38295. */
  38296. readonly audioContext: Nullable<AudioContext>;
  38297. /**
  38298. * The master gain node defines the global audio volume of your audio engine.
  38299. */
  38300. readonly masterGain: GainNode;
  38301. /**
  38302. * Gets whether or not mp3 are supported by your browser.
  38303. */
  38304. readonly isMP3supported: boolean;
  38305. /**
  38306. * Gets whether or not ogg are supported by your browser.
  38307. */
  38308. readonly isOGGsupported: boolean;
  38309. /**
  38310. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38311. * @ignoreNaming
  38312. */
  38313. WarnedWebAudioUnsupported: boolean;
  38314. /**
  38315. * Defines if the audio engine relies on a custom unlocked button.
  38316. * In this case, the embedded button will not be displayed.
  38317. */
  38318. useCustomUnlockedButton: boolean;
  38319. /**
  38320. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38321. */
  38322. readonly unlocked: boolean;
  38323. /**
  38324. * Event raised when audio has been unlocked on the browser.
  38325. */
  38326. onAudioUnlockedObservable: Observable<AudioEngine>;
  38327. /**
  38328. * Event raised when audio has been locked on the browser.
  38329. */
  38330. onAudioLockedObservable: Observable<AudioEngine>;
  38331. /**
  38332. * Flags the audio engine in Locked state.
  38333. * This happens due to new browser policies preventing audio to autoplay.
  38334. */
  38335. lock(): void;
  38336. /**
  38337. * Unlocks the audio engine once a user action has been done on the dom.
  38338. * This is helpful to resume play once browser policies have been satisfied.
  38339. */
  38340. unlock(): void;
  38341. /**
  38342. * Gets the global volume sets on the master gain.
  38343. * @returns the global volume if set or -1 otherwise
  38344. */
  38345. getGlobalVolume(): number;
  38346. /**
  38347. * Sets the global volume of your experience (sets on the master gain).
  38348. * @param newVolume Defines the new global volume of the application
  38349. */
  38350. setGlobalVolume(newVolume: number): void;
  38351. /**
  38352. * Connect the audio engine to an audio analyser allowing some amazing
  38353. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38354. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38355. * @param analyser The analyser to connect to the engine
  38356. */
  38357. connectToAnalyser(analyser: Analyser): void;
  38358. }
  38359. /**
  38360. * This represents the default audio engine used in babylon.
  38361. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38362. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38363. */
  38364. export class AudioEngine implements IAudioEngine {
  38365. private _audioContext;
  38366. private _audioContextInitialized;
  38367. private _muteButton;
  38368. private _hostElement;
  38369. /**
  38370. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38371. */
  38372. canUseWebAudio: boolean;
  38373. /**
  38374. * The master gain node defines the global audio volume of your audio engine.
  38375. */
  38376. masterGain: GainNode;
  38377. /**
  38378. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38379. * @ignoreNaming
  38380. */
  38381. WarnedWebAudioUnsupported: boolean;
  38382. /**
  38383. * Gets whether or not mp3 are supported by your browser.
  38384. */
  38385. isMP3supported: boolean;
  38386. /**
  38387. * Gets whether or not ogg are supported by your browser.
  38388. */
  38389. isOGGsupported: boolean;
  38390. /**
  38391. * Gets whether audio has been unlocked on the device.
  38392. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38393. * a user interaction has happened.
  38394. */
  38395. unlocked: boolean;
  38396. /**
  38397. * Defines if the audio engine relies on a custom unlocked button.
  38398. * In this case, the embedded button will not be displayed.
  38399. */
  38400. useCustomUnlockedButton: boolean;
  38401. /**
  38402. * Event raised when audio has been unlocked on the browser.
  38403. */
  38404. onAudioUnlockedObservable: Observable<AudioEngine>;
  38405. /**
  38406. * Event raised when audio has been locked on the browser.
  38407. */
  38408. onAudioLockedObservable: Observable<AudioEngine>;
  38409. /**
  38410. * Gets the current AudioContext if available.
  38411. */
  38412. get audioContext(): Nullable<AudioContext>;
  38413. private _connectedAnalyser;
  38414. /**
  38415. * Instantiates a new audio engine.
  38416. *
  38417. * There should be only one per page as some browsers restrict the number
  38418. * of audio contexts you can create.
  38419. * @param hostElement defines the host element where to display the mute icon if necessary
  38420. */
  38421. constructor(hostElement?: Nullable<HTMLElement>);
  38422. /**
  38423. * Flags the audio engine in Locked state.
  38424. * This happens due to new browser policies preventing audio to autoplay.
  38425. */
  38426. lock(): void;
  38427. /**
  38428. * Unlocks the audio engine once a user action has been done on the dom.
  38429. * This is helpful to resume play once browser policies have been satisfied.
  38430. */
  38431. unlock(): void;
  38432. private _resumeAudioContext;
  38433. private _initializeAudioContext;
  38434. private _tryToRun;
  38435. private _triggerRunningState;
  38436. private _triggerSuspendedState;
  38437. private _displayMuteButton;
  38438. private _moveButtonToTopLeft;
  38439. private _onResize;
  38440. private _hideMuteButton;
  38441. /**
  38442. * Destroy and release the resources associated with the audio ccontext.
  38443. */
  38444. dispose(): void;
  38445. /**
  38446. * Gets the global volume sets on the master gain.
  38447. * @returns the global volume if set or -1 otherwise
  38448. */
  38449. getGlobalVolume(): number;
  38450. /**
  38451. * Sets the global volume of your experience (sets on the master gain).
  38452. * @param newVolume Defines the new global volume of the application
  38453. */
  38454. setGlobalVolume(newVolume: number): void;
  38455. /**
  38456. * Connect the audio engine to an audio analyser allowing some amazing
  38457. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38458. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38459. * @param analyser The analyser to connect to the engine
  38460. */
  38461. connectToAnalyser(analyser: Analyser): void;
  38462. }
  38463. }
  38464. declare module "babylonjs/Loading/loadingScreen" {
  38465. /**
  38466. * Interface used to present a loading screen while loading a scene
  38467. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38468. */
  38469. export interface ILoadingScreen {
  38470. /**
  38471. * Function called to display the loading screen
  38472. */
  38473. displayLoadingUI: () => void;
  38474. /**
  38475. * Function called to hide the loading screen
  38476. */
  38477. hideLoadingUI: () => void;
  38478. /**
  38479. * Gets or sets the color to use for the background
  38480. */
  38481. loadingUIBackgroundColor: string;
  38482. /**
  38483. * Gets or sets the text to display while loading
  38484. */
  38485. loadingUIText: string;
  38486. }
  38487. /**
  38488. * Class used for the default loading screen
  38489. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38490. */
  38491. export class DefaultLoadingScreen implements ILoadingScreen {
  38492. private _renderingCanvas;
  38493. private _loadingText;
  38494. private _loadingDivBackgroundColor;
  38495. private _loadingDiv;
  38496. private _loadingTextDiv;
  38497. /** Gets or sets the logo url to use for the default loading screen */
  38498. static DefaultLogoUrl: string;
  38499. /** Gets or sets the spinner url to use for the default loading screen */
  38500. static DefaultSpinnerUrl: string;
  38501. /**
  38502. * Creates a new default loading screen
  38503. * @param _renderingCanvas defines the canvas used to render the scene
  38504. * @param _loadingText defines the default text to display
  38505. * @param _loadingDivBackgroundColor defines the default background color
  38506. */
  38507. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38508. /**
  38509. * Function called to display the loading screen
  38510. */
  38511. displayLoadingUI(): void;
  38512. /**
  38513. * Function called to hide the loading screen
  38514. */
  38515. hideLoadingUI(): void;
  38516. /**
  38517. * Gets or sets the text to display while loading
  38518. */
  38519. set loadingUIText(text: string);
  38520. get loadingUIText(): string;
  38521. /**
  38522. * Gets or sets the color to use for the background
  38523. */
  38524. get loadingUIBackgroundColor(): string;
  38525. set loadingUIBackgroundColor(color: string);
  38526. private _resizeLoadingUI;
  38527. }
  38528. }
  38529. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38530. /**
  38531. * Interface for any object that can request an animation frame
  38532. */
  38533. export interface ICustomAnimationFrameRequester {
  38534. /**
  38535. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38536. */
  38537. renderFunction?: Function;
  38538. /**
  38539. * Called to request the next frame to render to
  38540. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38541. */
  38542. requestAnimationFrame: Function;
  38543. /**
  38544. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38545. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38546. */
  38547. requestID?: number;
  38548. }
  38549. }
  38550. declare module "babylonjs/Misc/performanceMonitor" {
  38551. /**
  38552. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38553. */
  38554. export class PerformanceMonitor {
  38555. private _enabled;
  38556. private _rollingFrameTime;
  38557. private _lastFrameTimeMs;
  38558. /**
  38559. * constructor
  38560. * @param frameSampleSize The number of samples required to saturate the sliding window
  38561. */
  38562. constructor(frameSampleSize?: number);
  38563. /**
  38564. * Samples current frame
  38565. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38566. */
  38567. sampleFrame(timeMs?: number): void;
  38568. /**
  38569. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38570. */
  38571. get averageFrameTime(): number;
  38572. /**
  38573. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38574. */
  38575. get averageFrameTimeVariance(): number;
  38576. /**
  38577. * Returns the frame time of the most recent frame
  38578. */
  38579. get instantaneousFrameTime(): number;
  38580. /**
  38581. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38582. */
  38583. get averageFPS(): number;
  38584. /**
  38585. * Returns the average framerate in frames per second using the most recent frame time
  38586. */
  38587. get instantaneousFPS(): number;
  38588. /**
  38589. * Returns true if enough samples have been taken to completely fill the sliding window
  38590. */
  38591. get isSaturated(): boolean;
  38592. /**
  38593. * Enables contributions to the sliding window sample set
  38594. */
  38595. enable(): void;
  38596. /**
  38597. * Disables contributions to the sliding window sample set
  38598. * Samples will not be interpolated over the disabled period
  38599. */
  38600. disable(): void;
  38601. /**
  38602. * Returns true if sampling is enabled
  38603. */
  38604. get isEnabled(): boolean;
  38605. /**
  38606. * Resets performance monitor
  38607. */
  38608. reset(): void;
  38609. }
  38610. /**
  38611. * RollingAverage
  38612. *
  38613. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38614. */
  38615. export class RollingAverage {
  38616. /**
  38617. * Current average
  38618. */
  38619. average: number;
  38620. /**
  38621. * Current variance
  38622. */
  38623. variance: number;
  38624. protected _samples: Array<number>;
  38625. protected _sampleCount: number;
  38626. protected _pos: number;
  38627. protected _m2: number;
  38628. /**
  38629. * constructor
  38630. * @param length The number of samples required to saturate the sliding window
  38631. */
  38632. constructor(length: number);
  38633. /**
  38634. * Adds a sample to the sample set
  38635. * @param v The sample value
  38636. */
  38637. add(v: number): void;
  38638. /**
  38639. * Returns previously added values or null if outside of history or outside the sliding window domain
  38640. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38641. * @return Value previously recorded with add() or null if outside of range
  38642. */
  38643. history(i: number): number;
  38644. /**
  38645. * Returns true if enough samples have been taken to completely fill the sliding window
  38646. * @return true if sample-set saturated
  38647. */
  38648. isSaturated(): boolean;
  38649. /**
  38650. * Resets the rolling average (equivalent to 0 samples taken so far)
  38651. */
  38652. reset(): void;
  38653. /**
  38654. * Wraps a value around the sample range boundaries
  38655. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38656. * @return Wrapped position in sample range
  38657. */
  38658. protected _wrapPosition(i: number): number;
  38659. }
  38660. }
  38661. declare module "babylonjs/Misc/perfCounter" {
  38662. /**
  38663. * This class is used to track a performance counter which is number based.
  38664. * The user has access to many properties which give statistics of different nature.
  38665. *
  38666. * The implementer can track two kinds of Performance Counter: time and count.
  38667. * 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.
  38668. * 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.
  38669. */
  38670. export class PerfCounter {
  38671. /**
  38672. * Gets or sets a global boolean to turn on and off all the counters
  38673. */
  38674. static Enabled: boolean;
  38675. /**
  38676. * Returns the smallest value ever
  38677. */
  38678. get min(): number;
  38679. /**
  38680. * Returns the biggest value ever
  38681. */
  38682. get max(): number;
  38683. /**
  38684. * Returns the average value since the performance counter is running
  38685. */
  38686. get average(): number;
  38687. /**
  38688. * Returns the average value of the last second the counter was monitored
  38689. */
  38690. get lastSecAverage(): number;
  38691. /**
  38692. * Returns the current value
  38693. */
  38694. get current(): number;
  38695. /**
  38696. * Gets the accumulated total
  38697. */
  38698. get total(): number;
  38699. /**
  38700. * Gets the total value count
  38701. */
  38702. get count(): number;
  38703. /**
  38704. * Creates a new counter
  38705. */
  38706. constructor();
  38707. /**
  38708. * Call this method to start monitoring a new frame.
  38709. * 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.
  38710. */
  38711. fetchNewFrame(): void;
  38712. /**
  38713. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38714. * @param newCount the count value to add to the monitored count
  38715. * @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.
  38716. */
  38717. addCount(newCount: number, fetchResult: boolean): void;
  38718. /**
  38719. * Start monitoring this performance counter
  38720. */
  38721. beginMonitoring(): void;
  38722. /**
  38723. * Compute the time lapsed since the previous beginMonitoring() call.
  38724. * @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
  38725. */
  38726. endMonitoring(newFrame?: boolean): void;
  38727. private _fetchResult;
  38728. private _startMonitoringTime;
  38729. private _min;
  38730. private _max;
  38731. private _average;
  38732. private _current;
  38733. private _totalValueCount;
  38734. private _totalAccumulated;
  38735. private _lastSecAverage;
  38736. private _lastSecAccumulated;
  38737. private _lastSecTime;
  38738. private _lastSecValueCount;
  38739. }
  38740. }
  38741. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38743. import { Nullable } from "babylonjs/types";
  38744. module "babylonjs/Engines/thinEngine" {
  38745. interface ThinEngine {
  38746. /** @hidden */
  38747. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38748. }
  38749. }
  38750. }
  38751. declare module "babylonjs/Engines/engine" {
  38752. import { Observable } from "babylonjs/Misc/observable";
  38753. import { Nullable } from "babylonjs/types";
  38754. import { Scene } from "babylonjs/scene";
  38755. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38756. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38757. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38758. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38759. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38760. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38761. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38762. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38763. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38764. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38765. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38766. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38767. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38768. import "babylonjs/Engines/Extensions/engine.alpha";
  38769. import "babylonjs/Engines/Extensions/engine.readTexture";
  38770. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38771. import { Material } from "babylonjs/Materials/material";
  38772. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38773. /**
  38774. * Defines the interface used by display changed events
  38775. */
  38776. export interface IDisplayChangedEventArgs {
  38777. /** Gets the vrDisplay object (if any) */
  38778. vrDisplay: Nullable<any>;
  38779. /** Gets a boolean indicating if webVR is supported */
  38780. vrSupported: boolean;
  38781. }
  38782. /**
  38783. * Defines the interface used by objects containing a viewport (like a camera)
  38784. */
  38785. interface IViewportOwnerLike {
  38786. /**
  38787. * Gets or sets the viewport
  38788. */
  38789. viewport: IViewportLike;
  38790. }
  38791. /**
  38792. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38793. */
  38794. export class Engine extends ThinEngine {
  38795. /** Defines that alpha blending is disabled */
  38796. static readonly ALPHA_DISABLE: number;
  38797. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38798. static readonly ALPHA_ADD: number;
  38799. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38800. static readonly ALPHA_COMBINE: number;
  38801. /** Defines that alpha blending to DEST - SRC * DEST */
  38802. static readonly ALPHA_SUBTRACT: number;
  38803. /** Defines that alpha blending to SRC * DEST */
  38804. static readonly ALPHA_MULTIPLY: number;
  38805. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38806. static readonly ALPHA_MAXIMIZED: number;
  38807. /** Defines that alpha blending to SRC + DEST */
  38808. static readonly ALPHA_ONEONE: number;
  38809. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38810. static readonly ALPHA_PREMULTIPLIED: number;
  38811. /**
  38812. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38813. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38814. */
  38815. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38816. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38817. static readonly ALPHA_INTERPOLATE: number;
  38818. /**
  38819. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38820. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38821. */
  38822. static readonly ALPHA_SCREENMODE: number;
  38823. /** Defines that the ressource is not delayed*/
  38824. static readonly DELAYLOADSTATE_NONE: number;
  38825. /** Defines that the ressource was successfully delay loaded */
  38826. static readonly DELAYLOADSTATE_LOADED: number;
  38827. /** Defines that the ressource is currently delay loading */
  38828. static readonly DELAYLOADSTATE_LOADING: number;
  38829. /** Defines that the ressource is delayed and has not started loading */
  38830. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38831. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38832. static readonly NEVER: number;
  38833. /** 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 */
  38834. static readonly ALWAYS: number;
  38835. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38836. static readonly LESS: number;
  38837. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38838. static readonly EQUAL: number;
  38839. /** 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 */
  38840. static readonly LEQUAL: number;
  38841. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38842. static readonly GREATER: number;
  38843. /** 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 */
  38844. static readonly GEQUAL: number;
  38845. /** 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 */
  38846. static readonly NOTEQUAL: number;
  38847. /** Passed to stencilOperation to specify that stencil value must be kept */
  38848. static readonly KEEP: number;
  38849. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38850. static readonly REPLACE: number;
  38851. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38852. static readonly INCR: number;
  38853. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38854. static readonly DECR: number;
  38855. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38856. static readonly INVERT: number;
  38857. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38858. static readonly INCR_WRAP: number;
  38859. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38860. static readonly DECR_WRAP: number;
  38861. /** Texture is not repeating outside of 0..1 UVs */
  38862. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38863. /** Texture is repeating outside of 0..1 UVs */
  38864. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38865. /** Texture is repeating and mirrored */
  38866. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38867. /** ALPHA */
  38868. static readonly TEXTUREFORMAT_ALPHA: number;
  38869. /** LUMINANCE */
  38870. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38871. /** LUMINANCE_ALPHA */
  38872. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38873. /** RGB */
  38874. static readonly TEXTUREFORMAT_RGB: number;
  38875. /** RGBA */
  38876. static readonly TEXTUREFORMAT_RGBA: number;
  38877. /** RED */
  38878. static readonly TEXTUREFORMAT_RED: number;
  38879. /** RED (2nd reference) */
  38880. static readonly TEXTUREFORMAT_R: number;
  38881. /** RG */
  38882. static readonly TEXTUREFORMAT_RG: number;
  38883. /** RED_INTEGER */
  38884. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38885. /** RED_INTEGER (2nd reference) */
  38886. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38887. /** RG_INTEGER */
  38888. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38889. /** RGB_INTEGER */
  38890. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38891. /** RGBA_INTEGER */
  38892. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38893. /** UNSIGNED_BYTE */
  38894. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38895. /** UNSIGNED_BYTE (2nd reference) */
  38896. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38897. /** FLOAT */
  38898. static readonly TEXTURETYPE_FLOAT: number;
  38899. /** HALF_FLOAT */
  38900. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38901. /** BYTE */
  38902. static readonly TEXTURETYPE_BYTE: number;
  38903. /** SHORT */
  38904. static readonly TEXTURETYPE_SHORT: number;
  38905. /** UNSIGNED_SHORT */
  38906. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38907. /** INT */
  38908. static readonly TEXTURETYPE_INT: number;
  38909. /** UNSIGNED_INT */
  38910. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38911. /** UNSIGNED_SHORT_4_4_4_4 */
  38912. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38913. /** UNSIGNED_SHORT_5_5_5_1 */
  38914. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38915. /** UNSIGNED_SHORT_5_6_5 */
  38916. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38917. /** UNSIGNED_INT_2_10_10_10_REV */
  38918. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38919. /** UNSIGNED_INT_24_8 */
  38920. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38921. /** UNSIGNED_INT_10F_11F_11F_REV */
  38922. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38923. /** UNSIGNED_INT_5_9_9_9_REV */
  38924. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38925. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38926. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38927. /** nearest is mag = nearest and min = nearest and mip = linear */
  38928. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38929. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38930. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38931. /** Trilinear is mag = linear and min = linear and mip = linear */
  38932. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38933. /** nearest is mag = nearest and min = nearest and mip = linear */
  38934. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38935. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38936. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38937. /** Trilinear is mag = linear and min = linear and mip = linear */
  38938. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38939. /** mag = nearest and min = nearest and mip = nearest */
  38940. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38941. /** mag = nearest and min = linear and mip = nearest */
  38942. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38943. /** mag = nearest and min = linear and mip = linear */
  38944. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38945. /** mag = nearest and min = linear and mip = none */
  38946. static readonly TEXTURE_NEAREST_LINEAR: number;
  38947. /** mag = nearest and min = nearest and mip = none */
  38948. static readonly TEXTURE_NEAREST_NEAREST: number;
  38949. /** mag = linear and min = nearest and mip = nearest */
  38950. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38951. /** mag = linear and min = nearest and mip = linear */
  38952. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38953. /** mag = linear and min = linear and mip = none */
  38954. static readonly TEXTURE_LINEAR_LINEAR: number;
  38955. /** mag = linear and min = nearest and mip = none */
  38956. static readonly TEXTURE_LINEAR_NEAREST: number;
  38957. /** Explicit coordinates mode */
  38958. static readonly TEXTURE_EXPLICIT_MODE: number;
  38959. /** Spherical coordinates mode */
  38960. static readonly TEXTURE_SPHERICAL_MODE: number;
  38961. /** Planar coordinates mode */
  38962. static readonly TEXTURE_PLANAR_MODE: number;
  38963. /** Cubic coordinates mode */
  38964. static readonly TEXTURE_CUBIC_MODE: number;
  38965. /** Projection coordinates mode */
  38966. static readonly TEXTURE_PROJECTION_MODE: number;
  38967. /** Skybox coordinates mode */
  38968. static readonly TEXTURE_SKYBOX_MODE: number;
  38969. /** Inverse Cubic coordinates mode */
  38970. static readonly TEXTURE_INVCUBIC_MODE: number;
  38971. /** Equirectangular coordinates mode */
  38972. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38973. /** Equirectangular Fixed coordinates mode */
  38974. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38975. /** Equirectangular Fixed Mirrored coordinates mode */
  38976. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38977. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38978. static readonly SCALEMODE_FLOOR: number;
  38979. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38980. static readonly SCALEMODE_NEAREST: number;
  38981. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38982. static readonly SCALEMODE_CEILING: number;
  38983. /**
  38984. * Returns the current npm package of the sdk
  38985. */
  38986. static get NpmPackage(): string;
  38987. /**
  38988. * Returns the current version of the framework
  38989. */
  38990. static get Version(): string;
  38991. /** Gets the list of created engines */
  38992. static get Instances(): Engine[];
  38993. /**
  38994. * Gets the latest created engine
  38995. */
  38996. static get LastCreatedEngine(): Nullable<Engine>;
  38997. /**
  38998. * Gets the latest created scene
  38999. */
  39000. static get LastCreatedScene(): Nullable<Scene>;
  39001. /**
  39002. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  39003. * @param flag defines which part of the materials must be marked as dirty
  39004. * @param predicate defines a predicate used to filter which materials should be affected
  39005. */
  39006. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39007. /**
  39008. * Method called to create the default loading screen.
  39009. * This can be overriden in your own app.
  39010. * @param canvas The rendering canvas element
  39011. * @returns The loading screen
  39012. */
  39013. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  39014. /**
  39015. * Method called to create the default rescale post process on each engine.
  39016. */
  39017. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  39018. /**
  39019. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  39020. **/
  39021. enableOfflineSupport: boolean;
  39022. /**
  39023. * 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)
  39024. **/
  39025. disableManifestCheck: boolean;
  39026. /**
  39027. * Gets the list of created scenes
  39028. */
  39029. scenes: Scene[];
  39030. /**
  39031. * Event raised when a new scene is created
  39032. */
  39033. onNewSceneAddedObservable: Observable<Scene>;
  39034. /**
  39035. * Gets the list of created postprocesses
  39036. */
  39037. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  39038. /**
  39039. * Gets a boolean indicating if the pointer is currently locked
  39040. */
  39041. isPointerLock: boolean;
  39042. /**
  39043. * Observable event triggered each time the rendering canvas is resized
  39044. */
  39045. onResizeObservable: Observable<Engine>;
  39046. /**
  39047. * Observable event triggered each time the canvas loses focus
  39048. */
  39049. onCanvasBlurObservable: Observable<Engine>;
  39050. /**
  39051. * Observable event triggered each time the canvas gains focus
  39052. */
  39053. onCanvasFocusObservable: Observable<Engine>;
  39054. /**
  39055. * Observable event triggered each time the canvas receives pointerout event
  39056. */
  39057. onCanvasPointerOutObservable: Observable<PointerEvent>;
  39058. /**
  39059. * Observable raised when the engine begins a new frame
  39060. */
  39061. onBeginFrameObservable: Observable<Engine>;
  39062. /**
  39063. * If set, will be used to request the next animation frame for the render loop
  39064. */
  39065. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  39066. /**
  39067. * Observable raised when the engine ends the current frame
  39068. */
  39069. onEndFrameObservable: Observable<Engine>;
  39070. /**
  39071. * Observable raised when the engine is about to compile a shader
  39072. */
  39073. onBeforeShaderCompilationObservable: Observable<Engine>;
  39074. /**
  39075. * Observable raised when the engine has jsut compiled a shader
  39076. */
  39077. onAfterShaderCompilationObservable: Observable<Engine>;
  39078. /**
  39079. * Gets the audio engine
  39080. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39081. * @ignorenaming
  39082. */
  39083. static audioEngine: IAudioEngine;
  39084. /**
  39085. * Default AudioEngine factory responsible of creating the Audio Engine.
  39086. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39087. */
  39088. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39089. /**
  39090. * Default offline support factory responsible of creating a tool used to store data locally.
  39091. * By default, this will create a Database object if the workload has been embedded.
  39092. */
  39093. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39094. private _loadingScreen;
  39095. private _pointerLockRequested;
  39096. private _rescalePostProcess;
  39097. private _deterministicLockstep;
  39098. private _lockstepMaxSteps;
  39099. private _timeStep;
  39100. protected get _supportsHardwareTextureRescaling(): boolean;
  39101. private _fps;
  39102. private _deltaTime;
  39103. /** @hidden */
  39104. _drawCalls: PerfCounter;
  39105. /** 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 */
  39106. canvasTabIndex: number;
  39107. /**
  39108. * Turn this value on if you want to pause FPS computation when in background
  39109. */
  39110. disablePerformanceMonitorInBackground: boolean;
  39111. private _performanceMonitor;
  39112. /**
  39113. * Gets the performance monitor attached to this engine
  39114. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39115. */
  39116. get performanceMonitor(): PerformanceMonitor;
  39117. private _onFocus;
  39118. private _onBlur;
  39119. private _onCanvasPointerOut;
  39120. private _onCanvasBlur;
  39121. private _onCanvasFocus;
  39122. private _onFullscreenChange;
  39123. private _onPointerLockChange;
  39124. /**
  39125. * Gets the HTML element used to attach event listeners
  39126. * @returns a HTML element
  39127. */
  39128. getInputElement(): Nullable<HTMLElement>;
  39129. /**
  39130. * Creates a new engine
  39131. * @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
  39132. * @param antialias defines enable antialiasing (default: false)
  39133. * @param options defines further options to be sent to the getContext() function
  39134. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39135. */
  39136. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39137. /**
  39138. * Gets current aspect ratio
  39139. * @param viewportOwner defines the camera to use to get the aspect ratio
  39140. * @param useScreen defines if screen size must be used (or the current render target if any)
  39141. * @returns a number defining the aspect ratio
  39142. */
  39143. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39144. /**
  39145. * Gets current screen aspect ratio
  39146. * @returns a number defining the aspect ratio
  39147. */
  39148. getScreenAspectRatio(): number;
  39149. /**
  39150. * Gets the client rect of the HTML canvas attached with the current webGL context
  39151. * @returns a client rectanglee
  39152. */
  39153. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39154. /**
  39155. * Gets the client rect of the HTML element used for events
  39156. * @returns a client rectanglee
  39157. */
  39158. getInputElementClientRect(): Nullable<ClientRect>;
  39159. /**
  39160. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39161. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39162. * @returns true if engine is in deterministic lock step mode
  39163. */
  39164. isDeterministicLockStep(): boolean;
  39165. /**
  39166. * Gets the max steps when engine is running in deterministic lock step
  39167. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39168. * @returns the max steps
  39169. */
  39170. getLockstepMaxSteps(): number;
  39171. /**
  39172. * Returns the time in ms between steps when using deterministic lock step.
  39173. * @returns time step in (ms)
  39174. */
  39175. getTimeStep(): number;
  39176. /**
  39177. * Force the mipmap generation for the given render target texture
  39178. * @param texture defines the render target texture to use
  39179. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39180. */
  39181. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39182. /** States */
  39183. /**
  39184. * Set various states to the webGL context
  39185. * @param culling defines backface culling state
  39186. * @param zOffset defines the value to apply to zOffset (0 by default)
  39187. * @param force defines if states must be applied even if cache is up to date
  39188. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39189. */
  39190. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39191. /**
  39192. * Set the z offset to apply to current rendering
  39193. * @param value defines the offset to apply
  39194. */
  39195. setZOffset(value: number): void;
  39196. /**
  39197. * Gets the current value of the zOffset
  39198. * @returns the current zOffset state
  39199. */
  39200. getZOffset(): number;
  39201. /**
  39202. * Enable or disable depth buffering
  39203. * @param enable defines the state to set
  39204. */
  39205. setDepthBuffer(enable: boolean): void;
  39206. /**
  39207. * Gets a boolean indicating if depth writing is enabled
  39208. * @returns the current depth writing state
  39209. */
  39210. getDepthWrite(): boolean;
  39211. /**
  39212. * Enable or disable depth writing
  39213. * @param enable defines the state to set
  39214. */
  39215. setDepthWrite(enable: boolean): void;
  39216. /**
  39217. * Gets a boolean indicating if stencil buffer is enabled
  39218. * @returns the current stencil buffer state
  39219. */
  39220. getStencilBuffer(): boolean;
  39221. /**
  39222. * Enable or disable the stencil buffer
  39223. * @param enable defines if the stencil buffer must be enabled or disabled
  39224. */
  39225. setStencilBuffer(enable: boolean): void;
  39226. /**
  39227. * Gets the current stencil mask
  39228. * @returns a number defining the new stencil mask to use
  39229. */
  39230. getStencilMask(): number;
  39231. /**
  39232. * Sets the current stencil mask
  39233. * @param mask defines the new stencil mask to use
  39234. */
  39235. setStencilMask(mask: number): void;
  39236. /**
  39237. * Gets the current stencil function
  39238. * @returns a number defining the stencil function to use
  39239. */
  39240. getStencilFunction(): number;
  39241. /**
  39242. * Gets the current stencil reference value
  39243. * @returns a number defining the stencil reference value to use
  39244. */
  39245. getStencilFunctionReference(): number;
  39246. /**
  39247. * Gets the current stencil mask
  39248. * @returns a number defining the stencil mask to use
  39249. */
  39250. getStencilFunctionMask(): number;
  39251. /**
  39252. * Sets the current stencil function
  39253. * @param stencilFunc defines the new stencil function to use
  39254. */
  39255. setStencilFunction(stencilFunc: number): void;
  39256. /**
  39257. * Sets the current stencil reference
  39258. * @param reference defines the new stencil reference to use
  39259. */
  39260. setStencilFunctionReference(reference: number): void;
  39261. /**
  39262. * Sets the current stencil mask
  39263. * @param mask defines the new stencil mask to use
  39264. */
  39265. setStencilFunctionMask(mask: number): void;
  39266. /**
  39267. * Gets the current stencil operation when stencil fails
  39268. * @returns a number defining stencil operation to use when stencil fails
  39269. */
  39270. getStencilOperationFail(): number;
  39271. /**
  39272. * Gets the current stencil operation when depth fails
  39273. * @returns a number defining stencil operation to use when depth fails
  39274. */
  39275. getStencilOperationDepthFail(): number;
  39276. /**
  39277. * Gets the current stencil operation when stencil passes
  39278. * @returns a number defining stencil operation to use when stencil passes
  39279. */
  39280. getStencilOperationPass(): number;
  39281. /**
  39282. * Sets the stencil operation to use when stencil fails
  39283. * @param operation defines the stencil operation to use when stencil fails
  39284. */
  39285. setStencilOperationFail(operation: number): void;
  39286. /**
  39287. * Sets the stencil operation to use when depth fails
  39288. * @param operation defines the stencil operation to use when depth fails
  39289. */
  39290. setStencilOperationDepthFail(operation: number): void;
  39291. /**
  39292. * Sets the stencil operation to use when stencil passes
  39293. * @param operation defines the stencil operation to use when stencil passes
  39294. */
  39295. setStencilOperationPass(operation: number): void;
  39296. /**
  39297. * Sets a boolean indicating if the dithering state is enabled or disabled
  39298. * @param value defines the dithering state
  39299. */
  39300. setDitheringState(value: boolean): void;
  39301. /**
  39302. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39303. * @param value defines the rasterizer state
  39304. */
  39305. setRasterizerState(value: boolean): void;
  39306. /**
  39307. * Gets the current depth function
  39308. * @returns a number defining the depth function
  39309. */
  39310. getDepthFunction(): Nullable<number>;
  39311. /**
  39312. * Sets the current depth function
  39313. * @param depthFunc defines the function to use
  39314. */
  39315. setDepthFunction(depthFunc: number): void;
  39316. /**
  39317. * Sets the current depth function to GREATER
  39318. */
  39319. setDepthFunctionToGreater(): void;
  39320. /**
  39321. * Sets the current depth function to GEQUAL
  39322. */
  39323. setDepthFunctionToGreaterOrEqual(): void;
  39324. /**
  39325. * Sets the current depth function to LESS
  39326. */
  39327. setDepthFunctionToLess(): void;
  39328. /**
  39329. * Sets the current depth function to LEQUAL
  39330. */
  39331. setDepthFunctionToLessOrEqual(): void;
  39332. private _cachedStencilBuffer;
  39333. private _cachedStencilFunction;
  39334. private _cachedStencilMask;
  39335. private _cachedStencilOperationPass;
  39336. private _cachedStencilOperationFail;
  39337. private _cachedStencilOperationDepthFail;
  39338. private _cachedStencilReference;
  39339. /**
  39340. * Caches the the state of the stencil buffer
  39341. */
  39342. cacheStencilState(): void;
  39343. /**
  39344. * Restores the state of the stencil buffer
  39345. */
  39346. restoreStencilState(): void;
  39347. /**
  39348. * Directly set the WebGL Viewport
  39349. * @param x defines the x coordinate of the viewport (in screen space)
  39350. * @param y defines the y coordinate of the viewport (in screen space)
  39351. * @param width defines the width of the viewport (in screen space)
  39352. * @param height defines the height of the viewport (in screen space)
  39353. * @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
  39354. */
  39355. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39356. /**
  39357. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39358. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39359. * @param y defines the y-coordinate of the corner of the clear rectangle
  39360. * @param width defines the width of the clear rectangle
  39361. * @param height defines the height of the clear rectangle
  39362. * @param clearColor defines the clear color
  39363. */
  39364. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39365. /**
  39366. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39367. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39368. * @param y defines the y-coordinate of the corner of the clear rectangle
  39369. * @param width defines the width of the clear rectangle
  39370. * @param height defines the height of the clear rectangle
  39371. */
  39372. enableScissor(x: number, y: number, width: number, height: number): void;
  39373. /**
  39374. * Disable previously set scissor test rectangle
  39375. */
  39376. disableScissor(): void;
  39377. protected _reportDrawCall(): void;
  39378. /**
  39379. * Initializes a webVR display and starts listening to display change events
  39380. * The onVRDisplayChangedObservable will be notified upon these changes
  39381. * @returns The onVRDisplayChangedObservable
  39382. */
  39383. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39384. /** @hidden */
  39385. _prepareVRComponent(): void;
  39386. /** @hidden */
  39387. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39388. /** @hidden */
  39389. _submitVRFrame(): void;
  39390. /**
  39391. * Call this function to leave webVR mode
  39392. * Will do nothing if webVR is not supported or if there is no webVR device
  39393. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39394. */
  39395. disableVR(): void;
  39396. /**
  39397. * Gets a boolean indicating that the system is in VR mode and is presenting
  39398. * @returns true if VR mode is engaged
  39399. */
  39400. isVRPresenting(): boolean;
  39401. /** @hidden */
  39402. _requestVRFrame(): void;
  39403. /** @hidden */
  39404. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39405. /**
  39406. * Gets the source code of the vertex shader associated with a specific webGL program
  39407. * @param program defines the program to use
  39408. * @returns a string containing the source code of the vertex shader associated with the program
  39409. */
  39410. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39411. /**
  39412. * Gets the source code of the fragment shader associated with a specific webGL program
  39413. * @param program defines the program to use
  39414. * @returns a string containing the source code of the fragment shader associated with the program
  39415. */
  39416. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39417. /**
  39418. * Sets a depth stencil texture from a render target to the according uniform.
  39419. * @param channel The texture channel
  39420. * @param uniform The uniform to set
  39421. * @param texture The render target texture containing the depth stencil texture to apply
  39422. */
  39423. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39424. /**
  39425. * Sets a texture to the webGL context from a postprocess
  39426. * @param channel defines the channel to use
  39427. * @param postProcess defines the source postprocess
  39428. */
  39429. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39430. /**
  39431. * Binds the output of the passed in post process to the texture channel specified
  39432. * @param channel The channel the texture should be bound to
  39433. * @param postProcess The post process which's output should be bound
  39434. */
  39435. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39436. protected _rebuildBuffers(): void;
  39437. /** @hidden */
  39438. _renderFrame(): void;
  39439. _renderLoop(): void;
  39440. /** @hidden */
  39441. _renderViews(): boolean;
  39442. /**
  39443. * Toggle full screen mode
  39444. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39445. */
  39446. switchFullscreen(requestPointerLock: boolean): void;
  39447. /**
  39448. * Enters full screen mode
  39449. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39450. */
  39451. enterFullscreen(requestPointerLock: boolean): void;
  39452. /**
  39453. * Exits full screen mode
  39454. */
  39455. exitFullscreen(): void;
  39456. /**
  39457. * Enters Pointerlock mode
  39458. */
  39459. enterPointerlock(): void;
  39460. /**
  39461. * Exits Pointerlock mode
  39462. */
  39463. exitPointerlock(): void;
  39464. /**
  39465. * Begin a new frame
  39466. */
  39467. beginFrame(): void;
  39468. /**
  39469. * Enf the current frame
  39470. */
  39471. endFrame(): void;
  39472. resize(): void;
  39473. /**
  39474. * Force a specific size of the canvas
  39475. * @param width defines the new canvas' width
  39476. * @param height defines the new canvas' height
  39477. * @returns true if the size was changed
  39478. */
  39479. setSize(width: number, height: number): boolean;
  39480. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39481. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39482. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39483. _releaseTexture(texture: InternalTexture): void;
  39484. /**
  39485. * @hidden
  39486. * Rescales a texture
  39487. * @param source input texutre
  39488. * @param destination destination texture
  39489. * @param scene scene to use to render the resize
  39490. * @param internalFormat format to use when resizing
  39491. * @param onComplete callback to be called when resize has completed
  39492. */
  39493. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39494. /**
  39495. * Gets the current framerate
  39496. * @returns a number representing the framerate
  39497. */
  39498. getFps(): number;
  39499. /**
  39500. * Gets the time spent between current and previous frame
  39501. * @returns a number representing the delta time in ms
  39502. */
  39503. getDeltaTime(): number;
  39504. private _measureFps;
  39505. /** @hidden */
  39506. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39507. /**
  39508. * Updates the sample count of a render target texture
  39509. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39510. * @param texture defines the texture to update
  39511. * @param samples defines the sample count to set
  39512. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39513. */
  39514. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39515. /**
  39516. * Updates a depth texture Comparison Mode and Function.
  39517. * If the comparison Function is equal to 0, the mode will be set to none.
  39518. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39519. * @param texture The texture to set the comparison function for
  39520. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39521. */
  39522. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39523. /**
  39524. * Creates a webGL buffer to use with instanciation
  39525. * @param capacity defines the size of the buffer
  39526. * @returns the webGL buffer
  39527. */
  39528. createInstancesBuffer(capacity: number): DataBuffer;
  39529. /**
  39530. * Delete a webGL buffer used with instanciation
  39531. * @param buffer defines the webGL buffer to delete
  39532. */
  39533. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39534. private _clientWaitAsync;
  39535. /** @hidden */
  39536. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39537. dispose(): void;
  39538. private _disableTouchAction;
  39539. /**
  39540. * Display the loading screen
  39541. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39542. */
  39543. displayLoadingUI(): void;
  39544. /**
  39545. * Hide the loading screen
  39546. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39547. */
  39548. hideLoadingUI(): void;
  39549. /**
  39550. * Gets the current loading screen object
  39551. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39552. */
  39553. get loadingScreen(): ILoadingScreen;
  39554. /**
  39555. * Sets the current loading screen object
  39556. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39557. */
  39558. set loadingScreen(loadingScreen: ILoadingScreen);
  39559. /**
  39560. * Sets the current loading screen text
  39561. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39562. */
  39563. set loadingUIText(text: string);
  39564. /**
  39565. * Sets the current loading screen background color
  39566. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39567. */
  39568. set loadingUIBackgroundColor(color: string);
  39569. /** Pointerlock and fullscreen */
  39570. /**
  39571. * Ask the browser to promote the current element to pointerlock mode
  39572. * @param element defines the DOM element to promote
  39573. */
  39574. static _RequestPointerlock(element: HTMLElement): void;
  39575. /**
  39576. * Asks the browser to exit pointerlock mode
  39577. */
  39578. static _ExitPointerlock(): void;
  39579. /**
  39580. * Ask the browser to promote the current element to fullscreen rendering mode
  39581. * @param element defines the DOM element to promote
  39582. */
  39583. static _RequestFullscreen(element: HTMLElement): void;
  39584. /**
  39585. * Asks the browser to exit fullscreen mode
  39586. */
  39587. static _ExitFullscreen(): void;
  39588. }
  39589. }
  39590. declare module "babylonjs/Engines/engineStore" {
  39591. import { Nullable } from "babylonjs/types";
  39592. import { Engine } from "babylonjs/Engines/engine";
  39593. import { Scene } from "babylonjs/scene";
  39594. /**
  39595. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39596. * during the life time of the application.
  39597. */
  39598. export class EngineStore {
  39599. /** Gets the list of created engines */
  39600. static Instances: import("babylonjs/Engines/engine").Engine[];
  39601. /** @hidden */
  39602. static _LastCreatedScene: Nullable<Scene>;
  39603. /**
  39604. * Gets the latest created engine
  39605. */
  39606. static get LastCreatedEngine(): Nullable<Engine>;
  39607. /**
  39608. * Gets the latest created scene
  39609. */
  39610. static get LastCreatedScene(): Nullable<Scene>;
  39611. /**
  39612. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39613. * @ignorenaming
  39614. */
  39615. static UseFallbackTexture: boolean;
  39616. /**
  39617. * Texture content used if a texture cannot loaded
  39618. * @ignorenaming
  39619. */
  39620. static FallbackTexture: string;
  39621. }
  39622. }
  39623. declare module "babylonjs/Misc/promise" {
  39624. /**
  39625. * Helper class that provides a small promise polyfill
  39626. */
  39627. export class PromisePolyfill {
  39628. /**
  39629. * Static function used to check if the polyfill is required
  39630. * If this is the case then the function will inject the polyfill to window.Promise
  39631. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39632. */
  39633. static Apply(force?: boolean): void;
  39634. }
  39635. }
  39636. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39637. /**
  39638. * Interface for screenshot methods with describe argument called `size` as object with options
  39639. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39640. */
  39641. export interface IScreenshotSize {
  39642. /**
  39643. * number in pixels for canvas height
  39644. */
  39645. height?: number;
  39646. /**
  39647. * multiplier allowing render at a higher or lower resolution
  39648. * If value is defined then height and width will be ignored and taken from camera
  39649. */
  39650. precision?: number;
  39651. /**
  39652. * number in pixels for canvas width
  39653. */
  39654. width?: number;
  39655. }
  39656. }
  39657. declare module "babylonjs/Misc/tools" {
  39658. import { Nullable, float } from "babylonjs/types";
  39659. import { DomManagement } from "babylonjs/Misc/domManagement";
  39660. import { WebRequest } from "babylonjs/Misc/webRequest";
  39661. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39662. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39663. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39664. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39665. import { Camera } from "babylonjs/Cameras/camera";
  39666. import { Engine } from "babylonjs/Engines/engine";
  39667. interface IColor4Like {
  39668. r: float;
  39669. g: float;
  39670. b: float;
  39671. a: float;
  39672. }
  39673. /**
  39674. * Class containing a set of static utilities functions
  39675. */
  39676. export class Tools {
  39677. /**
  39678. * Gets or sets the base URL to use to load assets
  39679. */
  39680. static get BaseUrl(): string;
  39681. static set BaseUrl(value: string);
  39682. /**
  39683. * Enable/Disable Custom HTTP Request Headers globally.
  39684. * default = false
  39685. * @see CustomRequestHeaders
  39686. */
  39687. static UseCustomRequestHeaders: boolean;
  39688. /**
  39689. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39690. * i.e. when loading files, where the server/service expects an Authorization header
  39691. */
  39692. static CustomRequestHeaders: {
  39693. [key: string]: string;
  39694. };
  39695. /**
  39696. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39697. */
  39698. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39699. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39700. /**
  39701. * Default behaviour for cors in the application.
  39702. * It can be a string if the expected behavior is identical in the entire app.
  39703. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39704. */
  39705. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39706. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39707. /**
  39708. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39709. * @ignorenaming
  39710. */
  39711. static get UseFallbackTexture(): boolean;
  39712. static set UseFallbackTexture(value: boolean);
  39713. /**
  39714. * Use this object to register external classes like custom textures or material
  39715. * to allow the laoders to instantiate them
  39716. */
  39717. static get RegisteredExternalClasses(): {
  39718. [key: string]: Object;
  39719. };
  39720. static set RegisteredExternalClasses(classes: {
  39721. [key: string]: Object;
  39722. });
  39723. /**
  39724. * Texture content used if a texture cannot loaded
  39725. * @ignorenaming
  39726. */
  39727. static get fallbackTexture(): string;
  39728. static set fallbackTexture(value: string);
  39729. /**
  39730. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39731. * @param u defines the coordinate on X axis
  39732. * @param v defines the coordinate on Y axis
  39733. * @param width defines the width of the source data
  39734. * @param height defines the height of the source data
  39735. * @param pixels defines the source byte array
  39736. * @param color defines the output color
  39737. */
  39738. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39739. /**
  39740. * Interpolates between a and b via alpha
  39741. * @param a The lower value (returned when alpha = 0)
  39742. * @param b The upper value (returned when alpha = 1)
  39743. * @param alpha The interpolation-factor
  39744. * @return The mixed value
  39745. */
  39746. static Mix(a: number, b: number, alpha: number): number;
  39747. /**
  39748. * Tries to instantiate a new object from a given class name
  39749. * @param className defines the class name to instantiate
  39750. * @returns the new object or null if the system was not able to do the instantiation
  39751. */
  39752. static Instantiate(className: string): any;
  39753. /**
  39754. * Provides a slice function that will work even on IE
  39755. * @param data defines the array to slice
  39756. * @param start defines the start of the data (optional)
  39757. * @param end defines the end of the data (optional)
  39758. * @returns the new sliced array
  39759. */
  39760. static Slice<T>(data: T, start?: number, end?: number): T;
  39761. /**
  39762. * Polyfill for setImmediate
  39763. * @param action defines the action to execute after the current execution block
  39764. */
  39765. static SetImmediate(action: () => void): void;
  39766. /**
  39767. * Function indicating if a number is an exponent of 2
  39768. * @param value defines the value to test
  39769. * @returns true if the value is an exponent of 2
  39770. */
  39771. static IsExponentOfTwo(value: number): boolean;
  39772. private static _tmpFloatArray;
  39773. /**
  39774. * Returns the nearest 32-bit single precision float representation of a Number
  39775. * @param value A Number. If the parameter is of a different type, it will get converted
  39776. * to a number or to NaN if it cannot be converted
  39777. * @returns number
  39778. */
  39779. static FloatRound(value: number): number;
  39780. /**
  39781. * Extracts the filename from a path
  39782. * @param path defines the path to use
  39783. * @returns the filename
  39784. */
  39785. static GetFilename(path: string): string;
  39786. /**
  39787. * Extracts the "folder" part of a path (everything before the filename).
  39788. * @param uri The URI to extract the info from
  39789. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39790. * @returns The "folder" part of the path
  39791. */
  39792. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39793. /**
  39794. * Extracts text content from a DOM element hierarchy
  39795. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39796. */
  39797. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39798. /**
  39799. * Convert an angle in radians to degrees
  39800. * @param angle defines the angle to convert
  39801. * @returns the angle in degrees
  39802. */
  39803. static ToDegrees(angle: number): number;
  39804. /**
  39805. * Convert an angle in degrees to radians
  39806. * @param angle defines the angle to convert
  39807. * @returns the angle in radians
  39808. */
  39809. static ToRadians(angle: number): number;
  39810. /**
  39811. * Returns an array if obj is not an array
  39812. * @param obj defines the object to evaluate as an array
  39813. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39814. * @returns either obj directly if obj is an array or a new array containing obj
  39815. */
  39816. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39817. /**
  39818. * Gets the pointer prefix to use
  39819. * @param engine defines the engine we are finding the prefix for
  39820. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39821. */
  39822. static GetPointerPrefix(engine: Engine): string;
  39823. /**
  39824. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39825. * @param url define the url we are trying
  39826. * @param element define the dom element where to configure the cors policy
  39827. */
  39828. static SetCorsBehavior(url: string | string[], element: {
  39829. crossOrigin: string | null;
  39830. }): void;
  39831. /**
  39832. * Removes unwanted characters from an url
  39833. * @param url defines the url to clean
  39834. * @returns the cleaned url
  39835. */
  39836. static CleanUrl(url: string): string;
  39837. /**
  39838. * Gets or sets a function used to pre-process url before using them to load assets
  39839. */
  39840. static get PreprocessUrl(): (url: string) => string;
  39841. static set PreprocessUrl(processor: (url: string) => string);
  39842. /**
  39843. * Loads an image as an HTMLImageElement.
  39844. * @param input url string, ArrayBuffer, or Blob to load
  39845. * @param onLoad callback called when the image successfully loads
  39846. * @param onError callback called when the image fails to load
  39847. * @param offlineProvider offline provider for caching
  39848. * @param mimeType optional mime type
  39849. * @returns the HTMLImageElement of the loaded image
  39850. */
  39851. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39852. /**
  39853. * Loads a file from a url
  39854. * @param url url string, ArrayBuffer, or Blob to load
  39855. * @param onSuccess callback called when the file successfully loads
  39856. * @param onProgress callback called while file is loading (if the server supports this mode)
  39857. * @param offlineProvider defines the offline provider for caching
  39858. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39859. * @param onError callback called when the file fails to load
  39860. * @returns a file request object
  39861. */
  39862. 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;
  39863. /**
  39864. * Loads a file from a url
  39865. * @param url the file url to load
  39866. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39867. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39868. */
  39869. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39870. /**
  39871. * Load a script (identified by an url). When the url returns, the
  39872. * content of this file is added into a new script element, attached to the DOM (body element)
  39873. * @param scriptUrl defines the url of the script to laod
  39874. * @param onSuccess defines the callback called when the script is loaded
  39875. * @param onError defines the callback to call if an error occurs
  39876. * @param scriptId defines the id of the script element
  39877. */
  39878. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39879. /**
  39880. * Load an asynchronous script (identified by an url). When the url returns, the
  39881. * content of this file is added into a new script element, attached to the DOM (body element)
  39882. * @param scriptUrl defines the url of the script to laod
  39883. * @param scriptId defines the id of the script element
  39884. * @returns a promise request object
  39885. */
  39886. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39887. /**
  39888. * Loads a file from a blob
  39889. * @param fileToLoad defines the blob to use
  39890. * @param callback defines the callback to call when data is loaded
  39891. * @param progressCallback defines the callback to call during loading process
  39892. * @returns a file request object
  39893. */
  39894. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39895. /**
  39896. * Reads a file from a File object
  39897. * @param file defines the file to load
  39898. * @param onSuccess defines the callback to call when data is loaded
  39899. * @param onProgress defines the callback to call during loading process
  39900. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39901. * @param onError defines the callback to call when an error occurs
  39902. * @returns a file request object
  39903. */
  39904. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39905. /**
  39906. * Creates a data url from a given string content
  39907. * @param content defines the content to convert
  39908. * @returns the new data url link
  39909. */
  39910. static FileAsURL(content: string): string;
  39911. /**
  39912. * Format the given number to a specific decimal format
  39913. * @param value defines the number to format
  39914. * @param decimals defines the number of decimals to use
  39915. * @returns the formatted string
  39916. */
  39917. static Format(value: number, decimals?: number): string;
  39918. /**
  39919. * Tries to copy an object by duplicating every property
  39920. * @param source defines the source object
  39921. * @param destination defines the target object
  39922. * @param doNotCopyList defines a list of properties to avoid
  39923. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39924. */
  39925. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39926. /**
  39927. * Gets a boolean indicating if the given object has no own property
  39928. * @param obj defines the object to test
  39929. * @returns true if object has no own property
  39930. */
  39931. static IsEmpty(obj: any): boolean;
  39932. /**
  39933. * Function used to register events at window level
  39934. * @param windowElement defines the Window object to use
  39935. * @param events defines the events to register
  39936. */
  39937. static RegisterTopRootEvents(windowElement: Window, events: {
  39938. name: string;
  39939. handler: Nullable<(e: FocusEvent) => any>;
  39940. }[]): void;
  39941. /**
  39942. * Function used to unregister events from window level
  39943. * @param windowElement defines the Window object to use
  39944. * @param events defines the events to unregister
  39945. */
  39946. static UnregisterTopRootEvents(windowElement: Window, events: {
  39947. name: string;
  39948. handler: Nullable<(e: FocusEvent) => any>;
  39949. }[]): void;
  39950. /**
  39951. * @ignore
  39952. */
  39953. static _ScreenshotCanvas: HTMLCanvasElement;
  39954. /**
  39955. * Dumps the current bound framebuffer
  39956. * @param width defines the rendering width
  39957. * @param height defines the rendering height
  39958. * @param engine defines the hosting engine
  39959. * @param successCallback defines the callback triggered once the data are available
  39960. * @param mimeType defines the mime type of the result
  39961. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39962. */
  39963. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39964. /**
  39965. * Converts the canvas data to blob.
  39966. * This acts as a polyfill for browsers not supporting the to blob function.
  39967. * @param canvas Defines the canvas to extract the data from
  39968. * @param successCallback Defines the callback triggered once the data are available
  39969. * @param mimeType Defines the mime type of the result
  39970. */
  39971. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39972. /**
  39973. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39974. * @param successCallback defines the callback triggered once the data are available
  39975. * @param mimeType defines the mime type of the result
  39976. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39977. */
  39978. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39979. /**
  39980. * Downloads a blob in the browser
  39981. * @param blob defines the blob to download
  39982. * @param fileName defines the name of the downloaded file
  39983. */
  39984. static Download(blob: Blob, fileName: string): void;
  39985. /**
  39986. * Captures a screenshot of the current rendering
  39987. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39988. * @param engine defines the rendering engine
  39989. * @param camera defines the source camera
  39990. * @param size This parameter can be set to a single number or to an object with the
  39991. * following (optional) properties: precision, width, height. If a single number is passed,
  39992. * it will be used for both width and height. If an object is passed, the screenshot size
  39993. * will be derived from the parameters. The precision property is a multiplier allowing
  39994. * rendering at a higher or lower resolution
  39995. * @param successCallback defines the callback receives a single parameter which contains the
  39996. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39997. * src parameter of an <img> to display it
  39998. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39999. * Check your browser for supported MIME types
  40000. */
  40001. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  40002. /**
  40003. * Captures a screenshot of the current rendering
  40004. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40005. * @param engine defines the rendering engine
  40006. * @param camera defines the source camera
  40007. * @param size This parameter can be set to a single number or to an object with the
  40008. * following (optional) properties: precision, width, height. If a single number is passed,
  40009. * it will be used for both width and height. If an object is passed, the screenshot size
  40010. * will be derived from the parameters. The precision property is a multiplier allowing
  40011. * rendering at a higher or lower resolution
  40012. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40013. * Check your browser for supported MIME types
  40014. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40015. * to the src parameter of an <img> to display it
  40016. */
  40017. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  40018. /**
  40019. * Generates an image screenshot from the specified camera.
  40020. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40021. * @param engine The engine to use for rendering
  40022. * @param camera The camera to use for rendering
  40023. * @param size This parameter can be set to a single number or to an object with the
  40024. * following (optional) properties: precision, width, height. If a single number is passed,
  40025. * it will be used for both width and height. If an object is passed, the screenshot size
  40026. * will be derived from the parameters. The precision property is a multiplier allowing
  40027. * rendering at a higher or lower resolution
  40028. * @param successCallback The callback receives a single parameter which contains the
  40029. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40030. * src parameter of an <img> to display it
  40031. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40032. * Check your browser for supported MIME types
  40033. * @param samples Texture samples (default: 1)
  40034. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40035. * @param fileName A name for for the downloaded file.
  40036. */
  40037. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40038. /**
  40039. * Generates an image screenshot from the specified camera.
  40040. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40041. * @param engine The engine to use for rendering
  40042. * @param camera The camera to use for rendering
  40043. * @param size This parameter can be set to a single number or to an object with the
  40044. * following (optional) properties: precision, width, height. If a single number is passed,
  40045. * it will be used for both width and height. If an object is passed, the screenshot size
  40046. * will be derived from the parameters. The precision property is a multiplier allowing
  40047. * rendering at a higher or lower resolution
  40048. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40049. * Check your browser for supported MIME types
  40050. * @param samples Texture samples (default: 1)
  40051. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40052. * @param fileName A name for for the downloaded file.
  40053. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40054. * to the src parameter of an <img> to display it
  40055. */
  40056. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  40057. /**
  40058. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40059. * Be aware Math.random() could cause collisions, but:
  40060. * "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"
  40061. * @returns a pseudo random id
  40062. */
  40063. static RandomId(): string;
  40064. /**
  40065. * Test if the given uri is a base64 string
  40066. * @param uri The uri to test
  40067. * @return True if the uri is a base64 string or false otherwise
  40068. */
  40069. static IsBase64(uri: string): boolean;
  40070. /**
  40071. * Decode the given base64 uri.
  40072. * @param uri The uri to decode
  40073. * @return The decoded base64 data.
  40074. */
  40075. static DecodeBase64(uri: string): ArrayBuffer;
  40076. /**
  40077. * Gets the absolute url.
  40078. * @param url the input url
  40079. * @return the absolute url
  40080. */
  40081. static GetAbsoluteUrl(url: string): string;
  40082. /**
  40083. * No log
  40084. */
  40085. static readonly NoneLogLevel: number;
  40086. /**
  40087. * Only message logs
  40088. */
  40089. static readonly MessageLogLevel: number;
  40090. /**
  40091. * Only warning logs
  40092. */
  40093. static readonly WarningLogLevel: number;
  40094. /**
  40095. * Only error logs
  40096. */
  40097. static readonly ErrorLogLevel: number;
  40098. /**
  40099. * All logs
  40100. */
  40101. static readonly AllLogLevel: number;
  40102. /**
  40103. * Gets a value indicating the number of loading errors
  40104. * @ignorenaming
  40105. */
  40106. static get errorsCount(): number;
  40107. /**
  40108. * Callback called when a new log is added
  40109. */
  40110. static OnNewCacheEntry: (entry: string) => void;
  40111. /**
  40112. * Log a message to the console
  40113. * @param message defines the message to log
  40114. */
  40115. static Log(message: string): void;
  40116. /**
  40117. * Write a warning message to the console
  40118. * @param message defines the message to log
  40119. */
  40120. static Warn(message: string): void;
  40121. /**
  40122. * Write an error message to the console
  40123. * @param message defines the message to log
  40124. */
  40125. static Error(message: string): void;
  40126. /**
  40127. * Gets current log cache (list of logs)
  40128. */
  40129. static get LogCache(): string;
  40130. /**
  40131. * Clears the log cache
  40132. */
  40133. static ClearLogCache(): void;
  40134. /**
  40135. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40136. */
  40137. static set LogLevels(level: number);
  40138. /**
  40139. * Checks if the window object exists
  40140. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40141. */
  40142. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40143. /**
  40144. * No performance log
  40145. */
  40146. static readonly PerformanceNoneLogLevel: number;
  40147. /**
  40148. * Use user marks to log performance
  40149. */
  40150. static readonly PerformanceUserMarkLogLevel: number;
  40151. /**
  40152. * Log performance to the console
  40153. */
  40154. static readonly PerformanceConsoleLogLevel: number;
  40155. private static _performance;
  40156. /**
  40157. * Sets the current performance log level
  40158. */
  40159. static set PerformanceLogLevel(level: number);
  40160. private static _StartPerformanceCounterDisabled;
  40161. private static _EndPerformanceCounterDisabled;
  40162. private static _StartUserMark;
  40163. private static _EndUserMark;
  40164. private static _StartPerformanceConsole;
  40165. private static _EndPerformanceConsole;
  40166. /**
  40167. * Starts a performance counter
  40168. */
  40169. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40170. /**
  40171. * Ends a specific performance coutner
  40172. */
  40173. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40174. /**
  40175. * Gets either window.performance.now() if supported or Date.now() else
  40176. */
  40177. static get Now(): number;
  40178. /**
  40179. * This method will return the name of the class used to create the instance of the given object.
  40180. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40181. * @param object the object to get the class name from
  40182. * @param isType defines if the object is actually a type
  40183. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40184. */
  40185. static GetClassName(object: any, isType?: boolean): string;
  40186. /**
  40187. * Gets the first element of an array satisfying a given predicate
  40188. * @param array defines the array to browse
  40189. * @param predicate defines the predicate to use
  40190. * @returns null if not found or the element
  40191. */
  40192. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40193. /**
  40194. * This method will return the name of the full name of the class, including its owning module (if any).
  40195. * 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).
  40196. * @param object the object to get the class name from
  40197. * @param isType defines if the object is actually a type
  40198. * @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.
  40199. * @ignorenaming
  40200. */
  40201. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40202. /**
  40203. * Returns a promise that resolves after the given amount of time.
  40204. * @param delay Number of milliseconds to delay
  40205. * @returns Promise that resolves after the given amount of time
  40206. */
  40207. static DelayAsync(delay: number): Promise<void>;
  40208. /**
  40209. * Utility function to detect if the current user agent is Safari
  40210. * @returns whether or not the current user agent is safari
  40211. */
  40212. static IsSafari(): boolean;
  40213. }
  40214. /**
  40215. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40216. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40217. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40218. * @param name The name of the class, case should be preserved
  40219. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40220. */
  40221. export function className(name: string, module?: string): (target: Object) => void;
  40222. /**
  40223. * An implementation of a loop for asynchronous functions.
  40224. */
  40225. export class AsyncLoop {
  40226. /**
  40227. * Defines the number of iterations for the loop
  40228. */
  40229. iterations: number;
  40230. /**
  40231. * Defines the current index of the loop.
  40232. */
  40233. index: number;
  40234. private _done;
  40235. private _fn;
  40236. private _successCallback;
  40237. /**
  40238. * Constructor.
  40239. * @param iterations the number of iterations.
  40240. * @param func the function to run each iteration
  40241. * @param successCallback the callback that will be called upon succesful execution
  40242. * @param offset starting offset.
  40243. */
  40244. constructor(
  40245. /**
  40246. * Defines the number of iterations for the loop
  40247. */
  40248. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40249. /**
  40250. * Execute the next iteration. Must be called after the last iteration was finished.
  40251. */
  40252. executeNext(): void;
  40253. /**
  40254. * Break the loop and run the success callback.
  40255. */
  40256. breakLoop(): void;
  40257. /**
  40258. * Create and run an async loop.
  40259. * @param iterations the number of iterations.
  40260. * @param fn the function to run each iteration
  40261. * @param successCallback the callback that will be called upon succesful execution
  40262. * @param offset starting offset.
  40263. * @returns the created async loop object
  40264. */
  40265. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40266. /**
  40267. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40268. * @param iterations total number of iterations
  40269. * @param syncedIterations number of synchronous iterations in each async iteration.
  40270. * @param fn the function to call each iteration.
  40271. * @param callback a success call back that will be called when iterating stops.
  40272. * @param breakFunction a break condition (optional)
  40273. * @param timeout timeout settings for the setTimeout function. default - 0.
  40274. * @returns the created async loop object
  40275. */
  40276. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40277. }
  40278. }
  40279. declare module "babylonjs/Misc/stringDictionary" {
  40280. import { Nullable } from "babylonjs/types";
  40281. /**
  40282. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40283. * The underlying implementation relies on an associative array to ensure the best performances.
  40284. * The value can be anything including 'null' but except 'undefined'
  40285. */
  40286. export class StringDictionary<T> {
  40287. /**
  40288. * This will clear this dictionary and copy the content from the 'source' one.
  40289. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40290. * @param source the dictionary to take the content from and copy to this dictionary
  40291. */
  40292. copyFrom(source: StringDictionary<T>): void;
  40293. /**
  40294. * Get a value based from its key
  40295. * @param key the given key to get the matching value from
  40296. * @return the value if found, otherwise undefined is returned
  40297. */
  40298. get(key: string): T | undefined;
  40299. /**
  40300. * Get a value from its key or add it if it doesn't exist.
  40301. * This method will ensure you that a given key/data will be present in the dictionary.
  40302. * @param key the given key to get the matching value from
  40303. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40304. * The factory will only be invoked if there's no data for the given key.
  40305. * @return the value corresponding to the key.
  40306. */
  40307. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40308. /**
  40309. * Get a value from its key if present in the dictionary otherwise add it
  40310. * @param key the key to get the value from
  40311. * @param val if there's no such key/value pair in the dictionary add it with this value
  40312. * @return the value corresponding to the key
  40313. */
  40314. getOrAdd(key: string, val: T): T;
  40315. /**
  40316. * Check if there's a given key in the dictionary
  40317. * @param key the key to check for
  40318. * @return true if the key is present, false otherwise
  40319. */
  40320. contains(key: string): boolean;
  40321. /**
  40322. * Add a new key and its corresponding value
  40323. * @param key the key to add
  40324. * @param value the value corresponding to the key
  40325. * @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
  40326. */
  40327. add(key: string, value: T): boolean;
  40328. /**
  40329. * Update a specific value associated to a key
  40330. * @param key defines the key to use
  40331. * @param value defines the value to store
  40332. * @returns true if the value was updated (or false if the key was not found)
  40333. */
  40334. set(key: string, value: T): boolean;
  40335. /**
  40336. * Get the element of the given key and remove it from the dictionary
  40337. * @param key defines the key to search
  40338. * @returns the value associated with the key or null if not found
  40339. */
  40340. getAndRemove(key: string): Nullable<T>;
  40341. /**
  40342. * Remove a key/value from the dictionary.
  40343. * @param key the key to remove
  40344. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40345. */
  40346. remove(key: string): boolean;
  40347. /**
  40348. * Clear the whole content of the dictionary
  40349. */
  40350. clear(): void;
  40351. /**
  40352. * Gets the current count
  40353. */
  40354. get count(): number;
  40355. /**
  40356. * Execute a callback on each key/val of the dictionary.
  40357. * Note that you can remove any element in this dictionary in the callback implementation
  40358. * @param callback the callback to execute on a given key/value pair
  40359. */
  40360. forEach(callback: (key: string, val: T) => void): void;
  40361. /**
  40362. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40363. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40364. * Note that you can remove any element in this dictionary in the callback implementation
  40365. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40366. * @returns the first item
  40367. */
  40368. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40369. private _count;
  40370. private _data;
  40371. }
  40372. }
  40373. declare module "babylonjs/Collisions/collisionCoordinator" {
  40374. import { Nullable } from "babylonjs/types";
  40375. import { Scene } from "babylonjs/scene";
  40376. import { Vector3 } from "babylonjs/Maths/math.vector";
  40377. import { Collider } from "babylonjs/Collisions/collider";
  40378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40379. /** @hidden */
  40380. export interface ICollisionCoordinator {
  40381. createCollider(): Collider;
  40382. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40383. init(scene: Scene): void;
  40384. }
  40385. /** @hidden */
  40386. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40387. private _scene;
  40388. private _scaledPosition;
  40389. private _scaledVelocity;
  40390. private _finalPosition;
  40391. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40392. createCollider(): Collider;
  40393. init(scene: Scene): void;
  40394. private _collideWithWorld;
  40395. }
  40396. }
  40397. declare module "babylonjs/Inputs/scene.inputManager" {
  40398. import { Nullable } from "babylonjs/types";
  40399. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40400. import { Vector2 } from "babylonjs/Maths/math.vector";
  40401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40402. import { Scene } from "babylonjs/scene";
  40403. /**
  40404. * Class used to manage all inputs for the scene.
  40405. */
  40406. export class InputManager {
  40407. /** The distance in pixel that you have to move to prevent some events */
  40408. static DragMovementThreshold: number;
  40409. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40410. static LongPressDelay: number;
  40411. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40412. static DoubleClickDelay: number;
  40413. /** If you need to check double click without raising a single click at first click, enable this flag */
  40414. static ExclusiveDoubleClickMode: boolean;
  40415. /** 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. */
  40416. private _alreadyAttached;
  40417. private _wheelEventName;
  40418. private _onPointerMove;
  40419. private _onPointerDown;
  40420. private _onPointerUp;
  40421. private _initClickEvent;
  40422. private _initActionManager;
  40423. private _delayedSimpleClick;
  40424. private _delayedSimpleClickTimeout;
  40425. private _previousDelayedSimpleClickTimeout;
  40426. private _meshPickProceed;
  40427. private _previousButtonPressed;
  40428. private _currentPickResult;
  40429. private _previousPickResult;
  40430. private _totalPointersPressed;
  40431. private _doubleClickOccured;
  40432. private _pointerOverMesh;
  40433. private _pickedDownMesh;
  40434. private _pickedUpMesh;
  40435. private _pointerX;
  40436. private _pointerY;
  40437. private _unTranslatedPointerX;
  40438. private _unTranslatedPointerY;
  40439. private _startingPointerPosition;
  40440. private _previousStartingPointerPosition;
  40441. private _startingPointerTime;
  40442. private _previousStartingPointerTime;
  40443. private _pointerCaptures;
  40444. private _meshUnderPointerId;
  40445. private _onKeyDown;
  40446. private _onKeyUp;
  40447. private _onCanvasFocusObserver;
  40448. private _onCanvasBlurObserver;
  40449. private _scene;
  40450. /**
  40451. * Creates a new InputManager
  40452. * @param scene defines the hosting scene
  40453. */
  40454. constructor(scene: Scene);
  40455. /**
  40456. * Gets the mesh that is currently under the pointer
  40457. */
  40458. get meshUnderPointer(): Nullable<AbstractMesh>;
  40459. /**
  40460. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40461. * @param pointerId the pointer id to use
  40462. * @returns The mesh under this pointer id or null if not found
  40463. */
  40464. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40465. /**
  40466. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40467. */
  40468. get unTranslatedPointer(): Vector2;
  40469. /**
  40470. * Gets or sets the current on-screen X position of the pointer
  40471. */
  40472. get pointerX(): number;
  40473. set pointerX(value: number);
  40474. /**
  40475. * Gets or sets the current on-screen Y position of the pointer
  40476. */
  40477. get pointerY(): number;
  40478. set pointerY(value: number);
  40479. private _updatePointerPosition;
  40480. private _processPointerMove;
  40481. private _setRayOnPointerInfo;
  40482. private _checkPrePointerObservable;
  40483. /**
  40484. * Use this method to simulate a pointer move on a mesh
  40485. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40486. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40487. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40488. */
  40489. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40490. /**
  40491. * Use this method to simulate a pointer down on a mesh
  40492. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40493. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40494. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40495. */
  40496. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40497. private _processPointerDown;
  40498. /** @hidden */
  40499. _isPointerSwiping(): boolean;
  40500. /**
  40501. * Use this method to simulate a pointer up on a mesh
  40502. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40503. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40504. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40505. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40506. */
  40507. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40508. private _processPointerUp;
  40509. /**
  40510. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40511. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40512. * @returns true if the pointer was captured
  40513. */
  40514. isPointerCaptured(pointerId?: number): boolean;
  40515. /**
  40516. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40517. * @param attachUp defines if you want to attach events to pointerup
  40518. * @param attachDown defines if you want to attach events to pointerdown
  40519. * @param attachMove defines if you want to attach events to pointermove
  40520. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40521. */
  40522. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40523. /**
  40524. * Detaches all event handlers
  40525. */
  40526. detachControl(): void;
  40527. /**
  40528. * Force the value of meshUnderPointer
  40529. * @param mesh defines the mesh to use
  40530. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40531. */
  40532. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40533. /**
  40534. * Gets the mesh under the pointer
  40535. * @returns a Mesh or null if no mesh is under the pointer
  40536. */
  40537. getPointerOverMesh(): Nullable<AbstractMesh>;
  40538. }
  40539. }
  40540. declare module "babylonjs/Animations/animationGroup" {
  40541. import { Animatable } from "babylonjs/Animations/animatable";
  40542. import { Animation } from "babylonjs/Animations/animation";
  40543. import { Scene, IDisposable } from "babylonjs/scene";
  40544. import { Observable } from "babylonjs/Misc/observable";
  40545. import { Nullable } from "babylonjs/types";
  40546. import "babylonjs/Animations/animatable";
  40547. /**
  40548. * This class defines the direct association between an animation and a target
  40549. */
  40550. export class TargetedAnimation {
  40551. /**
  40552. * Animation to perform
  40553. */
  40554. animation: Animation;
  40555. /**
  40556. * Target to animate
  40557. */
  40558. target: any;
  40559. /**
  40560. * Returns the string "TargetedAnimation"
  40561. * @returns "TargetedAnimation"
  40562. */
  40563. getClassName(): string;
  40564. /**
  40565. * Serialize the object
  40566. * @returns the JSON object representing the current entity
  40567. */
  40568. serialize(): any;
  40569. }
  40570. /**
  40571. * Use this class to create coordinated animations on multiple targets
  40572. */
  40573. export class AnimationGroup implements IDisposable {
  40574. /** The name of the animation group */
  40575. name: string;
  40576. private _scene;
  40577. private _targetedAnimations;
  40578. private _animatables;
  40579. private _from;
  40580. private _to;
  40581. private _isStarted;
  40582. private _isPaused;
  40583. private _speedRatio;
  40584. private _loopAnimation;
  40585. private _isAdditive;
  40586. /**
  40587. * Gets or sets the unique id of the node
  40588. */
  40589. uniqueId: number;
  40590. /**
  40591. * This observable will notify when one animation have ended
  40592. */
  40593. onAnimationEndObservable: Observable<TargetedAnimation>;
  40594. /**
  40595. * Observer raised when one animation loops
  40596. */
  40597. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40598. /**
  40599. * Observer raised when all animations have looped
  40600. */
  40601. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40602. /**
  40603. * This observable will notify when all animations have ended.
  40604. */
  40605. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40606. /**
  40607. * This observable will notify when all animations have paused.
  40608. */
  40609. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40610. /**
  40611. * This observable will notify when all animations are playing.
  40612. */
  40613. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40614. /**
  40615. * Gets the first frame
  40616. */
  40617. get from(): number;
  40618. /**
  40619. * Gets the last frame
  40620. */
  40621. get to(): number;
  40622. /**
  40623. * Define if the animations are started
  40624. */
  40625. get isStarted(): boolean;
  40626. /**
  40627. * Gets a value indicating that the current group is playing
  40628. */
  40629. get isPlaying(): boolean;
  40630. /**
  40631. * Gets or sets the speed ratio to use for all animations
  40632. */
  40633. get speedRatio(): number;
  40634. /**
  40635. * Gets or sets the speed ratio to use for all animations
  40636. */
  40637. set speedRatio(value: number);
  40638. /**
  40639. * Gets or sets if all animations should loop or not
  40640. */
  40641. get loopAnimation(): boolean;
  40642. set loopAnimation(value: boolean);
  40643. /**
  40644. * Gets or sets if all animations should be evaluated additively
  40645. */
  40646. get isAdditive(): boolean;
  40647. set isAdditive(value: boolean);
  40648. /**
  40649. * Gets the targeted animations for this animation group
  40650. */
  40651. get targetedAnimations(): Array<TargetedAnimation>;
  40652. /**
  40653. * returning the list of animatables controlled by this animation group.
  40654. */
  40655. get animatables(): Array<Animatable>;
  40656. /**
  40657. * Gets the list of target animations
  40658. */
  40659. get children(): TargetedAnimation[];
  40660. /**
  40661. * Instantiates a new Animation Group.
  40662. * This helps managing several animations at once.
  40663. * @see https://doc.babylonjs.com/how_to/group
  40664. * @param name Defines the name of the group
  40665. * @param scene Defines the scene the group belongs to
  40666. */
  40667. constructor(
  40668. /** The name of the animation group */
  40669. name: string, scene?: Nullable<Scene>);
  40670. /**
  40671. * Add an animation (with its target) in the group
  40672. * @param animation defines the animation we want to add
  40673. * @param target defines the target of the animation
  40674. * @returns the TargetedAnimation object
  40675. */
  40676. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40677. /**
  40678. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40679. * It can add constant keys at begin or end
  40680. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40681. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40682. * @returns the animation group
  40683. */
  40684. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40685. private _animationLoopCount;
  40686. private _animationLoopFlags;
  40687. private _processLoop;
  40688. /**
  40689. * Start all animations on given targets
  40690. * @param loop defines if animations must loop
  40691. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40692. * @param from defines the from key (optional)
  40693. * @param to defines the to key (optional)
  40694. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40695. * @returns the current animation group
  40696. */
  40697. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40698. /**
  40699. * Pause all animations
  40700. * @returns the animation group
  40701. */
  40702. pause(): AnimationGroup;
  40703. /**
  40704. * Play all animations to initial state
  40705. * This function will start() the animations if they were not started or will restart() them if they were paused
  40706. * @param loop defines if animations must loop
  40707. * @returns the animation group
  40708. */
  40709. play(loop?: boolean): AnimationGroup;
  40710. /**
  40711. * Reset all animations to initial state
  40712. * @returns the animation group
  40713. */
  40714. reset(): AnimationGroup;
  40715. /**
  40716. * Restart animations from key 0
  40717. * @returns the animation group
  40718. */
  40719. restart(): AnimationGroup;
  40720. /**
  40721. * Stop all animations
  40722. * @returns the animation group
  40723. */
  40724. stop(): AnimationGroup;
  40725. /**
  40726. * Set animation weight for all animatables
  40727. * @param weight defines the weight to use
  40728. * @return the animationGroup
  40729. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40730. */
  40731. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40732. /**
  40733. * Synchronize and normalize all animatables with a source animatable
  40734. * @param root defines the root animatable to synchronize with
  40735. * @return the animationGroup
  40736. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40737. */
  40738. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40739. /**
  40740. * Goes to a specific frame in this animation group
  40741. * @param frame the frame number to go to
  40742. * @return the animationGroup
  40743. */
  40744. goToFrame(frame: number): AnimationGroup;
  40745. /**
  40746. * Dispose all associated resources
  40747. */
  40748. dispose(): void;
  40749. private _checkAnimationGroupEnded;
  40750. /**
  40751. * Clone the current animation group and returns a copy
  40752. * @param newName defines the name of the new group
  40753. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40754. * @returns the new aniamtion group
  40755. */
  40756. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40757. /**
  40758. * Serializes the animationGroup to an object
  40759. * @returns Serialized object
  40760. */
  40761. serialize(): any;
  40762. /**
  40763. * Returns a new AnimationGroup object parsed from the source provided.
  40764. * @param parsedAnimationGroup defines the source
  40765. * @param scene defines the scene that will receive the animationGroup
  40766. * @returns a new AnimationGroup
  40767. */
  40768. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40769. /**
  40770. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40771. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40772. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40773. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40774. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40775. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40776. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40777. */
  40778. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40779. /**
  40780. * Returns the string "AnimationGroup"
  40781. * @returns "AnimationGroup"
  40782. */
  40783. getClassName(): string;
  40784. /**
  40785. * Creates a detailled string about the object
  40786. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40787. * @returns a string representing the object
  40788. */
  40789. toString(fullDetails?: boolean): string;
  40790. }
  40791. }
  40792. declare module "babylonjs/scene" {
  40793. import { Nullable } from "babylonjs/types";
  40794. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40795. import { Observable } from "babylonjs/Misc/observable";
  40796. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40797. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40798. import { Geometry } from "babylonjs/Meshes/geometry";
  40799. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40800. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40802. import { Mesh } from "babylonjs/Meshes/mesh";
  40803. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40804. import { Bone } from "babylonjs/Bones/bone";
  40805. import { Skeleton } from "babylonjs/Bones/skeleton";
  40806. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40807. import { Camera } from "babylonjs/Cameras/camera";
  40808. import { AbstractScene } from "babylonjs/abstractScene";
  40809. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40810. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40811. import { Material } from "babylonjs/Materials/material";
  40812. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40813. import { Effect } from "babylonjs/Materials/effect";
  40814. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40815. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40816. import { Light } from "babylonjs/Lights/light";
  40817. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40818. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40819. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40820. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40821. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40822. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40823. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40824. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40825. import { Engine } from "babylonjs/Engines/engine";
  40826. import { Node } from "babylonjs/node";
  40827. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40828. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40829. import { WebRequest } from "babylonjs/Misc/webRequest";
  40830. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40831. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40832. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40833. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40834. import { Plane } from "babylonjs/Maths/math.plane";
  40835. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40836. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40837. import { Ray } from "babylonjs/Culling/ray";
  40838. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40839. import { Animation } from "babylonjs/Animations/animation";
  40840. import { Animatable } from "babylonjs/Animations/animatable";
  40841. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40842. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40843. import { Collider } from "babylonjs/Collisions/collider";
  40844. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40845. /**
  40846. * Define an interface for all classes that will hold resources
  40847. */
  40848. export interface IDisposable {
  40849. /**
  40850. * Releases all held resources
  40851. */
  40852. dispose(): void;
  40853. }
  40854. /** Interface defining initialization parameters for Scene class */
  40855. export interface SceneOptions {
  40856. /**
  40857. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40858. * It will improve performance when the number of geometries becomes important.
  40859. */
  40860. useGeometryUniqueIdsMap?: boolean;
  40861. /**
  40862. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40863. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40864. */
  40865. useMaterialMeshMap?: boolean;
  40866. /**
  40867. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40868. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40869. */
  40870. useClonedMeshMap?: boolean;
  40871. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40872. virtual?: boolean;
  40873. }
  40874. /**
  40875. * Represents a scene to be rendered by the engine.
  40876. * @see https://doc.babylonjs.com/features/scene
  40877. */
  40878. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40879. /** The fog is deactivated */
  40880. static readonly FOGMODE_NONE: number;
  40881. /** The fog density is following an exponential function */
  40882. static readonly FOGMODE_EXP: number;
  40883. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40884. static readonly FOGMODE_EXP2: number;
  40885. /** The fog density is following a linear function. */
  40886. static readonly FOGMODE_LINEAR: number;
  40887. /**
  40888. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40889. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40890. */
  40891. static MinDeltaTime: number;
  40892. /**
  40893. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40894. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40895. */
  40896. static MaxDeltaTime: number;
  40897. /**
  40898. * Factory used to create the default material.
  40899. * @param name The name of the material to create
  40900. * @param scene The scene to create the material for
  40901. * @returns The default material
  40902. */
  40903. static DefaultMaterialFactory(scene: Scene): Material;
  40904. /**
  40905. * Factory used to create the a collision coordinator.
  40906. * @returns The collision coordinator
  40907. */
  40908. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40909. /** @hidden */
  40910. _inputManager: InputManager;
  40911. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40912. cameraToUseForPointers: Nullable<Camera>;
  40913. /** @hidden */
  40914. readonly _isScene: boolean;
  40915. /** @hidden */
  40916. _blockEntityCollection: boolean;
  40917. /**
  40918. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40919. */
  40920. autoClear: boolean;
  40921. /**
  40922. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40923. */
  40924. autoClearDepthAndStencil: boolean;
  40925. /**
  40926. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40927. */
  40928. clearColor: Color4;
  40929. /**
  40930. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40931. */
  40932. ambientColor: Color3;
  40933. /**
  40934. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40935. * It should only be one of the following (if not the default embedded one):
  40936. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40937. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40938. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40939. * The material properties need to be setup according to the type of texture in use.
  40940. */
  40941. environmentBRDFTexture: BaseTexture;
  40942. /**
  40943. * Texture used in all pbr material as the reflection texture.
  40944. * As in the majority of the scene they are the same (exception for multi room and so on),
  40945. * this is easier to reference from here than from all the materials.
  40946. */
  40947. get environmentTexture(): Nullable<BaseTexture>;
  40948. /**
  40949. * Texture used in all pbr material as the reflection texture.
  40950. * As in the majority of the scene they are the same (exception for multi room and so on),
  40951. * this is easier to set here than in all the materials.
  40952. */
  40953. set environmentTexture(value: Nullable<BaseTexture>);
  40954. /** @hidden */
  40955. protected _environmentIntensity: number;
  40956. /**
  40957. * Intensity of the environment in all pbr material.
  40958. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40959. * As in the majority of the scene they are the same (exception for multi room and so on),
  40960. * this is easier to reference from here than from all the materials.
  40961. */
  40962. get environmentIntensity(): number;
  40963. /**
  40964. * Intensity of the environment in all pbr material.
  40965. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40966. * As in the majority of the scene they are the same (exception for multi room and so on),
  40967. * this is easier to set here than in all the materials.
  40968. */
  40969. set environmentIntensity(value: number);
  40970. /** @hidden */
  40971. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40972. /**
  40973. * Default image processing configuration used either in the rendering
  40974. * Forward main pass or through the imageProcessingPostProcess if present.
  40975. * As in the majority of the scene they are the same (exception for multi camera),
  40976. * this is easier to reference from here than from all the materials and post process.
  40977. *
  40978. * No setter as we it is a shared configuration, you can set the values instead.
  40979. */
  40980. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40981. private _forceWireframe;
  40982. /**
  40983. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40984. */
  40985. set forceWireframe(value: boolean);
  40986. get forceWireframe(): boolean;
  40987. private _skipFrustumClipping;
  40988. /**
  40989. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40990. */
  40991. set skipFrustumClipping(value: boolean);
  40992. get skipFrustumClipping(): boolean;
  40993. private _forcePointsCloud;
  40994. /**
  40995. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40996. */
  40997. set forcePointsCloud(value: boolean);
  40998. get forcePointsCloud(): boolean;
  40999. /**
  41000. * Gets or sets the active clipplane 1
  41001. */
  41002. clipPlane: Nullable<Plane>;
  41003. /**
  41004. * Gets or sets the active clipplane 2
  41005. */
  41006. clipPlane2: Nullable<Plane>;
  41007. /**
  41008. * Gets or sets the active clipplane 3
  41009. */
  41010. clipPlane3: Nullable<Plane>;
  41011. /**
  41012. * Gets or sets the active clipplane 4
  41013. */
  41014. clipPlane4: Nullable<Plane>;
  41015. /**
  41016. * Gets or sets the active clipplane 5
  41017. */
  41018. clipPlane5: Nullable<Plane>;
  41019. /**
  41020. * Gets or sets the active clipplane 6
  41021. */
  41022. clipPlane6: Nullable<Plane>;
  41023. /**
  41024. * Gets or sets a boolean indicating if animations are enabled
  41025. */
  41026. animationsEnabled: boolean;
  41027. private _animationPropertiesOverride;
  41028. /**
  41029. * Gets or sets the animation properties override
  41030. */
  41031. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  41032. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  41033. /**
  41034. * Gets or sets a boolean indicating if a constant deltatime has to be used
  41035. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  41036. */
  41037. useConstantAnimationDeltaTime: boolean;
  41038. /**
  41039. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  41040. * Please note that it requires to run a ray cast through the scene on every frame
  41041. */
  41042. constantlyUpdateMeshUnderPointer: boolean;
  41043. /**
  41044. * Defines the HTML cursor to use when hovering over interactive elements
  41045. */
  41046. hoverCursor: string;
  41047. /**
  41048. * Defines the HTML default cursor to use (empty by default)
  41049. */
  41050. defaultCursor: string;
  41051. /**
  41052. * Defines whether cursors are handled by the scene.
  41053. */
  41054. doNotHandleCursors: boolean;
  41055. /**
  41056. * This is used to call preventDefault() on pointer down
  41057. * in order to block unwanted artifacts like system double clicks
  41058. */
  41059. preventDefaultOnPointerDown: boolean;
  41060. /**
  41061. * This is used to call preventDefault() on pointer up
  41062. * in order to block unwanted artifacts like system double clicks
  41063. */
  41064. preventDefaultOnPointerUp: boolean;
  41065. /**
  41066. * Gets or sets user defined metadata
  41067. */
  41068. metadata: any;
  41069. /**
  41070. * For internal use only. Please do not use.
  41071. */
  41072. reservedDataStore: any;
  41073. /**
  41074. * Gets the name of the plugin used to load this scene (null by default)
  41075. */
  41076. loadingPluginName: string;
  41077. /**
  41078. * Use this array to add regular expressions used to disable offline support for specific urls
  41079. */
  41080. disableOfflineSupportExceptionRules: RegExp[];
  41081. /**
  41082. * An event triggered when the scene is disposed.
  41083. */
  41084. onDisposeObservable: Observable<Scene>;
  41085. private _onDisposeObserver;
  41086. /** Sets a function to be executed when this scene is disposed. */
  41087. set onDispose(callback: () => void);
  41088. /**
  41089. * An event triggered before rendering the scene (right after animations and physics)
  41090. */
  41091. onBeforeRenderObservable: Observable<Scene>;
  41092. private _onBeforeRenderObserver;
  41093. /** Sets a function to be executed before rendering this scene */
  41094. set beforeRender(callback: Nullable<() => void>);
  41095. /**
  41096. * An event triggered after rendering the scene
  41097. */
  41098. onAfterRenderObservable: Observable<Scene>;
  41099. /**
  41100. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41101. */
  41102. onAfterRenderCameraObservable: Observable<Camera>;
  41103. private _onAfterRenderObserver;
  41104. /** Sets a function to be executed after rendering this scene */
  41105. set afterRender(callback: Nullable<() => void>);
  41106. /**
  41107. * An event triggered before animating the scene
  41108. */
  41109. onBeforeAnimationsObservable: Observable<Scene>;
  41110. /**
  41111. * An event triggered after animations processing
  41112. */
  41113. onAfterAnimationsObservable: Observable<Scene>;
  41114. /**
  41115. * An event triggered before draw calls are ready to be sent
  41116. */
  41117. onBeforeDrawPhaseObservable: Observable<Scene>;
  41118. /**
  41119. * An event triggered after draw calls have been sent
  41120. */
  41121. onAfterDrawPhaseObservable: Observable<Scene>;
  41122. /**
  41123. * An event triggered when the scene is ready
  41124. */
  41125. onReadyObservable: Observable<Scene>;
  41126. /**
  41127. * An event triggered before rendering a camera
  41128. */
  41129. onBeforeCameraRenderObservable: Observable<Camera>;
  41130. private _onBeforeCameraRenderObserver;
  41131. /** Sets a function to be executed before rendering a camera*/
  41132. set beforeCameraRender(callback: () => void);
  41133. /**
  41134. * An event triggered after rendering a camera
  41135. */
  41136. onAfterCameraRenderObservable: Observable<Camera>;
  41137. private _onAfterCameraRenderObserver;
  41138. /** Sets a function to be executed after rendering a camera*/
  41139. set afterCameraRender(callback: () => void);
  41140. /**
  41141. * An event triggered when active meshes evaluation is about to start
  41142. */
  41143. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41144. /**
  41145. * An event triggered when active meshes evaluation is done
  41146. */
  41147. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41148. /**
  41149. * An event triggered when particles rendering is about to start
  41150. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41151. */
  41152. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41153. /**
  41154. * An event triggered when particles rendering is done
  41155. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41156. */
  41157. onAfterParticlesRenderingObservable: Observable<Scene>;
  41158. /**
  41159. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41160. */
  41161. onDataLoadedObservable: Observable<Scene>;
  41162. /**
  41163. * An event triggered when a camera is created
  41164. */
  41165. onNewCameraAddedObservable: Observable<Camera>;
  41166. /**
  41167. * An event triggered when a camera is removed
  41168. */
  41169. onCameraRemovedObservable: Observable<Camera>;
  41170. /**
  41171. * An event triggered when a light is created
  41172. */
  41173. onNewLightAddedObservable: Observable<Light>;
  41174. /**
  41175. * An event triggered when a light is removed
  41176. */
  41177. onLightRemovedObservable: Observable<Light>;
  41178. /**
  41179. * An event triggered when a geometry is created
  41180. */
  41181. onNewGeometryAddedObservable: Observable<Geometry>;
  41182. /**
  41183. * An event triggered when a geometry is removed
  41184. */
  41185. onGeometryRemovedObservable: Observable<Geometry>;
  41186. /**
  41187. * An event triggered when a transform node is created
  41188. */
  41189. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41190. /**
  41191. * An event triggered when a transform node is removed
  41192. */
  41193. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41194. /**
  41195. * An event triggered when a mesh is created
  41196. */
  41197. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41198. /**
  41199. * An event triggered when a mesh is removed
  41200. */
  41201. onMeshRemovedObservable: Observable<AbstractMesh>;
  41202. /**
  41203. * An event triggered when a skeleton is created
  41204. */
  41205. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41206. /**
  41207. * An event triggered when a skeleton is removed
  41208. */
  41209. onSkeletonRemovedObservable: Observable<Skeleton>;
  41210. /**
  41211. * An event triggered when a material is created
  41212. */
  41213. onNewMaterialAddedObservable: Observable<Material>;
  41214. /**
  41215. * An event triggered when a material is removed
  41216. */
  41217. onMaterialRemovedObservable: Observable<Material>;
  41218. /**
  41219. * An event triggered when a texture is created
  41220. */
  41221. onNewTextureAddedObservable: Observable<BaseTexture>;
  41222. /**
  41223. * An event triggered when a texture is removed
  41224. */
  41225. onTextureRemovedObservable: Observable<BaseTexture>;
  41226. /**
  41227. * An event triggered when render targets are about to be rendered
  41228. * Can happen multiple times per frame.
  41229. */
  41230. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41231. /**
  41232. * An event triggered when render targets were rendered.
  41233. * Can happen multiple times per frame.
  41234. */
  41235. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41236. /**
  41237. * An event triggered before calculating deterministic simulation step
  41238. */
  41239. onBeforeStepObservable: Observable<Scene>;
  41240. /**
  41241. * An event triggered after calculating deterministic simulation step
  41242. */
  41243. onAfterStepObservable: Observable<Scene>;
  41244. /**
  41245. * An event triggered when the activeCamera property is updated
  41246. */
  41247. onActiveCameraChanged: Observable<Scene>;
  41248. /**
  41249. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41250. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41251. * 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)
  41252. */
  41253. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41254. /**
  41255. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41256. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41257. * 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)
  41258. */
  41259. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41260. /**
  41261. * This Observable will when a mesh has been imported into the scene.
  41262. */
  41263. onMeshImportedObservable: Observable<AbstractMesh>;
  41264. /**
  41265. * This Observable will when an animation file has been imported into the scene.
  41266. */
  41267. onAnimationFileImportedObservable: Observable<Scene>;
  41268. /**
  41269. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41270. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41271. */
  41272. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41273. /** @hidden */
  41274. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41275. /**
  41276. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41277. */
  41278. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41279. /**
  41280. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41281. */
  41282. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41283. /**
  41284. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41285. */
  41286. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41287. /** Callback called when a pointer move is detected */
  41288. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41289. /** Callback called when a pointer down is detected */
  41290. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41291. /** Callback called when a pointer up is detected */
  41292. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41293. /** Callback called when a pointer pick is detected */
  41294. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41295. /**
  41296. * 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).
  41297. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41298. */
  41299. onPrePointerObservable: Observable<PointerInfoPre>;
  41300. /**
  41301. * Observable event triggered each time an input event is received from the rendering canvas
  41302. */
  41303. onPointerObservable: Observable<PointerInfo>;
  41304. /**
  41305. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41306. */
  41307. get unTranslatedPointer(): Vector2;
  41308. /**
  41309. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41310. */
  41311. static get DragMovementThreshold(): number;
  41312. static set DragMovementThreshold(value: number);
  41313. /**
  41314. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41315. */
  41316. static get LongPressDelay(): number;
  41317. static set LongPressDelay(value: number);
  41318. /**
  41319. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41320. */
  41321. static get DoubleClickDelay(): number;
  41322. static set DoubleClickDelay(value: number);
  41323. /** If you need to check double click without raising a single click at first click, enable this flag */
  41324. static get ExclusiveDoubleClickMode(): boolean;
  41325. static set ExclusiveDoubleClickMode(value: boolean);
  41326. /** @hidden */
  41327. _mirroredCameraPosition: Nullable<Vector3>;
  41328. /**
  41329. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41330. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41331. */
  41332. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41333. /**
  41334. * Observable event triggered each time an keyboard event is received from the hosting window
  41335. */
  41336. onKeyboardObservable: Observable<KeyboardInfo>;
  41337. private _useRightHandedSystem;
  41338. /**
  41339. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41340. */
  41341. set useRightHandedSystem(value: boolean);
  41342. get useRightHandedSystem(): boolean;
  41343. private _timeAccumulator;
  41344. private _currentStepId;
  41345. private _currentInternalStep;
  41346. /**
  41347. * Sets the step Id used by deterministic lock step
  41348. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41349. * @param newStepId defines the step Id
  41350. */
  41351. setStepId(newStepId: number): void;
  41352. /**
  41353. * Gets the step Id used by deterministic lock step
  41354. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41355. * @returns the step Id
  41356. */
  41357. getStepId(): number;
  41358. /**
  41359. * Gets the internal step used by deterministic lock step
  41360. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41361. * @returns the internal step
  41362. */
  41363. getInternalStep(): number;
  41364. private _fogEnabled;
  41365. /**
  41366. * Gets or sets a boolean indicating if fog is enabled on this scene
  41367. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41368. * (Default is true)
  41369. */
  41370. set fogEnabled(value: boolean);
  41371. get fogEnabled(): boolean;
  41372. private _fogMode;
  41373. /**
  41374. * Gets or sets the fog mode to use
  41375. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41376. * | mode | value |
  41377. * | --- | --- |
  41378. * | FOGMODE_NONE | 0 |
  41379. * | FOGMODE_EXP | 1 |
  41380. * | FOGMODE_EXP2 | 2 |
  41381. * | FOGMODE_LINEAR | 3 |
  41382. */
  41383. set fogMode(value: number);
  41384. get fogMode(): number;
  41385. /**
  41386. * Gets or sets the fog color to use
  41387. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41388. * (Default is Color3(0.2, 0.2, 0.3))
  41389. */
  41390. fogColor: Color3;
  41391. /**
  41392. * Gets or sets the fog density to use
  41393. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41394. * (Default is 0.1)
  41395. */
  41396. fogDensity: number;
  41397. /**
  41398. * Gets or sets the fog start distance to use
  41399. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41400. * (Default is 0)
  41401. */
  41402. fogStart: number;
  41403. /**
  41404. * Gets or sets the fog end distance to use
  41405. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41406. * (Default is 1000)
  41407. */
  41408. fogEnd: number;
  41409. /**
  41410. * Flag indicating that the frame buffer binding is handled by another component
  41411. */
  41412. prePass: boolean;
  41413. private _shadowsEnabled;
  41414. /**
  41415. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41416. */
  41417. set shadowsEnabled(value: boolean);
  41418. get shadowsEnabled(): boolean;
  41419. private _lightsEnabled;
  41420. /**
  41421. * Gets or sets a boolean indicating if lights are enabled on this scene
  41422. */
  41423. set lightsEnabled(value: boolean);
  41424. get lightsEnabled(): boolean;
  41425. /** All of the active cameras added to this scene. */
  41426. activeCameras: Camera[];
  41427. /** @hidden */
  41428. _activeCamera: Nullable<Camera>;
  41429. /** Gets or sets the current active camera */
  41430. get activeCamera(): Nullable<Camera>;
  41431. set activeCamera(value: Nullable<Camera>);
  41432. private _defaultMaterial;
  41433. /** The default material used on meshes when no material is affected */
  41434. get defaultMaterial(): Material;
  41435. /** The default material used on meshes when no material is affected */
  41436. set defaultMaterial(value: Material);
  41437. private _texturesEnabled;
  41438. /**
  41439. * Gets or sets a boolean indicating if textures are enabled on this scene
  41440. */
  41441. set texturesEnabled(value: boolean);
  41442. get texturesEnabled(): boolean;
  41443. /**
  41444. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41445. */
  41446. physicsEnabled: boolean;
  41447. /**
  41448. * Gets or sets a boolean indicating if particles are enabled on this scene
  41449. */
  41450. particlesEnabled: boolean;
  41451. /**
  41452. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41453. */
  41454. spritesEnabled: boolean;
  41455. private _skeletonsEnabled;
  41456. /**
  41457. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41458. */
  41459. set skeletonsEnabled(value: boolean);
  41460. get skeletonsEnabled(): boolean;
  41461. /**
  41462. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41463. */
  41464. lensFlaresEnabled: boolean;
  41465. /**
  41466. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41467. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41468. */
  41469. collisionsEnabled: boolean;
  41470. private _collisionCoordinator;
  41471. /** @hidden */
  41472. get collisionCoordinator(): ICollisionCoordinator;
  41473. /**
  41474. * Defines the gravity applied to this scene (used only for collisions)
  41475. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41476. */
  41477. gravity: Vector3;
  41478. /**
  41479. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41480. */
  41481. postProcessesEnabled: boolean;
  41482. /**
  41483. * Gets the current postprocess manager
  41484. */
  41485. postProcessManager: PostProcessManager;
  41486. /**
  41487. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41488. */
  41489. renderTargetsEnabled: boolean;
  41490. /**
  41491. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41492. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41493. */
  41494. dumpNextRenderTargets: boolean;
  41495. /**
  41496. * The list of user defined render targets added to the scene
  41497. */
  41498. customRenderTargets: RenderTargetTexture[];
  41499. /**
  41500. * Defines if texture loading must be delayed
  41501. * If true, textures will only be loaded when they need to be rendered
  41502. */
  41503. useDelayedTextureLoading: boolean;
  41504. /**
  41505. * Gets the list of meshes imported to the scene through SceneLoader
  41506. */
  41507. importedMeshesFiles: String[];
  41508. /**
  41509. * Gets or sets a boolean indicating if probes are enabled on this scene
  41510. */
  41511. probesEnabled: boolean;
  41512. /**
  41513. * Gets or sets the current offline provider to use to store scene data
  41514. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41515. */
  41516. offlineProvider: IOfflineProvider;
  41517. /**
  41518. * Gets or sets the action manager associated with the scene
  41519. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41520. */
  41521. actionManager: AbstractActionManager;
  41522. private _meshesForIntersections;
  41523. /**
  41524. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41525. */
  41526. proceduralTexturesEnabled: boolean;
  41527. private _engine;
  41528. private _totalVertices;
  41529. /** @hidden */
  41530. _activeIndices: PerfCounter;
  41531. /** @hidden */
  41532. _activeParticles: PerfCounter;
  41533. /** @hidden */
  41534. _activeBones: PerfCounter;
  41535. private _animationRatio;
  41536. /** @hidden */
  41537. _animationTimeLast: number;
  41538. /** @hidden */
  41539. _animationTime: number;
  41540. /**
  41541. * Gets or sets a general scale for animation speed
  41542. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41543. */
  41544. animationTimeScale: number;
  41545. /** @hidden */
  41546. _cachedMaterial: Nullable<Material>;
  41547. /** @hidden */
  41548. _cachedEffect: Nullable<Effect>;
  41549. /** @hidden */
  41550. _cachedVisibility: Nullable<number>;
  41551. private _renderId;
  41552. private _frameId;
  41553. private _executeWhenReadyTimeoutId;
  41554. private _intermediateRendering;
  41555. private _viewUpdateFlag;
  41556. private _projectionUpdateFlag;
  41557. /** @hidden */
  41558. _toBeDisposed: Nullable<IDisposable>[];
  41559. private _activeRequests;
  41560. /** @hidden */
  41561. _pendingData: any[];
  41562. private _isDisposed;
  41563. /**
  41564. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41565. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41566. */
  41567. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41568. private _activeMeshes;
  41569. private _processedMaterials;
  41570. private _renderTargets;
  41571. /** @hidden */
  41572. _activeParticleSystems: SmartArray<IParticleSystem>;
  41573. private _activeSkeletons;
  41574. private _softwareSkinnedMeshes;
  41575. private _renderingManager;
  41576. /** @hidden */
  41577. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41578. private _transformMatrix;
  41579. private _sceneUbo;
  41580. /** @hidden */
  41581. _viewMatrix: Matrix;
  41582. private _projectionMatrix;
  41583. /** @hidden */
  41584. _forcedViewPosition: Nullable<Vector3>;
  41585. /** @hidden */
  41586. _frustumPlanes: Plane[];
  41587. /**
  41588. * Gets the list of frustum planes (built from the active camera)
  41589. */
  41590. get frustumPlanes(): Plane[];
  41591. /**
  41592. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41593. * This is useful if there are more lights that the maximum simulteanous authorized
  41594. */
  41595. requireLightSorting: boolean;
  41596. /** @hidden */
  41597. readonly useMaterialMeshMap: boolean;
  41598. /** @hidden */
  41599. readonly useClonedMeshMap: boolean;
  41600. private _externalData;
  41601. private _uid;
  41602. /**
  41603. * @hidden
  41604. * Backing store of defined scene components.
  41605. */
  41606. _components: ISceneComponent[];
  41607. /**
  41608. * @hidden
  41609. * Backing store of defined scene components.
  41610. */
  41611. _serializableComponents: ISceneSerializableComponent[];
  41612. /**
  41613. * List of components to register on the next registration step.
  41614. */
  41615. private _transientComponents;
  41616. /**
  41617. * Registers the transient components if needed.
  41618. */
  41619. private _registerTransientComponents;
  41620. /**
  41621. * @hidden
  41622. * Add a component to the scene.
  41623. * Note that the ccomponent could be registered on th next frame if this is called after
  41624. * the register component stage.
  41625. * @param component Defines the component to add to the scene
  41626. */
  41627. _addComponent(component: ISceneComponent): void;
  41628. /**
  41629. * @hidden
  41630. * Gets a component from the scene.
  41631. * @param name defines the name of the component to retrieve
  41632. * @returns the component or null if not present
  41633. */
  41634. _getComponent(name: string): Nullable<ISceneComponent>;
  41635. /**
  41636. * @hidden
  41637. * Defines the actions happening before camera updates.
  41638. */
  41639. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41640. /**
  41641. * @hidden
  41642. * Defines the actions happening before clear the canvas.
  41643. */
  41644. _beforeClearStage: Stage<SimpleStageAction>;
  41645. /**
  41646. * @hidden
  41647. * Defines the actions when collecting render targets for the frame.
  41648. */
  41649. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41650. /**
  41651. * @hidden
  41652. * Defines the actions happening for one camera in the frame.
  41653. */
  41654. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41655. /**
  41656. * @hidden
  41657. * Defines the actions happening during the per mesh ready checks.
  41658. */
  41659. _isReadyForMeshStage: Stage<MeshStageAction>;
  41660. /**
  41661. * @hidden
  41662. * Defines the actions happening before evaluate active mesh checks.
  41663. */
  41664. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41665. /**
  41666. * @hidden
  41667. * Defines the actions happening during the evaluate sub mesh checks.
  41668. */
  41669. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41670. /**
  41671. * @hidden
  41672. * Defines the actions happening during the active mesh stage.
  41673. */
  41674. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41675. /**
  41676. * @hidden
  41677. * Defines the actions happening during the per camera render target step.
  41678. */
  41679. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41680. /**
  41681. * @hidden
  41682. * Defines the actions happening just before the active camera is drawing.
  41683. */
  41684. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41685. /**
  41686. * @hidden
  41687. * Defines the actions happening just before a render target is drawing.
  41688. */
  41689. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41690. /**
  41691. * @hidden
  41692. * Defines the actions happening just before a rendering group is drawing.
  41693. */
  41694. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41695. /**
  41696. * @hidden
  41697. * Defines the actions happening just before a mesh is drawing.
  41698. */
  41699. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41700. /**
  41701. * @hidden
  41702. * Defines the actions happening just after a mesh has been drawn.
  41703. */
  41704. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41705. /**
  41706. * @hidden
  41707. * Defines the actions happening just after a rendering group has been drawn.
  41708. */
  41709. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41710. /**
  41711. * @hidden
  41712. * Defines the actions happening just after the active camera has been drawn.
  41713. */
  41714. _afterCameraDrawStage: Stage<CameraStageAction>;
  41715. /**
  41716. * @hidden
  41717. * Defines the actions happening just after a render target has been drawn.
  41718. */
  41719. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41720. /**
  41721. * @hidden
  41722. * Defines the actions happening just after rendering all cameras and computing intersections.
  41723. */
  41724. _afterRenderStage: Stage<SimpleStageAction>;
  41725. /**
  41726. * @hidden
  41727. * Defines the actions happening when a pointer move event happens.
  41728. */
  41729. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41730. /**
  41731. * @hidden
  41732. * Defines the actions happening when a pointer down event happens.
  41733. */
  41734. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41735. /**
  41736. * @hidden
  41737. * Defines the actions happening when a pointer up event happens.
  41738. */
  41739. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41740. /**
  41741. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41742. */
  41743. private geometriesByUniqueId;
  41744. /**
  41745. * Creates a new Scene
  41746. * @param engine defines the engine to use to render this scene
  41747. * @param options defines the scene options
  41748. */
  41749. constructor(engine: Engine, options?: SceneOptions);
  41750. /**
  41751. * Gets a string identifying the name of the class
  41752. * @returns "Scene" string
  41753. */
  41754. getClassName(): string;
  41755. private _defaultMeshCandidates;
  41756. /**
  41757. * @hidden
  41758. */
  41759. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41760. private _defaultSubMeshCandidates;
  41761. /**
  41762. * @hidden
  41763. */
  41764. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41765. /**
  41766. * Sets the default candidate providers for the scene.
  41767. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41768. * and getCollidingSubMeshCandidates to their default function
  41769. */
  41770. setDefaultCandidateProviders(): void;
  41771. /**
  41772. * Gets the mesh that is currently under the pointer
  41773. */
  41774. get meshUnderPointer(): Nullable<AbstractMesh>;
  41775. /**
  41776. * Gets or sets the current on-screen X position of the pointer
  41777. */
  41778. get pointerX(): number;
  41779. set pointerX(value: number);
  41780. /**
  41781. * Gets or sets the current on-screen Y position of the pointer
  41782. */
  41783. get pointerY(): number;
  41784. set pointerY(value: number);
  41785. /**
  41786. * Gets the cached material (ie. the latest rendered one)
  41787. * @returns the cached material
  41788. */
  41789. getCachedMaterial(): Nullable<Material>;
  41790. /**
  41791. * Gets the cached effect (ie. the latest rendered one)
  41792. * @returns the cached effect
  41793. */
  41794. getCachedEffect(): Nullable<Effect>;
  41795. /**
  41796. * Gets the cached visibility state (ie. the latest rendered one)
  41797. * @returns the cached visibility state
  41798. */
  41799. getCachedVisibility(): Nullable<number>;
  41800. /**
  41801. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41802. * @param material defines the current material
  41803. * @param effect defines the current effect
  41804. * @param visibility defines the current visibility state
  41805. * @returns true if one parameter is not cached
  41806. */
  41807. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41808. /**
  41809. * Gets the engine associated with the scene
  41810. * @returns an Engine
  41811. */
  41812. getEngine(): Engine;
  41813. /**
  41814. * Gets the total number of vertices rendered per frame
  41815. * @returns the total number of vertices rendered per frame
  41816. */
  41817. getTotalVertices(): number;
  41818. /**
  41819. * Gets the performance counter for total vertices
  41820. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41821. */
  41822. get totalVerticesPerfCounter(): PerfCounter;
  41823. /**
  41824. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41825. * @returns the total number of active indices rendered per frame
  41826. */
  41827. getActiveIndices(): number;
  41828. /**
  41829. * Gets the performance counter for active indices
  41830. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41831. */
  41832. get totalActiveIndicesPerfCounter(): PerfCounter;
  41833. /**
  41834. * Gets the total number of active particles rendered per frame
  41835. * @returns the total number of active particles rendered per frame
  41836. */
  41837. getActiveParticles(): number;
  41838. /**
  41839. * Gets the performance counter for active particles
  41840. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41841. */
  41842. get activeParticlesPerfCounter(): PerfCounter;
  41843. /**
  41844. * Gets the total number of active bones rendered per frame
  41845. * @returns the total number of active bones rendered per frame
  41846. */
  41847. getActiveBones(): number;
  41848. /**
  41849. * Gets the performance counter for active bones
  41850. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41851. */
  41852. get activeBonesPerfCounter(): PerfCounter;
  41853. /**
  41854. * Gets the array of active meshes
  41855. * @returns an array of AbstractMesh
  41856. */
  41857. getActiveMeshes(): SmartArray<AbstractMesh>;
  41858. /**
  41859. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41860. * @returns a number
  41861. */
  41862. getAnimationRatio(): number;
  41863. /**
  41864. * Gets an unique Id for the current render phase
  41865. * @returns a number
  41866. */
  41867. getRenderId(): number;
  41868. /**
  41869. * Gets an unique Id for the current frame
  41870. * @returns a number
  41871. */
  41872. getFrameId(): number;
  41873. /** Call this function if you want to manually increment the render Id*/
  41874. incrementRenderId(): void;
  41875. private _createUbo;
  41876. /**
  41877. * Use this method to simulate a pointer move on a mesh
  41878. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41879. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41880. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41881. * @returns the current scene
  41882. */
  41883. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41884. /**
  41885. * Use this method to simulate a pointer down on a mesh
  41886. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41887. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41888. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41889. * @returns the current scene
  41890. */
  41891. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41892. /**
  41893. * Use this method to simulate a pointer up on a mesh
  41894. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41895. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41896. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41897. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41898. * @returns the current scene
  41899. */
  41900. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41901. /**
  41902. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41903. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41904. * @returns true if the pointer was captured
  41905. */
  41906. isPointerCaptured(pointerId?: number): boolean;
  41907. /**
  41908. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41909. * @param attachUp defines if you want to attach events to pointerup
  41910. * @param attachDown defines if you want to attach events to pointerdown
  41911. * @param attachMove defines if you want to attach events to pointermove
  41912. */
  41913. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41914. /** Detaches all event handlers*/
  41915. detachControl(): void;
  41916. /**
  41917. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41918. * Delay loaded resources are not taking in account
  41919. * @return true if all required resources are ready
  41920. */
  41921. isReady(): boolean;
  41922. /** Resets all cached information relative to material (including effect and visibility) */
  41923. resetCachedMaterial(): void;
  41924. /**
  41925. * Registers a function to be called before every frame render
  41926. * @param func defines the function to register
  41927. */
  41928. registerBeforeRender(func: () => void): void;
  41929. /**
  41930. * Unregisters a function called before every frame render
  41931. * @param func defines the function to unregister
  41932. */
  41933. unregisterBeforeRender(func: () => void): void;
  41934. /**
  41935. * Registers a function to be called after every frame render
  41936. * @param func defines the function to register
  41937. */
  41938. registerAfterRender(func: () => void): void;
  41939. /**
  41940. * Unregisters a function called after every frame render
  41941. * @param func defines the function to unregister
  41942. */
  41943. unregisterAfterRender(func: () => void): void;
  41944. private _executeOnceBeforeRender;
  41945. /**
  41946. * The provided function will run before render once and will be disposed afterwards.
  41947. * A timeout delay can be provided so that the function will be executed in N ms.
  41948. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41949. * @param func The function to be executed.
  41950. * @param timeout optional delay in ms
  41951. */
  41952. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41953. /** @hidden */
  41954. _addPendingData(data: any): void;
  41955. /** @hidden */
  41956. _removePendingData(data: any): void;
  41957. /**
  41958. * Returns the number of items waiting to be loaded
  41959. * @returns the number of items waiting to be loaded
  41960. */
  41961. getWaitingItemsCount(): number;
  41962. /**
  41963. * Returns a boolean indicating if the scene is still loading data
  41964. */
  41965. get isLoading(): boolean;
  41966. /**
  41967. * Registers a function to be executed when the scene is ready
  41968. * @param {Function} func - the function to be executed
  41969. */
  41970. executeWhenReady(func: () => void): void;
  41971. /**
  41972. * Returns a promise that resolves when the scene is ready
  41973. * @returns A promise that resolves when the scene is ready
  41974. */
  41975. whenReadyAsync(): Promise<void>;
  41976. /** @hidden */
  41977. _checkIsReady(): void;
  41978. /**
  41979. * Gets all animatable attached to the scene
  41980. */
  41981. get animatables(): Animatable[];
  41982. /**
  41983. * Resets the last animation time frame.
  41984. * Useful to override when animations start running when loading a scene for the first time.
  41985. */
  41986. resetLastAnimationTimeFrame(): void;
  41987. /**
  41988. * Gets the current view matrix
  41989. * @returns a Matrix
  41990. */
  41991. getViewMatrix(): Matrix;
  41992. /**
  41993. * Gets the current projection matrix
  41994. * @returns a Matrix
  41995. */
  41996. getProjectionMatrix(): Matrix;
  41997. /**
  41998. * Gets the current transform matrix
  41999. * @returns a Matrix made of View * Projection
  42000. */
  42001. getTransformMatrix(): Matrix;
  42002. /**
  42003. * Sets the current transform matrix
  42004. * @param viewL defines the View matrix to use
  42005. * @param projectionL defines the Projection matrix to use
  42006. * @param viewR defines the right View matrix to use (if provided)
  42007. * @param projectionR defines the right Projection matrix to use (if provided)
  42008. */
  42009. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  42010. /**
  42011. * Gets the uniform buffer used to store scene data
  42012. * @returns a UniformBuffer
  42013. */
  42014. getSceneUniformBuffer(): UniformBuffer;
  42015. /**
  42016. * Gets an unique (relatively to the current scene) Id
  42017. * @returns an unique number for the scene
  42018. */
  42019. getUniqueId(): number;
  42020. /**
  42021. * Add a mesh to the list of scene's meshes
  42022. * @param newMesh defines the mesh to add
  42023. * @param recursive if all child meshes should also be added to the scene
  42024. */
  42025. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  42026. /**
  42027. * Remove a mesh for the list of scene's meshes
  42028. * @param toRemove defines the mesh to remove
  42029. * @param recursive if all child meshes should also be removed from the scene
  42030. * @returns the index where the mesh was in the mesh list
  42031. */
  42032. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  42033. /**
  42034. * Add a transform node to the list of scene's transform nodes
  42035. * @param newTransformNode defines the transform node to add
  42036. */
  42037. addTransformNode(newTransformNode: TransformNode): void;
  42038. /**
  42039. * Remove a transform node for the list of scene's transform nodes
  42040. * @param toRemove defines the transform node to remove
  42041. * @returns the index where the transform node was in the transform node list
  42042. */
  42043. removeTransformNode(toRemove: TransformNode): number;
  42044. /**
  42045. * Remove a skeleton for the list of scene's skeletons
  42046. * @param toRemove defines the skeleton to remove
  42047. * @returns the index where the skeleton was in the skeleton list
  42048. */
  42049. removeSkeleton(toRemove: Skeleton): number;
  42050. /**
  42051. * Remove a morph target for the list of scene's morph targets
  42052. * @param toRemove defines the morph target to remove
  42053. * @returns the index where the morph target was in the morph target list
  42054. */
  42055. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  42056. /**
  42057. * Remove a light for the list of scene's lights
  42058. * @param toRemove defines the light to remove
  42059. * @returns the index where the light was in the light list
  42060. */
  42061. removeLight(toRemove: Light): number;
  42062. /**
  42063. * Remove a camera for the list of scene's cameras
  42064. * @param toRemove defines the camera to remove
  42065. * @returns the index where the camera was in the camera list
  42066. */
  42067. removeCamera(toRemove: Camera): number;
  42068. /**
  42069. * Remove a particle system for the list of scene's particle systems
  42070. * @param toRemove defines the particle system to remove
  42071. * @returns the index where the particle system was in the particle system list
  42072. */
  42073. removeParticleSystem(toRemove: IParticleSystem): number;
  42074. /**
  42075. * Remove a animation for the list of scene's animations
  42076. * @param toRemove defines the animation to remove
  42077. * @returns the index where the animation was in the animation list
  42078. */
  42079. removeAnimation(toRemove: Animation): number;
  42080. /**
  42081. * Will stop the animation of the given target
  42082. * @param target - the target
  42083. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42084. * @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)
  42085. */
  42086. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42087. /**
  42088. * Removes the given animation group from this scene.
  42089. * @param toRemove The animation group to remove
  42090. * @returns The index of the removed animation group
  42091. */
  42092. removeAnimationGroup(toRemove: AnimationGroup): number;
  42093. /**
  42094. * Removes the given multi-material from this scene.
  42095. * @param toRemove The multi-material to remove
  42096. * @returns The index of the removed multi-material
  42097. */
  42098. removeMultiMaterial(toRemove: MultiMaterial): number;
  42099. /**
  42100. * Removes the given material from this scene.
  42101. * @param toRemove The material to remove
  42102. * @returns The index of the removed material
  42103. */
  42104. removeMaterial(toRemove: Material): number;
  42105. /**
  42106. * Removes the given action manager from this scene.
  42107. * @param toRemove The action manager to remove
  42108. * @returns The index of the removed action manager
  42109. */
  42110. removeActionManager(toRemove: AbstractActionManager): number;
  42111. /**
  42112. * Removes the given texture from this scene.
  42113. * @param toRemove The texture to remove
  42114. * @returns The index of the removed texture
  42115. */
  42116. removeTexture(toRemove: BaseTexture): number;
  42117. /**
  42118. * Adds the given light to this scene
  42119. * @param newLight The light to add
  42120. */
  42121. addLight(newLight: Light): void;
  42122. /**
  42123. * Sorts the list list based on light priorities
  42124. */
  42125. sortLightsByPriority(): void;
  42126. /**
  42127. * Adds the given camera to this scene
  42128. * @param newCamera The camera to add
  42129. */
  42130. addCamera(newCamera: Camera): void;
  42131. /**
  42132. * Adds the given skeleton to this scene
  42133. * @param newSkeleton The skeleton to add
  42134. */
  42135. addSkeleton(newSkeleton: Skeleton): void;
  42136. /**
  42137. * Adds the given particle system to this scene
  42138. * @param newParticleSystem The particle system to add
  42139. */
  42140. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42141. /**
  42142. * Adds the given animation to this scene
  42143. * @param newAnimation The animation to add
  42144. */
  42145. addAnimation(newAnimation: Animation): void;
  42146. /**
  42147. * Adds the given animation group to this scene.
  42148. * @param newAnimationGroup The animation group to add
  42149. */
  42150. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42151. /**
  42152. * Adds the given multi-material to this scene
  42153. * @param newMultiMaterial The multi-material to add
  42154. */
  42155. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42156. /**
  42157. * Adds the given material to this scene
  42158. * @param newMaterial The material to add
  42159. */
  42160. addMaterial(newMaterial: Material): void;
  42161. /**
  42162. * Adds the given morph target to this scene
  42163. * @param newMorphTargetManager The morph target to add
  42164. */
  42165. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42166. /**
  42167. * Adds the given geometry to this scene
  42168. * @param newGeometry The geometry to add
  42169. */
  42170. addGeometry(newGeometry: Geometry): void;
  42171. /**
  42172. * Adds the given action manager to this scene
  42173. * @param newActionManager The action manager to add
  42174. */
  42175. addActionManager(newActionManager: AbstractActionManager): void;
  42176. /**
  42177. * Adds the given texture to this scene.
  42178. * @param newTexture The texture to add
  42179. */
  42180. addTexture(newTexture: BaseTexture): void;
  42181. /**
  42182. * Switch active camera
  42183. * @param newCamera defines the new active camera
  42184. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42185. */
  42186. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42187. /**
  42188. * sets the active camera of the scene using its ID
  42189. * @param id defines the camera's ID
  42190. * @return the new active camera or null if none found.
  42191. */
  42192. setActiveCameraByID(id: string): Nullable<Camera>;
  42193. /**
  42194. * sets the active camera of the scene using its name
  42195. * @param name defines the camera's name
  42196. * @returns the new active camera or null if none found.
  42197. */
  42198. setActiveCameraByName(name: string): Nullable<Camera>;
  42199. /**
  42200. * get an animation group using its name
  42201. * @param name defines the material's name
  42202. * @return the animation group or null if none found.
  42203. */
  42204. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42205. /**
  42206. * Get a material using its unique id
  42207. * @param uniqueId defines the material's unique id
  42208. * @return the material or null if none found.
  42209. */
  42210. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42211. /**
  42212. * get a material using its id
  42213. * @param id defines the material's ID
  42214. * @return the material or null if none found.
  42215. */
  42216. getMaterialByID(id: string): Nullable<Material>;
  42217. /**
  42218. * Gets a the last added material using a given id
  42219. * @param id defines the material's ID
  42220. * @return the last material with the given id or null if none found.
  42221. */
  42222. getLastMaterialByID(id: string): Nullable<Material>;
  42223. /**
  42224. * Gets a material using its name
  42225. * @param name defines the material's name
  42226. * @return the material or null if none found.
  42227. */
  42228. getMaterialByName(name: string): Nullable<Material>;
  42229. /**
  42230. * Get a texture using its unique id
  42231. * @param uniqueId defines the texture's unique id
  42232. * @return the texture or null if none found.
  42233. */
  42234. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42235. /**
  42236. * Gets a camera using its id
  42237. * @param id defines the id to look for
  42238. * @returns the camera or null if not found
  42239. */
  42240. getCameraByID(id: string): Nullable<Camera>;
  42241. /**
  42242. * Gets a camera using its unique id
  42243. * @param uniqueId defines the unique id to look for
  42244. * @returns the camera or null if not found
  42245. */
  42246. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42247. /**
  42248. * Gets a camera using its name
  42249. * @param name defines the camera's name
  42250. * @return the camera or null if none found.
  42251. */
  42252. getCameraByName(name: string): Nullable<Camera>;
  42253. /**
  42254. * Gets a bone using its id
  42255. * @param id defines the bone's id
  42256. * @return the bone or null if not found
  42257. */
  42258. getBoneByID(id: string): Nullable<Bone>;
  42259. /**
  42260. * Gets a bone using its id
  42261. * @param name defines the bone's name
  42262. * @return the bone or null if not found
  42263. */
  42264. getBoneByName(name: string): Nullable<Bone>;
  42265. /**
  42266. * Gets a light node using its name
  42267. * @param name defines the the light's name
  42268. * @return the light or null if none found.
  42269. */
  42270. getLightByName(name: string): Nullable<Light>;
  42271. /**
  42272. * Gets a light node using its id
  42273. * @param id defines the light's id
  42274. * @return the light or null if none found.
  42275. */
  42276. getLightByID(id: string): Nullable<Light>;
  42277. /**
  42278. * Gets a light node using its scene-generated unique ID
  42279. * @param uniqueId defines the light's unique id
  42280. * @return the light or null if none found.
  42281. */
  42282. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42283. /**
  42284. * Gets a particle system by id
  42285. * @param id defines the particle system id
  42286. * @return the corresponding system or null if none found
  42287. */
  42288. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42289. /**
  42290. * Gets a geometry using its ID
  42291. * @param id defines the geometry's id
  42292. * @return the geometry or null if none found.
  42293. */
  42294. getGeometryByID(id: string): Nullable<Geometry>;
  42295. private _getGeometryByUniqueID;
  42296. /**
  42297. * Add a new geometry to this scene
  42298. * @param geometry defines the geometry to be added to the scene.
  42299. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42300. * @return a boolean defining if the geometry was added or not
  42301. */
  42302. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42303. /**
  42304. * Removes an existing geometry
  42305. * @param geometry defines the geometry to be removed from the scene
  42306. * @return a boolean defining if the geometry was removed or not
  42307. */
  42308. removeGeometry(geometry: Geometry): boolean;
  42309. /**
  42310. * Gets the list of geometries attached to the scene
  42311. * @returns an array of Geometry
  42312. */
  42313. getGeometries(): Geometry[];
  42314. /**
  42315. * Gets the first added mesh found of a given ID
  42316. * @param id defines the id to search for
  42317. * @return the mesh found or null if not found at all
  42318. */
  42319. getMeshByID(id: string): Nullable<AbstractMesh>;
  42320. /**
  42321. * Gets a list of meshes using their id
  42322. * @param id defines the id to search for
  42323. * @returns a list of meshes
  42324. */
  42325. getMeshesByID(id: string): Array<AbstractMesh>;
  42326. /**
  42327. * Gets the first added transform node found of a given ID
  42328. * @param id defines the id to search for
  42329. * @return the found transform node or null if not found at all.
  42330. */
  42331. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42332. /**
  42333. * Gets a transform node with its auto-generated unique id
  42334. * @param uniqueId efines the unique id to search for
  42335. * @return the found transform node or null if not found at all.
  42336. */
  42337. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42338. /**
  42339. * Gets a list of transform nodes using their id
  42340. * @param id defines the id to search for
  42341. * @returns a list of transform nodes
  42342. */
  42343. getTransformNodesByID(id: string): Array<TransformNode>;
  42344. /**
  42345. * Gets a mesh with its auto-generated unique id
  42346. * @param uniqueId defines the unique id to search for
  42347. * @return the found mesh or null if not found at all.
  42348. */
  42349. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42350. /**
  42351. * Gets a the last added mesh using a given id
  42352. * @param id defines the id to search for
  42353. * @return the found mesh or null if not found at all.
  42354. */
  42355. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42356. /**
  42357. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42358. * @param id defines the id to search for
  42359. * @return the found node or null if not found at all
  42360. */
  42361. getLastEntryByID(id: string): Nullable<Node>;
  42362. /**
  42363. * Gets a node (Mesh, Camera, Light) using a given id
  42364. * @param id defines the id to search for
  42365. * @return the found node or null if not found at all
  42366. */
  42367. getNodeByID(id: string): Nullable<Node>;
  42368. /**
  42369. * Gets a node (Mesh, Camera, Light) using a given name
  42370. * @param name defines the name to search for
  42371. * @return the found node or null if not found at all.
  42372. */
  42373. getNodeByName(name: string): Nullable<Node>;
  42374. /**
  42375. * Gets a mesh using a given name
  42376. * @param name defines the name to search for
  42377. * @return the found mesh or null if not found at all.
  42378. */
  42379. getMeshByName(name: string): Nullable<AbstractMesh>;
  42380. /**
  42381. * Gets a transform node using a given name
  42382. * @param name defines the name to search for
  42383. * @return the found transform node or null if not found at all.
  42384. */
  42385. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42386. /**
  42387. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42388. * @param id defines the id to search for
  42389. * @return the found skeleton or null if not found at all.
  42390. */
  42391. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42392. /**
  42393. * Gets a skeleton using a given auto generated unique id
  42394. * @param uniqueId defines the unique id to search for
  42395. * @return the found skeleton or null if not found at all.
  42396. */
  42397. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42398. /**
  42399. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42400. * @param id defines the id to search for
  42401. * @return the found skeleton or null if not found at all.
  42402. */
  42403. getSkeletonById(id: string): Nullable<Skeleton>;
  42404. /**
  42405. * Gets a skeleton using a given name
  42406. * @param name defines the name to search for
  42407. * @return the found skeleton or null if not found at all.
  42408. */
  42409. getSkeletonByName(name: string): Nullable<Skeleton>;
  42410. /**
  42411. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42412. * @param id defines the id to search for
  42413. * @return the found morph target manager or null if not found at all.
  42414. */
  42415. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42416. /**
  42417. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42418. * @param id defines the id to search for
  42419. * @return the found morph target or null if not found at all.
  42420. */
  42421. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42422. /**
  42423. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42424. * @param name defines the name to search for
  42425. * @return the found morph target or null if not found at all.
  42426. */
  42427. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42428. /**
  42429. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42430. * @param name defines the name to search for
  42431. * @return the found post process or null if not found at all.
  42432. */
  42433. getPostProcessByName(name: string): Nullable<PostProcess>;
  42434. /**
  42435. * Gets a boolean indicating if the given mesh is active
  42436. * @param mesh defines the mesh to look for
  42437. * @returns true if the mesh is in the active list
  42438. */
  42439. isActiveMesh(mesh: AbstractMesh): boolean;
  42440. /**
  42441. * Return a unique id as a string which can serve as an identifier for the scene
  42442. */
  42443. get uid(): string;
  42444. /**
  42445. * Add an externaly attached data from its key.
  42446. * This method call will fail and return false, if such key already exists.
  42447. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42448. * @param key the unique key that identifies the data
  42449. * @param data the data object to associate to the key for this Engine instance
  42450. * @return true if no such key were already present and the data was added successfully, false otherwise
  42451. */
  42452. addExternalData<T>(key: string, data: T): boolean;
  42453. /**
  42454. * Get an externaly attached data from its key
  42455. * @param key the unique key that identifies the data
  42456. * @return the associated data, if present (can be null), or undefined if not present
  42457. */
  42458. getExternalData<T>(key: string): Nullable<T>;
  42459. /**
  42460. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42461. * @param key the unique key that identifies the data
  42462. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42463. * @return the associated data, can be null if the factory returned null.
  42464. */
  42465. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42466. /**
  42467. * Remove an externaly attached data from the Engine instance
  42468. * @param key the unique key that identifies the data
  42469. * @return true if the data was successfully removed, false if it doesn't exist
  42470. */
  42471. removeExternalData(key: string): boolean;
  42472. private _evaluateSubMesh;
  42473. /**
  42474. * Clear the processed materials smart array preventing retention point in material dispose.
  42475. */
  42476. freeProcessedMaterials(): void;
  42477. private _preventFreeActiveMeshesAndRenderingGroups;
  42478. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42479. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42480. * when disposing several meshes in a row or a hierarchy of meshes.
  42481. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42482. */
  42483. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42484. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42485. /**
  42486. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42487. */
  42488. freeActiveMeshes(): void;
  42489. /**
  42490. * Clear the info related to rendering groups preventing retention points during dispose.
  42491. */
  42492. freeRenderingGroups(): void;
  42493. /** @hidden */
  42494. _isInIntermediateRendering(): boolean;
  42495. /**
  42496. * Lambda returning the list of potentially active meshes.
  42497. */
  42498. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42499. /**
  42500. * Lambda returning the list of potentially active sub meshes.
  42501. */
  42502. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42503. /**
  42504. * Lambda returning the list of potentially intersecting sub meshes.
  42505. */
  42506. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42507. /**
  42508. * Lambda returning the list of potentially colliding sub meshes.
  42509. */
  42510. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42511. private _activeMeshesFrozen;
  42512. private _skipEvaluateActiveMeshesCompletely;
  42513. /**
  42514. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42515. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42516. * @returns the current scene
  42517. */
  42518. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42519. /**
  42520. * Use this function to restart evaluating active meshes on every frame
  42521. * @returns the current scene
  42522. */
  42523. unfreezeActiveMeshes(): Scene;
  42524. private _evaluateActiveMeshes;
  42525. private _activeMesh;
  42526. /**
  42527. * Update the transform matrix to update from the current active camera
  42528. * @param force defines a boolean used to force the update even if cache is up to date
  42529. */
  42530. updateTransformMatrix(force?: boolean): void;
  42531. private _bindFrameBuffer;
  42532. /** @hidden */
  42533. _allowPostProcessClearColor: boolean;
  42534. /** @hidden */
  42535. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42536. private _processSubCameras;
  42537. private _checkIntersections;
  42538. /** @hidden */
  42539. _advancePhysicsEngineStep(step: number): void;
  42540. /**
  42541. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42542. */
  42543. getDeterministicFrameTime: () => number;
  42544. /** @hidden */
  42545. _animate(): void;
  42546. /** Execute all animations (for a frame) */
  42547. animate(): void;
  42548. /**
  42549. * Render the scene
  42550. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42551. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42552. */
  42553. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42554. /**
  42555. * Freeze all materials
  42556. * A frozen material will not be updatable but should be faster to render
  42557. */
  42558. freezeMaterials(): void;
  42559. /**
  42560. * Unfreeze all materials
  42561. * A frozen material will not be updatable but should be faster to render
  42562. */
  42563. unfreezeMaterials(): void;
  42564. /**
  42565. * Releases all held ressources
  42566. */
  42567. dispose(): void;
  42568. /**
  42569. * Gets if the scene is already disposed
  42570. */
  42571. get isDisposed(): boolean;
  42572. /**
  42573. * Call this function to reduce memory footprint of the scene.
  42574. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42575. */
  42576. clearCachedVertexData(): void;
  42577. /**
  42578. * This function will remove the local cached buffer data from texture.
  42579. * It will save memory but will prevent the texture from being rebuilt
  42580. */
  42581. cleanCachedTextureBuffer(): void;
  42582. /**
  42583. * Get the world extend vectors with an optional filter
  42584. *
  42585. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42586. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42587. */
  42588. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42589. min: Vector3;
  42590. max: Vector3;
  42591. };
  42592. /**
  42593. * Creates a ray that can be used to pick in the scene
  42594. * @param x defines the x coordinate of the origin (on-screen)
  42595. * @param y defines the y coordinate of the origin (on-screen)
  42596. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42597. * @param camera defines the camera to use for the picking
  42598. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42599. * @returns a Ray
  42600. */
  42601. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42602. /**
  42603. * Creates a ray that can be used to pick in the scene
  42604. * @param x defines the x coordinate of the origin (on-screen)
  42605. * @param y defines the y coordinate of the origin (on-screen)
  42606. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42607. * @param result defines the ray where to store the picking ray
  42608. * @param camera defines the camera to use for the picking
  42609. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42610. * @returns the current scene
  42611. */
  42612. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42613. /**
  42614. * Creates a ray that can be used to pick in the scene
  42615. * @param x defines the x coordinate of the origin (on-screen)
  42616. * @param y defines the y coordinate of the origin (on-screen)
  42617. * @param camera defines the camera to use for the picking
  42618. * @returns a Ray
  42619. */
  42620. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42621. /**
  42622. * Creates a ray that can be used to pick in the scene
  42623. * @param x defines the x coordinate of the origin (on-screen)
  42624. * @param y defines the y coordinate of the origin (on-screen)
  42625. * @param result defines the ray where to store the picking ray
  42626. * @param camera defines the camera to use for the picking
  42627. * @returns the current scene
  42628. */
  42629. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42630. /** Launch a ray to try to pick a mesh in the scene
  42631. * @param x position on screen
  42632. * @param y position on screen
  42633. * @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
  42634. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42635. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42636. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42637. * @returns a PickingInfo
  42638. */
  42639. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42640. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42641. * @param x position on screen
  42642. * @param y position on screen
  42643. * @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
  42644. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42645. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42646. * @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)
  42647. */
  42648. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42649. /** Use the given ray to pick a mesh in the scene
  42650. * @param ray The ray to use to pick meshes
  42651. * @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
  42652. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42653. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42654. * @returns a PickingInfo
  42655. */
  42656. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42657. /**
  42658. * Launch a ray to try to pick a mesh in the scene
  42659. * @param x X position on screen
  42660. * @param y Y position on screen
  42661. * @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
  42662. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42663. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42664. * @returns an array of PickingInfo
  42665. */
  42666. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42667. /**
  42668. * Launch a ray to try to pick a mesh in the scene
  42669. * @param ray Ray to use
  42670. * @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
  42671. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42672. * @returns an array of PickingInfo
  42673. */
  42674. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42675. /**
  42676. * Force the value of meshUnderPointer
  42677. * @param mesh defines the mesh to use
  42678. * @param pointerId optional pointer id when using more than one pointer
  42679. */
  42680. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42681. /**
  42682. * Gets the mesh under the pointer
  42683. * @returns a Mesh or null if no mesh is under the pointer
  42684. */
  42685. getPointerOverMesh(): Nullable<AbstractMesh>;
  42686. /** @hidden */
  42687. _rebuildGeometries(): void;
  42688. /** @hidden */
  42689. _rebuildTextures(): void;
  42690. private _getByTags;
  42691. /**
  42692. * Get a list of meshes by tags
  42693. * @param tagsQuery defines the tags query to use
  42694. * @param forEach defines a predicate used to filter results
  42695. * @returns an array of Mesh
  42696. */
  42697. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42698. /**
  42699. * Get a list of cameras by tags
  42700. * @param tagsQuery defines the tags query to use
  42701. * @param forEach defines a predicate used to filter results
  42702. * @returns an array of Camera
  42703. */
  42704. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42705. /**
  42706. * Get a list of lights by tags
  42707. * @param tagsQuery defines the tags query to use
  42708. * @param forEach defines a predicate used to filter results
  42709. * @returns an array of Light
  42710. */
  42711. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42712. /**
  42713. * Get a list of materials by tags
  42714. * @param tagsQuery defines the tags query to use
  42715. * @param forEach defines a predicate used to filter results
  42716. * @returns an array of Material
  42717. */
  42718. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42719. /**
  42720. * Get a list of transform nodes by tags
  42721. * @param tagsQuery defines the tags query to use
  42722. * @param forEach defines a predicate used to filter results
  42723. * @returns an array of TransformNode
  42724. */
  42725. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42726. /**
  42727. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42728. * This allowed control for front to back rendering or reversly depending of the special needs.
  42729. *
  42730. * @param renderingGroupId The rendering group id corresponding to its index
  42731. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42732. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42733. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42734. */
  42735. 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;
  42736. /**
  42737. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42738. *
  42739. * @param renderingGroupId The rendering group id corresponding to its index
  42740. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42741. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42742. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42743. */
  42744. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42745. /**
  42746. * Gets the current auto clear configuration for one rendering group of the rendering
  42747. * manager.
  42748. * @param index the rendering group index to get the information for
  42749. * @returns The auto clear setup for the requested rendering group
  42750. */
  42751. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42752. private _blockMaterialDirtyMechanism;
  42753. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42754. get blockMaterialDirtyMechanism(): boolean;
  42755. set blockMaterialDirtyMechanism(value: boolean);
  42756. /**
  42757. * Will flag all materials as dirty to trigger new shader compilation
  42758. * @param flag defines the flag used to specify which material part must be marked as dirty
  42759. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42760. */
  42761. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42762. /** @hidden */
  42763. _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;
  42764. /** @hidden */
  42765. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42766. /** @hidden */
  42767. _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;
  42768. /** @hidden */
  42769. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42770. /** @hidden */
  42771. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42772. /** @hidden */
  42773. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42774. }
  42775. }
  42776. declare module "babylonjs/assetContainer" {
  42777. import { AbstractScene } from "babylonjs/abstractScene";
  42778. import { Scene } from "babylonjs/scene";
  42779. import { Mesh } from "babylonjs/Meshes/mesh";
  42780. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42781. import { Skeleton } from "babylonjs/Bones/skeleton";
  42782. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42783. import { Animatable } from "babylonjs/Animations/animatable";
  42784. import { Nullable } from "babylonjs/types";
  42785. import { Node } from "babylonjs/node";
  42786. /**
  42787. * Set of assets to keep when moving a scene into an asset container.
  42788. */
  42789. export class KeepAssets extends AbstractScene {
  42790. }
  42791. /**
  42792. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42793. */
  42794. export class InstantiatedEntries {
  42795. /**
  42796. * List of new root nodes (eg. nodes with no parent)
  42797. */
  42798. rootNodes: TransformNode[];
  42799. /**
  42800. * List of new skeletons
  42801. */
  42802. skeletons: Skeleton[];
  42803. /**
  42804. * List of new animation groups
  42805. */
  42806. animationGroups: AnimationGroup[];
  42807. }
  42808. /**
  42809. * Container with a set of assets that can be added or removed from a scene.
  42810. */
  42811. export class AssetContainer extends AbstractScene {
  42812. private _wasAddedToScene;
  42813. /**
  42814. * The scene the AssetContainer belongs to.
  42815. */
  42816. scene: Scene;
  42817. /**
  42818. * Instantiates an AssetContainer.
  42819. * @param scene The scene the AssetContainer belongs to.
  42820. */
  42821. constructor(scene: Scene);
  42822. /**
  42823. * Instantiate or clone all meshes and add the new ones to the scene.
  42824. * Skeletons and animation groups will all be cloned
  42825. * @param nameFunction defines an optional function used to get new names for clones
  42826. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42827. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42828. */
  42829. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42830. /**
  42831. * Adds all the assets from the container to the scene.
  42832. */
  42833. addAllToScene(): void;
  42834. /**
  42835. * Removes all the assets in the container from the scene
  42836. */
  42837. removeAllFromScene(): void;
  42838. /**
  42839. * Disposes all the assets in the container
  42840. */
  42841. dispose(): void;
  42842. private _moveAssets;
  42843. /**
  42844. * Removes all the assets contained in the scene and adds them to the container.
  42845. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42846. */
  42847. moveAllFromScene(keepAssets?: KeepAssets): void;
  42848. /**
  42849. * 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.
  42850. * @returns the root mesh
  42851. */
  42852. createRootMesh(): Mesh;
  42853. /**
  42854. * Merge animations (direct and animation groups) from this asset container into a scene
  42855. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42856. * @param animatables set of animatables to retarget to a node from the scene
  42857. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42858. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42859. */
  42860. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42861. }
  42862. }
  42863. declare module "babylonjs/abstractScene" {
  42864. import { Scene } from "babylonjs/scene";
  42865. import { Nullable } from "babylonjs/types";
  42866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42867. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42868. import { Geometry } from "babylonjs/Meshes/geometry";
  42869. import { Skeleton } from "babylonjs/Bones/skeleton";
  42870. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42871. import { AssetContainer } from "babylonjs/assetContainer";
  42872. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42873. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42875. import { Material } from "babylonjs/Materials/material";
  42876. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42877. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42878. import { Camera } from "babylonjs/Cameras/camera";
  42879. import { Light } from "babylonjs/Lights/light";
  42880. import { Node } from "babylonjs/node";
  42881. import { Animation } from "babylonjs/Animations/animation";
  42882. /**
  42883. * Defines how the parser contract is defined.
  42884. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42885. */
  42886. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42887. /**
  42888. * Defines how the individual parser contract is defined.
  42889. * These parser can parse an individual asset
  42890. */
  42891. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42892. /**
  42893. * Base class of the scene acting as a container for the different elements composing a scene.
  42894. * This class is dynamically extended by the different components of the scene increasing
  42895. * flexibility and reducing coupling
  42896. */
  42897. export abstract class AbstractScene {
  42898. /**
  42899. * Stores the list of available parsers in the application.
  42900. */
  42901. private static _BabylonFileParsers;
  42902. /**
  42903. * Stores the list of available individual parsers in the application.
  42904. */
  42905. private static _IndividualBabylonFileParsers;
  42906. /**
  42907. * Adds a parser in the list of available ones
  42908. * @param name Defines the name of the parser
  42909. * @param parser Defines the parser to add
  42910. */
  42911. static AddParser(name: string, parser: BabylonFileParser): void;
  42912. /**
  42913. * Gets a general parser from the list of avaialble ones
  42914. * @param name Defines the name of the parser
  42915. * @returns the requested parser or null
  42916. */
  42917. static GetParser(name: string): Nullable<BabylonFileParser>;
  42918. /**
  42919. * Adds n individual parser in the list of available ones
  42920. * @param name Defines the name of the parser
  42921. * @param parser Defines the parser to add
  42922. */
  42923. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42924. /**
  42925. * Gets an individual parser from the list of avaialble ones
  42926. * @param name Defines the name of the parser
  42927. * @returns the requested parser or null
  42928. */
  42929. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42930. /**
  42931. * Parser json data and populate both a scene and its associated container object
  42932. * @param jsonData Defines the data to parse
  42933. * @param scene Defines the scene to parse the data for
  42934. * @param container Defines the container attached to the parsing sequence
  42935. * @param rootUrl Defines the root url of the data
  42936. */
  42937. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42938. /**
  42939. * Gets the list of root nodes (ie. nodes with no parent)
  42940. */
  42941. rootNodes: Node[];
  42942. /** All of the cameras added to this scene
  42943. * @see https://doc.babylonjs.com/babylon101/cameras
  42944. */
  42945. cameras: Camera[];
  42946. /**
  42947. * All of the lights added to this scene
  42948. * @see https://doc.babylonjs.com/babylon101/lights
  42949. */
  42950. lights: Light[];
  42951. /**
  42952. * All of the (abstract) meshes added to this scene
  42953. */
  42954. meshes: AbstractMesh[];
  42955. /**
  42956. * The list of skeletons added to the scene
  42957. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42958. */
  42959. skeletons: Skeleton[];
  42960. /**
  42961. * All of the particle systems added to this scene
  42962. * @see https://doc.babylonjs.com/babylon101/particles
  42963. */
  42964. particleSystems: IParticleSystem[];
  42965. /**
  42966. * Gets a list of Animations associated with the scene
  42967. */
  42968. animations: Animation[];
  42969. /**
  42970. * All of the animation groups added to this scene
  42971. * @see https://doc.babylonjs.com/how_to/group
  42972. */
  42973. animationGroups: AnimationGroup[];
  42974. /**
  42975. * All of the multi-materials added to this scene
  42976. * @see https://doc.babylonjs.com/how_to/multi_materials
  42977. */
  42978. multiMaterials: MultiMaterial[];
  42979. /**
  42980. * All of the materials added to this scene
  42981. * In the context of a Scene, it is not supposed to be modified manually.
  42982. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42983. * Note also that the order of the Material within the array is not significant and might change.
  42984. * @see https://doc.babylonjs.com/babylon101/materials
  42985. */
  42986. materials: Material[];
  42987. /**
  42988. * The list of morph target managers added to the scene
  42989. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42990. */
  42991. morphTargetManagers: MorphTargetManager[];
  42992. /**
  42993. * The list of geometries used in the scene.
  42994. */
  42995. geometries: Geometry[];
  42996. /**
  42997. * All of the tranform nodes added to this scene
  42998. * In the context of a Scene, it is not supposed to be modified manually.
  42999. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  43000. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  43001. * @see https://doc.babylonjs.com/how_to/transformnode
  43002. */
  43003. transformNodes: TransformNode[];
  43004. /**
  43005. * ActionManagers available on the scene.
  43006. */
  43007. actionManagers: AbstractActionManager[];
  43008. /**
  43009. * Textures to keep.
  43010. */
  43011. textures: BaseTexture[];
  43012. /** @hidden */
  43013. protected _environmentTexture: Nullable<BaseTexture>;
  43014. /**
  43015. * Texture used in all pbr material as the reflection texture.
  43016. * As in the majority of the scene they are the same (exception for multi room and so on),
  43017. * this is easier to reference from here than from all the materials.
  43018. */
  43019. get environmentTexture(): Nullable<BaseTexture>;
  43020. set environmentTexture(value: Nullable<BaseTexture>);
  43021. /**
  43022. * The list of postprocesses added to the scene
  43023. */
  43024. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  43025. /**
  43026. * @returns all meshes, lights, cameras, transformNodes and bones
  43027. */
  43028. getNodes(): Array<Node>;
  43029. }
  43030. }
  43031. declare module "babylonjs/Audio/sound" {
  43032. import { Observable } from "babylonjs/Misc/observable";
  43033. import { Vector3 } from "babylonjs/Maths/math.vector";
  43034. import { Nullable } from "babylonjs/types";
  43035. import { Scene } from "babylonjs/scene";
  43036. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43037. /**
  43038. * Interface used to define options for Sound class
  43039. */
  43040. export interface ISoundOptions {
  43041. /**
  43042. * Does the sound autoplay once loaded.
  43043. */
  43044. autoplay?: boolean;
  43045. /**
  43046. * Does the sound loop after it finishes playing once.
  43047. */
  43048. loop?: boolean;
  43049. /**
  43050. * Sound's volume
  43051. */
  43052. volume?: number;
  43053. /**
  43054. * Is it a spatial sound?
  43055. */
  43056. spatialSound?: boolean;
  43057. /**
  43058. * Maximum distance to hear that sound
  43059. */
  43060. maxDistance?: number;
  43061. /**
  43062. * Uses user defined attenuation function
  43063. */
  43064. useCustomAttenuation?: boolean;
  43065. /**
  43066. * Define the roll off factor of spatial sounds.
  43067. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43068. */
  43069. rolloffFactor?: number;
  43070. /**
  43071. * Define the reference distance the sound should be heard perfectly.
  43072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43073. */
  43074. refDistance?: number;
  43075. /**
  43076. * Define the distance attenuation model the sound will follow.
  43077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43078. */
  43079. distanceModel?: string;
  43080. /**
  43081. * Defines the playback speed (1 by default)
  43082. */
  43083. playbackRate?: number;
  43084. /**
  43085. * Defines if the sound is from a streaming source
  43086. */
  43087. streaming?: boolean;
  43088. /**
  43089. * Defines an optional length (in seconds) inside the sound file
  43090. */
  43091. length?: number;
  43092. /**
  43093. * Defines an optional offset (in seconds) inside the sound file
  43094. */
  43095. offset?: number;
  43096. /**
  43097. * If true, URLs will not be required to state the audio file codec to use.
  43098. */
  43099. skipCodecCheck?: boolean;
  43100. }
  43101. /**
  43102. * Defines a sound that can be played in the application.
  43103. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43104. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43105. */
  43106. export class Sound {
  43107. /**
  43108. * The name of the sound in the scene.
  43109. */
  43110. name: string;
  43111. /**
  43112. * Does the sound autoplay once loaded.
  43113. */
  43114. autoplay: boolean;
  43115. /**
  43116. * Does the sound loop after it finishes playing once.
  43117. */
  43118. loop: boolean;
  43119. /**
  43120. * Does the sound use a custom attenuation curve to simulate the falloff
  43121. * happening when the source gets further away from the camera.
  43122. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43123. */
  43124. useCustomAttenuation: boolean;
  43125. /**
  43126. * The sound track id this sound belongs to.
  43127. */
  43128. soundTrackId: number;
  43129. /**
  43130. * Is this sound currently played.
  43131. */
  43132. isPlaying: boolean;
  43133. /**
  43134. * Is this sound currently paused.
  43135. */
  43136. isPaused: boolean;
  43137. /**
  43138. * Does this sound enables spatial sound.
  43139. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43140. */
  43141. spatialSound: boolean;
  43142. /**
  43143. * Define the reference distance the sound should be heard perfectly.
  43144. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43145. */
  43146. refDistance: number;
  43147. /**
  43148. * Define the roll off factor of spatial sounds.
  43149. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43150. */
  43151. rolloffFactor: number;
  43152. /**
  43153. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43154. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43155. */
  43156. maxDistance: number;
  43157. /**
  43158. * Define the distance attenuation model the sound will follow.
  43159. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43160. */
  43161. distanceModel: string;
  43162. /**
  43163. * @hidden
  43164. * Back Compat
  43165. **/
  43166. onended: () => any;
  43167. /**
  43168. * Gets or sets an object used to store user defined information for the sound.
  43169. */
  43170. metadata: any;
  43171. /**
  43172. * Observable event when the current playing sound finishes.
  43173. */
  43174. onEndedObservable: Observable<Sound>;
  43175. private _panningModel;
  43176. private _playbackRate;
  43177. private _streaming;
  43178. private _startTime;
  43179. private _startOffset;
  43180. private _position;
  43181. /** @hidden */
  43182. _positionInEmitterSpace: boolean;
  43183. private _localDirection;
  43184. private _volume;
  43185. private _isReadyToPlay;
  43186. private _isDirectional;
  43187. private _readyToPlayCallback;
  43188. private _audioBuffer;
  43189. private _soundSource;
  43190. private _streamingSource;
  43191. private _soundPanner;
  43192. private _soundGain;
  43193. private _inputAudioNode;
  43194. private _outputAudioNode;
  43195. private _coneInnerAngle;
  43196. private _coneOuterAngle;
  43197. private _coneOuterGain;
  43198. private _scene;
  43199. private _connectedTransformNode;
  43200. private _customAttenuationFunction;
  43201. private _registerFunc;
  43202. private _isOutputConnected;
  43203. private _htmlAudioElement;
  43204. private _urlType;
  43205. private _length?;
  43206. private _offset?;
  43207. /** @hidden */
  43208. static _SceneComponentInitialization: (scene: Scene) => void;
  43209. /**
  43210. * Create a sound and attach it to a scene
  43211. * @param name Name of your sound
  43212. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43213. * @param scene defines the scene the sound belongs to
  43214. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43215. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43216. */
  43217. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43218. /**
  43219. * Release the sound and its associated resources
  43220. */
  43221. dispose(): void;
  43222. /**
  43223. * Gets if the sounds is ready to be played or not.
  43224. * @returns true if ready, otherwise false
  43225. */
  43226. isReady(): boolean;
  43227. private _soundLoaded;
  43228. /**
  43229. * Sets the data of the sound from an audiobuffer
  43230. * @param audioBuffer The audioBuffer containing the data
  43231. */
  43232. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43233. /**
  43234. * Updates the current sounds options such as maxdistance, loop...
  43235. * @param options A JSON object containing values named as the object properties
  43236. */
  43237. updateOptions(options: ISoundOptions): void;
  43238. private _createSpatialParameters;
  43239. private _updateSpatialParameters;
  43240. /**
  43241. * Switch the panning model to HRTF:
  43242. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43243. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43244. */
  43245. switchPanningModelToHRTF(): void;
  43246. /**
  43247. * Switch the panning model to Equal Power:
  43248. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43249. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43250. */
  43251. switchPanningModelToEqualPower(): void;
  43252. private _switchPanningModel;
  43253. /**
  43254. * Connect this sound to a sound track audio node like gain...
  43255. * @param soundTrackAudioNode the sound track audio node to connect to
  43256. */
  43257. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43258. /**
  43259. * Transform this sound into a directional source
  43260. * @param coneInnerAngle Size of the inner cone in degree
  43261. * @param coneOuterAngle Size of the outer cone in degree
  43262. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43263. */
  43264. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43265. /**
  43266. * Gets or sets the inner angle for the directional cone.
  43267. */
  43268. get directionalConeInnerAngle(): number;
  43269. /**
  43270. * Gets or sets the inner angle for the directional cone.
  43271. */
  43272. set directionalConeInnerAngle(value: number);
  43273. /**
  43274. * Gets or sets the outer angle for the directional cone.
  43275. */
  43276. get directionalConeOuterAngle(): number;
  43277. /**
  43278. * Gets or sets the outer angle for the directional cone.
  43279. */
  43280. set directionalConeOuterAngle(value: number);
  43281. /**
  43282. * Sets the position of the emitter if spatial sound is enabled
  43283. * @param newPosition Defines the new posisiton
  43284. */
  43285. setPosition(newPosition: Vector3): void;
  43286. /**
  43287. * Sets the local direction of the emitter if spatial sound is enabled
  43288. * @param newLocalDirection Defines the new local direction
  43289. */
  43290. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43291. private _updateDirection;
  43292. /** @hidden */
  43293. updateDistanceFromListener(): void;
  43294. /**
  43295. * Sets a new custom attenuation function for the sound.
  43296. * @param callback Defines the function used for the attenuation
  43297. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43298. */
  43299. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43300. /**
  43301. * Play the sound
  43302. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43303. * @param offset (optional) Start the sound at a specific time in seconds
  43304. * @param length (optional) Sound duration (in seconds)
  43305. */
  43306. play(time?: number, offset?: number, length?: number): void;
  43307. private _onended;
  43308. /**
  43309. * Stop the sound
  43310. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43311. */
  43312. stop(time?: number): void;
  43313. /**
  43314. * Put the sound in pause
  43315. */
  43316. pause(): void;
  43317. /**
  43318. * Sets a dedicated volume for this sounds
  43319. * @param newVolume Define the new volume of the sound
  43320. * @param time Define time for gradual change to new volume
  43321. */
  43322. setVolume(newVolume: number, time?: number): void;
  43323. /**
  43324. * Set the sound play back rate
  43325. * @param newPlaybackRate Define the playback rate the sound should be played at
  43326. */
  43327. setPlaybackRate(newPlaybackRate: number): void;
  43328. /**
  43329. * Gets the volume of the sound.
  43330. * @returns the volume of the sound
  43331. */
  43332. getVolume(): number;
  43333. /**
  43334. * Attach the sound to a dedicated mesh
  43335. * @param transformNode The transform node to connect the sound with
  43336. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43337. */
  43338. attachToMesh(transformNode: TransformNode): void;
  43339. /**
  43340. * Detach the sound from the previously attached mesh
  43341. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43342. */
  43343. detachFromMesh(): void;
  43344. private _onRegisterAfterWorldMatrixUpdate;
  43345. /**
  43346. * Clone the current sound in the scene.
  43347. * @returns the new sound clone
  43348. */
  43349. clone(): Nullable<Sound>;
  43350. /**
  43351. * Gets the current underlying audio buffer containing the data
  43352. * @returns the audio buffer
  43353. */
  43354. getAudioBuffer(): Nullable<AudioBuffer>;
  43355. /**
  43356. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43357. * @returns the source node
  43358. */
  43359. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43360. /**
  43361. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43362. * @returns the gain node
  43363. */
  43364. getSoundGain(): Nullable<GainNode>;
  43365. /**
  43366. * Serializes the Sound in a JSON representation
  43367. * @returns the JSON representation of the sound
  43368. */
  43369. serialize(): any;
  43370. /**
  43371. * Parse a JSON representation of a sound to innstantiate in a given scene
  43372. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43373. * @param scene Define the scene the new parsed sound should be created in
  43374. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43375. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43376. * @returns the newly parsed sound
  43377. */
  43378. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43379. }
  43380. }
  43381. declare module "babylonjs/Actions/directAudioActions" {
  43382. import { Action } from "babylonjs/Actions/action";
  43383. import { Condition } from "babylonjs/Actions/condition";
  43384. import { Sound } from "babylonjs/Audio/sound";
  43385. /**
  43386. * This defines an action helpful to play a defined sound on a triggered action.
  43387. */
  43388. export class PlaySoundAction extends Action {
  43389. private _sound;
  43390. /**
  43391. * Instantiate the action
  43392. * @param triggerOptions defines the trigger options
  43393. * @param sound defines the sound to play
  43394. * @param condition defines the trigger related conditions
  43395. */
  43396. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43397. /** @hidden */
  43398. _prepare(): void;
  43399. /**
  43400. * Execute the action and play the sound.
  43401. */
  43402. execute(): void;
  43403. /**
  43404. * Serializes the actions and its related information.
  43405. * @param parent defines the object to serialize in
  43406. * @returns the serialized object
  43407. */
  43408. serialize(parent: any): any;
  43409. }
  43410. /**
  43411. * This defines an action helpful to stop a defined sound on a triggered action.
  43412. */
  43413. export class StopSoundAction extends Action {
  43414. private _sound;
  43415. /**
  43416. * Instantiate the action
  43417. * @param triggerOptions defines the trigger options
  43418. * @param sound defines the sound to stop
  43419. * @param condition defines the trigger related conditions
  43420. */
  43421. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43422. /** @hidden */
  43423. _prepare(): void;
  43424. /**
  43425. * Execute the action and stop the sound.
  43426. */
  43427. execute(): void;
  43428. /**
  43429. * Serializes the actions and its related information.
  43430. * @param parent defines the object to serialize in
  43431. * @returns the serialized object
  43432. */
  43433. serialize(parent: any): any;
  43434. }
  43435. }
  43436. declare module "babylonjs/Actions/interpolateValueAction" {
  43437. import { Action } from "babylonjs/Actions/action";
  43438. import { Condition } from "babylonjs/Actions/condition";
  43439. import { Observable } from "babylonjs/Misc/observable";
  43440. /**
  43441. * This defines an action responsible to change the value of a property
  43442. * by interpolating between its current value and the newly set one once triggered.
  43443. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43444. */
  43445. export class InterpolateValueAction extends Action {
  43446. /**
  43447. * Defines the path of the property where the value should be interpolated
  43448. */
  43449. propertyPath: string;
  43450. /**
  43451. * Defines the target value at the end of the interpolation.
  43452. */
  43453. value: any;
  43454. /**
  43455. * Defines the time it will take for the property to interpolate to the value.
  43456. */
  43457. duration: number;
  43458. /**
  43459. * Defines if the other scene animations should be stopped when the action has been triggered
  43460. */
  43461. stopOtherAnimations?: boolean;
  43462. /**
  43463. * Defines a callback raised once the interpolation animation has been done.
  43464. */
  43465. onInterpolationDone?: () => void;
  43466. /**
  43467. * Observable triggered once the interpolation animation has been done.
  43468. */
  43469. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43470. private _target;
  43471. private _effectiveTarget;
  43472. private _property;
  43473. /**
  43474. * Instantiate the action
  43475. * @param triggerOptions defines the trigger options
  43476. * @param target defines the object containing the value to interpolate
  43477. * @param propertyPath defines the path to the property in the target object
  43478. * @param value defines the target value at the end of the interpolation
  43479. * @param duration deines the time it will take for the property to interpolate to the value.
  43480. * @param condition defines the trigger related conditions
  43481. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43482. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43483. */
  43484. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43485. /** @hidden */
  43486. _prepare(): void;
  43487. /**
  43488. * Execute the action starts the value interpolation.
  43489. */
  43490. execute(): void;
  43491. /**
  43492. * Serializes the actions and its related information.
  43493. * @param parent defines the object to serialize in
  43494. * @returns the serialized object
  43495. */
  43496. serialize(parent: any): any;
  43497. }
  43498. }
  43499. declare module "babylonjs/Actions/index" {
  43500. export * from "babylonjs/Actions/abstractActionManager";
  43501. export * from "babylonjs/Actions/action";
  43502. export * from "babylonjs/Actions/actionEvent";
  43503. export * from "babylonjs/Actions/actionManager";
  43504. export * from "babylonjs/Actions/condition";
  43505. export * from "babylonjs/Actions/directActions";
  43506. export * from "babylonjs/Actions/directAudioActions";
  43507. export * from "babylonjs/Actions/interpolateValueAction";
  43508. }
  43509. declare module "babylonjs/Animations/index" {
  43510. export * from "babylonjs/Animations/animatable";
  43511. export * from "babylonjs/Animations/animation";
  43512. export * from "babylonjs/Animations/animationGroup";
  43513. export * from "babylonjs/Animations/animationPropertiesOverride";
  43514. export * from "babylonjs/Animations/easing";
  43515. export * from "babylonjs/Animations/runtimeAnimation";
  43516. export * from "babylonjs/Animations/animationEvent";
  43517. export * from "babylonjs/Animations/animationGroup";
  43518. export * from "babylonjs/Animations/animationKey";
  43519. export * from "babylonjs/Animations/animationRange";
  43520. export * from "babylonjs/Animations/animatable.interface";
  43521. }
  43522. declare module "babylonjs/Audio/soundTrack" {
  43523. import { Sound } from "babylonjs/Audio/sound";
  43524. import { Analyser } from "babylonjs/Audio/analyser";
  43525. import { Scene } from "babylonjs/scene";
  43526. /**
  43527. * Options allowed during the creation of a sound track.
  43528. */
  43529. export interface ISoundTrackOptions {
  43530. /**
  43531. * The volume the sound track should take during creation
  43532. */
  43533. volume?: number;
  43534. /**
  43535. * Define if the sound track is the main sound track of the scene
  43536. */
  43537. mainTrack?: boolean;
  43538. }
  43539. /**
  43540. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43541. * It will be also used in a future release to apply effects on a specific track.
  43542. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43543. */
  43544. export class SoundTrack {
  43545. /**
  43546. * The unique identifier of the sound track in the scene.
  43547. */
  43548. id: number;
  43549. /**
  43550. * The list of sounds included in the sound track.
  43551. */
  43552. soundCollection: Array<Sound>;
  43553. private _outputAudioNode;
  43554. private _scene;
  43555. private _connectedAnalyser;
  43556. private _options;
  43557. private _isInitialized;
  43558. /**
  43559. * Creates a new sound track.
  43560. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43561. * @param scene Define the scene the sound track belongs to
  43562. * @param options
  43563. */
  43564. constructor(scene: Scene, options?: ISoundTrackOptions);
  43565. private _initializeSoundTrackAudioGraph;
  43566. /**
  43567. * Release the sound track and its associated resources
  43568. */
  43569. dispose(): void;
  43570. /**
  43571. * Adds a sound to this sound track
  43572. * @param sound define the cound to add
  43573. * @ignoreNaming
  43574. */
  43575. AddSound(sound: Sound): void;
  43576. /**
  43577. * Removes a sound to this sound track
  43578. * @param sound define the cound to remove
  43579. * @ignoreNaming
  43580. */
  43581. RemoveSound(sound: Sound): void;
  43582. /**
  43583. * Set a global volume for the full sound track.
  43584. * @param newVolume Define the new volume of the sound track
  43585. */
  43586. setVolume(newVolume: number): void;
  43587. /**
  43588. * Switch the panning model to HRTF:
  43589. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43590. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43591. */
  43592. switchPanningModelToHRTF(): void;
  43593. /**
  43594. * Switch the panning model to Equal Power:
  43595. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43596. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43597. */
  43598. switchPanningModelToEqualPower(): void;
  43599. /**
  43600. * Connect the sound track to an audio analyser allowing some amazing
  43601. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43602. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43603. * @param analyser The analyser to connect to the engine
  43604. */
  43605. connectToAnalyser(analyser: Analyser): void;
  43606. }
  43607. }
  43608. declare module "babylonjs/Audio/audioSceneComponent" {
  43609. import { Sound } from "babylonjs/Audio/sound";
  43610. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43611. import { Nullable } from "babylonjs/types";
  43612. import { Vector3 } from "babylonjs/Maths/math.vector";
  43613. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43614. import { Scene } from "babylonjs/scene";
  43615. import { AbstractScene } from "babylonjs/abstractScene";
  43616. import "babylonjs/Audio/audioEngine";
  43617. module "babylonjs/abstractScene" {
  43618. interface AbstractScene {
  43619. /**
  43620. * The list of sounds used in the scene.
  43621. */
  43622. sounds: Nullable<Array<Sound>>;
  43623. }
  43624. }
  43625. module "babylonjs/scene" {
  43626. interface Scene {
  43627. /**
  43628. * @hidden
  43629. * Backing field
  43630. */
  43631. _mainSoundTrack: SoundTrack;
  43632. /**
  43633. * The main sound track played by the scene.
  43634. * It cotains your primary collection of sounds.
  43635. */
  43636. mainSoundTrack: SoundTrack;
  43637. /**
  43638. * The list of sound tracks added to the scene
  43639. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43640. */
  43641. soundTracks: Nullable<Array<SoundTrack>>;
  43642. /**
  43643. * Gets a sound using a given name
  43644. * @param name defines the name to search for
  43645. * @return the found sound or null if not found at all.
  43646. */
  43647. getSoundByName(name: string): Nullable<Sound>;
  43648. /**
  43649. * Gets or sets if audio support is enabled
  43650. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43651. */
  43652. audioEnabled: boolean;
  43653. /**
  43654. * Gets or sets if audio will be output to headphones
  43655. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43656. */
  43657. headphone: boolean;
  43658. /**
  43659. * Gets or sets custom audio listener position provider
  43660. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43661. */
  43662. audioListenerPositionProvider: Nullable<() => Vector3>;
  43663. /**
  43664. * Gets or sets a refresh rate when using 3D audio positioning
  43665. */
  43666. audioPositioningRefreshRate: number;
  43667. }
  43668. }
  43669. /**
  43670. * Defines the sound scene component responsible to manage any sounds
  43671. * in a given scene.
  43672. */
  43673. export class AudioSceneComponent implements ISceneSerializableComponent {
  43674. private static _CameraDirectionLH;
  43675. private static _CameraDirectionRH;
  43676. /**
  43677. * The component name helpfull to identify the component in the list of scene components.
  43678. */
  43679. readonly name: string;
  43680. /**
  43681. * The scene the component belongs to.
  43682. */
  43683. scene: Scene;
  43684. private _audioEnabled;
  43685. /**
  43686. * Gets whether audio is enabled or not.
  43687. * Please use related enable/disable method to switch state.
  43688. */
  43689. get audioEnabled(): boolean;
  43690. private _headphone;
  43691. /**
  43692. * Gets whether audio is outputing to headphone or not.
  43693. * Please use the according Switch methods to change output.
  43694. */
  43695. get headphone(): boolean;
  43696. /**
  43697. * Gets or sets a refresh rate when using 3D audio positioning
  43698. */
  43699. audioPositioningRefreshRate: number;
  43700. private _audioListenerPositionProvider;
  43701. /**
  43702. * Gets the current audio listener position provider
  43703. */
  43704. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43705. /**
  43706. * Sets a custom listener position for all sounds in the scene
  43707. * By default, this is the position of the first active camera
  43708. */
  43709. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43710. /**
  43711. * Creates a new instance of the component for the given scene
  43712. * @param scene Defines the scene to register the component in
  43713. */
  43714. constructor(scene: Scene);
  43715. /**
  43716. * Registers the component in a given scene
  43717. */
  43718. register(): void;
  43719. /**
  43720. * Rebuilds the elements related to this component in case of
  43721. * context lost for instance.
  43722. */
  43723. rebuild(): void;
  43724. /**
  43725. * Serializes the component data to the specified json object
  43726. * @param serializationObject The object to serialize to
  43727. */
  43728. serialize(serializationObject: any): void;
  43729. /**
  43730. * Adds all the elements from the container to the scene
  43731. * @param container the container holding the elements
  43732. */
  43733. addFromContainer(container: AbstractScene): void;
  43734. /**
  43735. * Removes all the elements in the container from the scene
  43736. * @param container contains the elements to remove
  43737. * @param dispose if the removed element should be disposed (default: false)
  43738. */
  43739. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43740. /**
  43741. * Disposes the component and the associated ressources.
  43742. */
  43743. dispose(): void;
  43744. /**
  43745. * Disables audio in the associated scene.
  43746. */
  43747. disableAudio(): void;
  43748. /**
  43749. * Enables audio in the associated scene.
  43750. */
  43751. enableAudio(): void;
  43752. /**
  43753. * Switch audio to headphone output.
  43754. */
  43755. switchAudioModeForHeadphones(): void;
  43756. /**
  43757. * Switch audio to normal speakers.
  43758. */
  43759. switchAudioModeForNormalSpeakers(): void;
  43760. private _cachedCameraDirection;
  43761. private _cachedCameraPosition;
  43762. private _lastCheck;
  43763. private _afterRender;
  43764. }
  43765. }
  43766. declare module "babylonjs/Audio/weightedsound" {
  43767. import { Sound } from "babylonjs/Audio/sound";
  43768. /**
  43769. * Wraps one or more Sound objects and selects one with random weight for playback.
  43770. */
  43771. export class WeightedSound {
  43772. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43773. loop: boolean;
  43774. private _coneInnerAngle;
  43775. private _coneOuterAngle;
  43776. private _volume;
  43777. /** A Sound is currently playing. */
  43778. isPlaying: boolean;
  43779. /** A Sound is currently paused. */
  43780. isPaused: boolean;
  43781. private _sounds;
  43782. private _weights;
  43783. private _currentIndex?;
  43784. /**
  43785. * Creates a new WeightedSound from the list of sounds given.
  43786. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43787. * @param sounds Array of Sounds that will be selected from.
  43788. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43789. */
  43790. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43791. /**
  43792. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43793. */
  43794. get directionalConeInnerAngle(): number;
  43795. /**
  43796. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43797. */
  43798. set directionalConeInnerAngle(value: number);
  43799. /**
  43800. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43801. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43802. */
  43803. get directionalConeOuterAngle(): number;
  43804. /**
  43805. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43806. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43807. */
  43808. set directionalConeOuterAngle(value: number);
  43809. /**
  43810. * Playback volume.
  43811. */
  43812. get volume(): number;
  43813. /**
  43814. * Playback volume.
  43815. */
  43816. set volume(value: number);
  43817. private _onended;
  43818. /**
  43819. * Suspend playback
  43820. */
  43821. pause(): void;
  43822. /**
  43823. * Stop playback
  43824. */
  43825. stop(): void;
  43826. /**
  43827. * Start playback.
  43828. * @param startOffset Position the clip head at a specific time in seconds.
  43829. */
  43830. play(startOffset?: number): void;
  43831. }
  43832. }
  43833. declare module "babylonjs/Audio/index" {
  43834. export * from "babylonjs/Audio/analyser";
  43835. export * from "babylonjs/Audio/audioEngine";
  43836. export * from "babylonjs/Audio/audioSceneComponent";
  43837. export * from "babylonjs/Audio/sound";
  43838. export * from "babylonjs/Audio/soundTrack";
  43839. export * from "babylonjs/Audio/weightedsound";
  43840. }
  43841. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43842. import { Behavior } from "babylonjs/Behaviors/behavior";
  43843. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43844. import { BackEase } from "babylonjs/Animations/easing";
  43845. /**
  43846. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43847. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43848. */
  43849. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43850. /**
  43851. * Gets the name of the behavior.
  43852. */
  43853. get name(): string;
  43854. /**
  43855. * The easing function used by animations
  43856. */
  43857. static EasingFunction: BackEase;
  43858. /**
  43859. * The easing mode used by animations
  43860. */
  43861. static EasingMode: number;
  43862. /**
  43863. * The duration of the animation, in milliseconds
  43864. */
  43865. transitionDuration: number;
  43866. /**
  43867. * Length of the distance animated by the transition when lower radius is reached
  43868. */
  43869. lowerRadiusTransitionRange: number;
  43870. /**
  43871. * Length of the distance animated by the transition when upper radius is reached
  43872. */
  43873. upperRadiusTransitionRange: number;
  43874. private _autoTransitionRange;
  43875. /**
  43876. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43877. */
  43878. get autoTransitionRange(): boolean;
  43879. /**
  43880. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43881. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43882. */
  43883. set autoTransitionRange(value: boolean);
  43884. private _attachedCamera;
  43885. private _onAfterCheckInputsObserver;
  43886. private _onMeshTargetChangedObserver;
  43887. /**
  43888. * Initializes the behavior.
  43889. */
  43890. init(): void;
  43891. /**
  43892. * Attaches the behavior to its arc rotate camera.
  43893. * @param camera Defines the camera to attach the behavior to
  43894. */
  43895. attach(camera: ArcRotateCamera): void;
  43896. /**
  43897. * Detaches the behavior from its current arc rotate camera.
  43898. */
  43899. detach(): void;
  43900. private _radiusIsAnimating;
  43901. private _radiusBounceTransition;
  43902. private _animatables;
  43903. private _cachedWheelPrecision;
  43904. /**
  43905. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43906. * @param radiusLimit The limit to check against.
  43907. * @return Bool to indicate if at limit.
  43908. */
  43909. private _isRadiusAtLimit;
  43910. /**
  43911. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43912. * @param radiusDelta The delta by which to animate to. Can be negative.
  43913. */
  43914. private _applyBoundRadiusAnimation;
  43915. /**
  43916. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43917. */
  43918. protected _clearAnimationLocks(): void;
  43919. /**
  43920. * Stops and removes all animations that have been applied to the camera
  43921. */
  43922. stopAllAnimations(): void;
  43923. }
  43924. }
  43925. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43926. import { Behavior } from "babylonjs/Behaviors/behavior";
  43927. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43928. import { ExponentialEase } from "babylonjs/Animations/easing";
  43929. import { Nullable } from "babylonjs/types";
  43930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43931. import { Vector3 } from "babylonjs/Maths/math.vector";
  43932. /**
  43933. * 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.
  43934. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43935. */
  43936. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43937. /**
  43938. * Gets the name of the behavior.
  43939. */
  43940. get name(): string;
  43941. private _mode;
  43942. private _radiusScale;
  43943. private _positionScale;
  43944. private _defaultElevation;
  43945. private _elevationReturnTime;
  43946. private _elevationReturnWaitTime;
  43947. private _zoomStopsAnimation;
  43948. private _framingTime;
  43949. /**
  43950. * The easing function used by animations
  43951. */
  43952. static EasingFunction: ExponentialEase;
  43953. /**
  43954. * The easing mode used by animations
  43955. */
  43956. static EasingMode: number;
  43957. /**
  43958. * Sets the current mode used by the behavior
  43959. */
  43960. set mode(mode: number);
  43961. /**
  43962. * Gets current mode used by the behavior.
  43963. */
  43964. get mode(): number;
  43965. /**
  43966. * Sets the scale applied to the radius (1 by default)
  43967. */
  43968. set radiusScale(radius: number);
  43969. /**
  43970. * Gets the scale applied to the radius
  43971. */
  43972. get radiusScale(): number;
  43973. /**
  43974. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43975. */
  43976. set positionScale(scale: number);
  43977. /**
  43978. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43979. */
  43980. get positionScale(): number;
  43981. /**
  43982. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43983. * behaviour is triggered, in radians.
  43984. */
  43985. set defaultElevation(elevation: number);
  43986. /**
  43987. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43988. * behaviour is triggered, in radians.
  43989. */
  43990. get defaultElevation(): number;
  43991. /**
  43992. * Sets the time (in milliseconds) taken to return to the default beta position.
  43993. * Negative value indicates camera should not return to default.
  43994. */
  43995. set elevationReturnTime(speed: number);
  43996. /**
  43997. * Gets the time (in milliseconds) taken to return to the default beta position.
  43998. * Negative value indicates camera should not return to default.
  43999. */
  44000. get elevationReturnTime(): number;
  44001. /**
  44002. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  44003. */
  44004. set elevationReturnWaitTime(time: number);
  44005. /**
  44006. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  44007. */
  44008. get elevationReturnWaitTime(): number;
  44009. /**
  44010. * Sets the flag that indicates if user zooming should stop animation.
  44011. */
  44012. set zoomStopsAnimation(flag: boolean);
  44013. /**
  44014. * Gets the flag that indicates if user zooming should stop animation.
  44015. */
  44016. get zoomStopsAnimation(): boolean;
  44017. /**
  44018. * Sets the transition time when framing the mesh, in milliseconds
  44019. */
  44020. set framingTime(time: number);
  44021. /**
  44022. * Gets the transition time when framing the mesh, in milliseconds
  44023. */
  44024. get framingTime(): number;
  44025. /**
  44026. * Define if the behavior should automatically change the configured
  44027. * camera limits and sensibilities.
  44028. */
  44029. autoCorrectCameraLimitsAndSensibility: boolean;
  44030. private _onPrePointerObservableObserver;
  44031. private _onAfterCheckInputsObserver;
  44032. private _onMeshTargetChangedObserver;
  44033. private _attachedCamera;
  44034. private _isPointerDown;
  44035. private _lastInteractionTime;
  44036. /**
  44037. * Initializes the behavior.
  44038. */
  44039. init(): void;
  44040. /**
  44041. * Attaches the behavior to its arc rotate camera.
  44042. * @param camera Defines the camera to attach the behavior to
  44043. */
  44044. attach(camera: ArcRotateCamera): void;
  44045. /**
  44046. * Detaches the behavior from its current arc rotate camera.
  44047. */
  44048. detach(): void;
  44049. private _animatables;
  44050. private _betaIsAnimating;
  44051. private _betaTransition;
  44052. private _radiusTransition;
  44053. private _vectorTransition;
  44054. /**
  44055. * Targets the given mesh and updates zoom level accordingly.
  44056. * @param mesh The mesh to target.
  44057. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44058. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44059. */
  44060. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44061. /**
  44062. * Targets the given mesh with its children and updates zoom level accordingly.
  44063. * @param mesh The mesh to target.
  44064. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44065. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44066. */
  44067. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44068. /**
  44069. * Targets the given meshes with their children and updates zoom level accordingly.
  44070. * @param meshes The mesh to target.
  44071. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44072. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44073. */
  44074. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44075. /**
  44076. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44077. * @param minimumWorld Determines the smaller position of the bounding box extend
  44078. * @param maximumWorld Determines the bigger position of the bounding box extend
  44079. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44080. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44081. */
  44082. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44083. /**
  44084. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44085. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44086. * frustum width.
  44087. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44088. * to fully enclose the mesh in the viewing frustum.
  44089. */
  44090. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44091. /**
  44092. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44093. * is automatically returned to its default position (expected to be above ground plane).
  44094. */
  44095. private _maintainCameraAboveGround;
  44096. /**
  44097. * Returns the frustum slope based on the canvas ratio and camera FOV
  44098. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44099. */
  44100. private _getFrustumSlope;
  44101. /**
  44102. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44103. */
  44104. private _clearAnimationLocks;
  44105. /**
  44106. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44107. */
  44108. private _applyUserInteraction;
  44109. /**
  44110. * Stops and removes all animations that have been applied to the camera
  44111. */
  44112. stopAllAnimations(): void;
  44113. /**
  44114. * Gets a value indicating if the user is moving the camera
  44115. */
  44116. get isUserIsMoving(): boolean;
  44117. /**
  44118. * The camera can move all the way towards the mesh.
  44119. */
  44120. static IgnoreBoundsSizeMode: number;
  44121. /**
  44122. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44123. */
  44124. static FitFrustumSidesMode: number;
  44125. }
  44126. }
  44127. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44128. import { Nullable } from "babylonjs/types";
  44129. import { Camera } from "babylonjs/Cameras/camera";
  44130. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44131. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44132. /**
  44133. * Base class for Camera Pointer Inputs.
  44134. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44135. * for example usage.
  44136. */
  44137. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44138. /**
  44139. * Defines the camera the input is attached to.
  44140. */
  44141. abstract camera: Camera;
  44142. /**
  44143. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44144. */
  44145. protected _altKey: boolean;
  44146. protected _ctrlKey: boolean;
  44147. protected _metaKey: boolean;
  44148. protected _shiftKey: boolean;
  44149. /**
  44150. * Which mouse buttons were pressed at time of last mouse event.
  44151. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44152. */
  44153. protected _buttonsPressed: number;
  44154. /**
  44155. * Defines the buttons associated with the input to handle camera move.
  44156. */
  44157. buttons: number[];
  44158. /**
  44159. * Attach the input controls to a specific dom element to get the input from.
  44160. * @param element Defines the element the controls should be listened from
  44161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44162. */
  44163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44164. /**
  44165. * Detach the current controls from the specified dom element.
  44166. * @param element Defines the element to stop listening the inputs from
  44167. */
  44168. detachControl(element: Nullable<HTMLElement>): void;
  44169. /**
  44170. * Gets the class name of the current input.
  44171. * @returns the class name
  44172. */
  44173. getClassName(): string;
  44174. /**
  44175. * Get the friendly name associated with the input class.
  44176. * @returns the input friendly name
  44177. */
  44178. getSimpleName(): string;
  44179. /**
  44180. * Called on pointer POINTERDOUBLETAP event.
  44181. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44182. */
  44183. protected onDoubleTap(type: string): void;
  44184. /**
  44185. * Called on pointer POINTERMOVE event if only a single touch is active.
  44186. * Override this method to provide functionality.
  44187. */
  44188. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44189. /**
  44190. * Called on pointer POINTERMOVE event if multiple touches are active.
  44191. * Override this method to provide functionality.
  44192. */
  44193. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44194. /**
  44195. * Called on JS contextmenu event.
  44196. * Override this method to provide functionality.
  44197. */
  44198. protected onContextMenu(evt: PointerEvent): void;
  44199. /**
  44200. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44201. * press.
  44202. * Override this method to provide functionality.
  44203. */
  44204. protected onButtonDown(evt: PointerEvent): void;
  44205. /**
  44206. * Called each time a new POINTERUP event occurs. Ie, for each button
  44207. * release.
  44208. * Override this method to provide functionality.
  44209. */
  44210. protected onButtonUp(evt: PointerEvent): void;
  44211. /**
  44212. * Called when window becomes inactive.
  44213. * Override this method to provide functionality.
  44214. */
  44215. protected onLostFocus(): void;
  44216. private _pointerInput;
  44217. private _observer;
  44218. private _onLostFocus;
  44219. private pointA;
  44220. private pointB;
  44221. }
  44222. }
  44223. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44224. import { Nullable } from "babylonjs/types";
  44225. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44226. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44227. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44228. /**
  44229. * Manage the pointers inputs to control an arc rotate camera.
  44230. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44231. */
  44232. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44233. /**
  44234. * Defines the camera the input is attached to.
  44235. */
  44236. camera: ArcRotateCamera;
  44237. /**
  44238. * Gets the class name of the current input.
  44239. * @returns the class name
  44240. */
  44241. getClassName(): string;
  44242. /**
  44243. * Defines the buttons associated with the input to handle camera move.
  44244. */
  44245. buttons: number[];
  44246. /**
  44247. * Defines the pointer angular sensibility along the X axis or how fast is
  44248. * the camera rotating.
  44249. */
  44250. angularSensibilityX: number;
  44251. /**
  44252. * Defines the pointer angular sensibility along the Y axis or how fast is
  44253. * the camera rotating.
  44254. */
  44255. angularSensibilityY: number;
  44256. /**
  44257. * Defines the pointer pinch precision or how fast is the camera zooming.
  44258. */
  44259. pinchPrecision: number;
  44260. /**
  44261. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44262. * from 0.
  44263. * It defines the percentage of current camera.radius to use as delta when
  44264. * pinch zoom is used.
  44265. */
  44266. pinchDeltaPercentage: number;
  44267. /**
  44268. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44269. * that any object in the plane at the camera's target point will scale
  44270. * perfectly with finger motion.
  44271. * Overrides pinchDeltaPercentage and pinchPrecision.
  44272. */
  44273. useNaturalPinchZoom: boolean;
  44274. /**
  44275. * Defines the pointer panning sensibility or how fast is the camera moving.
  44276. */
  44277. panningSensibility: number;
  44278. /**
  44279. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44280. */
  44281. multiTouchPanning: boolean;
  44282. /**
  44283. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44284. * zoom (pinch) through multitouch.
  44285. */
  44286. multiTouchPanAndZoom: boolean;
  44287. /**
  44288. * Revers pinch action direction.
  44289. */
  44290. pinchInwards: boolean;
  44291. private _isPanClick;
  44292. private _twoFingerActivityCount;
  44293. private _isPinching;
  44294. /**
  44295. * Called on pointer POINTERMOVE event if only a single touch is active.
  44296. */
  44297. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44298. /**
  44299. * Called on pointer POINTERDOUBLETAP event.
  44300. */
  44301. protected onDoubleTap(type: string): void;
  44302. /**
  44303. * Called on pointer POINTERMOVE event if multiple touches are active.
  44304. */
  44305. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44306. /**
  44307. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44308. * press.
  44309. */
  44310. protected onButtonDown(evt: PointerEvent): void;
  44311. /**
  44312. * Called each time a new POINTERUP event occurs. Ie, for each button
  44313. * release.
  44314. */
  44315. protected onButtonUp(evt: PointerEvent): void;
  44316. /**
  44317. * Called when window becomes inactive.
  44318. */
  44319. protected onLostFocus(): void;
  44320. }
  44321. }
  44322. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44323. import { Nullable } from "babylonjs/types";
  44324. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44325. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44326. /**
  44327. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44328. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44329. */
  44330. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44331. /**
  44332. * Defines the camera the input is attached to.
  44333. */
  44334. camera: ArcRotateCamera;
  44335. /**
  44336. * Defines the list of key codes associated with the up action (increase alpha)
  44337. */
  44338. keysUp: number[];
  44339. /**
  44340. * Defines the list of key codes associated with the down action (decrease alpha)
  44341. */
  44342. keysDown: number[];
  44343. /**
  44344. * Defines the list of key codes associated with the left action (increase beta)
  44345. */
  44346. keysLeft: number[];
  44347. /**
  44348. * Defines the list of key codes associated with the right action (decrease beta)
  44349. */
  44350. keysRight: number[];
  44351. /**
  44352. * Defines the list of key codes associated with the reset action.
  44353. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44354. */
  44355. keysReset: number[];
  44356. /**
  44357. * Defines the panning sensibility of the inputs.
  44358. * (How fast is the camera panning)
  44359. */
  44360. panningSensibility: number;
  44361. /**
  44362. * Defines the zooming sensibility of the inputs.
  44363. * (How fast is the camera zooming)
  44364. */
  44365. zoomingSensibility: number;
  44366. /**
  44367. * Defines whether maintaining the alt key down switch the movement mode from
  44368. * orientation to zoom.
  44369. */
  44370. useAltToZoom: boolean;
  44371. /**
  44372. * Rotation speed of the camera
  44373. */
  44374. angularSpeed: number;
  44375. private _keys;
  44376. private _ctrlPressed;
  44377. private _altPressed;
  44378. private _onCanvasBlurObserver;
  44379. private _onKeyboardObserver;
  44380. private _engine;
  44381. private _scene;
  44382. /**
  44383. * Attach the input controls to a specific dom element to get the input from.
  44384. * @param element Defines the element the controls should be listened from
  44385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44386. */
  44387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44388. /**
  44389. * Detach the current controls from the specified dom element.
  44390. * @param element Defines the element to stop listening the inputs from
  44391. */
  44392. detachControl(element: Nullable<HTMLElement>): void;
  44393. /**
  44394. * Update the current camera state depending on the inputs that have been used this frame.
  44395. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44396. */
  44397. checkInputs(): void;
  44398. /**
  44399. * Gets the class name of the current intput.
  44400. * @returns the class name
  44401. */
  44402. getClassName(): string;
  44403. /**
  44404. * Get the friendly name associated with the input class.
  44405. * @returns the input friendly name
  44406. */
  44407. getSimpleName(): string;
  44408. }
  44409. }
  44410. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44411. import { Nullable } from "babylonjs/types";
  44412. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44413. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44414. /**
  44415. * Manage the mouse wheel inputs to control an arc rotate camera.
  44416. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44417. */
  44418. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44419. /**
  44420. * Defines the camera the input is attached to.
  44421. */
  44422. camera: ArcRotateCamera;
  44423. /**
  44424. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44425. */
  44426. wheelPrecision: number;
  44427. /**
  44428. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44429. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44430. */
  44431. wheelDeltaPercentage: number;
  44432. private _wheel;
  44433. private _observer;
  44434. private computeDeltaFromMouseWheelLegacyEvent;
  44435. /**
  44436. * Attach the input controls to a specific dom element to get the input from.
  44437. * @param element Defines the element the controls should be listened from
  44438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44439. */
  44440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44441. /**
  44442. * Detach the current controls from the specified dom element.
  44443. * @param element Defines the element to stop listening the inputs from
  44444. */
  44445. detachControl(element: Nullable<HTMLElement>): void;
  44446. /**
  44447. * Gets the class name of the current intput.
  44448. * @returns the class name
  44449. */
  44450. getClassName(): string;
  44451. /**
  44452. * Get the friendly name associated with the input class.
  44453. * @returns the input friendly name
  44454. */
  44455. getSimpleName(): string;
  44456. }
  44457. }
  44458. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44459. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44460. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44461. /**
  44462. * Default Inputs manager for the ArcRotateCamera.
  44463. * It groups all the default supported inputs for ease of use.
  44464. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44465. */
  44466. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44467. /**
  44468. * Instantiates a new ArcRotateCameraInputsManager.
  44469. * @param camera Defines the camera the inputs belong to
  44470. */
  44471. constructor(camera: ArcRotateCamera);
  44472. /**
  44473. * Add mouse wheel input support to the input manager.
  44474. * @returns the current input manager
  44475. */
  44476. addMouseWheel(): ArcRotateCameraInputsManager;
  44477. /**
  44478. * Add pointers input support to the input manager.
  44479. * @returns the current input manager
  44480. */
  44481. addPointers(): ArcRotateCameraInputsManager;
  44482. /**
  44483. * Add keyboard input support to the input manager.
  44484. * @returns the current input manager
  44485. */
  44486. addKeyboard(): ArcRotateCameraInputsManager;
  44487. }
  44488. }
  44489. declare module "babylonjs/Cameras/arcRotateCamera" {
  44490. import { Observable } from "babylonjs/Misc/observable";
  44491. import { Nullable } from "babylonjs/types";
  44492. import { Scene } from "babylonjs/scene";
  44493. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44495. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44496. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44497. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44498. import { Camera } from "babylonjs/Cameras/camera";
  44499. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44500. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44501. import { Collider } from "babylonjs/Collisions/collider";
  44502. /**
  44503. * This represents an orbital type of camera.
  44504. *
  44505. * 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.
  44506. * 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.
  44507. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44508. */
  44509. export class ArcRotateCamera extends TargetCamera {
  44510. /**
  44511. * Defines the rotation angle of the camera along the longitudinal axis.
  44512. */
  44513. alpha: number;
  44514. /**
  44515. * Defines the rotation angle of the camera along the latitudinal axis.
  44516. */
  44517. beta: number;
  44518. /**
  44519. * Defines the radius of the camera from it s target point.
  44520. */
  44521. radius: number;
  44522. protected _target: Vector3;
  44523. protected _targetHost: Nullable<AbstractMesh>;
  44524. /**
  44525. * Defines the target point of the camera.
  44526. * The camera looks towards it form the radius distance.
  44527. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44528. */
  44529. get target(): Vector3;
  44530. set target(value: Vector3);
  44531. /**
  44532. * Define the current local position of the camera in the scene
  44533. */
  44534. get position(): Vector3;
  44535. set position(newPosition: Vector3);
  44536. protected _upToYMatrix: Matrix;
  44537. protected _YToUpMatrix: Matrix;
  44538. /**
  44539. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44540. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44541. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44542. */
  44543. set upVector(vec: Vector3);
  44544. get upVector(): Vector3;
  44545. /**
  44546. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44547. */
  44548. setMatUp(): void;
  44549. /**
  44550. * Current inertia value on the longitudinal axis.
  44551. * The bigger this number the longer it will take for the camera to stop.
  44552. */
  44553. inertialAlphaOffset: number;
  44554. /**
  44555. * Current inertia value on the latitudinal axis.
  44556. * The bigger this number the longer it will take for the camera to stop.
  44557. */
  44558. inertialBetaOffset: number;
  44559. /**
  44560. * Current inertia value on the radius axis.
  44561. * The bigger this number the longer it will take for the camera to stop.
  44562. */
  44563. inertialRadiusOffset: number;
  44564. /**
  44565. * Minimum allowed angle on the longitudinal axis.
  44566. * This can help limiting how the Camera is able to move in the scene.
  44567. */
  44568. lowerAlphaLimit: Nullable<number>;
  44569. /**
  44570. * Maximum allowed angle on the longitudinal axis.
  44571. * This can help limiting how the Camera is able to move in the scene.
  44572. */
  44573. upperAlphaLimit: Nullable<number>;
  44574. /**
  44575. * Minimum allowed angle on the latitudinal axis.
  44576. * This can help limiting how the Camera is able to move in the scene.
  44577. */
  44578. lowerBetaLimit: number;
  44579. /**
  44580. * Maximum allowed angle on the latitudinal axis.
  44581. * This can help limiting how the Camera is able to move in the scene.
  44582. */
  44583. upperBetaLimit: number;
  44584. /**
  44585. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44586. * This can help limiting how the Camera is able to move in the scene.
  44587. */
  44588. lowerRadiusLimit: Nullable<number>;
  44589. /**
  44590. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44591. * This can help limiting how the Camera is able to move in the scene.
  44592. */
  44593. upperRadiusLimit: Nullable<number>;
  44594. /**
  44595. * Defines the current inertia value used during panning of the camera along the X axis.
  44596. */
  44597. inertialPanningX: number;
  44598. /**
  44599. * Defines the current inertia value used during panning of the camera along the Y axis.
  44600. */
  44601. inertialPanningY: number;
  44602. /**
  44603. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44604. * Basically if your fingers moves away from more than this distance you will be considered
  44605. * in pinch mode.
  44606. */
  44607. pinchToPanMaxDistance: number;
  44608. /**
  44609. * Defines the maximum distance the camera can pan.
  44610. * This could help keeping the cammera always in your scene.
  44611. */
  44612. panningDistanceLimit: Nullable<number>;
  44613. /**
  44614. * Defines the target of the camera before paning.
  44615. */
  44616. panningOriginTarget: Vector3;
  44617. /**
  44618. * Defines the value of the inertia used during panning.
  44619. * 0 would mean stop inertia and one would mean no decelleration at all.
  44620. */
  44621. panningInertia: number;
  44622. /**
  44623. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44624. */
  44625. get angularSensibilityX(): number;
  44626. set angularSensibilityX(value: number);
  44627. /**
  44628. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44629. */
  44630. get angularSensibilityY(): number;
  44631. set angularSensibilityY(value: number);
  44632. /**
  44633. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44634. */
  44635. get pinchPrecision(): number;
  44636. set pinchPrecision(value: number);
  44637. /**
  44638. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44639. * It will be used instead of pinchDeltaPrecision if different from 0.
  44640. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44641. */
  44642. get pinchDeltaPercentage(): number;
  44643. set pinchDeltaPercentage(value: number);
  44644. /**
  44645. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44646. * and pinch delta percentage.
  44647. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44648. * that any object in the plane at the camera's target point will scale
  44649. * perfectly with finger motion.
  44650. */
  44651. get useNaturalPinchZoom(): boolean;
  44652. set useNaturalPinchZoom(value: boolean);
  44653. /**
  44654. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44655. */
  44656. get panningSensibility(): number;
  44657. set panningSensibility(value: number);
  44658. /**
  44659. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44660. */
  44661. get keysUp(): number[];
  44662. set keysUp(value: number[]);
  44663. /**
  44664. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44665. */
  44666. get keysDown(): number[];
  44667. set keysDown(value: number[]);
  44668. /**
  44669. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44670. */
  44671. get keysLeft(): number[];
  44672. set keysLeft(value: number[]);
  44673. /**
  44674. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44675. */
  44676. get keysRight(): number[];
  44677. set keysRight(value: number[]);
  44678. /**
  44679. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44680. */
  44681. get wheelPrecision(): number;
  44682. set wheelPrecision(value: number);
  44683. /**
  44684. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44685. * It will be used instead of pinchDeltaPrecision if different from 0.
  44686. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44687. */
  44688. get wheelDeltaPercentage(): number;
  44689. set wheelDeltaPercentage(value: number);
  44690. /**
  44691. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44692. */
  44693. zoomOnFactor: number;
  44694. /**
  44695. * Defines a screen offset for the camera position.
  44696. */
  44697. targetScreenOffset: Vector2;
  44698. /**
  44699. * Allows the camera to be completely reversed.
  44700. * If false the camera can not arrive upside down.
  44701. */
  44702. allowUpsideDown: boolean;
  44703. /**
  44704. * Define if double tap/click is used to restore the previously saved state of the camera.
  44705. */
  44706. useInputToRestoreState: boolean;
  44707. /** @hidden */
  44708. _viewMatrix: Matrix;
  44709. /** @hidden */
  44710. _useCtrlForPanning: boolean;
  44711. /** @hidden */
  44712. _panningMouseButton: number;
  44713. /**
  44714. * Defines the input associated to the camera.
  44715. */
  44716. inputs: ArcRotateCameraInputsManager;
  44717. /** @hidden */
  44718. _reset: () => void;
  44719. /**
  44720. * Defines the allowed panning axis.
  44721. */
  44722. panningAxis: Vector3;
  44723. protected _localDirection: Vector3;
  44724. protected _transformedDirection: Vector3;
  44725. private _bouncingBehavior;
  44726. /**
  44727. * Gets the bouncing behavior of the camera if it has been enabled.
  44728. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44729. */
  44730. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44731. /**
  44732. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44733. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44734. */
  44735. get useBouncingBehavior(): boolean;
  44736. set useBouncingBehavior(value: boolean);
  44737. private _framingBehavior;
  44738. /**
  44739. * Gets the framing behavior of the camera if it has been enabled.
  44740. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44741. */
  44742. get framingBehavior(): Nullable<FramingBehavior>;
  44743. /**
  44744. * Defines if the framing behavior of the camera is enabled on the camera.
  44745. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44746. */
  44747. get useFramingBehavior(): boolean;
  44748. set useFramingBehavior(value: boolean);
  44749. private _autoRotationBehavior;
  44750. /**
  44751. * Gets the auto rotation behavior of the camera if it has been enabled.
  44752. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44753. */
  44754. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44755. /**
  44756. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44757. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44758. */
  44759. get useAutoRotationBehavior(): boolean;
  44760. set useAutoRotationBehavior(value: boolean);
  44761. /**
  44762. * Observable triggered when the mesh target has been changed on the camera.
  44763. */
  44764. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44765. /**
  44766. * Event raised when the camera is colliding with a mesh.
  44767. */
  44768. onCollide: (collidedMesh: AbstractMesh) => void;
  44769. /**
  44770. * Defines whether the camera should check collision with the objects oh the scene.
  44771. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44772. */
  44773. checkCollisions: boolean;
  44774. /**
  44775. * Defines the collision radius of the camera.
  44776. * This simulates a sphere around the camera.
  44777. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44778. */
  44779. collisionRadius: Vector3;
  44780. protected _collider: Collider;
  44781. protected _previousPosition: Vector3;
  44782. protected _collisionVelocity: Vector3;
  44783. protected _newPosition: Vector3;
  44784. protected _previousAlpha: number;
  44785. protected _previousBeta: number;
  44786. protected _previousRadius: number;
  44787. protected _collisionTriggered: boolean;
  44788. protected _targetBoundingCenter: Nullable<Vector3>;
  44789. private _computationVector;
  44790. /**
  44791. * Instantiates a new ArcRotateCamera in a given scene
  44792. * @param name Defines the name of the camera
  44793. * @param alpha Defines the camera rotation along the logitudinal axis
  44794. * @param beta Defines the camera rotation along the latitudinal axis
  44795. * @param radius Defines the camera distance from its target
  44796. * @param target Defines the camera target
  44797. * @param scene Defines the scene the camera belongs to
  44798. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44799. */
  44800. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44801. /** @hidden */
  44802. _initCache(): void;
  44803. /** @hidden */
  44804. _updateCache(ignoreParentClass?: boolean): void;
  44805. protected _getTargetPosition(): Vector3;
  44806. private _storedAlpha;
  44807. private _storedBeta;
  44808. private _storedRadius;
  44809. private _storedTarget;
  44810. private _storedTargetScreenOffset;
  44811. /**
  44812. * Stores the current state of the camera (alpha, beta, radius and target)
  44813. * @returns the camera itself
  44814. */
  44815. storeState(): Camera;
  44816. /**
  44817. * @hidden
  44818. * Restored camera state. You must call storeState() first
  44819. */
  44820. _restoreStateValues(): boolean;
  44821. /** @hidden */
  44822. _isSynchronizedViewMatrix(): boolean;
  44823. /**
  44824. * Attached controls to the current camera.
  44825. * @param element Defines the element the controls should be listened from
  44826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44827. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44828. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44829. */
  44830. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44831. /**
  44832. * Detach the current controls from the camera.
  44833. * The camera will stop reacting to inputs.
  44834. * @param element Defines the element to stop listening the inputs from
  44835. */
  44836. detachControl(element: HTMLElement): void;
  44837. /** @hidden */
  44838. _checkInputs(): void;
  44839. protected _checkLimits(): void;
  44840. /**
  44841. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44842. */
  44843. rebuildAnglesAndRadius(): void;
  44844. /**
  44845. * Use a position to define the current camera related information like alpha, beta and radius
  44846. * @param position Defines the position to set the camera at
  44847. */
  44848. setPosition(position: Vector3): void;
  44849. /**
  44850. * Defines the target the camera should look at.
  44851. * This will automatically adapt alpha beta and radius to fit within the new target.
  44852. * @param target Defines the new target as a Vector or a mesh
  44853. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44854. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44855. */
  44856. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44857. /** @hidden */
  44858. _getViewMatrix(): Matrix;
  44859. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44860. /**
  44861. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44862. * @param meshes Defines the mesh to zoom on
  44863. * @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)
  44864. */
  44865. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44866. /**
  44867. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44868. * The target will be changed but the radius
  44869. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44870. * @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)
  44871. */
  44872. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44873. min: Vector3;
  44874. max: Vector3;
  44875. distance: number;
  44876. }, doNotUpdateMaxZ?: boolean): void;
  44877. /**
  44878. * @override
  44879. * Override Camera.createRigCamera
  44880. */
  44881. createRigCamera(name: string, cameraIndex: number): Camera;
  44882. /**
  44883. * @hidden
  44884. * @override
  44885. * Override Camera._updateRigCameras
  44886. */
  44887. _updateRigCameras(): void;
  44888. /**
  44889. * Destroy the camera and release the current resources hold by it.
  44890. */
  44891. dispose(): void;
  44892. /**
  44893. * Gets the current object class name.
  44894. * @return the class name
  44895. */
  44896. getClassName(): string;
  44897. }
  44898. }
  44899. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44900. import { Behavior } from "babylonjs/Behaviors/behavior";
  44901. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44902. /**
  44903. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44904. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44905. */
  44906. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44907. /**
  44908. * Gets the name of the behavior.
  44909. */
  44910. get name(): string;
  44911. private _zoomStopsAnimation;
  44912. private _idleRotationSpeed;
  44913. private _idleRotationWaitTime;
  44914. private _idleRotationSpinupTime;
  44915. /**
  44916. * Sets the flag that indicates if user zooming should stop animation.
  44917. */
  44918. set zoomStopsAnimation(flag: boolean);
  44919. /**
  44920. * Gets the flag that indicates if user zooming should stop animation.
  44921. */
  44922. get zoomStopsAnimation(): boolean;
  44923. /**
  44924. * Sets the default speed at which the camera rotates around the model.
  44925. */
  44926. set idleRotationSpeed(speed: number);
  44927. /**
  44928. * Gets the default speed at which the camera rotates around the model.
  44929. */
  44930. get idleRotationSpeed(): number;
  44931. /**
  44932. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44933. */
  44934. set idleRotationWaitTime(time: number);
  44935. /**
  44936. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44937. */
  44938. get idleRotationWaitTime(): number;
  44939. /**
  44940. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44941. */
  44942. set idleRotationSpinupTime(time: number);
  44943. /**
  44944. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44945. */
  44946. get idleRotationSpinupTime(): number;
  44947. /**
  44948. * Gets a value indicating if the camera is currently rotating because of this behavior
  44949. */
  44950. get rotationInProgress(): boolean;
  44951. private _onPrePointerObservableObserver;
  44952. private _onAfterCheckInputsObserver;
  44953. private _attachedCamera;
  44954. private _isPointerDown;
  44955. private _lastFrameTime;
  44956. private _lastInteractionTime;
  44957. private _cameraRotationSpeed;
  44958. /**
  44959. * Initializes the behavior.
  44960. */
  44961. init(): void;
  44962. /**
  44963. * Attaches the behavior to its arc rotate camera.
  44964. * @param camera Defines the camera to attach the behavior to
  44965. */
  44966. attach(camera: ArcRotateCamera): void;
  44967. /**
  44968. * Detaches the behavior from its current arc rotate camera.
  44969. */
  44970. detach(): void;
  44971. /**
  44972. * Returns true if user is scrolling.
  44973. * @return true if user is scrolling.
  44974. */
  44975. private _userIsZooming;
  44976. private _lastFrameRadius;
  44977. private _shouldAnimationStopForInteraction;
  44978. /**
  44979. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44980. */
  44981. private _applyUserInteraction;
  44982. private _userIsMoving;
  44983. }
  44984. }
  44985. declare module "babylonjs/Behaviors/Cameras/index" {
  44986. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44987. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44988. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44989. }
  44990. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44991. import { Mesh } from "babylonjs/Meshes/mesh";
  44992. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44993. import { Behavior } from "babylonjs/Behaviors/behavior";
  44994. /**
  44995. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44996. */
  44997. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44998. private ui;
  44999. /**
  45000. * The name of the behavior
  45001. */
  45002. name: string;
  45003. /**
  45004. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  45005. */
  45006. distanceAwayFromFace: number;
  45007. /**
  45008. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  45009. */
  45010. distanceAwayFromBottomOfFace: number;
  45011. private _faceVectors;
  45012. private _target;
  45013. private _scene;
  45014. private _onRenderObserver;
  45015. private _tmpMatrix;
  45016. private _tmpVector;
  45017. /**
  45018. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  45019. * @param ui The transform node that should be attched to the mesh
  45020. */
  45021. constructor(ui: TransformNode);
  45022. /**
  45023. * Initializes the behavior
  45024. */
  45025. init(): void;
  45026. private _closestFace;
  45027. private _zeroVector;
  45028. private _lookAtTmpMatrix;
  45029. private _lookAtToRef;
  45030. /**
  45031. * Attaches the AttachToBoxBehavior to the passed in mesh
  45032. * @param target The mesh that the specified node will be attached to
  45033. */
  45034. attach(target: Mesh): void;
  45035. /**
  45036. * Detaches the behavior from the mesh
  45037. */
  45038. detach(): void;
  45039. }
  45040. }
  45041. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  45042. import { Behavior } from "babylonjs/Behaviors/behavior";
  45043. import { Mesh } from "babylonjs/Meshes/mesh";
  45044. /**
  45045. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  45046. */
  45047. export class FadeInOutBehavior implements Behavior<Mesh> {
  45048. /**
  45049. * Time in milliseconds to delay before fading in (Default: 0)
  45050. */
  45051. delay: number;
  45052. /**
  45053. * Time in milliseconds for the mesh to fade in (Default: 300)
  45054. */
  45055. fadeInTime: number;
  45056. private _millisecondsPerFrame;
  45057. private _hovered;
  45058. private _hoverValue;
  45059. private _ownerNode;
  45060. /**
  45061. * Instatiates the FadeInOutBehavior
  45062. */
  45063. constructor();
  45064. /**
  45065. * The name of the behavior
  45066. */
  45067. get name(): string;
  45068. /**
  45069. * Initializes the behavior
  45070. */
  45071. init(): void;
  45072. /**
  45073. * Attaches the fade behavior on the passed in mesh
  45074. * @param ownerNode The mesh that will be faded in/out once attached
  45075. */
  45076. attach(ownerNode: Mesh): void;
  45077. /**
  45078. * Detaches the behavior from the mesh
  45079. */
  45080. detach(): void;
  45081. /**
  45082. * Triggers the mesh to begin fading in or out
  45083. * @param value if the object should fade in or out (true to fade in)
  45084. */
  45085. fadeIn(value: boolean): void;
  45086. private _update;
  45087. private _setAllVisibility;
  45088. }
  45089. }
  45090. declare module "babylonjs/Misc/pivotTools" {
  45091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45092. /**
  45093. * Class containing a set of static utilities functions for managing Pivots
  45094. * @hidden
  45095. */
  45096. export class PivotTools {
  45097. private static _PivotCached;
  45098. private static _OldPivotPoint;
  45099. private static _PivotTranslation;
  45100. private static _PivotTmpVector;
  45101. private static _PivotPostMultiplyPivotMatrix;
  45102. /** @hidden */
  45103. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45104. /** @hidden */
  45105. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45106. }
  45107. }
  45108. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45109. import { Scene } from "babylonjs/scene";
  45110. import { Vector4 } from "babylonjs/Maths/math.vector";
  45111. import { Mesh } from "babylonjs/Meshes/mesh";
  45112. import { Nullable } from "babylonjs/types";
  45113. import { Plane } from "babylonjs/Maths/math.plane";
  45114. /**
  45115. * Class containing static functions to help procedurally build meshes
  45116. */
  45117. export class PlaneBuilder {
  45118. /**
  45119. * Creates a plane mesh
  45120. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45121. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45122. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45126. * @param name defines the name of the mesh
  45127. * @param options defines the options used to create the mesh
  45128. * @param scene defines the hosting scene
  45129. * @returns the plane mesh
  45130. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45131. */
  45132. static CreatePlane(name: string, options: {
  45133. size?: number;
  45134. width?: number;
  45135. height?: number;
  45136. sideOrientation?: number;
  45137. frontUVs?: Vector4;
  45138. backUVs?: Vector4;
  45139. updatable?: boolean;
  45140. sourcePlane?: Plane;
  45141. }, scene?: Nullable<Scene>): Mesh;
  45142. }
  45143. }
  45144. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45145. import { Behavior } from "babylonjs/Behaviors/behavior";
  45146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45147. import { Observable } from "babylonjs/Misc/observable";
  45148. import { Vector3 } from "babylonjs/Maths/math.vector";
  45149. import { Ray } from "babylonjs/Culling/ray";
  45150. import "babylonjs/Meshes/Builders/planeBuilder";
  45151. /**
  45152. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45153. */
  45154. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45155. private static _AnyMouseID;
  45156. /**
  45157. * Abstract mesh the behavior is set on
  45158. */
  45159. attachedNode: AbstractMesh;
  45160. private _dragPlane;
  45161. private _scene;
  45162. private _pointerObserver;
  45163. private _beforeRenderObserver;
  45164. private static _planeScene;
  45165. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45166. /**
  45167. * 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)
  45168. */
  45169. maxDragAngle: number;
  45170. /**
  45171. * @hidden
  45172. */
  45173. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45174. /**
  45175. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45176. */
  45177. currentDraggingPointerID: number;
  45178. /**
  45179. * The last position where the pointer hit the drag plane in world space
  45180. */
  45181. lastDragPosition: Vector3;
  45182. /**
  45183. * If the behavior is currently in a dragging state
  45184. */
  45185. dragging: boolean;
  45186. /**
  45187. * 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)
  45188. */
  45189. dragDeltaRatio: number;
  45190. /**
  45191. * If the drag plane orientation should be updated during the dragging (Default: true)
  45192. */
  45193. updateDragPlane: boolean;
  45194. private _debugMode;
  45195. private _moving;
  45196. /**
  45197. * Fires each time the attached mesh is dragged with the pointer
  45198. * * delta between last drag position and current drag position in world space
  45199. * * dragDistance along the drag axis
  45200. * * dragPlaneNormal normal of the current drag plane used during the drag
  45201. * * dragPlanePoint in world space where the drag intersects the drag plane
  45202. */
  45203. onDragObservable: Observable<{
  45204. delta: Vector3;
  45205. dragPlanePoint: Vector3;
  45206. dragPlaneNormal: Vector3;
  45207. dragDistance: number;
  45208. pointerId: number;
  45209. }>;
  45210. /**
  45211. * Fires each time a drag begins (eg. mouse down on mesh)
  45212. */
  45213. onDragStartObservable: Observable<{
  45214. dragPlanePoint: Vector3;
  45215. pointerId: number;
  45216. }>;
  45217. /**
  45218. * Fires each time a drag ends (eg. mouse release after drag)
  45219. */
  45220. onDragEndObservable: Observable<{
  45221. dragPlanePoint: Vector3;
  45222. pointerId: number;
  45223. }>;
  45224. /**
  45225. * If the attached mesh should be moved when dragged
  45226. */
  45227. moveAttached: boolean;
  45228. /**
  45229. * If the drag behavior will react to drag events (Default: true)
  45230. */
  45231. enabled: boolean;
  45232. /**
  45233. * If pointer events should start and release the drag (Default: true)
  45234. */
  45235. startAndReleaseDragOnPointerEvents: boolean;
  45236. /**
  45237. * If camera controls should be detached during the drag
  45238. */
  45239. detachCameraControls: boolean;
  45240. /**
  45241. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45242. */
  45243. useObjectOrientationForDragging: boolean;
  45244. private _options;
  45245. /**
  45246. * Gets the options used by the behavior
  45247. */
  45248. get options(): {
  45249. dragAxis?: Vector3;
  45250. dragPlaneNormal?: Vector3;
  45251. };
  45252. /**
  45253. * Sets the options used by the behavior
  45254. */
  45255. set options(options: {
  45256. dragAxis?: Vector3;
  45257. dragPlaneNormal?: Vector3;
  45258. });
  45259. /**
  45260. * Creates a pointer drag behavior that can be attached to a mesh
  45261. * @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)
  45262. */
  45263. constructor(options?: {
  45264. dragAxis?: Vector3;
  45265. dragPlaneNormal?: Vector3;
  45266. });
  45267. /**
  45268. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45269. */
  45270. validateDrag: (targetPosition: Vector3) => boolean;
  45271. /**
  45272. * The name of the behavior
  45273. */
  45274. get name(): string;
  45275. /**
  45276. * Initializes the behavior
  45277. */
  45278. init(): void;
  45279. private _tmpVector;
  45280. private _alternatePickedPoint;
  45281. private _worldDragAxis;
  45282. private _targetPosition;
  45283. private _attachedElement;
  45284. /**
  45285. * Attaches the drag behavior the passed in mesh
  45286. * @param ownerNode The mesh that will be dragged around once attached
  45287. * @param predicate Predicate to use for pick filtering
  45288. */
  45289. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45290. /**
  45291. * Force relase the drag action by code.
  45292. */
  45293. releaseDrag(): void;
  45294. private _startDragRay;
  45295. private _lastPointerRay;
  45296. /**
  45297. * Simulates the start of a pointer drag event on the behavior
  45298. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45299. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45300. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45301. */
  45302. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45303. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45304. private _dragDelta;
  45305. protected _moveDrag(ray: Ray): void;
  45306. private _pickWithRayOnDragPlane;
  45307. private _pointA;
  45308. private _pointC;
  45309. private _localAxis;
  45310. private _lookAt;
  45311. private _updateDragPlanePosition;
  45312. /**
  45313. * Detaches the behavior from the mesh
  45314. */
  45315. detach(): void;
  45316. }
  45317. }
  45318. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45319. import { Mesh } from "babylonjs/Meshes/mesh";
  45320. import { Behavior } from "babylonjs/Behaviors/behavior";
  45321. /**
  45322. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45323. */
  45324. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45325. private _dragBehaviorA;
  45326. private _dragBehaviorB;
  45327. private _startDistance;
  45328. private _initialScale;
  45329. private _targetScale;
  45330. private _ownerNode;
  45331. private _sceneRenderObserver;
  45332. /**
  45333. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45334. */
  45335. constructor();
  45336. /**
  45337. * The name of the behavior
  45338. */
  45339. get name(): string;
  45340. /**
  45341. * Initializes the behavior
  45342. */
  45343. init(): void;
  45344. private _getCurrentDistance;
  45345. /**
  45346. * Attaches the scale behavior the passed in mesh
  45347. * @param ownerNode The mesh that will be scaled around once attached
  45348. */
  45349. attach(ownerNode: Mesh): void;
  45350. /**
  45351. * Detaches the behavior from the mesh
  45352. */
  45353. detach(): void;
  45354. }
  45355. }
  45356. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45357. import { Behavior } from "babylonjs/Behaviors/behavior";
  45358. import { Mesh } from "babylonjs/Meshes/mesh";
  45359. import { Observable } from "babylonjs/Misc/observable";
  45360. /**
  45361. * 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
  45362. */
  45363. export class SixDofDragBehavior implements Behavior<Mesh> {
  45364. private static _virtualScene;
  45365. private _ownerNode;
  45366. private _sceneRenderObserver;
  45367. private _scene;
  45368. private _targetPosition;
  45369. private _virtualOriginMesh;
  45370. private _virtualDragMesh;
  45371. private _pointerObserver;
  45372. private _moving;
  45373. private _startingOrientation;
  45374. private _attachedElement;
  45375. /**
  45376. * 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)
  45377. */
  45378. private zDragFactor;
  45379. /**
  45380. * If the object should rotate to face the drag origin
  45381. */
  45382. rotateDraggedObject: boolean;
  45383. /**
  45384. * If the behavior is currently in a dragging state
  45385. */
  45386. dragging: boolean;
  45387. /**
  45388. * 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)
  45389. */
  45390. dragDeltaRatio: number;
  45391. /**
  45392. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45393. */
  45394. currentDraggingPointerID: number;
  45395. /**
  45396. * If camera controls should be detached during the drag
  45397. */
  45398. detachCameraControls: boolean;
  45399. /**
  45400. * Fires each time a drag starts
  45401. */
  45402. onDragStartObservable: Observable<{}>;
  45403. /**
  45404. * Fires each time a drag ends (eg. mouse release after drag)
  45405. */
  45406. onDragEndObservable: Observable<{}>;
  45407. /**
  45408. * 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
  45409. */
  45410. constructor();
  45411. /**
  45412. * The name of the behavior
  45413. */
  45414. get name(): string;
  45415. /**
  45416. * Initializes the behavior
  45417. */
  45418. init(): void;
  45419. /**
  45420. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45421. */
  45422. private get _pointerCamera();
  45423. /**
  45424. * Attaches the scale behavior the passed in mesh
  45425. * @param ownerNode The mesh that will be scaled around once attached
  45426. */
  45427. attach(ownerNode: Mesh): void;
  45428. /**
  45429. * Detaches the behavior from the mesh
  45430. */
  45431. detach(): void;
  45432. }
  45433. }
  45434. declare module "babylonjs/Behaviors/Meshes/index" {
  45435. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45436. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45437. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45438. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45439. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45440. }
  45441. declare module "babylonjs/Behaviors/index" {
  45442. export * from "babylonjs/Behaviors/behavior";
  45443. export * from "babylonjs/Behaviors/Cameras/index";
  45444. export * from "babylonjs/Behaviors/Meshes/index";
  45445. }
  45446. declare module "babylonjs/Bones/boneIKController" {
  45447. import { Bone } from "babylonjs/Bones/bone";
  45448. import { Vector3 } from "babylonjs/Maths/math.vector";
  45449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45450. import { Nullable } from "babylonjs/types";
  45451. /**
  45452. * Class used to apply inverse kinematics to bones
  45453. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45454. */
  45455. export class BoneIKController {
  45456. private static _tmpVecs;
  45457. private static _tmpQuat;
  45458. private static _tmpMats;
  45459. /**
  45460. * Gets or sets the target mesh
  45461. */
  45462. targetMesh: AbstractMesh;
  45463. /** Gets or sets the mesh used as pole */
  45464. poleTargetMesh: AbstractMesh;
  45465. /**
  45466. * Gets or sets the bone used as pole
  45467. */
  45468. poleTargetBone: Nullable<Bone>;
  45469. /**
  45470. * Gets or sets the target position
  45471. */
  45472. targetPosition: Vector3;
  45473. /**
  45474. * Gets or sets the pole target position
  45475. */
  45476. poleTargetPosition: Vector3;
  45477. /**
  45478. * Gets or sets the pole target local offset
  45479. */
  45480. poleTargetLocalOffset: Vector3;
  45481. /**
  45482. * Gets or sets the pole angle
  45483. */
  45484. poleAngle: number;
  45485. /**
  45486. * Gets or sets the mesh associated with the controller
  45487. */
  45488. mesh: AbstractMesh;
  45489. /**
  45490. * 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)
  45491. */
  45492. slerpAmount: number;
  45493. private _bone1Quat;
  45494. private _bone1Mat;
  45495. private _bone2Ang;
  45496. private _bone1;
  45497. private _bone2;
  45498. private _bone1Length;
  45499. private _bone2Length;
  45500. private _maxAngle;
  45501. private _maxReach;
  45502. private _rightHandedSystem;
  45503. private _bendAxis;
  45504. private _slerping;
  45505. private _adjustRoll;
  45506. /**
  45507. * Gets or sets maximum allowed angle
  45508. */
  45509. get maxAngle(): number;
  45510. set maxAngle(value: number);
  45511. /**
  45512. * Creates a new BoneIKController
  45513. * @param mesh defines the mesh to control
  45514. * @param bone defines the bone to control
  45515. * @param options defines options to set up the controller
  45516. */
  45517. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45518. targetMesh?: AbstractMesh;
  45519. poleTargetMesh?: AbstractMesh;
  45520. poleTargetBone?: Bone;
  45521. poleTargetLocalOffset?: Vector3;
  45522. poleAngle?: number;
  45523. bendAxis?: Vector3;
  45524. maxAngle?: number;
  45525. slerpAmount?: number;
  45526. });
  45527. private _setMaxAngle;
  45528. /**
  45529. * Force the controller to update the bones
  45530. */
  45531. update(): void;
  45532. }
  45533. }
  45534. declare module "babylonjs/Bones/boneLookController" {
  45535. import { Vector3 } from "babylonjs/Maths/math.vector";
  45536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45537. import { Bone } from "babylonjs/Bones/bone";
  45538. import { Space } from "babylonjs/Maths/math.axis";
  45539. /**
  45540. * Class used to make a bone look toward a point in space
  45541. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45542. */
  45543. export class BoneLookController {
  45544. private static _tmpVecs;
  45545. private static _tmpQuat;
  45546. private static _tmpMats;
  45547. /**
  45548. * The target Vector3 that the bone will look at
  45549. */
  45550. target: Vector3;
  45551. /**
  45552. * The mesh that the bone is attached to
  45553. */
  45554. mesh: AbstractMesh;
  45555. /**
  45556. * The bone that will be looking to the target
  45557. */
  45558. bone: Bone;
  45559. /**
  45560. * The up axis of the coordinate system that is used when the bone is rotated
  45561. */
  45562. upAxis: Vector3;
  45563. /**
  45564. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45565. */
  45566. upAxisSpace: Space;
  45567. /**
  45568. * Used to make an adjustment to the yaw of the bone
  45569. */
  45570. adjustYaw: number;
  45571. /**
  45572. * Used to make an adjustment to the pitch of the bone
  45573. */
  45574. adjustPitch: number;
  45575. /**
  45576. * Used to make an adjustment to the roll of the bone
  45577. */
  45578. adjustRoll: number;
  45579. /**
  45580. * 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)
  45581. */
  45582. slerpAmount: number;
  45583. private _minYaw;
  45584. private _maxYaw;
  45585. private _minPitch;
  45586. private _maxPitch;
  45587. private _minYawSin;
  45588. private _minYawCos;
  45589. private _maxYawSin;
  45590. private _maxYawCos;
  45591. private _midYawConstraint;
  45592. private _minPitchTan;
  45593. private _maxPitchTan;
  45594. private _boneQuat;
  45595. private _slerping;
  45596. private _transformYawPitch;
  45597. private _transformYawPitchInv;
  45598. private _firstFrameSkipped;
  45599. private _yawRange;
  45600. private _fowardAxis;
  45601. /**
  45602. * Gets or sets the minimum yaw angle that the bone can look to
  45603. */
  45604. get minYaw(): number;
  45605. set minYaw(value: number);
  45606. /**
  45607. * Gets or sets the maximum yaw angle that the bone can look to
  45608. */
  45609. get maxYaw(): number;
  45610. set maxYaw(value: number);
  45611. /**
  45612. * Gets or sets the minimum pitch angle that the bone can look to
  45613. */
  45614. get minPitch(): number;
  45615. set minPitch(value: number);
  45616. /**
  45617. * Gets or sets the maximum pitch angle that the bone can look to
  45618. */
  45619. get maxPitch(): number;
  45620. set maxPitch(value: number);
  45621. /**
  45622. * Create a BoneLookController
  45623. * @param mesh the mesh that the bone belongs to
  45624. * @param bone the bone that will be looking to the target
  45625. * @param target the target Vector3 to look at
  45626. * @param options optional settings:
  45627. * * maxYaw: the maximum angle the bone will yaw to
  45628. * * minYaw: the minimum angle the bone will yaw to
  45629. * * maxPitch: the maximum angle the bone will pitch to
  45630. * * minPitch: the minimum angle the bone will yaw to
  45631. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45632. * * upAxis: the up axis of the coordinate system
  45633. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45634. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45635. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45636. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45637. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45638. * * adjustRoll: used to make an adjustment to the roll of the bone
  45639. **/
  45640. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45641. maxYaw?: number;
  45642. minYaw?: number;
  45643. maxPitch?: number;
  45644. minPitch?: number;
  45645. slerpAmount?: number;
  45646. upAxis?: Vector3;
  45647. upAxisSpace?: Space;
  45648. yawAxis?: Vector3;
  45649. pitchAxis?: Vector3;
  45650. adjustYaw?: number;
  45651. adjustPitch?: number;
  45652. adjustRoll?: number;
  45653. });
  45654. /**
  45655. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45656. */
  45657. update(): void;
  45658. private _getAngleDiff;
  45659. private _getAngleBetween;
  45660. private _isAngleBetween;
  45661. }
  45662. }
  45663. declare module "babylonjs/Bones/index" {
  45664. export * from "babylonjs/Bones/bone";
  45665. export * from "babylonjs/Bones/boneIKController";
  45666. export * from "babylonjs/Bones/boneLookController";
  45667. export * from "babylonjs/Bones/skeleton";
  45668. }
  45669. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45670. import { Nullable } from "babylonjs/types";
  45671. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45672. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45673. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45674. /**
  45675. * Manage the gamepad inputs to control an arc rotate camera.
  45676. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45677. */
  45678. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45679. /**
  45680. * Defines the camera the input is attached to.
  45681. */
  45682. camera: ArcRotateCamera;
  45683. /**
  45684. * Defines the gamepad the input is gathering event from.
  45685. */
  45686. gamepad: Nullable<Gamepad>;
  45687. /**
  45688. * Defines the gamepad rotation sensiblity.
  45689. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45690. */
  45691. gamepadRotationSensibility: number;
  45692. /**
  45693. * Defines the gamepad move sensiblity.
  45694. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45695. */
  45696. gamepadMoveSensibility: number;
  45697. private _yAxisScale;
  45698. /**
  45699. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45700. */
  45701. get invertYAxis(): boolean;
  45702. set invertYAxis(value: boolean);
  45703. private _onGamepadConnectedObserver;
  45704. private _onGamepadDisconnectedObserver;
  45705. /**
  45706. * Attach the input controls to a specific dom element to get the input from.
  45707. * @param element Defines the element the controls should be listened from
  45708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45709. */
  45710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45711. /**
  45712. * Detach the current controls from the specified dom element.
  45713. * @param element Defines the element to stop listening the inputs from
  45714. */
  45715. detachControl(element: Nullable<HTMLElement>): void;
  45716. /**
  45717. * Update the current camera state depending on the inputs that have been used this frame.
  45718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45719. */
  45720. checkInputs(): void;
  45721. /**
  45722. * Gets the class name of the current intput.
  45723. * @returns the class name
  45724. */
  45725. getClassName(): string;
  45726. /**
  45727. * Get the friendly name associated with the input class.
  45728. * @returns the input friendly name
  45729. */
  45730. getSimpleName(): string;
  45731. }
  45732. }
  45733. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45734. import { Nullable } from "babylonjs/types";
  45735. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45736. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45737. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45738. interface ArcRotateCameraInputsManager {
  45739. /**
  45740. * Add orientation input support to the input manager.
  45741. * @returns the current input manager
  45742. */
  45743. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45744. }
  45745. }
  45746. /**
  45747. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45748. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45749. */
  45750. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45751. /**
  45752. * Defines the camera the input is attached to.
  45753. */
  45754. camera: ArcRotateCamera;
  45755. /**
  45756. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45757. */
  45758. alphaCorrection: number;
  45759. /**
  45760. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45761. */
  45762. gammaCorrection: number;
  45763. private _alpha;
  45764. private _gamma;
  45765. private _dirty;
  45766. private _deviceOrientationHandler;
  45767. /**
  45768. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45769. */
  45770. constructor();
  45771. /**
  45772. * Attach the input controls to a specific dom element to get the input from.
  45773. * @param element Defines the element the controls should be listened from
  45774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45775. */
  45776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45777. /** @hidden */
  45778. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45779. /**
  45780. * Update the current camera state depending on the inputs that have been used this frame.
  45781. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45782. */
  45783. checkInputs(): void;
  45784. /**
  45785. * Detach the current controls from the specified dom element.
  45786. * @param element Defines the element to stop listening the inputs from
  45787. */
  45788. detachControl(element: Nullable<HTMLElement>): void;
  45789. /**
  45790. * Gets the class name of the current intput.
  45791. * @returns the class name
  45792. */
  45793. getClassName(): string;
  45794. /**
  45795. * Get the friendly name associated with the input class.
  45796. * @returns the input friendly name
  45797. */
  45798. getSimpleName(): string;
  45799. }
  45800. }
  45801. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45802. import { Nullable } from "babylonjs/types";
  45803. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45804. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45805. /**
  45806. * Listen to mouse events to control the camera.
  45807. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45808. */
  45809. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45810. /**
  45811. * Defines the camera the input is attached to.
  45812. */
  45813. camera: FlyCamera;
  45814. /**
  45815. * Defines if touch is enabled. (Default is true.)
  45816. */
  45817. touchEnabled: boolean;
  45818. /**
  45819. * Defines the buttons associated with the input to handle camera rotation.
  45820. */
  45821. buttons: number[];
  45822. /**
  45823. * Assign buttons for Yaw control.
  45824. */
  45825. buttonsYaw: number[];
  45826. /**
  45827. * Assign buttons for Pitch control.
  45828. */
  45829. buttonsPitch: number[];
  45830. /**
  45831. * Assign buttons for Roll control.
  45832. */
  45833. buttonsRoll: number[];
  45834. /**
  45835. * Detect if any button is being pressed while mouse is moved.
  45836. * -1 = Mouse locked.
  45837. * 0 = Left button.
  45838. * 1 = Middle Button.
  45839. * 2 = Right Button.
  45840. */
  45841. activeButton: number;
  45842. /**
  45843. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45844. * Higher values reduce its sensitivity.
  45845. */
  45846. angularSensibility: number;
  45847. private _mousemoveCallback;
  45848. private _observer;
  45849. private _rollObserver;
  45850. private previousPosition;
  45851. private noPreventDefault;
  45852. private element;
  45853. /**
  45854. * Listen to mouse events to control the camera.
  45855. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45856. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45857. */
  45858. constructor(touchEnabled?: boolean);
  45859. /**
  45860. * Attach the mouse control to the HTML DOM element.
  45861. * @param element Defines the element that listens to the input events.
  45862. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45863. */
  45864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45865. /**
  45866. * Detach the current controls from the specified dom element.
  45867. * @param element Defines the element to stop listening the inputs from
  45868. */
  45869. detachControl(element: Nullable<HTMLElement>): void;
  45870. /**
  45871. * Gets the class name of the current input.
  45872. * @returns the class name.
  45873. */
  45874. getClassName(): string;
  45875. /**
  45876. * Get the friendly name associated with the input class.
  45877. * @returns the input's friendly name.
  45878. */
  45879. getSimpleName(): string;
  45880. private _pointerInput;
  45881. private _onMouseMove;
  45882. /**
  45883. * Rotate camera by mouse offset.
  45884. */
  45885. private rotateCamera;
  45886. }
  45887. }
  45888. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45889. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45890. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45891. /**
  45892. * Default Inputs manager for the FlyCamera.
  45893. * It groups all the default supported inputs for ease of use.
  45894. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45895. */
  45896. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45897. /**
  45898. * Instantiates a new FlyCameraInputsManager.
  45899. * @param camera Defines the camera the inputs belong to.
  45900. */
  45901. constructor(camera: FlyCamera);
  45902. /**
  45903. * Add keyboard input support to the input manager.
  45904. * @returns the new FlyCameraKeyboardMoveInput().
  45905. */
  45906. addKeyboard(): FlyCameraInputsManager;
  45907. /**
  45908. * Add mouse input support to the input manager.
  45909. * @param touchEnabled Enable touch screen support.
  45910. * @returns the new FlyCameraMouseInput().
  45911. */
  45912. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45913. }
  45914. }
  45915. declare module "babylonjs/Cameras/flyCamera" {
  45916. import { Scene } from "babylonjs/scene";
  45917. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45919. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45920. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45921. /**
  45922. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45923. * such as in a 3D Space Shooter or a Flight Simulator.
  45924. */
  45925. export class FlyCamera extends TargetCamera {
  45926. /**
  45927. * Define the collision ellipsoid of the camera.
  45928. * This is helpful for simulating a camera body, like a player's body.
  45929. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45930. */
  45931. ellipsoid: Vector3;
  45932. /**
  45933. * Define an offset for the position of the ellipsoid around the camera.
  45934. * This can be helpful if the camera is attached away from the player's body center,
  45935. * such as at its head.
  45936. */
  45937. ellipsoidOffset: Vector3;
  45938. /**
  45939. * Enable or disable collisions of the camera with the rest of the scene objects.
  45940. */
  45941. checkCollisions: boolean;
  45942. /**
  45943. * Enable or disable gravity on the camera.
  45944. */
  45945. applyGravity: boolean;
  45946. /**
  45947. * Define the current direction the camera is moving to.
  45948. */
  45949. cameraDirection: Vector3;
  45950. /**
  45951. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45952. * This overrides and empties cameraRotation.
  45953. */
  45954. rotationQuaternion: Quaternion;
  45955. /**
  45956. * Track Roll to maintain the wanted Rolling when looking around.
  45957. */
  45958. _trackRoll: number;
  45959. /**
  45960. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45961. */
  45962. rollCorrect: number;
  45963. /**
  45964. * Mimic a banked turn, Rolling the camera when Yawing.
  45965. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45966. */
  45967. bankedTurn: boolean;
  45968. /**
  45969. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45970. */
  45971. bankedTurnLimit: number;
  45972. /**
  45973. * Value of 0 disables the banked Roll.
  45974. * Value of 1 is equal to the Yaw angle in radians.
  45975. */
  45976. bankedTurnMultiplier: number;
  45977. /**
  45978. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45979. */
  45980. inputs: FlyCameraInputsManager;
  45981. /**
  45982. * Gets the input sensibility for mouse input.
  45983. * Higher values reduce sensitivity.
  45984. */
  45985. get angularSensibility(): number;
  45986. /**
  45987. * Sets the input sensibility for a mouse input.
  45988. * Higher values reduce sensitivity.
  45989. */
  45990. set angularSensibility(value: number);
  45991. /**
  45992. * Get the keys for camera movement forward.
  45993. */
  45994. get keysForward(): number[];
  45995. /**
  45996. * Set the keys for camera movement forward.
  45997. */
  45998. set keysForward(value: number[]);
  45999. /**
  46000. * Get the keys for camera movement backward.
  46001. */
  46002. get keysBackward(): number[];
  46003. set keysBackward(value: number[]);
  46004. /**
  46005. * Get the keys for camera movement up.
  46006. */
  46007. get keysUp(): number[];
  46008. /**
  46009. * Set the keys for camera movement up.
  46010. */
  46011. set keysUp(value: number[]);
  46012. /**
  46013. * Get the keys for camera movement down.
  46014. */
  46015. get keysDown(): number[];
  46016. /**
  46017. * Set the keys for camera movement down.
  46018. */
  46019. set keysDown(value: number[]);
  46020. /**
  46021. * Get the keys for camera movement left.
  46022. */
  46023. get keysLeft(): number[];
  46024. /**
  46025. * Set the keys for camera movement left.
  46026. */
  46027. set keysLeft(value: number[]);
  46028. /**
  46029. * Set the keys for camera movement right.
  46030. */
  46031. get keysRight(): number[];
  46032. /**
  46033. * Set the keys for camera movement right.
  46034. */
  46035. set keysRight(value: number[]);
  46036. /**
  46037. * Event raised when the camera collides with a mesh in the scene.
  46038. */
  46039. onCollide: (collidedMesh: AbstractMesh) => void;
  46040. private _collider;
  46041. private _needMoveForGravity;
  46042. private _oldPosition;
  46043. private _diffPosition;
  46044. private _newPosition;
  46045. /** @hidden */
  46046. _localDirection: Vector3;
  46047. /** @hidden */
  46048. _transformedDirection: Vector3;
  46049. /**
  46050. * Instantiates a FlyCamera.
  46051. * This is a flying camera, designed for 3D movement and rotation in all directions,
  46052. * such as in a 3D Space Shooter or a Flight Simulator.
  46053. * @param name Define the name of the camera in the scene.
  46054. * @param position Define the starting position of the camera in the scene.
  46055. * @param scene Define the scene the camera belongs to.
  46056. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  46057. */
  46058. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46059. /**
  46060. * Attach a control to the HTML DOM element.
  46061. * @param element Defines the element that listens to the input events.
  46062. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  46063. */
  46064. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46065. /**
  46066. * Detach a control from the HTML DOM element.
  46067. * The camera will stop reacting to that input.
  46068. * @param element Defines the element that listens to the input events.
  46069. */
  46070. detachControl(element: HTMLElement): void;
  46071. private _collisionMask;
  46072. /**
  46073. * Get the mask that the camera ignores in collision events.
  46074. */
  46075. get collisionMask(): number;
  46076. /**
  46077. * Set the mask that the camera ignores in collision events.
  46078. */
  46079. set collisionMask(mask: number);
  46080. /** @hidden */
  46081. _collideWithWorld(displacement: Vector3): void;
  46082. /** @hidden */
  46083. private _onCollisionPositionChange;
  46084. /** @hidden */
  46085. _checkInputs(): void;
  46086. /** @hidden */
  46087. _decideIfNeedsToMove(): boolean;
  46088. /** @hidden */
  46089. _updatePosition(): void;
  46090. /**
  46091. * Restore the Roll to its target value at the rate specified.
  46092. * @param rate - Higher means slower restoring.
  46093. * @hidden
  46094. */
  46095. restoreRoll(rate: number): void;
  46096. /**
  46097. * Destroy the camera and release the current resources held by it.
  46098. */
  46099. dispose(): void;
  46100. /**
  46101. * Get the current object class name.
  46102. * @returns the class name.
  46103. */
  46104. getClassName(): string;
  46105. }
  46106. }
  46107. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46108. import { Nullable } from "babylonjs/types";
  46109. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46110. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46111. /**
  46112. * Listen to keyboard events to control the camera.
  46113. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46114. */
  46115. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46116. /**
  46117. * Defines the camera the input is attached to.
  46118. */
  46119. camera: FlyCamera;
  46120. /**
  46121. * The list of keyboard keys used to control the forward move of the camera.
  46122. */
  46123. keysForward: number[];
  46124. /**
  46125. * The list of keyboard keys used to control the backward move of the camera.
  46126. */
  46127. keysBackward: number[];
  46128. /**
  46129. * The list of keyboard keys used to control the forward move of the camera.
  46130. */
  46131. keysUp: number[];
  46132. /**
  46133. * The list of keyboard keys used to control the backward move of the camera.
  46134. */
  46135. keysDown: number[];
  46136. /**
  46137. * The list of keyboard keys used to control the right strafe move of the camera.
  46138. */
  46139. keysRight: number[];
  46140. /**
  46141. * The list of keyboard keys used to control the left strafe move of the camera.
  46142. */
  46143. keysLeft: number[];
  46144. private _keys;
  46145. private _onCanvasBlurObserver;
  46146. private _onKeyboardObserver;
  46147. private _engine;
  46148. private _scene;
  46149. /**
  46150. * Attach the input controls to a specific dom element to get the input from.
  46151. * @param element Defines the element the controls should be listened from
  46152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46153. */
  46154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46155. /**
  46156. * Detach the current controls from the specified dom element.
  46157. * @param element Defines the element to stop listening the inputs from
  46158. */
  46159. detachControl(element: Nullable<HTMLElement>): void;
  46160. /**
  46161. * Gets the class name of the current intput.
  46162. * @returns the class name
  46163. */
  46164. getClassName(): string;
  46165. /** @hidden */
  46166. _onLostFocus(e: FocusEvent): void;
  46167. /**
  46168. * Get the friendly name associated with the input class.
  46169. * @returns the input friendly name
  46170. */
  46171. getSimpleName(): string;
  46172. /**
  46173. * Update the current camera state depending on the inputs that have been used this frame.
  46174. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46175. */
  46176. checkInputs(): void;
  46177. }
  46178. }
  46179. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46180. import { Nullable } from "babylonjs/types";
  46181. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46182. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46183. /**
  46184. * Manage the mouse wheel inputs to control a follow camera.
  46185. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46186. */
  46187. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46188. /**
  46189. * Defines the camera the input is attached to.
  46190. */
  46191. camera: FollowCamera;
  46192. /**
  46193. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46194. */
  46195. axisControlRadius: boolean;
  46196. /**
  46197. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46198. */
  46199. axisControlHeight: boolean;
  46200. /**
  46201. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46202. */
  46203. axisControlRotation: boolean;
  46204. /**
  46205. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46206. * relation to mouseWheel events.
  46207. */
  46208. wheelPrecision: number;
  46209. /**
  46210. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46211. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46212. */
  46213. wheelDeltaPercentage: number;
  46214. private _wheel;
  46215. private _observer;
  46216. /**
  46217. * Attach the input controls to a specific dom element to get the input from.
  46218. * @param element Defines the element the controls should be listened from
  46219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46220. */
  46221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46222. /**
  46223. * Detach the current controls from the specified dom element.
  46224. * @param element Defines the element to stop listening the inputs from
  46225. */
  46226. detachControl(element: Nullable<HTMLElement>): void;
  46227. /**
  46228. * Gets the class name of the current intput.
  46229. * @returns the class name
  46230. */
  46231. getClassName(): string;
  46232. /**
  46233. * Get the friendly name associated with the input class.
  46234. * @returns the input friendly name
  46235. */
  46236. getSimpleName(): string;
  46237. }
  46238. }
  46239. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46240. import { Nullable } from "babylonjs/types";
  46241. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46242. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46243. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46244. /**
  46245. * Manage the pointers inputs to control an follow camera.
  46246. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46247. */
  46248. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46249. /**
  46250. * Defines the camera the input is attached to.
  46251. */
  46252. camera: FollowCamera;
  46253. /**
  46254. * Gets the class name of the current input.
  46255. * @returns the class name
  46256. */
  46257. getClassName(): string;
  46258. /**
  46259. * Defines the pointer angular sensibility along the X axis or how fast is
  46260. * the camera rotating.
  46261. * A negative number will reverse the axis direction.
  46262. */
  46263. angularSensibilityX: number;
  46264. /**
  46265. * Defines the pointer angular sensibility along the Y axis or how fast is
  46266. * the camera rotating.
  46267. * A negative number will reverse the axis direction.
  46268. */
  46269. angularSensibilityY: number;
  46270. /**
  46271. * Defines the pointer pinch precision or how fast is the camera zooming.
  46272. * A negative number will reverse the axis direction.
  46273. */
  46274. pinchPrecision: number;
  46275. /**
  46276. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46277. * from 0.
  46278. * It defines the percentage of current camera.radius to use as delta when
  46279. * pinch zoom is used.
  46280. */
  46281. pinchDeltaPercentage: number;
  46282. /**
  46283. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46284. */
  46285. axisXControlRadius: boolean;
  46286. /**
  46287. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46288. */
  46289. axisXControlHeight: boolean;
  46290. /**
  46291. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46292. */
  46293. axisXControlRotation: boolean;
  46294. /**
  46295. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46296. */
  46297. axisYControlRadius: boolean;
  46298. /**
  46299. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46300. */
  46301. axisYControlHeight: boolean;
  46302. /**
  46303. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46304. */
  46305. axisYControlRotation: boolean;
  46306. /**
  46307. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46308. */
  46309. axisPinchControlRadius: boolean;
  46310. /**
  46311. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46312. */
  46313. axisPinchControlHeight: boolean;
  46314. /**
  46315. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46316. */
  46317. axisPinchControlRotation: boolean;
  46318. /**
  46319. * Log error messages if basic misconfiguration has occurred.
  46320. */
  46321. warningEnable: boolean;
  46322. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46323. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46324. private _warningCounter;
  46325. private _warning;
  46326. }
  46327. }
  46328. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46329. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46330. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46331. /**
  46332. * Default Inputs manager for the FollowCamera.
  46333. * It groups all the default supported inputs for ease of use.
  46334. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46335. */
  46336. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46337. /**
  46338. * Instantiates a new FollowCameraInputsManager.
  46339. * @param camera Defines the camera the inputs belong to
  46340. */
  46341. constructor(camera: FollowCamera);
  46342. /**
  46343. * Add keyboard input support to the input manager.
  46344. * @returns the current input manager
  46345. */
  46346. addKeyboard(): FollowCameraInputsManager;
  46347. /**
  46348. * Add mouse wheel input support to the input manager.
  46349. * @returns the current input manager
  46350. */
  46351. addMouseWheel(): FollowCameraInputsManager;
  46352. /**
  46353. * Add pointers input support to the input manager.
  46354. * @returns the current input manager
  46355. */
  46356. addPointers(): FollowCameraInputsManager;
  46357. /**
  46358. * Add orientation input support to the input manager.
  46359. * @returns the current input manager
  46360. */
  46361. addVRDeviceOrientation(): FollowCameraInputsManager;
  46362. }
  46363. }
  46364. declare module "babylonjs/Cameras/followCamera" {
  46365. import { Nullable } from "babylonjs/types";
  46366. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46367. import { Scene } from "babylonjs/scene";
  46368. import { Vector3 } from "babylonjs/Maths/math.vector";
  46369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46370. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46371. /**
  46372. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46373. * an arc rotate version arcFollowCamera are available.
  46374. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46375. */
  46376. export class FollowCamera extends TargetCamera {
  46377. /**
  46378. * Distance the follow camera should follow an object at
  46379. */
  46380. radius: number;
  46381. /**
  46382. * Minimum allowed distance of the camera to the axis of rotation
  46383. * (The camera can not get closer).
  46384. * This can help limiting how the Camera is able to move in the scene.
  46385. */
  46386. lowerRadiusLimit: Nullable<number>;
  46387. /**
  46388. * Maximum allowed distance of the camera to the axis of rotation
  46389. * (The camera can not get further).
  46390. * This can help limiting how the Camera is able to move in the scene.
  46391. */
  46392. upperRadiusLimit: Nullable<number>;
  46393. /**
  46394. * Define a rotation offset between the camera and the object it follows
  46395. */
  46396. rotationOffset: number;
  46397. /**
  46398. * Minimum allowed angle to camera position relative to target object.
  46399. * This can help limiting how the Camera is able to move in the scene.
  46400. */
  46401. lowerRotationOffsetLimit: Nullable<number>;
  46402. /**
  46403. * Maximum allowed angle to camera position relative to target object.
  46404. * This can help limiting how the Camera is able to move in the scene.
  46405. */
  46406. upperRotationOffsetLimit: Nullable<number>;
  46407. /**
  46408. * Define a height offset between the camera and the object it follows.
  46409. * It can help following an object from the top (like a car chaing a plane)
  46410. */
  46411. heightOffset: number;
  46412. /**
  46413. * Minimum allowed height of camera position relative to target object.
  46414. * This can help limiting how the Camera is able to move in the scene.
  46415. */
  46416. lowerHeightOffsetLimit: Nullable<number>;
  46417. /**
  46418. * Maximum allowed height of camera position relative to target object.
  46419. * This can help limiting how the Camera is able to move in the scene.
  46420. */
  46421. upperHeightOffsetLimit: Nullable<number>;
  46422. /**
  46423. * Define how fast the camera can accelerate to follow it s target.
  46424. */
  46425. cameraAcceleration: number;
  46426. /**
  46427. * Define the speed limit of the camera following an object.
  46428. */
  46429. maxCameraSpeed: number;
  46430. /**
  46431. * Define the target of the camera.
  46432. */
  46433. lockedTarget: Nullable<AbstractMesh>;
  46434. /**
  46435. * Defines the input associated with the camera.
  46436. */
  46437. inputs: FollowCameraInputsManager;
  46438. /**
  46439. * Instantiates the follow camera.
  46440. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46441. * @param name Define the name of the camera in the scene
  46442. * @param position Define the position of the camera
  46443. * @param scene Define the scene the camera belong to
  46444. * @param lockedTarget Define the target of the camera
  46445. */
  46446. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46447. private _follow;
  46448. /**
  46449. * Attached controls to the current camera.
  46450. * @param element Defines the element the controls should be listened from
  46451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46452. */
  46453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46454. /**
  46455. * Detach the current controls from the camera.
  46456. * The camera will stop reacting to inputs.
  46457. * @param element Defines the element to stop listening the inputs from
  46458. */
  46459. detachControl(element: HTMLElement): void;
  46460. /** @hidden */
  46461. _checkInputs(): void;
  46462. private _checkLimits;
  46463. /**
  46464. * Gets the camera class name.
  46465. * @returns the class name
  46466. */
  46467. getClassName(): string;
  46468. }
  46469. /**
  46470. * Arc Rotate version of the follow camera.
  46471. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46472. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46473. */
  46474. export class ArcFollowCamera extends TargetCamera {
  46475. /** The longitudinal angle of the camera */
  46476. alpha: number;
  46477. /** The latitudinal angle of the camera */
  46478. beta: number;
  46479. /** The radius of the camera from its target */
  46480. radius: number;
  46481. private _cartesianCoordinates;
  46482. /** Define the camera target (the mesh it should follow) */
  46483. private _meshTarget;
  46484. /**
  46485. * Instantiates a new ArcFollowCamera
  46486. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46487. * @param name Define the name of the camera
  46488. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46489. * @param beta Define the rotation angle of the camera around the elevation axis
  46490. * @param radius Define the radius of the camera from its target point
  46491. * @param target Define the target of the camera
  46492. * @param scene Define the scene the camera belongs to
  46493. */
  46494. constructor(name: string,
  46495. /** The longitudinal angle of the camera */
  46496. alpha: number,
  46497. /** The latitudinal angle of the camera */
  46498. beta: number,
  46499. /** The radius of the camera from its target */
  46500. radius: number,
  46501. /** Define the camera target (the mesh it should follow) */
  46502. target: Nullable<AbstractMesh>, scene: Scene);
  46503. private _follow;
  46504. /** @hidden */
  46505. _checkInputs(): void;
  46506. /**
  46507. * Returns the class name of the object.
  46508. * It is mostly used internally for serialization purposes.
  46509. */
  46510. getClassName(): string;
  46511. }
  46512. }
  46513. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46514. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46515. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46516. import { Nullable } from "babylonjs/types";
  46517. /**
  46518. * Manage the keyboard inputs to control the movement of a follow camera.
  46519. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46520. */
  46521. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46522. /**
  46523. * Defines the camera the input is attached to.
  46524. */
  46525. camera: FollowCamera;
  46526. /**
  46527. * Defines the list of key codes associated with the up action (increase heightOffset)
  46528. */
  46529. keysHeightOffsetIncr: number[];
  46530. /**
  46531. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46532. */
  46533. keysHeightOffsetDecr: number[];
  46534. /**
  46535. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46536. */
  46537. keysHeightOffsetModifierAlt: boolean;
  46538. /**
  46539. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46540. */
  46541. keysHeightOffsetModifierCtrl: boolean;
  46542. /**
  46543. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46544. */
  46545. keysHeightOffsetModifierShift: boolean;
  46546. /**
  46547. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46548. */
  46549. keysRotationOffsetIncr: number[];
  46550. /**
  46551. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46552. */
  46553. keysRotationOffsetDecr: number[];
  46554. /**
  46555. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46556. */
  46557. keysRotationOffsetModifierAlt: boolean;
  46558. /**
  46559. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46560. */
  46561. keysRotationOffsetModifierCtrl: boolean;
  46562. /**
  46563. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46564. */
  46565. keysRotationOffsetModifierShift: boolean;
  46566. /**
  46567. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46568. */
  46569. keysRadiusIncr: number[];
  46570. /**
  46571. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46572. */
  46573. keysRadiusDecr: number[];
  46574. /**
  46575. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46576. */
  46577. keysRadiusModifierAlt: boolean;
  46578. /**
  46579. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46580. */
  46581. keysRadiusModifierCtrl: boolean;
  46582. /**
  46583. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46584. */
  46585. keysRadiusModifierShift: boolean;
  46586. /**
  46587. * Defines the rate of change of heightOffset.
  46588. */
  46589. heightSensibility: number;
  46590. /**
  46591. * Defines the rate of change of rotationOffset.
  46592. */
  46593. rotationSensibility: number;
  46594. /**
  46595. * Defines the rate of change of radius.
  46596. */
  46597. radiusSensibility: number;
  46598. private _keys;
  46599. private _ctrlPressed;
  46600. private _altPressed;
  46601. private _shiftPressed;
  46602. private _onCanvasBlurObserver;
  46603. private _onKeyboardObserver;
  46604. private _engine;
  46605. private _scene;
  46606. /**
  46607. * Attach the input controls to a specific dom element to get the input from.
  46608. * @param element Defines the element the controls should be listened from
  46609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46610. */
  46611. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46612. /**
  46613. * Detach the current controls from the specified dom element.
  46614. * @param element Defines the element to stop listening the inputs from
  46615. */
  46616. detachControl(element: Nullable<HTMLElement>): void;
  46617. /**
  46618. * Update the current camera state depending on the inputs that have been used this frame.
  46619. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46620. */
  46621. checkInputs(): void;
  46622. /**
  46623. * Gets the class name of the current input.
  46624. * @returns the class name
  46625. */
  46626. getClassName(): string;
  46627. /**
  46628. * Get the friendly name associated with the input class.
  46629. * @returns the input friendly name
  46630. */
  46631. getSimpleName(): string;
  46632. /**
  46633. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46634. * allow modification of the heightOffset value.
  46635. */
  46636. private _modifierHeightOffset;
  46637. /**
  46638. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46639. * allow modification of the rotationOffset value.
  46640. */
  46641. private _modifierRotationOffset;
  46642. /**
  46643. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46644. * allow modification of the radius value.
  46645. */
  46646. private _modifierRadius;
  46647. }
  46648. }
  46649. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46650. import { Nullable } from "babylonjs/types";
  46651. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46652. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46653. import { Observable } from "babylonjs/Misc/observable";
  46654. module "babylonjs/Cameras/freeCameraInputsManager" {
  46655. interface FreeCameraInputsManager {
  46656. /**
  46657. * @hidden
  46658. */
  46659. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46660. /**
  46661. * Add orientation input support to the input manager.
  46662. * @returns the current input manager
  46663. */
  46664. addDeviceOrientation(): FreeCameraInputsManager;
  46665. }
  46666. }
  46667. /**
  46668. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46669. * Screen rotation is taken into account.
  46670. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46671. */
  46672. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46673. private _camera;
  46674. private _screenOrientationAngle;
  46675. private _constantTranform;
  46676. private _screenQuaternion;
  46677. private _alpha;
  46678. private _beta;
  46679. private _gamma;
  46680. /**
  46681. * Can be used to detect if a device orientation sensor is available on a device
  46682. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46683. * @returns a promise that will resolve on orientation change
  46684. */
  46685. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46686. /**
  46687. * @hidden
  46688. */
  46689. _onDeviceOrientationChangedObservable: Observable<void>;
  46690. /**
  46691. * Instantiates a new input
  46692. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46693. */
  46694. constructor();
  46695. /**
  46696. * Define the camera controlled by the input.
  46697. */
  46698. get camera(): FreeCamera;
  46699. set camera(camera: FreeCamera);
  46700. /**
  46701. * Attach the input controls to a specific dom element to get the input from.
  46702. * @param element Defines the element the controls should be listened from
  46703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46704. */
  46705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46706. private _orientationChanged;
  46707. private _deviceOrientation;
  46708. /**
  46709. * Detach the current controls from the specified dom element.
  46710. * @param element Defines the element to stop listening the inputs from
  46711. */
  46712. detachControl(element: Nullable<HTMLElement>): void;
  46713. /**
  46714. * Update the current camera state depending on the inputs that have been used this frame.
  46715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46716. */
  46717. checkInputs(): void;
  46718. /**
  46719. * Gets the class name of the current intput.
  46720. * @returns the class name
  46721. */
  46722. getClassName(): string;
  46723. /**
  46724. * Get the friendly name associated with the input class.
  46725. * @returns the input friendly name
  46726. */
  46727. getSimpleName(): string;
  46728. }
  46729. }
  46730. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46731. import { Nullable } from "babylonjs/types";
  46732. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46733. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46734. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46735. /**
  46736. * Manage the gamepad inputs to control a free camera.
  46737. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46738. */
  46739. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46740. /**
  46741. * Define the camera the input is attached to.
  46742. */
  46743. camera: FreeCamera;
  46744. /**
  46745. * Define the Gamepad controlling the input
  46746. */
  46747. gamepad: Nullable<Gamepad>;
  46748. /**
  46749. * Defines the gamepad rotation sensiblity.
  46750. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46751. */
  46752. gamepadAngularSensibility: number;
  46753. /**
  46754. * Defines the gamepad move sensiblity.
  46755. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46756. */
  46757. gamepadMoveSensibility: number;
  46758. private _yAxisScale;
  46759. /**
  46760. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46761. */
  46762. get invertYAxis(): boolean;
  46763. set invertYAxis(value: boolean);
  46764. private _onGamepadConnectedObserver;
  46765. private _onGamepadDisconnectedObserver;
  46766. private _cameraTransform;
  46767. private _deltaTransform;
  46768. private _vector3;
  46769. private _vector2;
  46770. /**
  46771. * Attach the input controls to a specific dom element to get the input from.
  46772. * @param element Defines the element the controls should be listened from
  46773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46774. */
  46775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46776. /**
  46777. * Detach the current controls from the specified dom element.
  46778. * @param element Defines the element to stop listening the inputs from
  46779. */
  46780. detachControl(element: Nullable<HTMLElement>): void;
  46781. /**
  46782. * Update the current camera state depending on the inputs that have been used this frame.
  46783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46784. */
  46785. checkInputs(): void;
  46786. /**
  46787. * Gets the class name of the current intput.
  46788. * @returns the class name
  46789. */
  46790. getClassName(): string;
  46791. /**
  46792. * Get the friendly name associated with the input class.
  46793. * @returns the input friendly name
  46794. */
  46795. getSimpleName(): string;
  46796. }
  46797. }
  46798. declare module "babylonjs/Misc/virtualJoystick" {
  46799. import { Nullable } from "babylonjs/types";
  46800. import { Vector3 } from "babylonjs/Maths/math.vector";
  46801. /**
  46802. * Defines the potential axis of a Joystick
  46803. */
  46804. export enum JoystickAxis {
  46805. /** X axis */
  46806. X = 0,
  46807. /** Y axis */
  46808. Y = 1,
  46809. /** Z axis */
  46810. Z = 2
  46811. }
  46812. /**
  46813. * Represents the different customization options available
  46814. * for VirtualJoystick
  46815. */
  46816. interface VirtualJoystickCustomizations {
  46817. /**
  46818. * Size of the joystick's puck
  46819. */
  46820. puckSize: number;
  46821. /**
  46822. * Size of the joystick's container
  46823. */
  46824. containerSize: number;
  46825. /**
  46826. * Color of the joystick && puck
  46827. */
  46828. color: string;
  46829. /**
  46830. * Image URL for the joystick's puck
  46831. */
  46832. puckImage?: string;
  46833. /**
  46834. * Image URL for the joystick's container
  46835. */
  46836. containerImage?: string;
  46837. /**
  46838. * Defines the unmoving position of the joystick container
  46839. */
  46840. position?: {
  46841. x: number;
  46842. y: number;
  46843. };
  46844. /**
  46845. * Defines whether or not the joystick container is always visible
  46846. */
  46847. alwaysVisible: boolean;
  46848. /**
  46849. * Defines whether or not to limit the movement of the puck to the joystick's container
  46850. */
  46851. limitToContainer: boolean;
  46852. }
  46853. /**
  46854. * Class used to define virtual joystick (used in touch mode)
  46855. */
  46856. export class VirtualJoystick {
  46857. /**
  46858. * Gets or sets a boolean indicating that left and right values must be inverted
  46859. */
  46860. reverseLeftRight: boolean;
  46861. /**
  46862. * Gets or sets a boolean indicating that up and down values must be inverted
  46863. */
  46864. reverseUpDown: boolean;
  46865. /**
  46866. * Gets the offset value for the position (ie. the change of the position value)
  46867. */
  46868. deltaPosition: Vector3;
  46869. /**
  46870. * Gets a boolean indicating if the virtual joystick was pressed
  46871. */
  46872. pressed: boolean;
  46873. /**
  46874. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46875. */
  46876. static Canvas: Nullable<HTMLCanvasElement>;
  46877. /**
  46878. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46879. */
  46880. limitToContainer: boolean;
  46881. private static _globalJoystickIndex;
  46882. private static _alwaysVisibleSticks;
  46883. private static vjCanvasContext;
  46884. private static vjCanvasWidth;
  46885. private static vjCanvasHeight;
  46886. private static halfWidth;
  46887. private static _GetDefaultOptions;
  46888. private _action;
  46889. private _axisTargetedByLeftAndRight;
  46890. private _axisTargetedByUpAndDown;
  46891. private _joystickSensibility;
  46892. private _inversedSensibility;
  46893. private _joystickPointerID;
  46894. private _joystickColor;
  46895. private _joystickPointerPos;
  46896. private _joystickPreviousPointerPos;
  46897. private _joystickPointerStartPos;
  46898. private _deltaJoystickVector;
  46899. private _leftJoystick;
  46900. private _touches;
  46901. private _joystickPosition;
  46902. private _alwaysVisible;
  46903. private _puckImage;
  46904. private _containerImage;
  46905. private _joystickPuckSize;
  46906. private _joystickContainerSize;
  46907. private _clearPuckSize;
  46908. private _clearContainerSize;
  46909. private _clearPuckSizeOffset;
  46910. private _clearContainerSizeOffset;
  46911. private _onPointerDownHandlerRef;
  46912. private _onPointerMoveHandlerRef;
  46913. private _onPointerUpHandlerRef;
  46914. private _onResize;
  46915. /**
  46916. * Creates a new virtual joystick
  46917. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46918. * @param customizations Defines the options we want to customize the VirtualJoystick
  46919. */
  46920. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46921. /**
  46922. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46923. * @param newJoystickSensibility defines the new sensibility
  46924. */
  46925. setJoystickSensibility(newJoystickSensibility: number): void;
  46926. private _onPointerDown;
  46927. private _onPointerMove;
  46928. private _onPointerUp;
  46929. /**
  46930. * Change the color of the virtual joystick
  46931. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46932. */
  46933. setJoystickColor(newColor: string): void;
  46934. /**
  46935. * Size of the joystick's container
  46936. */
  46937. set containerSize(newSize: number);
  46938. get containerSize(): number;
  46939. /**
  46940. * Size of the joystick's puck
  46941. */
  46942. set puckSize(newSize: number);
  46943. get puckSize(): number;
  46944. /**
  46945. * Clears the set position of the joystick
  46946. */
  46947. clearPosition(): void;
  46948. /**
  46949. * Defines whether or not the joystick container is always visible
  46950. */
  46951. set alwaysVisible(value: boolean);
  46952. get alwaysVisible(): boolean;
  46953. /**
  46954. * Sets the constant position of the Joystick container
  46955. * @param x X axis coordinate
  46956. * @param y Y axis coordinate
  46957. */
  46958. setPosition(x: number, y: number): void;
  46959. /**
  46960. * Defines a callback to call when the joystick is touched
  46961. * @param action defines the callback
  46962. */
  46963. setActionOnTouch(action: () => any): void;
  46964. /**
  46965. * Defines which axis you'd like to control for left & right
  46966. * @param axis defines the axis to use
  46967. */
  46968. setAxisForLeftRight(axis: JoystickAxis): void;
  46969. /**
  46970. * Defines which axis you'd like to control for up & down
  46971. * @param axis defines the axis to use
  46972. */
  46973. setAxisForUpDown(axis: JoystickAxis): void;
  46974. /**
  46975. * Clears the canvas from the previous puck / container draw
  46976. */
  46977. private _clearPreviousDraw;
  46978. /**
  46979. * Loads `urlPath` to be used for the container's image
  46980. * @param urlPath defines the urlPath of an image to use
  46981. */
  46982. setContainerImage(urlPath: string): void;
  46983. /**
  46984. * Loads `urlPath` to be used for the puck's image
  46985. * @param urlPath defines the urlPath of an image to use
  46986. */
  46987. setPuckImage(urlPath: string): void;
  46988. /**
  46989. * Draws the Virtual Joystick's container
  46990. */
  46991. private _drawContainer;
  46992. /**
  46993. * Draws the Virtual Joystick's puck
  46994. */
  46995. private _drawPuck;
  46996. private _drawVirtualJoystick;
  46997. /**
  46998. * Release internal HTML canvas
  46999. */
  47000. releaseCanvas(): void;
  47001. }
  47002. }
  47003. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  47004. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  47005. import { Nullable } from "babylonjs/types";
  47006. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47007. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47008. module "babylonjs/Cameras/freeCameraInputsManager" {
  47009. interface FreeCameraInputsManager {
  47010. /**
  47011. * Add virtual joystick input support to the input manager.
  47012. * @returns the current input manager
  47013. */
  47014. addVirtualJoystick(): FreeCameraInputsManager;
  47015. }
  47016. }
  47017. /**
  47018. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  47019. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47020. */
  47021. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  47022. /**
  47023. * Defines the camera the input is attached to.
  47024. */
  47025. camera: FreeCamera;
  47026. private _leftjoystick;
  47027. private _rightjoystick;
  47028. /**
  47029. * Gets the left stick of the virtual joystick.
  47030. * @returns The virtual Joystick
  47031. */
  47032. getLeftJoystick(): VirtualJoystick;
  47033. /**
  47034. * Gets the right stick of the virtual joystick.
  47035. * @returns The virtual Joystick
  47036. */
  47037. getRightJoystick(): VirtualJoystick;
  47038. /**
  47039. * Update the current camera state depending on the inputs that have been used this frame.
  47040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47041. */
  47042. checkInputs(): void;
  47043. /**
  47044. * Attach the input controls to a specific dom element to get the input from.
  47045. * @param element Defines the element the controls should be listened from
  47046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47047. */
  47048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47049. /**
  47050. * Detach the current controls from the specified dom element.
  47051. * @param element Defines the element to stop listening the inputs from
  47052. */
  47053. detachControl(element: Nullable<HTMLElement>): void;
  47054. /**
  47055. * Gets the class name of the current intput.
  47056. * @returns the class name
  47057. */
  47058. getClassName(): string;
  47059. /**
  47060. * Get the friendly name associated with the input class.
  47061. * @returns the input friendly name
  47062. */
  47063. getSimpleName(): string;
  47064. }
  47065. }
  47066. declare module "babylonjs/Cameras/Inputs/index" {
  47067. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47068. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47069. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47070. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47071. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47072. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47073. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47074. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47075. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47076. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47077. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47078. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47079. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47080. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47081. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47082. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47083. }
  47084. declare module "babylonjs/Cameras/touchCamera" {
  47085. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47086. import { Scene } from "babylonjs/scene";
  47087. import { Vector3 } from "babylonjs/Maths/math.vector";
  47088. /**
  47089. * This represents a FPS type of camera controlled by touch.
  47090. * This is like a universal camera minus the Gamepad controls.
  47091. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47092. */
  47093. export class TouchCamera extends FreeCamera {
  47094. /**
  47095. * Defines the touch sensibility for rotation.
  47096. * The higher the faster.
  47097. */
  47098. get touchAngularSensibility(): number;
  47099. set touchAngularSensibility(value: number);
  47100. /**
  47101. * Defines the touch sensibility for move.
  47102. * The higher the faster.
  47103. */
  47104. get touchMoveSensibility(): number;
  47105. set touchMoveSensibility(value: number);
  47106. /**
  47107. * Instantiates a new touch camera.
  47108. * This represents a FPS type of camera controlled by touch.
  47109. * This is like a universal camera minus the Gamepad controls.
  47110. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47111. * @param name Define the name of the camera in the scene
  47112. * @param position Define the start position of the camera in the scene
  47113. * @param scene Define the scene the camera belongs to
  47114. */
  47115. constructor(name: string, position: Vector3, scene: Scene);
  47116. /**
  47117. * Gets the current object class name.
  47118. * @return the class name
  47119. */
  47120. getClassName(): string;
  47121. /** @hidden */
  47122. _setupInputs(): void;
  47123. }
  47124. }
  47125. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47126. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47127. import { Scene } from "babylonjs/scene";
  47128. import { Vector3 } from "babylonjs/Maths/math.vector";
  47129. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47130. import { Axis } from "babylonjs/Maths/math.axis";
  47131. /**
  47132. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47133. * being tilted forward or back and left or right.
  47134. */
  47135. export class DeviceOrientationCamera extends FreeCamera {
  47136. private _initialQuaternion;
  47137. private _quaternionCache;
  47138. private _tmpDragQuaternion;
  47139. private _disablePointerInputWhenUsingDeviceOrientation;
  47140. /**
  47141. * Creates a new device orientation camera
  47142. * @param name The name of the camera
  47143. * @param position The start position camera
  47144. * @param scene The scene the camera belongs to
  47145. */
  47146. constructor(name: string, position: Vector3, scene: Scene);
  47147. /**
  47148. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47149. */
  47150. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47151. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47152. private _dragFactor;
  47153. /**
  47154. * Enabled turning on the y axis when the orientation sensor is active
  47155. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47156. */
  47157. enableHorizontalDragging(dragFactor?: number): void;
  47158. /**
  47159. * Gets the current instance class name ("DeviceOrientationCamera").
  47160. * This helps avoiding instanceof at run time.
  47161. * @returns the class name
  47162. */
  47163. getClassName(): string;
  47164. /**
  47165. * @hidden
  47166. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47167. */
  47168. _checkInputs(): void;
  47169. /**
  47170. * Reset the camera to its default orientation on the specified axis only.
  47171. * @param axis The axis to reset
  47172. */
  47173. resetToCurrentRotation(axis?: Axis): void;
  47174. }
  47175. }
  47176. declare module "babylonjs/Gamepads/xboxGamepad" {
  47177. import { Observable } from "babylonjs/Misc/observable";
  47178. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47179. /**
  47180. * Defines supported buttons for XBox360 compatible gamepads
  47181. */
  47182. export enum Xbox360Button {
  47183. /** A */
  47184. A = 0,
  47185. /** B */
  47186. B = 1,
  47187. /** X */
  47188. X = 2,
  47189. /** Y */
  47190. Y = 3,
  47191. /** Left button */
  47192. LB = 4,
  47193. /** Right button */
  47194. RB = 5,
  47195. /** Back */
  47196. Back = 8,
  47197. /** Start */
  47198. Start = 9,
  47199. /** Left stick */
  47200. LeftStick = 10,
  47201. /** Right stick */
  47202. RightStick = 11
  47203. }
  47204. /** Defines values for XBox360 DPad */
  47205. export enum Xbox360Dpad {
  47206. /** Up */
  47207. Up = 12,
  47208. /** Down */
  47209. Down = 13,
  47210. /** Left */
  47211. Left = 14,
  47212. /** Right */
  47213. Right = 15
  47214. }
  47215. /**
  47216. * Defines a XBox360 gamepad
  47217. */
  47218. export class Xbox360Pad extends Gamepad {
  47219. private _leftTrigger;
  47220. private _rightTrigger;
  47221. private _onlefttriggerchanged;
  47222. private _onrighttriggerchanged;
  47223. private _onbuttondown;
  47224. private _onbuttonup;
  47225. private _ondpaddown;
  47226. private _ondpadup;
  47227. /** Observable raised when a button is pressed */
  47228. onButtonDownObservable: Observable<Xbox360Button>;
  47229. /** Observable raised when a button is released */
  47230. onButtonUpObservable: Observable<Xbox360Button>;
  47231. /** Observable raised when a pad is pressed */
  47232. onPadDownObservable: Observable<Xbox360Dpad>;
  47233. /** Observable raised when a pad is released */
  47234. onPadUpObservable: Observable<Xbox360Dpad>;
  47235. private _buttonA;
  47236. private _buttonB;
  47237. private _buttonX;
  47238. private _buttonY;
  47239. private _buttonBack;
  47240. private _buttonStart;
  47241. private _buttonLB;
  47242. private _buttonRB;
  47243. private _buttonLeftStick;
  47244. private _buttonRightStick;
  47245. private _dPadUp;
  47246. private _dPadDown;
  47247. private _dPadLeft;
  47248. private _dPadRight;
  47249. private _isXboxOnePad;
  47250. /**
  47251. * Creates a new XBox360 gamepad object
  47252. * @param id defines the id of this gamepad
  47253. * @param index defines its index
  47254. * @param gamepad defines the internal HTML gamepad object
  47255. * @param xboxOne defines if it is a XBox One gamepad
  47256. */
  47257. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47258. /**
  47259. * Defines the callback to call when left trigger is pressed
  47260. * @param callback defines the callback to use
  47261. */
  47262. onlefttriggerchanged(callback: (value: number) => void): void;
  47263. /**
  47264. * Defines the callback to call when right trigger is pressed
  47265. * @param callback defines the callback to use
  47266. */
  47267. onrighttriggerchanged(callback: (value: number) => void): void;
  47268. /**
  47269. * Gets the left trigger value
  47270. */
  47271. get leftTrigger(): number;
  47272. /**
  47273. * Sets the left trigger value
  47274. */
  47275. set leftTrigger(newValue: number);
  47276. /**
  47277. * Gets the right trigger value
  47278. */
  47279. get rightTrigger(): number;
  47280. /**
  47281. * Sets the right trigger value
  47282. */
  47283. set rightTrigger(newValue: number);
  47284. /**
  47285. * Defines the callback to call when a button is pressed
  47286. * @param callback defines the callback to use
  47287. */
  47288. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47289. /**
  47290. * Defines the callback to call when a button is released
  47291. * @param callback defines the callback to use
  47292. */
  47293. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47294. /**
  47295. * Defines the callback to call when a pad is pressed
  47296. * @param callback defines the callback to use
  47297. */
  47298. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47299. /**
  47300. * Defines the callback to call when a pad is released
  47301. * @param callback defines the callback to use
  47302. */
  47303. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47304. private _setButtonValue;
  47305. private _setDPadValue;
  47306. /**
  47307. * Gets the value of the `A` button
  47308. */
  47309. get buttonA(): number;
  47310. /**
  47311. * Sets the value of the `A` button
  47312. */
  47313. set buttonA(value: number);
  47314. /**
  47315. * Gets the value of the `B` button
  47316. */
  47317. get buttonB(): number;
  47318. /**
  47319. * Sets the value of the `B` button
  47320. */
  47321. set buttonB(value: number);
  47322. /**
  47323. * Gets the value of the `X` button
  47324. */
  47325. get buttonX(): number;
  47326. /**
  47327. * Sets the value of the `X` button
  47328. */
  47329. set buttonX(value: number);
  47330. /**
  47331. * Gets the value of the `Y` button
  47332. */
  47333. get buttonY(): number;
  47334. /**
  47335. * Sets the value of the `Y` button
  47336. */
  47337. set buttonY(value: number);
  47338. /**
  47339. * Gets the value of the `Start` button
  47340. */
  47341. get buttonStart(): number;
  47342. /**
  47343. * Sets the value of the `Start` button
  47344. */
  47345. set buttonStart(value: number);
  47346. /**
  47347. * Gets the value of the `Back` button
  47348. */
  47349. get buttonBack(): number;
  47350. /**
  47351. * Sets the value of the `Back` button
  47352. */
  47353. set buttonBack(value: number);
  47354. /**
  47355. * Gets the value of the `Left` button
  47356. */
  47357. get buttonLB(): number;
  47358. /**
  47359. * Sets the value of the `Left` button
  47360. */
  47361. set buttonLB(value: number);
  47362. /**
  47363. * Gets the value of the `Right` button
  47364. */
  47365. get buttonRB(): number;
  47366. /**
  47367. * Sets the value of the `Right` button
  47368. */
  47369. set buttonRB(value: number);
  47370. /**
  47371. * Gets the value of the Left joystick
  47372. */
  47373. get buttonLeftStick(): number;
  47374. /**
  47375. * Sets the value of the Left joystick
  47376. */
  47377. set buttonLeftStick(value: number);
  47378. /**
  47379. * Gets the value of the Right joystick
  47380. */
  47381. get buttonRightStick(): number;
  47382. /**
  47383. * Sets the value of the Right joystick
  47384. */
  47385. set buttonRightStick(value: number);
  47386. /**
  47387. * Gets the value of D-pad up
  47388. */
  47389. get dPadUp(): number;
  47390. /**
  47391. * Sets the value of D-pad up
  47392. */
  47393. set dPadUp(value: number);
  47394. /**
  47395. * Gets the value of D-pad down
  47396. */
  47397. get dPadDown(): number;
  47398. /**
  47399. * Sets the value of D-pad down
  47400. */
  47401. set dPadDown(value: number);
  47402. /**
  47403. * Gets the value of D-pad left
  47404. */
  47405. get dPadLeft(): number;
  47406. /**
  47407. * Sets the value of D-pad left
  47408. */
  47409. set dPadLeft(value: number);
  47410. /**
  47411. * Gets the value of D-pad right
  47412. */
  47413. get dPadRight(): number;
  47414. /**
  47415. * Sets the value of D-pad right
  47416. */
  47417. set dPadRight(value: number);
  47418. /**
  47419. * Force the gamepad to synchronize with device values
  47420. */
  47421. update(): void;
  47422. /**
  47423. * Disposes the gamepad
  47424. */
  47425. dispose(): void;
  47426. }
  47427. }
  47428. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47429. import { Observable } from "babylonjs/Misc/observable";
  47430. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47431. /**
  47432. * Defines supported buttons for DualShock compatible gamepads
  47433. */
  47434. export enum DualShockButton {
  47435. /** Cross */
  47436. Cross = 0,
  47437. /** Circle */
  47438. Circle = 1,
  47439. /** Square */
  47440. Square = 2,
  47441. /** Triangle */
  47442. Triangle = 3,
  47443. /** L1 */
  47444. L1 = 4,
  47445. /** R1 */
  47446. R1 = 5,
  47447. /** Share */
  47448. Share = 8,
  47449. /** Options */
  47450. Options = 9,
  47451. /** Left stick */
  47452. LeftStick = 10,
  47453. /** Right stick */
  47454. RightStick = 11
  47455. }
  47456. /** Defines values for DualShock DPad */
  47457. export enum DualShockDpad {
  47458. /** Up */
  47459. Up = 12,
  47460. /** Down */
  47461. Down = 13,
  47462. /** Left */
  47463. Left = 14,
  47464. /** Right */
  47465. Right = 15
  47466. }
  47467. /**
  47468. * Defines a DualShock gamepad
  47469. */
  47470. export class DualShockPad extends Gamepad {
  47471. private _leftTrigger;
  47472. private _rightTrigger;
  47473. private _onlefttriggerchanged;
  47474. private _onrighttriggerchanged;
  47475. private _onbuttondown;
  47476. private _onbuttonup;
  47477. private _ondpaddown;
  47478. private _ondpadup;
  47479. /** Observable raised when a button is pressed */
  47480. onButtonDownObservable: Observable<DualShockButton>;
  47481. /** Observable raised when a button is released */
  47482. onButtonUpObservable: Observable<DualShockButton>;
  47483. /** Observable raised when a pad is pressed */
  47484. onPadDownObservable: Observable<DualShockDpad>;
  47485. /** Observable raised when a pad is released */
  47486. onPadUpObservable: Observable<DualShockDpad>;
  47487. private _buttonCross;
  47488. private _buttonCircle;
  47489. private _buttonSquare;
  47490. private _buttonTriangle;
  47491. private _buttonShare;
  47492. private _buttonOptions;
  47493. private _buttonL1;
  47494. private _buttonR1;
  47495. private _buttonLeftStick;
  47496. private _buttonRightStick;
  47497. private _dPadUp;
  47498. private _dPadDown;
  47499. private _dPadLeft;
  47500. private _dPadRight;
  47501. /**
  47502. * Creates a new DualShock gamepad object
  47503. * @param id defines the id of this gamepad
  47504. * @param index defines its index
  47505. * @param gamepad defines the internal HTML gamepad object
  47506. */
  47507. constructor(id: string, index: number, gamepad: any);
  47508. /**
  47509. * Defines the callback to call when left trigger is pressed
  47510. * @param callback defines the callback to use
  47511. */
  47512. onlefttriggerchanged(callback: (value: number) => void): void;
  47513. /**
  47514. * Defines the callback to call when right trigger is pressed
  47515. * @param callback defines the callback to use
  47516. */
  47517. onrighttriggerchanged(callback: (value: number) => void): void;
  47518. /**
  47519. * Gets the left trigger value
  47520. */
  47521. get leftTrigger(): number;
  47522. /**
  47523. * Sets the left trigger value
  47524. */
  47525. set leftTrigger(newValue: number);
  47526. /**
  47527. * Gets the right trigger value
  47528. */
  47529. get rightTrigger(): number;
  47530. /**
  47531. * Sets the right trigger value
  47532. */
  47533. set rightTrigger(newValue: number);
  47534. /**
  47535. * Defines the callback to call when a button is pressed
  47536. * @param callback defines the callback to use
  47537. */
  47538. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47539. /**
  47540. * Defines the callback to call when a button is released
  47541. * @param callback defines the callback to use
  47542. */
  47543. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47544. /**
  47545. * Defines the callback to call when a pad is pressed
  47546. * @param callback defines the callback to use
  47547. */
  47548. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47549. /**
  47550. * Defines the callback to call when a pad is released
  47551. * @param callback defines the callback to use
  47552. */
  47553. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47554. private _setButtonValue;
  47555. private _setDPadValue;
  47556. /**
  47557. * Gets the value of the `Cross` button
  47558. */
  47559. get buttonCross(): number;
  47560. /**
  47561. * Sets the value of the `Cross` button
  47562. */
  47563. set buttonCross(value: number);
  47564. /**
  47565. * Gets the value of the `Circle` button
  47566. */
  47567. get buttonCircle(): number;
  47568. /**
  47569. * Sets the value of the `Circle` button
  47570. */
  47571. set buttonCircle(value: number);
  47572. /**
  47573. * Gets the value of the `Square` button
  47574. */
  47575. get buttonSquare(): number;
  47576. /**
  47577. * Sets the value of the `Square` button
  47578. */
  47579. set buttonSquare(value: number);
  47580. /**
  47581. * Gets the value of the `Triangle` button
  47582. */
  47583. get buttonTriangle(): number;
  47584. /**
  47585. * Sets the value of the `Triangle` button
  47586. */
  47587. set buttonTriangle(value: number);
  47588. /**
  47589. * Gets the value of the `Options` button
  47590. */
  47591. get buttonOptions(): number;
  47592. /**
  47593. * Sets the value of the `Options` button
  47594. */
  47595. set buttonOptions(value: number);
  47596. /**
  47597. * Gets the value of the `Share` button
  47598. */
  47599. get buttonShare(): number;
  47600. /**
  47601. * Sets the value of the `Share` button
  47602. */
  47603. set buttonShare(value: number);
  47604. /**
  47605. * Gets the value of the `L1` button
  47606. */
  47607. get buttonL1(): number;
  47608. /**
  47609. * Sets the value of the `L1` button
  47610. */
  47611. set buttonL1(value: number);
  47612. /**
  47613. * Gets the value of the `R1` button
  47614. */
  47615. get buttonR1(): number;
  47616. /**
  47617. * Sets the value of the `R1` button
  47618. */
  47619. set buttonR1(value: number);
  47620. /**
  47621. * Gets the value of the Left joystick
  47622. */
  47623. get buttonLeftStick(): number;
  47624. /**
  47625. * Sets the value of the Left joystick
  47626. */
  47627. set buttonLeftStick(value: number);
  47628. /**
  47629. * Gets the value of the Right joystick
  47630. */
  47631. get buttonRightStick(): number;
  47632. /**
  47633. * Sets the value of the Right joystick
  47634. */
  47635. set buttonRightStick(value: number);
  47636. /**
  47637. * Gets the value of D-pad up
  47638. */
  47639. get dPadUp(): number;
  47640. /**
  47641. * Sets the value of D-pad up
  47642. */
  47643. set dPadUp(value: number);
  47644. /**
  47645. * Gets the value of D-pad down
  47646. */
  47647. get dPadDown(): number;
  47648. /**
  47649. * Sets the value of D-pad down
  47650. */
  47651. set dPadDown(value: number);
  47652. /**
  47653. * Gets the value of D-pad left
  47654. */
  47655. get dPadLeft(): number;
  47656. /**
  47657. * Sets the value of D-pad left
  47658. */
  47659. set dPadLeft(value: number);
  47660. /**
  47661. * Gets the value of D-pad right
  47662. */
  47663. get dPadRight(): number;
  47664. /**
  47665. * Sets the value of D-pad right
  47666. */
  47667. set dPadRight(value: number);
  47668. /**
  47669. * Force the gamepad to synchronize with device values
  47670. */
  47671. update(): void;
  47672. /**
  47673. * Disposes the gamepad
  47674. */
  47675. dispose(): void;
  47676. }
  47677. }
  47678. declare module "babylonjs/Gamepads/gamepadManager" {
  47679. import { Observable } from "babylonjs/Misc/observable";
  47680. import { Nullable } from "babylonjs/types";
  47681. import { Scene } from "babylonjs/scene";
  47682. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47683. /**
  47684. * Manager for handling gamepads
  47685. */
  47686. export class GamepadManager {
  47687. private _scene?;
  47688. private _babylonGamepads;
  47689. private _oneGamepadConnected;
  47690. /** @hidden */
  47691. _isMonitoring: boolean;
  47692. private _gamepadEventSupported;
  47693. private _gamepadSupport?;
  47694. /**
  47695. * observable to be triggered when the gamepad controller has been connected
  47696. */
  47697. onGamepadConnectedObservable: Observable<Gamepad>;
  47698. /**
  47699. * observable to be triggered when the gamepad controller has been disconnected
  47700. */
  47701. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47702. private _onGamepadConnectedEvent;
  47703. private _onGamepadDisconnectedEvent;
  47704. /**
  47705. * Initializes the gamepad manager
  47706. * @param _scene BabylonJS scene
  47707. */
  47708. constructor(_scene?: Scene | undefined);
  47709. /**
  47710. * The gamepads in the game pad manager
  47711. */
  47712. get gamepads(): Gamepad[];
  47713. /**
  47714. * Get the gamepad controllers based on type
  47715. * @param type The type of gamepad controller
  47716. * @returns Nullable gamepad
  47717. */
  47718. getGamepadByType(type?: number): Nullable<Gamepad>;
  47719. /**
  47720. * Disposes the gamepad manager
  47721. */
  47722. dispose(): void;
  47723. private _addNewGamepad;
  47724. private _startMonitoringGamepads;
  47725. private _stopMonitoringGamepads;
  47726. /** @hidden */
  47727. _checkGamepadsStatus(): void;
  47728. private _updateGamepadObjects;
  47729. }
  47730. }
  47731. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47732. import { Nullable } from "babylonjs/types";
  47733. import { Scene } from "babylonjs/scene";
  47734. import { ISceneComponent } from "babylonjs/sceneComponent";
  47735. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47736. module "babylonjs/scene" {
  47737. interface Scene {
  47738. /** @hidden */
  47739. _gamepadManager: Nullable<GamepadManager>;
  47740. /**
  47741. * Gets the gamepad manager associated with the scene
  47742. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47743. */
  47744. gamepadManager: GamepadManager;
  47745. }
  47746. }
  47747. module "babylonjs/Cameras/freeCameraInputsManager" {
  47748. /**
  47749. * Interface representing a free camera inputs manager
  47750. */
  47751. interface FreeCameraInputsManager {
  47752. /**
  47753. * Adds gamepad input support to the FreeCameraInputsManager.
  47754. * @returns the FreeCameraInputsManager
  47755. */
  47756. addGamepad(): FreeCameraInputsManager;
  47757. }
  47758. }
  47759. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47760. /**
  47761. * Interface representing an arc rotate camera inputs manager
  47762. */
  47763. interface ArcRotateCameraInputsManager {
  47764. /**
  47765. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47766. * @returns the camera inputs manager
  47767. */
  47768. addGamepad(): ArcRotateCameraInputsManager;
  47769. }
  47770. }
  47771. /**
  47772. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47773. */
  47774. export class GamepadSystemSceneComponent implements ISceneComponent {
  47775. /**
  47776. * The component name helpfull to identify the component in the list of scene components.
  47777. */
  47778. readonly name: string;
  47779. /**
  47780. * The scene the component belongs to.
  47781. */
  47782. scene: Scene;
  47783. /**
  47784. * Creates a new instance of the component for the given scene
  47785. * @param scene Defines the scene to register the component in
  47786. */
  47787. constructor(scene: Scene);
  47788. /**
  47789. * Registers the component in a given scene
  47790. */
  47791. register(): void;
  47792. /**
  47793. * Rebuilds the elements related to this component in case of
  47794. * context lost for instance.
  47795. */
  47796. rebuild(): void;
  47797. /**
  47798. * Disposes the component and the associated ressources
  47799. */
  47800. dispose(): void;
  47801. private _beforeCameraUpdate;
  47802. }
  47803. }
  47804. declare module "babylonjs/Cameras/universalCamera" {
  47805. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47806. import { Scene } from "babylonjs/scene";
  47807. import { Vector3 } from "babylonjs/Maths/math.vector";
  47808. import "babylonjs/Gamepads/gamepadSceneComponent";
  47809. /**
  47810. * 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,
  47811. * which still works and will still be found in many Playgrounds.
  47812. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47813. */
  47814. export class UniversalCamera extends TouchCamera {
  47815. /**
  47816. * Defines the gamepad rotation sensiblity.
  47817. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47818. */
  47819. get gamepadAngularSensibility(): number;
  47820. set gamepadAngularSensibility(value: number);
  47821. /**
  47822. * Defines the gamepad move sensiblity.
  47823. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47824. */
  47825. get gamepadMoveSensibility(): number;
  47826. set gamepadMoveSensibility(value: number);
  47827. /**
  47828. * 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,
  47829. * which still works and will still be found in many Playgrounds.
  47830. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47831. * @param name Define the name of the camera in the scene
  47832. * @param position Define the start position of the camera in the scene
  47833. * @param scene Define the scene the camera belongs to
  47834. */
  47835. constructor(name: string, position: Vector3, scene: Scene);
  47836. /**
  47837. * Gets the current object class name.
  47838. * @return the class name
  47839. */
  47840. getClassName(): string;
  47841. }
  47842. }
  47843. declare module "babylonjs/Cameras/gamepadCamera" {
  47844. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47845. import { Scene } from "babylonjs/scene";
  47846. import { Vector3 } from "babylonjs/Maths/math.vector";
  47847. /**
  47848. * This represents a FPS type of camera. This is only here for back compat purpose.
  47849. * Please use the UniversalCamera instead as both are identical.
  47850. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47851. */
  47852. export class GamepadCamera extends UniversalCamera {
  47853. /**
  47854. * Instantiates a new Gamepad Camera
  47855. * This represents a FPS type of camera. This is only here for back compat purpose.
  47856. * Please use the UniversalCamera instead as both are identical.
  47857. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47858. * @param name Define the name of the camera in the scene
  47859. * @param position Define the start position of the camera in the scene
  47860. * @param scene Define the scene the camera belongs to
  47861. */
  47862. constructor(name: string, position: Vector3, scene: Scene);
  47863. /**
  47864. * Gets the current object class name.
  47865. * @return the class name
  47866. */
  47867. getClassName(): string;
  47868. }
  47869. }
  47870. declare module "babylonjs/Shaders/pass.fragment" {
  47871. /** @hidden */
  47872. export var passPixelShader: {
  47873. name: string;
  47874. shader: string;
  47875. };
  47876. }
  47877. declare module "babylonjs/Shaders/passCube.fragment" {
  47878. /** @hidden */
  47879. export var passCubePixelShader: {
  47880. name: string;
  47881. shader: string;
  47882. };
  47883. }
  47884. declare module "babylonjs/PostProcesses/passPostProcess" {
  47885. import { Nullable } from "babylonjs/types";
  47886. import { Camera } from "babylonjs/Cameras/camera";
  47887. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47888. import { Engine } from "babylonjs/Engines/engine";
  47889. import "babylonjs/Shaders/pass.fragment";
  47890. import "babylonjs/Shaders/passCube.fragment";
  47891. import { Scene } from "babylonjs/scene";
  47892. /**
  47893. * PassPostProcess which produces an output the same as it's input
  47894. */
  47895. export class PassPostProcess extends PostProcess {
  47896. /**
  47897. * Gets a string identifying the name of the class
  47898. * @returns "PassPostProcess" string
  47899. */
  47900. getClassName(): string;
  47901. /**
  47902. * Creates the PassPostProcess
  47903. * @param name The name of the effect.
  47904. * @param options The required width/height ratio to downsize to before computing the render pass.
  47905. * @param camera The camera to apply the render pass to.
  47906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47907. * @param engine The engine which the post process will be applied. (default: current engine)
  47908. * @param reusable If the post process can be reused on the same frame. (default: false)
  47909. * @param textureType The type of texture to be used when performing the post processing.
  47910. * @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)
  47911. */
  47912. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47913. /** @hidden */
  47914. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47915. }
  47916. /**
  47917. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47918. */
  47919. export class PassCubePostProcess extends PostProcess {
  47920. private _face;
  47921. /**
  47922. * Gets or sets the cube face to display.
  47923. * * 0 is +X
  47924. * * 1 is -X
  47925. * * 2 is +Y
  47926. * * 3 is -Y
  47927. * * 4 is +Z
  47928. * * 5 is -Z
  47929. */
  47930. get face(): number;
  47931. set face(value: number);
  47932. /**
  47933. * Gets a string identifying the name of the class
  47934. * @returns "PassCubePostProcess" string
  47935. */
  47936. getClassName(): string;
  47937. /**
  47938. * Creates the PassCubePostProcess
  47939. * @param name The name of the effect.
  47940. * @param options The required width/height ratio to downsize to before computing the render pass.
  47941. * @param camera The camera to apply the render pass to.
  47942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47943. * @param engine The engine which the post process will be applied. (default: current engine)
  47944. * @param reusable If the post process can be reused on the same frame. (default: false)
  47945. * @param textureType The type of texture to be used when performing the post processing.
  47946. * @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)
  47947. */
  47948. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47949. /** @hidden */
  47950. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47951. }
  47952. }
  47953. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47954. /** @hidden */
  47955. export var anaglyphPixelShader: {
  47956. name: string;
  47957. shader: string;
  47958. };
  47959. }
  47960. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47961. import { Engine } from "babylonjs/Engines/engine";
  47962. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47963. import { Camera } from "babylonjs/Cameras/camera";
  47964. import "babylonjs/Shaders/anaglyph.fragment";
  47965. /**
  47966. * Postprocess used to generate anaglyphic rendering
  47967. */
  47968. export class AnaglyphPostProcess extends PostProcess {
  47969. private _passedProcess;
  47970. /**
  47971. * Gets a string identifying the name of the class
  47972. * @returns "AnaglyphPostProcess" string
  47973. */
  47974. getClassName(): string;
  47975. /**
  47976. * Creates a new AnaglyphPostProcess
  47977. * @param name defines postprocess name
  47978. * @param options defines creation options or target ratio scale
  47979. * @param rigCameras defines cameras using this postprocess
  47980. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47981. * @param engine defines hosting engine
  47982. * @param reusable defines if the postprocess will be reused multiple times per frame
  47983. */
  47984. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47985. }
  47986. }
  47987. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47988. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47989. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47990. import { Scene } from "babylonjs/scene";
  47991. import { Vector3 } from "babylonjs/Maths/math.vector";
  47992. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47993. /**
  47994. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47995. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47996. */
  47997. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47998. /**
  47999. * Creates a new AnaglyphArcRotateCamera
  48000. * @param name defines camera name
  48001. * @param alpha defines alpha angle (in radians)
  48002. * @param beta defines beta angle (in radians)
  48003. * @param radius defines radius
  48004. * @param target defines camera target
  48005. * @param interaxialDistance defines distance between each color axis
  48006. * @param scene defines the hosting scene
  48007. */
  48008. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  48009. /**
  48010. * Gets camera class name
  48011. * @returns AnaglyphArcRotateCamera
  48012. */
  48013. getClassName(): string;
  48014. }
  48015. }
  48016. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  48017. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48018. import { Scene } from "babylonjs/scene";
  48019. import { Vector3 } from "babylonjs/Maths/math.vector";
  48020. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48021. /**
  48022. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  48023. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48024. */
  48025. export class AnaglyphFreeCamera extends FreeCamera {
  48026. /**
  48027. * Creates a new AnaglyphFreeCamera
  48028. * @param name defines camera name
  48029. * @param position defines initial position
  48030. * @param interaxialDistance defines distance between each color axis
  48031. * @param scene defines the hosting scene
  48032. */
  48033. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48034. /**
  48035. * Gets camera class name
  48036. * @returns AnaglyphFreeCamera
  48037. */
  48038. getClassName(): string;
  48039. }
  48040. }
  48041. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  48042. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48043. import { Scene } from "babylonjs/scene";
  48044. import { Vector3 } from "babylonjs/Maths/math.vector";
  48045. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48046. /**
  48047. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  48048. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48049. */
  48050. export class AnaglyphGamepadCamera extends GamepadCamera {
  48051. /**
  48052. * Creates a new AnaglyphGamepadCamera
  48053. * @param name defines camera name
  48054. * @param position defines initial position
  48055. * @param interaxialDistance defines distance between each color axis
  48056. * @param scene defines the hosting scene
  48057. */
  48058. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48059. /**
  48060. * Gets camera class name
  48061. * @returns AnaglyphGamepadCamera
  48062. */
  48063. getClassName(): string;
  48064. }
  48065. }
  48066. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48067. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48068. import { Scene } from "babylonjs/scene";
  48069. import { Vector3 } from "babylonjs/Maths/math.vector";
  48070. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48071. /**
  48072. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48073. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48074. */
  48075. export class AnaglyphUniversalCamera extends UniversalCamera {
  48076. /**
  48077. * Creates a new AnaglyphUniversalCamera
  48078. * @param name defines camera name
  48079. * @param position defines initial position
  48080. * @param interaxialDistance defines distance between each color axis
  48081. * @param scene defines the hosting scene
  48082. */
  48083. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48084. /**
  48085. * Gets camera class name
  48086. * @returns AnaglyphUniversalCamera
  48087. */
  48088. getClassName(): string;
  48089. }
  48090. }
  48091. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48092. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48093. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48094. import { Scene } from "babylonjs/scene";
  48095. import { Vector3 } from "babylonjs/Maths/math.vector";
  48096. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48097. /**
  48098. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48099. * @see https://doc.babylonjs.com/features/cameras
  48100. */
  48101. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48102. /**
  48103. * Creates a new StereoscopicArcRotateCamera
  48104. * @param name defines camera name
  48105. * @param alpha defines alpha angle (in radians)
  48106. * @param beta defines beta angle (in radians)
  48107. * @param radius defines radius
  48108. * @param target defines camera target
  48109. * @param interaxialDistance defines distance between each color axis
  48110. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48111. * @param scene defines the hosting scene
  48112. */
  48113. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48114. /**
  48115. * Gets camera class name
  48116. * @returns StereoscopicArcRotateCamera
  48117. */
  48118. getClassName(): string;
  48119. }
  48120. }
  48121. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48122. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48123. import { Scene } from "babylonjs/scene";
  48124. import { Vector3 } from "babylonjs/Maths/math.vector";
  48125. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48126. /**
  48127. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48128. * @see https://doc.babylonjs.com/features/cameras
  48129. */
  48130. export class StereoscopicFreeCamera extends FreeCamera {
  48131. /**
  48132. * Creates a new StereoscopicFreeCamera
  48133. * @param name defines camera name
  48134. * @param position defines initial position
  48135. * @param interaxialDistance defines distance between each color axis
  48136. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48137. * @param scene defines the hosting scene
  48138. */
  48139. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48140. /**
  48141. * Gets camera class name
  48142. * @returns StereoscopicFreeCamera
  48143. */
  48144. getClassName(): string;
  48145. }
  48146. }
  48147. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48148. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48149. import { Scene } from "babylonjs/scene";
  48150. import { Vector3 } from "babylonjs/Maths/math.vector";
  48151. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48152. /**
  48153. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48154. * @see https://doc.babylonjs.com/features/cameras
  48155. */
  48156. export class StereoscopicGamepadCamera extends GamepadCamera {
  48157. /**
  48158. * Creates a new StereoscopicGamepadCamera
  48159. * @param name defines camera name
  48160. * @param position defines initial position
  48161. * @param interaxialDistance defines distance between each color axis
  48162. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48163. * @param scene defines the hosting scene
  48164. */
  48165. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48166. /**
  48167. * Gets camera class name
  48168. * @returns StereoscopicGamepadCamera
  48169. */
  48170. getClassName(): string;
  48171. }
  48172. }
  48173. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48174. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48175. import { Scene } from "babylonjs/scene";
  48176. import { Vector3 } from "babylonjs/Maths/math.vector";
  48177. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48178. /**
  48179. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48180. * @see https://doc.babylonjs.com/features/cameras
  48181. */
  48182. export class StereoscopicUniversalCamera extends UniversalCamera {
  48183. /**
  48184. * Creates a new StereoscopicUniversalCamera
  48185. * @param name defines camera name
  48186. * @param position defines initial position
  48187. * @param interaxialDistance defines distance between each color axis
  48188. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48189. * @param scene defines the hosting scene
  48190. */
  48191. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48192. /**
  48193. * Gets camera class name
  48194. * @returns StereoscopicUniversalCamera
  48195. */
  48196. getClassName(): string;
  48197. }
  48198. }
  48199. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48200. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48201. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48202. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48203. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48204. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48205. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48206. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48207. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48208. }
  48209. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48210. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48211. import { Scene } from "babylonjs/scene";
  48212. import { Vector3 } from "babylonjs/Maths/math.vector";
  48213. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48214. /**
  48215. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48216. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48217. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48218. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48219. */
  48220. export class VirtualJoysticksCamera extends FreeCamera {
  48221. /**
  48222. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48223. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48224. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48225. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48226. * @param name Define the name of the camera in the scene
  48227. * @param position Define the start position of the camera in the scene
  48228. * @param scene Define the scene the camera belongs to
  48229. */
  48230. constructor(name: string, position: Vector3, scene: Scene);
  48231. /**
  48232. * Gets the current object class name.
  48233. * @return the class name
  48234. */
  48235. getClassName(): string;
  48236. }
  48237. }
  48238. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48239. import { Matrix } from "babylonjs/Maths/math.vector";
  48240. /**
  48241. * This represents all the required metrics to create a VR camera.
  48242. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48243. */
  48244. export class VRCameraMetrics {
  48245. /**
  48246. * Define the horizontal resolution off the screen.
  48247. */
  48248. hResolution: number;
  48249. /**
  48250. * Define the vertical resolution off the screen.
  48251. */
  48252. vResolution: number;
  48253. /**
  48254. * Define the horizontal screen size.
  48255. */
  48256. hScreenSize: number;
  48257. /**
  48258. * Define the vertical screen size.
  48259. */
  48260. vScreenSize: number;
  48261. /**
  48262. * Define the vertical screen center position.
  48263. */
  48264. vScreenCenter: number;
  48265. /**
  48266. * Define the distance of the eyes to the screen.
  48267. */
  48268. eyeToScreenDistance: number;
  48269. /**
  48270. * Define the distance between both lenses
  48271. */
  48272. lensSeparationDistance: number;
  48273. /**
  48274. * Define the distance between both viewer's eyes.
  48275. */
  48276. interpupillaryDistance: number;
  48277. /**
  48278. * Define the distortion factor of the VR postprocess.
  48279. * Please, touch with care.
  48280. */
  48281. distortionK: number[];
  48282. /**
  48283. * Define the chromatic aberration correction factors for the VR post process.
  48284. */
  48285. chromaAbCorrection: number[];
  48286. /**
  48287. * Define the scale factor of the post process.
  48288. * The smaller the better but the slower.
  48289. */
  48290. postProcessScaleFactor: number;
  48291. /**
  48292. * Define an offset for the lens center.
  48293. */
  48294. lensCenterOffset: number;
  48295. /**
  48296. * Define if the current vr camera should compensate the distortion of the lense or not.
  48297. */
  48298. compensateDistortion: boolean;
  48299. /**
  48300. * Defines if multiview should be enabled when rendering (Default: false)
  48301. */
  48302. multiviewEnabled: boolean;
  48303. /**
  48304. * Gets the rendering aspect ratio based on the provided resolutions.
  48305. */
  48306. get aspectRatio(): number;
  48307. /**
  48308. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48309. */
  48310. get aspectRatioFov(): number;
  48311. /**
  48312. * @hidden
  48313. */
  48314. get leftHMatrix(): Matrix;
  48315. /**
  48316. * @hidden
  48317. */
  48318. get rightHMatrix(): Matrix;
  48319. /**
  48320. * @hidden
  48321. */
  48322. get leftPreViewMatrix(): Matrix;
  48323. /**
  48324. * @hidden
  48325. */
  48326. get rightPreViewMatrix(): Matrix;
  48327. /**
  48328. * Get the default VRMetrics based on the most generic setup.
  48329. * @returns the default vr metrics
  48330. */
  48331. static GetDefault(): VRCameraMetrics;
  48332. }
  48333. }
  48334. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48335. /** @hidden */
  48336. export var vrDistortionCorrectionPixelShader: {
  48337. name: string;
  48338. shader: string;
  48339. };
  48340. }
  48341. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48342. import { Camera } from "babylonjs/Cameras/camera";
  48343. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48344. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48345. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48346. /**
  48347. * VRDistortionCorrectionPostProcess used for mobile VR
  48348. */
  48349. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48350. private _isRightEye;
  48351. private _distortionFactors;
  48352. private _postProcessScaleFactor;
  48353. private _lensCenterOffset;
  48354. private _scaleIn;
  48355. private _scaleFactor;
  48356. private _lensCenter;
  48357. /**
  48358. * Gets a string identifying the name of the class
  48359. * @returns "VRDistortionCorrectionPostProcess" string
  48360. */
  48361. getClassName(): string;
  48362. /**
  48363. * Initializes the VRDistortionCorrectionPostProcess
  48364. * @param name The name of the effect.
  48365. * @param camera The camera to apply the render pass to.
  48366. * @param isRightEye If this is for the right eye distortion
  48367. * @param vrMetrics All the required metrics for the VR camera
  48368. */
  48369. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48370. }
  48371. }
  48372. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48373. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48374. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48375. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48376. import { Scene } from "babylonjs/scene";
  48377. import { Vector3 } from "babylonjs/Maths/math.vector";
  48378. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48379. import "babylonjs/Cameras/RigModes/vrRigMode";
  48380. /**
  48381. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48382. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48383. */
  48384. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48385. /**
  48386. * Creates a new VRDeviceOrientationArcRotateCamera
  48387. * @param name defines camera name
  48388. * @param alpha defines the camera rotation along the logitudinal axis
  48389. * @param beta defines the camera rotation along the latitudinal axis
  48390. * @param radius defines the camera distance from its target
  48391. * @param target defines the camera target
  48392. * @param scene defines the scene the camera belongs to
  48393. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48394. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48395. */
  48396. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48397. /**
  48398. * Gets camera class name
  48399. * @returns VRDeviceOrientationArcRotateCamera
  48400. */
  48401. getClassName(): string;
  48402. }
  48403. }
  48404. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48405. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48406. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48407. import { Scene } from "babylonjs/scene";
  48408. import { Vector3 } from "babylonjs/Maths/math.vector";
  48409. import "babylonjs/Cameras/RigModes/vrRigMode";
  48410. /**
  48411. * Camera used to simulate VR rendering (based on FreeCamera)
  48412. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48413. */
  48414. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48415. /**
  48416. * Creates a new VRDeviceOrientationFreeCamera
  48417. * @param name defines camera name
  48418. * @param position defines the start position of the camera
  48419. * @param scene defines the scene the camera belongs to
  48420. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48421. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48422. */
  48423. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48424. /**
  48425. * Gets camera class name
  48426. * @returns VRDeviceOrientationFreeCamera
  48427. */
  48428. getClassName(): string;
  48429. }
  48430. }
  48431. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48432. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48433. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48434. import { Scene } from "babylonjs/scene";
  48435. import { Vector3 } from "babylonjs/Maths/math.vector";
  48436. import "babylonjs/Gamepads/gamepadSceneComponent";
  48437. /**
  48438. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48439. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48440. */
  48441. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48442. /**
  48443. * Creates a new VRDeviceOrientationGamepadCamera
  48444. * @param name defines camera name
  48445. * @param position defines the start position of the camera
  48446. * @param scene defines the scene the camera belongs to
  48447. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48448. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48449. */
  48450. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48451. /**
  48452. * Gets camera class name
  48453. * @returns VRDeviceOrientationGamepadCamera
  48454. */
  48455. getClassName(): string;
  48456. }
  48457. }
  48458. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48459. import { Scene } from "babylonjs/scene";
  48460. import { Texture } from "babylonjs/Materials/Textures/texture";
  48461. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48462. /**
  48463. * A class extending Texture allowing drawing on a texture
  48464. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48465. */
  48466. export class DynamicTexture extends Texture {
  48467. private _generateMipMaps;
  48468. private _canvas;
  48469. private _context;
  48470. /**
  48471. * Creates a DynamicTexture
  48472. * @param name defines the name of the texture
  48473. * @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
  48474. * @param scene defines the scene where you want the texture
  48475. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48476. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48477. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48478. */
  48479. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48480. /**
  48481. * Get the current class name of the texture useful for serialization or dynamic coding.
  48482. * @returns "DynamicTexture"
  48483. */
  48484. getClassName(): string;
  48485. /**
  48486. * Gets the current state of canRescale
  48487. */
  48488. get canRescale(): boolean;
  48489. private _recreate;
  48490. /**
  48491. * Scales the texture
  48492. * @param ratio the scale factor to apply to both width and height
  48493. */
  48494. scale(ratio: number): void;
  48495. /**
  48496. * Resizes the texture
  48497. * @param width the new width
  48498. * @param height the new height
  48499. */
  48500. scaleTo(width: number, height: number): void;
  48501. /**
  48502. * Gets the context of the canvas used by the texture
  48503. * @returns the canvas context of the dynamic texture
  48504. */
  48505. getContext(): CanvasRenderingContext2D;
  48506. /**
  48507. * Clears the texture
  48508. */
  48509. clear(): void;
  48510. /**
  48511. * Updates the texture
  48512. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48513. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48514. */
  48515. update(invertY?: boolean, premulAlpha?: boolean): void;
  48516. /**
  48517. * Draws text onto the texture
  48518. * @param text defines the text to be drawn
  48519. * @param x defines the placement of the text from the left
  48520. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48521. * @param font defines the font to be used with font-style, font-size, font-name
  48522. * @param color defines the color used for the text
  48523. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48524. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48525. * @param update defines whether texture is immediately update (default is true)
  48526. */
  48527. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48528. /**
  48529. * Clones the texture
  48530. * @returns the clone of the texture.
  48531. */
  48532. clone(): DynamicTexture;
  48533. /**
  48534. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48535. * @returns a serialized dynamic texture object
  48536. */
  48537. serialize(): any;
  48538. private _IsCanvasElement;
  48539. /** @hidden */
  48540. _rebuild(): void;
  48541. }
  48542. }
  48543. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48544. import { Scene } from "babylonjs/scene";
  48545. import { Color3 } from "babylonjs/Maths/math.color";
  48546. import { Mesh } from "babylonjs/Meshes/mesh";
  48547. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48548. import { Nullable } from "babylonjs/types";
  48549. /**
  48550. * Class containing static functions to help procedurally build meshes
  48551. */
  48552. export class GroundBuilder {
  48553. /**
  48554. * Creates a ground mesh
  48555. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48556. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48558. * @param name defines the name of the mesh
  48559. * @param options defines the options used to create the mesh
  48560. * @param scene defines the hosting scene
  48561. * @returns the ground mesh
  48562. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48563. */
  48564. static CreateGround(name: string, options: {
  48565. width?: number;
  48566. height?: number;
  48567. subdivisions?: number;
  48568. subdivisionsX?: number;
  48569. subdivisionsY?: number;
  48570. updatable?: boolean;
  48571. }, scene: any): Mesh;
  48572. /**
  48573. * Creates a tiled ground mesh
  48574. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48575. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48576. * * 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
  48577. * * 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
  48578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48579. * @param name defines the name of the mesh
  48580. * @param options defines the options used to create the mesh
  48581. * @param scene defines the hosting scene
  48582. * @returns the tiled ground mesh
  48583. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48584. */
  48585. static CreateTiledGround(name: string, options: {
  48586. xmin: number;
  48587. zmin: number;
  48588. xmax: number;
  48589. zmax: number;
  48590. subdivisions?: {
  48591. w: number;
  48592. h: number;
  48593. };
  48594. precision?: {
  48595. w: number;
  48596. h: number;
  48597. };
  48598. updatable?: boolean;
  48599. }, scene?: Nullable<Scene>): Mesh;
  48600. /**
  48601. * Creates a ground mesh from a height map
  48602. * * The parameter `url` sets the URL of the height map image resource.
  48603. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48604. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48605. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48606. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48607. * * 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.
  48608. * * 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).
  48609. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48611. * @param name defines the name of the mesh
  48612. * @param url defines the url to the height map
  48613. * @param options defines the options used to create the mesh
  48614. * @param scene defines the hosting scene
  48615. * @returns the ground mesh
  48616. * @see https://doc.babylonjs.com/babylon101/height_map
  48617. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48618. */
  48619. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48620. width?: number;
  48621. height?: number;
  48622. subdivisions?: number;
  48623. minHeight?: number;
  48624. maxHeight?: number;
  48625. colorFilter?: Color3;
  48626. alphaFilter?: number;
  48627. updatable?: boolean;
  48628. onReady?: (mesh: GroundMesh) => void;
  48629. }, scene?: Nullable<Scene>): GroundMesh;
  48630. }
  48631. }
  48632. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48633. import { Vector4 } from "babylonjs/Maths/math.vector";
  48634. import { Mesh } from "babylonjs/Meshes/mesh";
  48635. /**
  48636. * Class containing static functions to help procedurally build meshes
  48637. */
  48638. export class TorusBuilder {
  48639. /**
  48640. * Creates a torus mesh
  48641. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48642. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48643. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48647. * @param name defines the name of the mesh
  48648. * @param options defines the options used to create the mesh
  48649. * @param scene defines the hosting scene
  48650. * @returns the torus mesh
  48651. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48652. */
  48653. static CreateTorus(name: string, options: {
  48654. diameter?: number;
  48655. thickness?: number;
  48656. tessellation?: number;
  48657. updatable?: boolean;
  48658. sideOrientation?: number;
  48659. frontUVs?: Vector4;
  48660. backUVs?: Vector4;
  48661. }, scene: any): Mesh;
  48662. }
  48663. }
  48664. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48665. import { Vector4 } from "babylonjs/Maths/math.vector";
  48666. import { Color4 } from "babylonjs/Maths/math.color";
  48667. import { Mesh } from "babylonjs/Meshes/mesh";
  48668. /**
  48669. * Class containing static functions to help procedurally build meshes
  48670. */
  48671. export class CylinderBuilder {
  48672. /**
  48673. * Creates a cylinder or a cone mesh
  48674. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48675. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48676. * * 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.
  48677. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48678. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48679. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48680. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48681. * * 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).
  48682. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48683. * * 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).
  48684. * * 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
  48685. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48686. * * 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
  48687. * * 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.
  48688. * * If `enclose` is false, a ring surface is one element.
  48689. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48690. * * 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
  48691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48694. * @param name defines the name of the mesh
  48695. * @param options defines the options used to create the mesh
  48696. * @param scene defines the hosting scene
  48697. * @returns the cylinder mesh
  48698. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48699. */
  48700. static CreateCylinder(name: string, options: {
  48701. height?: number;
  48702. diameterTop?: number;
  48703. diameterBottom?: number;
  48704. diameter?: number;
  48705. tessellation?: number;
  48706. subdivisions?: number;
  48707. arc?: number;
  48708. faceColors?: Color4[];
  48709. faceUV?: Vector4[];
  48710. updatable?: boolean;
  48711. hasRings?: boolean;
  48712. enclose?: boolean;
  48713. cap?: number;
  48714. sideOrientation?: number;
  48715. frontUVs?: Vector4;
  48716. backUVs?: Vector4;
  48717. }, scene: any): Mesh;
  48718. }
  48719. }
  48720. declare module "babylonjs/XR/webXRTypes" {
  48721. import { Nullable } from "babylonjs/types";
  48722. import { IDisposable } from "babylonjs/scene";
  48723. /**
  48724. * States of the webXR experience
  48725. */
  48726. export enum WebXRState {
  48727. /**
  48728. * Transitioning to being in XR mode
  48729. */
  48730. ENTERING_XR = 0,
  48731. /**
  48732. * Transitioning to non XR mode
  48733. */
  48734. EXITING_XR = 1,
  48735. /**
  48736. * In XR mode and presenting
  48737. */
  48738. IN_XR = 2,
  48739. /**
  48740. * Not entered XR mode
  48741. */
  48742. NOT_IN_XR = 3
  48743. }
  48744. /**
  48745. * Abstraction of the XR render target
  48746. */
  48747. export interface WebXRRenderTarget extends IDisposable {
  48748. /**
  48749. * xrpresent context of the canvas which can be used to display/mirror xr content
  48750. */
  48751. canvasContext: WebGLRenderingContext;
  48752. /**
  48753. * xr layer for the canvas
  48754. */
  48755. xrLayer: Nullable<XRWebGLLayer>;
  48756. /**
  48757. * Initializes the xr layer for the session
  48758. * @param xrSession xr session
  48759. * @returns a promise that will resolve once the XR Layer has been created
  48760. */
  48761. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48762. }
  48763. }
  48764. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48765. import { Nullable } from "babylonjs/types";
  48766. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48767. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48768. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48769. import { Observable } from "babylonjs/Misc/observable";
  48770. /**
  48771. * COnfiguration object for WebXR output canvas
  48772. */
  48773. export class WebXRManagedOutputCanvasOptions {
  48774. /**
  48775. * An optional canvas in case you wish to create it yourself and provide it here.
  48776. * If not provided, a new canvas will be created
  48777. */
  48778. canvasElement?: HTMLCanvasElement;
  48779. /**
  48780. * Options for this XR Layer output
  48781. */
  48782. canvasOptions?: XRWebGLLayerOptions;
  48783. /**
  48784. * CSS styling for a newly created canvas (if not provided)
  48785. */
  48786. newCanvasCssStyle?: string;
  48787. /**
  48788. * Get the default values of the configuration object
  48789. * @param engine defines the engine to use (can be null)
  48790. * @returns default values of this configuration object
  48791. */
  48792. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48793. }
  48794. /**
  48795. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48796. */
  48797. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48798. private _options;
  48799. private _canvas;
  48800. private _engine;
  48801. private _originalCanvasSize;
  48802. /**
  48803. * Rendering context of the canvas which can be used to display/mirror xr content
  48804. */
  48805. canvasContext: WebGLRenderingContext;
  48806. /**
  48807. * xr layer for the canvas
  48808. */
  48809. xrLayer: Nullable<XRWebGLLayer>;
  48810. /**
  48811. * Obseervers registered here will be triggered when the xr layer was initialized
  48812. */
  48813. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48814. /**
  48815. * Initializes the canvas to be added/removed upon entering/exiting xr
  48816. * @param _xrSessionManager The XR Session manager
  48817. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48818. */
  48819. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48820. /**
  48821. * Disposes of the object
  48822. */
  48823. dispose(): void;
  48824. /**
  48825. * Initializes the xr layer for the session
  48826. * @param xrSession xr session
  48827. * @returns a promise that will resolve once the XR Layer has been created
  48828. */
  48829. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48830. private _addCanvas;
  48831. private _removeCanvas;
  48832. private _setCanvasSize;
  48833. private _setManagedOutputCanvas;
  48834. }
  48835. }
  48836. declare module "babylonjs/XR/webXRSessionManager" {
  48837. import { Observable } from "babylonjs/Misc/observable";
  48838. import { Nullable } from "babylonjs/types";
  48839. import { IDisposable, Scene } from "babylonjs/scene";
  48840. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48841. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48842. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48843. /**
  48844. * Manages an XRSession to work with Babylon's engine
  48845. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48846. */
  48847. export class WebXRSessionManager implements IDisposable {
  48848. /** The scene which the session should be created for */
  48849. scene: Scene;
  48850. private _referenceSpace;
  48851. private _rttProvider;
  48852. private _sessionEnded;
  48853. private _xrNavigator;
  48854. private baseLayer;
  48855. /**
  48856. * The base reference space from which the session started. good if you want to reset your
  48857. * reference space
  48858. */
  48859. baseReferenceSpace: XRReferenceSpace;
  48860. /**
  48861. * Current XR frame
  48862. */
  48863. currentFrame: Nullable<XRFrame>;
  48864. /** WebXR timestamp updated every frame */
  48865. currentTimestamp: number;
  48866. /**
  48867. * Used just in case of a failure to initialize an immersive session.
  48868. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48869. */
  48870. defaultHeightCompensation: number;
  48871. /**
  48872. * Fires every time a new xrFrame arrives which can be used to update the camera
  48873. */
  48874. onXRFrameObservable: Observable<XRFrame>;
  48875. /**
  48876. * Fires when the reference space changed
  48877. */
  48878. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48879. /**
  48880. * Fires when the xr session is ended either by the device or manually done
  48881. */
  48882. onXRSessionEnded: Observable<any>;
  48883. /**
  48884. * Fires when the xr session is ended either by the device or manually done
  48885. */
  48886. onXRSessionInit: Observable<XRSession>;
  48887. /**
  48888. * Underlying xr session
  48889. */
  48890. session: XRSession;
  48891. /**
  48892. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48893. * or get the offset the player is currently at.
  48894. */
  48895. viewerReferenceSpace: XRReferenceSpace;
  48896. /**
  48897. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48898. * @param scene The scene which the session should be created for
  48899. */
  48900. constructor(
  48901. /** The scene which the session should be created for */
  48902. scene: Scene);
  48903. /**
  48904. * The current reference space used in this session. This reference space can constantly change!
  48905. * It is mainly used to offset the camera's position.
  48906. */
  48907. get referenceSpace(): XRReferenceSpace;
  48908. /**
  48909. * Set a new reference space and triggers the observable
  48910. */
  48911. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48912. /**
  48913. * Disposes of the session manager
  48914. */
  48915. dispose(): void;
  48916. /**
  48917. * Stops the xrSession and restores the render loop
  48918. * @returns Promise which resolves after it exits XR
  48919. */
  48920. exitXRAsync(): Promise<void>;
  48921. /**
  48922. * Gets the correct render target texture to be rendered this frame for this eye
  48923. * @param eye the eye for which to get the render target
  48924. * @returns the render target for the specified eye
  48925. */
  48926. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48927. /**
  48928. * Creates a WebXRRenderTarget object for the XR session
  48929. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48930. * @param options optional options to provide when creating a new render target
  48931. * @returns a WebXR render target to which the session can render
  48932. */
  48933. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48934. /**
  48935. * Initializes the manager
  48936. * After initialization enterXR can be called to start an XR session
  48937. * @returns Promise which resolves after it is initialized
  48938. */
  48939. initializeAsync(): Promise<void>;
  48940. /**
  48941. * Initializes an xr session
  48942. * @param xrSessionMode mode to initialize
  48943. * @param xrSessionInit defines optional and required values to pass to the session builder
  48944. * @returns a promise which will resolve once the session has been initialized
  48945. */
  48946. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48947. /**
  48948. * Checks if a session would be supported for the creation options specified
  48949. * @param sessionMode session mode to check if supported eg. immersive-vr
  48950. * @returns A Promise that resolves to true if supported and false if not
  48951. */
  48952. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48953. /**
  48954. * Resets the reference space to the one started the session
  48955. */
  48956. resetReferenceSpace(): void;
  48957. /**
  48958. * Starts rendering to the xr layer
  48959. */
  48960. runXRRenderLoop(): void;
  48961. /**
  48962. * Sets the reference space on the xr session
  48963. * @param referenceSpaceType space to set
  48964. * @returns a promise that will resolve once the reference space has been set
  48965. */
  48966. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48967. /**
  48968. * Updates the render state of the session
  48969. * @param state state to set
  48970. * @returns a promise that resolves once the render state has been updated
  48971. */
  48972. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48973. /**
  48974. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48975. * @param sessionMode defines the session to test
  48976. * @returns a promise with boolean as final value
  48977. */
  48978. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48979. private _createRenderTargetTexture;
  48980. }
  48981. }
  48982. declare module "babylonjs/XR/webXRCamera" {
  48983. import { Vector3 } from "babylonjs/Maths/math.vector";
  48984. import { Scene } from "babylonjs/scene";
  48985. import { Camera } from "babylonjs/Cameras/camera";
  48986. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48987. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48988. import { Observable } from "babylonjs/Misc/observable";
  48989. /**
  48990. * WebXR Camera which holds the views for the xrSession
  48991. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48992. */
  48993. export class WebXRCamera extends FreeCamera {
  48994. private _xrSessionManager;
  48995. private _firstFrame;
  48996. private _referenceQuaternion;
  48997. private _referencedPosition;
  48998. private _xrInvPositionCache;
  48999. private _xrInvQuaternionCache;
  49000. /**
  49001. * Observable raised before camera teleportation
  49002. */
  49003. onBeforeCameraTeleport: Observable<Vector3>;
  49004. /**
  49005. * Observable raised after camera teleportation
  49006. */
  49007. onAfterCameraTeleport: Observable<Vector3>;
  49008. /**
  49009. * Should position compensation execute on first frame.
  49010. * This is used when copying the position from a native (non XR) camera
  49011. */
  49012. compensateOnFirstFrame: boolean;
  49013. /**
  49014. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  49015. * @param name the name of the camera
  49016. * @param scene the scene to add the camera to
  49017. * @param _xrSessionManager a constructed xr session manager
  49018. */
  49019. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  49020. /**
  49021. * Return the user's height, unrelated to the current ground.
  49022. * This will be the y position of this camera, when ground level is 0.
  49023. */
  49024. get realWorldHeight(): number;
  49025. /** @hidden */
  49026. _updateForDualEyeDebugging(): void;
  49027. /**
  49028. * Sets this camera's transformation based on a non-vr camera
  49029. * @param otherCamera the non-vr camera to copy the transformation from
  49030. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  49031. */
  49032. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  49033. /**
  49034. * Gets the current instance class name ("WebXRCamera").
  49035. * @returns the class name
  49036. */
  49037. getClassName(): string;
  49038. private _rotate180;
  49039. private _updateFromXRSession;
  49040. private _updateNumberOfRigCameras;
  49041. private _updateReferenceSpace;
  49042. private _updateReferenceSpaceOffset;
  49043. }
  49044. }
  49045. declare module "babylonjs/XR/webXRFeaturesManager" {
  49046. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49047. import { IDisposable } from "babylonjs/scene";
  49048. /**
  49049. * Defining the interface required for a (webxr) feature
  49050. */
  49051. export interface IWebXRFeature extends IDisposable {
  49052. /**
  49053. * Is this feature attached
  49054. */
  49055. attached: boolean;
  49056. /**
  49057. * Should auto-attach be disabled?
  49058. */
  49059. disableAutoAttach: boolean;
  49060. /**
  49061. * Attach the feature to the session
  49062. * Will usually be called by the features manager
  49063. *
  49064. * @param force should attachment be forced (even when already attached)
  49065. * @returns true if successful.
  49066. */
  49067. attach(force?: boolean): boolean;
  49068. /**
  49069. * Detach the feature from the session
  49070. * Will usually be called by the features manager
  49071. *
  49072. * @returns true if successful.
  49073. */
  49074. detach(): boolean;
  49075. /**
  49076. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49077. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49078. *
  49079. * @returns whether or not the feature is compatible in this environment
  49080. */
  49081. isCompatible(): boolean;
  49082. /**
  49083. * Was this feature disposed;
  49084. */
  49085. isDisposed: boolean;
  49086. /**
  49087. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49088. */
  49089. xrNativeFeatureName?: string;
  49090. /**
  49091. * A list of (Babylon WebXR) features this feature depends on
  49092. */
  49093. dependsOn?: string[];
  49094. }
  49095. /**
  49096. * A list of the currently available features without referencing them
  49097. */
  49098. export class WebXRFeatureName {
  49099. /**
  49100. * The name of the anchor system feature
  49101. */
  49102. static readonly ANCHOR_SYSTEM: string;
  49103. /**
  49104. * The name of the background remover feature
  49105. */
  49106. static readonly BACKGROUND_REMOVER: string;
  49107. /**
  49108. * The name of the hit test feature
  49109. */
  49110. static readonly HIT_TEST: string;
  49111. /**
  49112. * physics impostors for xr controllers feature
  49113. */
  49114. static readonly PHYSICS_CONTROLLERS: string;
  49115. /**
  49116. * The name of the plane detection feature
  49117. */
  49118. static readonly PLANE_DETECTION: string;
  49119. /**
  49120. * The name of the pointer selection feature
  49121. */
  49122. static readonly POINTER_SELECTION: string;
  49123. /**
  49124. * The name of the teleportation feature
  49125. */
  49126. static readonly TELEPORTATION: string;
  49127. /**
  49128. * The name of the feature points feature.
  49129. */
  49130. static readonly FEATURE_POINTS: string;
  49131. /**
  49132. * The name of the hand tracking feature.
  49133. */
  49134. static readonly HAND_TRACKING: string;
  49135. }
  49136. /**
  49137. * Defining the constructor of a feature. Used to register the modules.
  49138. */
  49139. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49140. /**
  49141. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49142. * It is mainly used in AR sessions.
  49143. *
  49144. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49145. */
  49146. export class WebXRFeaturesManager implements IDisposable {
  49147. private _xrSessionManager;
  49148. private static readonly _AvailableFeatures;
  49149. private _features;
  49150. /**
  49151. * constructs a new features manages.
  49152. *
  49153. * @param _xrSessionManager an instance of WebXRSessionManager
  49154. */
  49155. constructor(_xrSessionManager: WebXRSessionManager);
  49156. /**
  49157. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49158. * Mainly used internally.
  49159. *
  49160. * @param featureName the name of the feature to register
  49161. * @param constructorFunction the function used to construct the module
  49162. * @param version the (babylon) version of the module
  49163. * @param stable is that a stable version of this module
  49164. */
  49165. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49166. /**
  49167. * Returns a constructor of a specific feature.
  49168. *
  49169. * @param featureName the name of the feature to construct
  49170. * @param version the version of the feature to load
  49171. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49172. * @param options optional options provided to the module.
  49173. * @returns a function that, when called, will return a new instance of this feature
  49174. */
  49175. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49176. /**
  49177. * Can be used to return the list of features currently registered
  49178. *
  49179. * @returns an Array of available features
  49180. */
  49181. static GetAvailableFeatures(): string[];
  49182. /**
  49183. * Gets the versions available for a specific feature
  49184. * @param featureName the name of the feature
  49185. * @returns an array with the available versions
  49186. */
  49187. static GetAvailableVersions(featureName: string): string[];
  49188. /**
  49189. * Return the latest unstable version of this feature
  49190. * @param featureName the name of the feature to search
  49191. * @returns the version number. if not found will return -1
  49192. */
  49193. static GetLatestVersionOfFeature(featureName: string): number;
  49194. /**
  49195. * Return the latest stable version of this feature
  49196. * @param featureName the name of the feature to search
  49197. * @returns the version number. if not found will return -1
  49198. */
  49199. static GetStableVersionOfFeature(featureName: string): number;
  49200. /**
  49201. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49202. * Can be used during a session to start a feature
  49203. * @param featureName the name of feature to attach
  49204. */
  49205. attachFeature(featureName: string): void;
  49206. /**
  49207. * Can be used inside a session or when the session ends to detach a specific feature
  49208. * @param featureName the name of the feature to detach
  49209. */
  49210. detachFeature(featureName: string): void;
  49211. /**
  49212. * Used to disable an already-enabled feature
  49213. * The feature will be disposed and will be recreated once enabled.
  49214. * @param featureName the feature to disable
  49215. * @returns true if disable was successful
  49216. */
  49217. disableFeature(featureName: string | {
  49218. Name: string;
  49219. }): boolean;
  49220. /**
  49221. * dispose this features manager
  49222. */
  49223. dispose(): void;
  49224. /**
  49225. * 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.
  49226. * 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.
  49227. *
  49228. * @param featureName the name of the feature to load or the class of the feature
  49229. * @param version optional version to load. if not provided the latest version will be enabled
  49230. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49231. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49232. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49233. * @returns a new constructed feature or throws an error if feature not found.
  49234. */
  49235. enableFeature(featureName: string | {
  49236. Name: string;
  49237. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49238. /**
  49239. * get the implementation of an enabled feature.
  49240. * @param featureName the name of the feature to load
  49241. * @returns the feature class, if found
  49242. */
  49243. getEnabledFeature(featureName: string): IWebXRFeature;
  49244. /**
  49245. * Get the list of enabled features
  49246. * @returns an array of enabled features
  49247. */
  49248. getEnabledFeatures(): string[];
  49249. /**
  49250. * This function will exten the session creation configuration object with enabled features.
  49251. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49252. * according to the defined "required" variable, provided during enableFeature call
  49253. * @param xrSessionInit the xr Session init object to extend
  49254. *
  49255. * @returns an extended XRSessionInit object
  49256. */
  49257. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49258. }
  49259. }
  49260. declare module "babylonjs/XR/webXRExperienceHelper" {
  49261. import { Observable } from "babylonjs/Misc/observable";
  49262. import { IDisposable, Scene } from "babylonjs/scene";
  49263. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49264. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49265. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49266. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49267. /**
  49268. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49269. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49270. */
  49271. export class WebXRExperienceHelper implements IDisposable {
  49272. private scene;
  49273. private _nonVRCamera;
  49274. private _originalSceneAutoClear;
  49275. private _supported;
  49276. /**
  49277. * Camera used to render xr content
  49278. */
  49279. camera: WebXRCamera;
  49280. /** A features manager for this xr session */
  49281. featuresManager: WebXRFeaturesManager;
  49282. /**
  49283. * Observers registered here will be triggered after the camera's initial transformation is set
  49284. * This can be used to set a different ground level or an extra rotation.
  49285. *
  49286. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49287. * to the position set after this observable is done executing.
  49288. */
  49289. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49290. /**
  49291. * Fires when the state of the experience helper has changed
  49292. */
  49293. onStateChangedObservable: Observable<WebXRState>;
  49294. /** Session manager used to keep track of xr session */
  49295. sessionManager: WebXRSessionManager;
  49296. /**
  49297. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49298. */
  49299. state: WebXRState;
  49300. /**
  49301. * Creates a WebXRExperienceHelper
  49302. * @param scene The scene the helper should be created in
  49303. */
  49304. private constructor();
  49305. /**
  49306. * Creates the experience helper
  49307. * @param scene the scene to attach the experience helper to
  49308. * @returns a promise for the experience helper
  49309. */
  49310. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49311. /**
  49312. * Disposes of the experience helper
  49313. */
  49314. dispose(): void;
  49315. /**
  49316. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49317. * @param sessionMode options for the XR session
  49318. * @param referenceSpaceType frame of reference of the XR session
  49319. * @param renderTarget the output canvas that will be used to enter XR mode
  49320. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49321. * @returns promise that resolves after xr mode has entered
  49322. */
  49323. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49324. /**
  49325. * Exits XR mode and returns the scene to its original state
  49326. * @returns promise that resolves after xr mode has exited
  49327. */
  49328. exitXRAsync(): Promise<void>;
  49329. private _nonXRToXRCamera;
  49330. private _setState;
  49331. }
  49332. }
  49333. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49334. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49335. import { Observable } from "babylonjs/Misc/observable";
  49336. import { IDisposable } from "babylonjs/scene";
  49337. /**
  49338. * X-Y values for axes in WebXR
  49339. */
  49340. export interface IWebXRMotionControllerAxesValue {
  49341. /**
  49342. * The value of the x axis
  49343. */
  49344. x: number;
  49345. /**
  49346. * The value of the y-axis
  49347. */
  49348. y: number;
  49349. }
  49350. /**
  49351. * changed / previous values for the values of this component
  49352. */
  49353. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49354. /**
  49355. * current (this frame) value
  49356. */
  49357. current: T;
  49358. /**
  49359. * previous (last change) value
  49360. */
  49361. previous: T;
  49362. }
  49363. /**
  49364. * Represents changes in the component between current frame and last values recorded
  49365. */
  49366. export interface IWebXRMotionControllerComponentChanges {
  49367. /**
  49368. * will be populated with previous and current values if axes changed
  49369. */
  49370. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49371. /**
  49372. * will be populated with previous and current values if pressed changed
  49373. */
  49374. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49375. /**
  49376. * will be populated with previous and current values if touched changed
  49377. */
  49378. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49379. /**
  49380. * will be populated with previous and current values if value changed
  49381. */
  49382. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49383. }
  49384. /**
  49385. * This class represents a single component (for example button or thumbstick) of a motion controller
  49386. */
  49387. export class WebXRControllerComponent implements IDisposable {
  49388. /**
  49389. * the id of this component
  49390. */
  49391. id: string;
  49392. /**
  49393. * the type of the component
  49394. */
  49395. type: MotionControllerComponentType;
  49396. private _buttonIndex;
  49397. private _axesIndices;
  49398. private _axes;
  49399. private _changes;
  49400. private _currentValue;
  49401. private _hasChanges;
  49402. private _pressed;
  49403. private _touched;
  49404. /**
  49405. * button component type
  49406. */
  49407. static BUTTON_TYPE: MotionControllerComponentType;
  49408. /**
  49409. * squeeze component type
  49410. */
  49411. static SQUEEZE_TYPE: MotionControllerComponentType;
  49412. /**
  49413. * Thumbstick component type
  49414. */
  49415. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49416. /**
  49417. * Touchpad component type
  49418. */
  49419. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49420. /**
  49421. * trigger component type
  49422. */
  49423. static TRIGGER_TYPE: MotionControllerComponentType;
  49424. /**
  49425. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49426. * the axes data changes
  49427. */
  49428. onAxisValueChangedObservable: Observable<{
  49429. x: number;
  49430. y: number;
  49431. }>;
  49432. /**
  49433. * Observers registered here will be triggered when the state of a button changes
  49434. * State change is either pressed / touched / value
  49435. */
  49436. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49437. /**
  49438. * Creates a new component for a motion controller.
  49439. * It is created by the motion controller itself
  49440. *
  49441. * @param id the id of this component
  49442. * @param type the type of the component
  49443. * @param _buttonIndex index in the buttons array of the gamepad
  49444. * @param _axesIndices indices of the values in the axes array of the gamepad
  49445. */
  49446. constructor(
  49447. /**
  49448. * the id of this component
  49449. */
  49450. id: string,
  49451. /**
  49452. * the type of the component
  49453. */
  49454. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49455. /**
  49456. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49457. */
  49458. get axes(): IWebXRMotionControllerAxesValue;
  49459. /**
  49460. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49461. */
  49462. get changes(): IWebXRMotionControllerComponentChanges;
  49463. /**
  49464. * Return whether or not the component changed the last frame
  49465. */
  49466. get hasChanges(): boolean;
  49467. /**
  49468. * is the button currently pressed
  49469. */
  49470. get pressed(): boolean;
  49471. /**
  49472. * is the button currently touched
  49473. */
  49474. get touched(): boolean;
  49475. /**
  49476. * Get the current value of this component
  49477. */
  49478. get value(): number;
  49479. /**
  49480. * Dispose this component
  49481. */
  49482. dispose(): void;
  49483. /**
  49484. * Are there axes correlating to this component
  49485. * @return true is axes data is available
  49486. */
  49487. isAxes(): boolean;
  49488. /**
  49489. * Is this component a button (hence - pressable)
  49490. * @returns true if can be pressed
  49491. */
  49492. isButton(): boolean;
  49493. /**
  49494. * update this component using the gamepad object it is in. Called on every frame
  49495. * @param nativeController the native gamepad controller object
  49496. */
  49497. update(nativeController: IMinimalMotionControllerObject): void;
  49498. }
  49499. }
  49500. declare module "babylonjs/Loading/sceneLoader" {
  49501. import { Observable } from "babylonjs/Misc/observable";
  49502. import { Nullable } from "babylonjs/types";
  49503. import { Scene } from "babylonjs/scene";
  49504. import { Engine } from "babylonjs/Engines/engine";
  49505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49506. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49507. import { AssetContainer } from "babylonjs/assetContainer";
  49508. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49509. import { Skeleton } from "babylonjs/Bones/skeleton";
  49510. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49511. import { WebRequest } from "babylonjs/Misc/webRequest";
  49512. /**
  49513. * Interface used to represent data loading progression
  49514. */
  49515. export interface ISceneLoaderProgressEvent {
  49516. /**
  49517. * Defines if data length to load can be evaluated
  49518. */
  49519. readonly lengthComputable: boolean;
  49520. /**
  49521. * Defines the loaded data length
  49522. */
  49523. readonly loaded: number;
  49524. /**
  49525. * Defines the data length to load
  49526. */
  49527. readonly total: number;
  49528. }
  49529. /**
  49530. * Interface used by SceneLoader plugins to define supported file extensions
  49531. */
  49532. export interface ISceneLoaderPluginExtensions {
  49533. /**
  49534. * Defines the list of supported extensions
  49535. */
  49536. [extension: string]: {
  49537. isBinary: boolean;
  49538. };
  49539. }
  49540. /**
  49541. * Interface used by SceneLoader plugin factory
  49542. */
  49543. export interface ISceneLoaderPluginFactory {
  49544. /**
  49545. * Defines the name of the factory
  49546. */
  49547. name: string;
  49548. /**
  49549. * Function called to create a new plugin
  49550. * @return the new plugin
  49551. */
  49552. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49553. /**
  49554. * The callback that returns true if the data can be directly loaded.
  49555. * @param data string containing the file data
  49556. * @returns if the data can be loaded directly
  49557. */
  49558. canDirectLoad?(data: string): boolean;
  49559. }
  49560. /**
  49561. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49562. */
  49563. export interface ISceneLoaderPluginBase {
  49564. /**
  49565. * The friendly name of this plugin.
  49566. */
  49567. name: string;
  49568. /**
  49569. * The file extensions supported by this plugin.
  49570. */
  49571. extensions: string | ISceneLoaderPluginExtensions;
  49572. /**
  49573. * The callback called when loading from a url.
  49574. * @param scene scene loading this url
  49575. * @param url url to load
  49576. * @param onSuccess callback called when the file successfully loads
  49577. * @param onProgress callback called while file is loading (if the server supports this mode)
  49578. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49579. * @param onError callback called when the file fails to load
  49580. * @returns a file request object
  49581. */
  49582. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49583. /**
  49584. * The callback called when loading from a file object.
  49585. * @param scene scene loading this file
  49586. * @param file defines the file to load
  49587. * @param onSuccess defines the callback to call when data is loaded
  49588. * @param onProgress defines the callback to call during loading process
  49589. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49590. * @param onError defines the callback to call when an error occurs
  49591. * @returns a file request object
  49592. */
  49593. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49594. /**
  49595. * The callback that returns true if the data can be directly loaded.
  49596. * @param data string containing the file data
  49597. * @returns if the data can be loaded directly
  49598. */
  49599. canDirectLoad?(data: string): boolean;
  49600. /**
  49601. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49602. * @param scene scene loading this data
  49603. * @param data string containing the data
  49604. * @returns data to pass to the plugin
  49605. */
  49606. directLoad?(scene: Scene, data: string): any;
  49607. /**
  49608. * The callback that allows custom handling of the root url based on the response url.
  49609. * @param rootUrl the original root url
  49610. * @param responseURL the response url if available
  49611. * @returns the new root url
  49612. */
  49613. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49614. }
  49615. /**
  49616. * Interface used to define a SceneLoader plugin
  49617. */
  49618. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49619. /**
  49620. * Import meshes into a scene.
  49621. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49622. * @param scene The scene to import into
  49623. * @param data The data to import
  49624. * @param rootUrl The root url for scene and resources
  49625. * @param meshes The meshes array to import into
  49626. * @param particleSystems The particle systems array to import into
  49627. * @param skeletons The skeletons array to import into
  49628. * @param onError The callback when import fails
  49629. * @returns True if successful or false otherwise
  49630. */
  49631. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49632. /**
  49633. * Load into a scene.
  49634. * @param scene The scene to load into
  49635. * @param data The data to import
  49636. * @param rootUrl The root url for scene and resources
  49637. * @param onError The callback when import fails
  49638. * @returns True if successful or false otherwise
  49639. */
  49640. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49641. /**
  49642. * Load into an asset container.
  49643. * @param scene The scene to load into
  49644. * @param data The data to import
  49645. * @param rootUrl The root url for scene and resources
  49646. * @param onError The callback when import fails
  49647. * @returns The loaded asset container
  49648. */
  49649. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49650. }
  49651. /**
  49652. * Interface used to define an async SceneLoader plugin
  49653. */
  49654. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49655. /**
  49656. * Import meshes into a scene.
  49657. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49658. * @param scene The scene to import into
  49659. * @param data The data to import
  49660. * @param rootUrl The root url for scene and resources
  49661. * @param onProgress The callback when the load progresses
  49662. * @param fileName Defines the name of the file to load
  49663. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49664. */
  49665. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49666. meshes: AbstractMesh[];
  49667. particleSystems: IParticleSystem[];
  49668. skeletons: Skeleton[];
  49669. animationGroups: AnimationGroup[];
  49670. }>;
  49671. /**
  49672. * Load into a scene.
  49673. * @param scene The scene to load into
  49674. * @param data The data to import
  49675. * @param rootUrl The root url for scene and resources
  49676. * @param onProgress The callback when the load progresses
  49677. * @param fileName Defines the name of the file to load
  49678. * @returns Nothing
  49679. */
  49680. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49681. /**
  49682. * Load into an asset container.
  49683. * @param scene The scene to load into
  49684. * @param data The data to import
  49685. * @param rootUrl The root url for scene and resources
  49686. * @param onProgress The callback when the load progresses
  49687. * @param fileName Defines the name of the file to load
  49688. * @returns The loaded asset container
  49689. */
  49690. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49691. }
  49692. /**
  49693. * Mode that determines how to handle old animation groups before loading new ones.
  49694. */
  49695. export enum SceneLoaderAnimationGroupLoadingMode {
  49696. /**
  49697. * Reset all old animations to initial state then dispose them.
  49698. */
  49699. Clean = 0,
  49700. /**
  49701. * Stop all old animations.
  49702. */
  49703. Stop = 1,
  49704. /**
  49705. * Restart old animations from first frame.
  49706. */
  49707. Sync = 2,
  49708. /**
  49709. * Old animations remains untouched.
  49710. */
  49711. NoSync = 3
  49712. }
  49713. /**
  49714. * Defines a plugin registered by the SceneLoader
  49715. */
  49716. interface IRegisteredPlugin {
  49717. /**
  49718. * Defines the plugin to use
  49719. */
  49720. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49721. /**
  49722. * Defines if the plugin supports binary data
  49723. */
  49724. isBinary: boolean;
  49725. }
  49726. /**
  49727. * Class used to load scene from various file formats using registered plugins
  49728. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49729. */
  49730. export class SceneLoader {
  49731. /**
  49732. * No logging while loading
  49733. */
  49734. static readonly NO_LOGGING: number;
  49735. /**
  49736. * Minimal logging while loading
  49737. */
  49738. static readonly MINIMAL_LOGGING: number;
  49739. /**
  49740. * Summary logging while loading
  49741. */
  49742. static readonly SUMMARY_LOGGING: number;
  49743. /**
  49744. * Detailled logging while loading
  49745. */
  49746. static readonly DETAILED_LOGGING: number;
  49747. /**
  49748. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49749. */
  49750. static get ForceFullSceneLoadingForIncremental(): boolean;
  49751. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49752. /**
  49753. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49754. */
  49755. static get ShowLoadingScreen(): boolean;
  49756. static set ShowLoadingScreen(value: boolean);
  49757. /**
  49758. * Defines the current logging level (while loading the scene)
  49759. * @ignorenaming
  49760. */
  49761. static get loggingLevel(): number;
  49762. static set loggingLevel(value: number);
  49763. /**
  49764. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49765. */
  49766. static get CleanBoneMatrixWeights(): boolean;
  49767. static set CleanBoneMatrixWeights(value: boolean);
  49768. /**
  49769. * Event raised when a plugin is used to load a scene
  49770. */
  49771. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49772. private static _registeredPlugins;
  49773. private static _showingLoadingScreen;
  49774. /**
  49775. * Gets the default plugin (used to load Babylon files)
  49776. * @returns the .babylon plugin
  49777. */
  49778. static GetDefaultPlugin(): IRegisteredPlugin;
  49779. private static _GetPluginForExtension;
  49780. private static _GetPluginForDirectLoad;
  49781. private static _GetPluginForFilename;
  49782. private static _GetDirectLoad;
  49783. private static _LoadData;
  49784. private static _GetFileInfo;
  49785. /**
  49786. * Gets a plugin that can load the given extension
  49787. * @param extension defines the extension to load
  49788. * @returns a plugin or null if none works
  49789. */
  49790. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49791. /**
  49792. * Gets a boolean indicating that the given extension can be loaded
  49793. * @param extension defines the extension to load
  49794. * @returns true if the extension is supported
  49795. */
  49796. static IsPluginForExtensionAvailable(extension: string): boolean;
  49797. /**
  49798. * Adds a new plugin to the list of registered plugins
  49799. * @param plugin defines the plugin to add
  49800. */
  49801. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49802. /**
  49803. * Import meshes into a scene
  49804. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49805. * @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)
  49806. * @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)
  49807. * @param scene the instance of BABYLON.Scene to append to
  49808. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49809. * @param onProgress a callback with a progress event for each file being loaded
  49810. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49811. * @param pluginExtension the extension used to determine the plugin
  49812. * @returns The loaded plugin
  49813. */
  49814. 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>;
  49815. /**
  49816. * Import meshes into a scene
  49817. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49818. * @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)
  49819. * @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)
  49820. * @param scene the instance of BABYLON.Scene to append to
  49821. * @param onProgress a callback with a progress event for each file being loaded
  49822. * @param pluginExtension the extension used to determine the plugin
  49823. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49824. */
  49825. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49826. meshes: AbstractMesh[];
  49827. particleSystems: IParticleSystem[];
  49828. skeletons: Skeleton[];
  49829. animationGroups: AnimationGroup[];
  49830. }>;
  49831. /**
  49832. * Load a scene
  49833. * @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)
  49834. * @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)
  49835. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49836. * @param onSuccess a callback with the scene when import succeeds
  49837. * @param onProgress a callback with a progress event for each file being loaded
  49838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49839. * @param pluginExtension the extension used to determine the plugin
  49840. * @returns The loaded plugin
  49841. */
  49842. 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>;
  49843. /**
  49844. * Load a scene
  49845. * @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)
  49846. * @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)
  49847. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49848. * @param onProgress a callback with a progress event for each file being loaded
  49849. * @param pluginExtension the extension used to determine the plugin
  49850. * @returns The loaded scene
  49851. */
  49852. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49853. /**
  49854. * Append a scene
  49855. * @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)
  49856. * @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)
  49857. * @param scene is the instance of BABYLON.Scene to append to
  49858. * @param onSuccess a callback with the scene when import succeeds
  49859. * @param onProgress a callback with a progress event for each file being loaded
  49860. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49861. * @param pluginExtension the extension used to determine the plugin
  49862. * @returns The loaded plugin
  49863. */
  49864. 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>;
  49865. /**
  49866. * Append a scene
  49867. * @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)
  49868. * @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)
  49869. * @param scene is the instance of BABYLON.Scene to append to
  49870. * @param onProgress a callback with a progress event for each file being loaded
  49871. * @param pluginExtension the extension used to determine the plugin
  49872. * @returns The given scene
  49873. */
  49874. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49875. /**
  49876. * Load a scene into an asset container
  49877. * @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)
  49878. * @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)
  49879. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49880. * @param onSuccess a callback with the scene when import succeeds
  49881. * @param onProgress a callback with a progress event for each file being loaded
  49882. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49883. * @param pluginExtension the extension used to determine the plugin
  49884. * @returns The loaded plugin
  49885. */
  49886. 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>;
  49887. /**
  49888. * Load a scene into an asset container
  49889. * @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)
  49890. * @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)
  49891. * @param scene is the instance of Scene to append to
  49892. * @param onProgress a callback with a progress event for each file being loaded
  49893. * @param pluginExtension the extension used to determine the plugin
  49894. * @returns The loaded asset container
  49895. */
  49896. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49897. /**
  49898. * Import animations from a file into a scene
  49899. * @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)
  49900. * @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)
  49901. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49902. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49903. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49904. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49905. * @param onSuccess a callback with the scene when import succeeds
  49906. * @param onProgress a callback with a progress event for each file being loaded
  49907. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49908. * @param pluginExtension the extension used to determine the plugin
  49909. */
  49910. 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;
  49911. /**
  49912. * Import animations from a file into a scene
  49913. * @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)
  49914. * @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)
  49915. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49916. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49917. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49918. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49919. * @param onSuccess a callback with the scene when import succeeds
  49920. * @param onProgress a callback with a progress event for each file being loaded
  49921. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49922. * @param pluginExtension the extension used to determine the plugin
  49923. * @returns the updated scene with imported animations
  49924. */
  49925. 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>;
  49926. }
  49927. }
  49928. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49929. import { IDisposable, Scene } from "babylonjs/scene";
  49930. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49931. import { Observable } from "babylonjs/Misc/observable";
  49932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49933. import { Nullable } from "babylonjs/types";
  49934. /**
  49935. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49936. */
  49937. export type MotionControllerHandedness = "none" | "left" | "right";
  49938. /**
  49939. * The type of components available in motion controllers.
  49940. * This is not the name of the component.
  49941. */
  49942. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49943. /**
  49944. * The state of a controller component
  49945. */
  49946. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49947. /**
  49948. * The schema of motion controller layout.
  49949. * No object will be initialized using this interface
  49950. * This is used just to define the profile.
  49951. */
  49952. export interface IMotionControllerLayout {
  49953. /**
  49954. * Path to load the assets. Usually relative to the base path
  49955. */
  49956. assetPath: string;
  49957. /**
  49958. * Available components (unsorted)
  49959. */
  49960. components: {
  49961. /**
  49962. * A map of component Ids
  49963. */
  49964. [componentId: string]: {
  49965. /**
  49966. * The type of input the component outputs
  49967. */
  49968. type: MotionControllerComponentType;
  49969. /**
  49970. * The indices of this component in the gamepad object
  49971. */
  49972. gamepadIndices: {
  49973. /**
  49974. * Index of button
  49975. */
  49976. button?: number;
  49977. /**
  49978. * If available, index of x-axis
  49979. */
  49980. xAxis?: number;
  49981. /**
  49982. * If available, index of y-axis
  49983. */
  49984. yAxis?: number;
  49985. };
  49986. /**
  49987. * The mesh's root node name
  49988. */
  49989. rootNodeName: string;
  49990. /**
  49991. * Animation definitions for this model
  49992. */
  49993. visualResponses: {
  49994. [stateKey: string]: {
  49995. /**
  49996. * What property will be animated
  49997. */
  49998. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49999. /**
  50000. * What states influence this visual response
  50001. */
  50002. states: MotionControllerComponentStateType[];
  50003. /**
  50004. * Type of animation - movement or visibility
  50005. */
  50006. valueNodeProperty: "transform" | "visibility";
  50007. /**
  50008. * Base node name to move. Its position will be calculated according to the min and max nodes
  50009. */
  50010. valueNodeName?: string;
  50011. /**
  50012. * Minimum movement node
  50013. */
  50014. minNodeName?: string;
  50015. /**
  50016. * Max movement node
  50017. */
  50018. maxNodeName?: string;
  50019. };
  50020. };
  50021. /**
  50022. * If touch enabled, what is the name of node to display user feedback
  50023. */
  50024. touchPointNodeName?: string;
  50025. };
  50026. };
  50027. /**
  50028. * Is it xr standard mapping or not
  50029. */
  50030. gamepadMapping: "" | "xr-standard";
  50031. /**
  50032. * Base root node of this entire model
  50033. */
  50034. rootNodeName: string;
  50035. /**
  50036. * Defines the main button component id
  50037. */
  50038. selectComponentId: string;
  50039. }
  50040. /**
  50041. * A definition for the layout map in the input profile
  50042. */
  50043. export interface IMotionControllerLayoutMap {
  50044. /**
  50045. * Layouts with handedness type as a key
  50046. */
  50047. [handedness: string]: IMotionControllerLayout;
  50048. }
  50049. /**
  50050. * The XR Input profile schema
  50051. * Profiles can be found here:
  50052. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  50053. */
  50054. export interface IMotionControllerProfile {
  50055. /**
  50056. * fallback profiles for this profileId
  50057. */
  50058. fallbackProfileIds: string[];
  50059. /**
  50060. * The layout map, with handedness as key
  50061. */
  50062. layouts: IMotionControllerLayoutMap;
  50063. /**
  50064. * The id of this profile
  50065. * correlates to the profile(s) in the xrInput.profiles array
  50066. */
  50067. profileId: string;
  50068. }
  50069. /**
  50070. * A helper-interface for the 3 meshes needed for controller button animation
  50071. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50072. */
  50073. export interface IMotionControllerButtonMeshMap {
  50074. /**
  50075. * the mesh that defines the pressed value mesh position.
  50076. * This is used to find the max-position of this button
  50077. */
  50078. pressedMesh: AbstractMesh;
  50079. /**
  50080. * the mesh that defines the unpressed value mesh position.
  50081. * This is used to find the min (or initial) position of this button
  50082. */
  50083. unpressedMesh: AbstractMesh;
  50084. /**
  50085. * The mesh that will be changed when value changes
  50086. */
  50087. valueMesh: AbstractMesh;
  50088. }
  50089. /**
  50090. * A helper-interface for the 3 meshes needed for controller axis animation.
  50091. * This will be expanded when touchpad animations are fully supported
  50092. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50093. */
  50094. export interface IMotionControllerMeshMap {
  50095. /**
  50096. * the mesh that defines the maximum value mesh position.
  50097. */
  50098. maxMesh?: AbstractMesh;
  50099. /**
  50100. * the mesh that defines the minimum value mesh position.
  50101. */
  50102. minMesh?: AbstractMesh;
  50103. /**
  50104. * The mesh that will be changed when axis value changes
  50105. */
  50106. valueMesh?: AbstractMesh;
  50107. }
  50108. /**
  50109. * The elements needed for change-detection of the gamepad objects in motion controllers
  50110. */
  50111. export interface IMinimalMotionControllerObject {
  50112. /**
  50113. * Available axes of this controller
  50114. */
  50115. axes: number[];
  50116. /**
  50117. * An array of available buttons
  50118. */
  50119. buttons: Array<{
  50120. /**
  50121. * Value of the button/trigger
  50122. */
  50123. value: number;
  50124. /**
  50125. * If the button/trigger is currently touched
  50126. */
  50127. touched: boolean;
  50128. /**
  50129. * If the button/trigger is currently pressed
  50130. */
  50131. pressed: boolean;
  50132. }>;
  50133. /**
  50134. * EXPERIMENTAL haptic support.
  50135. */
  50136. hapticActuators?: Array<{
  50137. pulse: (value: number, duration: number) => Promise<boolean>;
  50138. }>;
  50139. }
  50140. /**
  50141. * An Abstract Motion controller
  50142. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50143. * Each component has an observable to check for changes in value and state
  50144. */
  50145. export abstract class WebXRAbstractMotionController implements IDisposable {
  50146. protected scene: Scene;
  50147. protected layout: IMotionControllerLayout;
  50148. /**
  50149. * The gamepad object correlating to this controller
  50150. */
  50151. gamepadObject: IMinimalMotionControllerObject;
  50152. /**
  50153. * handedness (left/right/none) of this controller
  50154. */
  50155. handedness: MotionControllerHandedness;
  50156. private _initComponent;
  50157. private _modelReady;
  50158. /**
  50159. * A map of components (WebXRControllerComponent) in this motion controller
  50160. * Components have a ComponentType and can also have both button and axis definitions
  50161. */
  50162. readonly components: {
  50163. [id: string]: WebXRControllerComponent;
  50164. };
  50165. /**
  50166. * Disable the model's animation. Can be set at any time.
  50167. */
  50168. disableAnimation: boolean;
  50169. /**
  50170. * Observers registered here will be triggered when the model of this controller is done loading
  50171. */
  50172. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50173. /**
  50174. * The profile id of this motion controller
  50175. */
  50176. abstract profileId: string;
  50177. /**
  50178. * The root mesh of the model. It is null if the model was not yet initialized
  50179. */
  50180. rootMesh: Nullable<AbstractMesh>;
  50181. /**
  50182. * constructs a new abstract motion controller
  50183. * @param scene the scene to which the model of the controller will be added
  50184. * @param layout The profile layout to load
  50185. * @param gamepadObject The gamepad object correlating to this controller
  50186. * @param handedness handedness (left/right/none) of this controller
  50187. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50188. */
  50189. constructor(scene: Scene, layout: IMotionControllerLayout,
  50190. /**
  50191. * The gamepad object correlating to this controller
  50192. */
  50193. gamepadObject: IMinimalMotionControllerObject,
  50194. /**
  50195. * handedness (left/right/none) of this controller
  50196. */
  50197. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50198. /**
  50199. * Dispose this controller, the model mesh and all its components
  50200. */
  50201. dispose(): void;
  50202. /**
  50203. * Returns all components of specific type
  50204. * @param type the type to search for
  50205. * @return an array of components with this type
  50206. */
  50207. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50208. /**
  50209. * get a component based an its component id as defined in layout.components
  50210. * @param id the id of the component
  50211. * @returns the component correlates to the id or undefined if not found
  50212. */
  50213. getComponent(id: string): WebXRControllerComponent;
  50214. /**
  50215. * Get the list of components available in this motion controller
  50216. * @returns an array of strings correlating to available components
  50217. */
  50218. getComponentIds(): string[];
  50219. /**
  50220. * Get the first component of specific type
  50221. * @param type type of component to find
  50222. * @return a controller component or null if not found
  50223. */
  50224. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50225. /**
  50226. * Get the main (Select) component of this controller as defined in the layout
  50227. * @returns the main component of this controller
  50228. */
  50229. getMainComponent(): WebXRControllerComponent;
  50230. /**
  50231. * Loads the model correlating to this controller
  50232. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50233. * @returns A promise fulfilled with the result of the model loading
  50234. */
  50235. loadModel(): Promise<boolean>;
  50236. /**
  50237. * Update this model using the current XRFrame
  50238. * @param xrFrame the current xr frame to use and update the model
  50239. */
  50240. updateFromXRFrame(xrFrame: XRFrame): void;
  50241. /**
  50242. * Backwards compatibility due to a deeply-integrated typo
  50243. */
  50244. get handness(): XREye;
  50245. /**
  50246. * Pulse (vibrate) this controller
  50247. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50248. * Consecutive calls to this function will cancel the last pulse call
  50249. *
  50250. * @param value the strength of the pulse in 0.0...1.0 range
  50251. * @param duration Duration of the pulse in milliseconds
  50252. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50253. * @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
  50254. */
  50255. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50256. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50257. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50258. /**
  50259. * Moves the axis on the controller mesh based on its current state
  50260. * @param axis the index of the axis
  50261. * @param axisValue the value of the axis which determines the meshes new position
  50262. * @hidden
  50263. */
  50264. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50265. /**
  50266. * Update the model itself with the current frame data
  50267. * @param xrFrame the frame to use for updating the model mesh
  50268. */
  50269. protected updateModel(xrFrame: XRFrame): void;
  50270. /**
  50271. * Get the filename and path for this controller's model
  50272. * @returns a map of filename and path
  50273. */
  50274. protected abstract _getFilenameAndPath(): {
  50275. filename: string;
  50276. path: string;
  50277. };
  50278. /**
  50279. * This function is called before the mesh is loaded. It checks for loading constraints.
  50280. * For example, this function can check if the GLB loader is available
  50281. * If this function returns false, the generic controller will be loaded instead
  50282. * @returns Is the client ready to load the mesh
  50283. */
  50284. protected abstract _getModelLoadingConstraints(): boolean;
  50285. /**
  50286. * This function will be called after the model was successfully loaded and can be used
  50287. * for mesh transformations before it is available for the user
  50288. * @param meshes the loaded meshes
  50289. */
  50290. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50291. /**
  50292. * Set the root mesh for this controller. Important for the WebXR controller class
  50293. * @param meshes the loaded meshes
  50294. */
  50295. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50296. /**
  50297. * A function executed each frame that updates the mesh (if needed)
  50298. * @param xrFrame the current xrFrame
  50299. */
  50300. protected abstract _updateModel(xrFrame: XRFrame): void;
  50301. private _getGenericFilenameAndPath;
  50302. private _getGenericParentMesh;
  50303. }
  50304. }
  50305. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50306. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50308. import { Scene } from "babylonjs/scene";
  50309. /**
  50310. * A generic trigger-only motion controller for WebXR
  50311. */
  50312. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50313. /**
  50314. * Static version of the profile id of this controller
  50315. */
  50316. static ProfileId: string;
  50317. profileId: string;
  50318. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50319. protected _getFilenameAndPath(): {
  50320. filename: string;
  50321. path: string;
  50322. };
  50323. protected _getModelLoadingConstraints(): boolean;
  50324. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50325. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50326. protected _updateModel(): void;
  50327. }
  50328. }
  50329. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50330. import { Vector4 } from "babylonjs/Maths/math.vector";
  50331. import { Mesh } from "babylonjs/Meshes/mesh";
  50332. import { Scene } from "babylonjs/scene";
  50333. import { Nullable } from "babylonjs/types";
  50334. /**
  50335. * Class containing static functions to help procedurally build meshes
  50336. */
  50337. export class SphereBuilder {
  50338. /**
  50339. * Creates a sphere mesh
  50340. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50341. * * 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`)
  50342. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50343. * * 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
  50344. * * 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)
  50345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50348. * @param name defines the name of the mesh
  50349. * @param options defines the options used to create the mesh
  50350. * @param scene defines the hosting scene
  50351. * @returns the sphere mesh
  50352. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50353. */
  50354. static CreateSphere(name: string, options: {
  50355. segments?: number;
  50356. diameter?: number;
  50357. diameterX?: number;
  50358. diameterY?: number;
  50359. diameterZ?: number;
  50360. arc?: number;
  50361. slice?: number;
  50362. sideOrientation?: number;
  50363. frontUVs?: Vector4;
  50364. backUVs?: Vector4;
  50365. updatable?: boolean;
  50366. }, scene?: Nullable<Scene>): Mesh;
  50367. }
  50368. }
  50369. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50371. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50372. import { Scene } from "babylonjs/scene";
  50373. /**
  50374. * A profiled motion controller has its profile loaded from an online repository.
  50375. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50376. */
  50377. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50378. private _repositoryUrl;
  50379. private _buttonMeshMapping;
  50380. private _touchDots;
  50381. /**
  50382. * The profile ID of this controller. Will be populated when the controller initializes.
  50383. */
  50384. profileId: string;
  50385. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50386. dispose(): void;
  50387. protected _getFilenameAndPath(): {
  50388. filename: string;
  50389. path: string;
  50390. };
  50391. protected _getModelLoadingConstraints(): boolean;
  50392. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50393. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50394. protected _updateModel(_xrFrame: XRFrame): void;
  50395. }
  50396. }
  50397. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50398. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50399. import { Scene } from "babylonjs/scene";
  50400. /**
  50401. * A construction function type to create a new controller based on an xrInput object
  50402. */
  50403. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50404. /**
  50405. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50406. *
  50407. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50408. * it should be replaced with auto-loaded controllers.
  50409. *
  50410. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50411. */
  50412. export class WebXRMotionControllerManager {
  50413. private static _AvailableControllers;
  50414. private static _Fallbacks;
  50415. private static _ProfileLoadingPromises;
  50416. private static _ProfilesList;
  50417. /**
  50418. * The base URL of the online controller repository. Can be changed at any time.
  50419. */
  50420. static BaseRepositoryUrl: string;
  50421. /**
  50422. * Which repository gets priority - local or online
  50423. */
  50424. static PrioritizeOnlineRepository: boolean;
  50425. /**
  50426. * Use the online repository, or use only locally-defined controllers
  50427. */
  50428. static UseOnlineRepository: boolean;
  50429. /**
  50430. * Clear the cache used for profile loading and reload when requested again
  50431. */
  50432. static ClearProfilesCache(): void;
  50433. /**
  50434. * Register the default fallbacks.
  50435. * This function is called automatically when this file is imported.
  50436. */
  50437. static DefaultFallbacks(): void;
  50438. /**
  50439. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50440. * @param profileId the profile to which a fallback needs to be found
  50441. * @return an array with corresponding fallback profiles
  50442. */
  50443. static FindFallbackWithProfileId(profileId: string): string[];
  50444. /**
  50445. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50446. * The order of search:
  50447. *
  50448. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50449. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50450. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50451. * 4) return the generic trigger controller if none were found
  50452. *
  50453. * @param xrInput the xrInput to which a new controller is initialized
  50454. * @param scene the scene to which the model will be added
  50455. * @param forceProfile force a certain profile for this controller
  50456. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50457. */
  50458. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50459. /**
  50460. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50461. *
  50462. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50463. *
  50464. * @param type the profile type to register
  50465. * @param constructFunction the function to be called when loading this profile
  50466. */
  50467. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50468. /**
  50469. * Register a fallback to a specific profile.
  50470. * @param profileId the profileId that will receive the fallbacks
  50471. * @param fallbacks A list of fallback profiles
  50472. */
  50473. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50474. /**
  50475. * Will update the list of profiles available in the repository
  50476. * @return a promise that resolves to a map of profiles available online
  50477. */
  50478. static UpdateProfilesList(): Promise<{
  50479. [profile: string]: string;
  50480. }>;
  50481. private static _LoadProfileFromRepository;
  50482. private static _LoadProfilesFromAvailableControllers;
  50483. }
  50484. }
  50485. declare module "babylonjs/XR/webXRInputSource" {
  50486. import { Observable } from "babylonjs/Misc/observable";
  50487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50488. import { Ray } from "babylonjs/Culling/ray";
  50489. import { Scene } from "babylonjs/scene";
  50490. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50491. /**
  50492. * Configuration options for the WebXR controller creation
  50493. */
  50494. export interface IWebXRControllerOptions {
  50495. /**
  50496. * Should the controller mesh be animated when a user interacts with it
  50497. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50498. */
  50499. disableMotionControllerAnimation?: boolean;
  50500. /**
  50501. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50502. */
  50503. doNotLoadControllerMesh?: boolean;
  50504. /**
  50505. * Force a specific controller type for this controller.
  50506. * This can be used when creating your own profile or when testing different controllers
  50507. */
  50508. forceControllerProfile?: string;
  50509. /**
  50510. * Defines a rendering group ID for meshes that will be loaded.
  50511. * This is for the default controllers only.
  50512. */
  50513. renderingGroupId?: number;
  50514. }
  50515. /**
  50516. * Represents an XR controller
  50517. */
  50518. export class WebXRInputSource {
  50519. private _scene;
  50520. /** The underlying input source for the controller */
  50521. inputSource: XRInputSource;
  50522. private _options;
  50523. private _tmpVector;
  50524. private _uniqueId;
  50525. private _disposed;
  50526. /**
  50527. * 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
  50528. */
  50529. grip?: AbstractMesh;
  50530. /**
  50531. * If available, this is the gamepad object related to this controller.
  50532. * Using this object it is possible to get click events and trackpad changes of the
  50533. * webxr controller that is currently being used.
  50534. */
  50535. motionController?: WebXRAbstractMotionController;
  50536. /**
  50537. * Event that fires when the controller is removed/disposed.
  50538. * The object provided as event data is this controller, after associated assets were disposed.
  50539. * uniqueId is still available.
  50540. */
  50541. onDisposeObservable: Observable<WebXRInputSource>;
  50542. /**
  50543. * Will be triggered when the mesh associated with the motion controller is done loading.
  50544. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50545. * A shortened version of controller -> motion controller -> on mesh loaded.
  50546. */
  50547. onMeshLoadedObservable: Observable<AbstractMesh>;
  50548. /**
  50549. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50550. */
  50551. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50552. /**
  50553. * Pointer which can be used to select objects or attach a visible laser to
  50554. */
  50555. pointer: AbstractMesh;
  50556. /**
  50557. * Creates the input source object
  50558. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50559. * @param _scene the scene which the controller should be associated to
  50560. * @param inputSource the underlying input source for the controller
  50561. * @param _options options for this controller creation
  50562. */
  50563. constructor(_scene: Scene,
  50564. /** The underlying input source for the controller */
  50565. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50566. /**
  50567. * Get this controllers unique id
  50568. */
  50569. get uniqueId(): string;
  50570. /**
  50571. * Disposes of the object
  50572. */
  50573. dispose(): void;
  50574. /**
  50575. * Gets a world space ray coming from the pointer or grip
  50576. * @param result the resulting ray
  50577. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50578. */
  50579. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50580. /**
  50581. * Updates the controller pose based on the given XRFrame
  50582. * @param xrFrame xr frame to update the pose with
  50583. * @param referenceSpace reference space to use
  50584. */
  50585. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50586. }
  50587. }
  50588. declare module "babylonjs/XR/webXRInput" {
  50589. import { Observable } from "babylonjs/Misc/observable";
  50590. import { IDisposable } from "babylonjs/scene";
  50591. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50592. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50593. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50594. /**
  50595. * The schema for initialization options of the XR Input class
  50596. */
  50597. export interface IWebXRInputOptions {
  50598. /**
  50599. * If set to true no model will be automatically loaded
  50600. */
  50601. doNotLoadControllerMeshes?: boolean;
  50602. /**
  50603. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50604. * If not found, the xr input profile data will be used.
  50605. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50606. */
  50607. forceInputProfile?: string;
  50608. /**
  50609. * Do not send a request to the controller repository to load the profile.
  50610. *
  50611. * Instead, use the controllers available in babylon itself.
  50612. */
  50613. disableOnlineControllerRepository?: boolean;
  50614. /**
  50615. * A custom URL for the controllers repository
  50616. */
  50617. customControllersRepositoryURL?: string;
  50618. /**
  50619. * Should the controller model's components not move according to the user input
  50620. */
  50621. disableControllerAnimation?: boolean;
  50622. /**
  50623. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50624. */
  50625. controllerOptions?: IWebXRControllerOptions;
  50626. }
  50627. /**
  50628. * XR input used to track XR inputs such as controllers/rays
  50629. */
  50630. export class WebXRInput implements IDisposable {
  50631. /**
  50632. * the xr session manager for this session
  50633. */
  50634. xrSessionManager: WebXRSessionManager;
  50635. /**
  50636. * the WebXR camera for this session. Mainly used for teleportation
  50637. */
  50638. xrCamera: WebXRCamera;
  50639. private readonly options;
  50640. /**
  50641. * XR controllers being tracked
  50642. */
  50643. controllers: Array<WebXRInputSource>;
  50644. private _frameObserver;
  50645. private _sessionEndedObserver;
  50646. private _sessionInitObserver;
  50647. /**
  50648. * Event when a controller has been connected/added
  50649. */
  50650. onControllerAddedObservable: Observable<WebXRInputSource>;
  50651. /**
  50652. * Event when a controller has been removed/disconnected
  50653. */
  50654. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50655. /**
  50656. * Initializes the WebXRInput
  50657. * @param xrSessionManager the xr session manager for this session
  50658. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50659. * @param options = initialization options for this xr input
  50660. */
  50661. constructor(
  50662. /**
  50663. * the xr session manager for this session
  50664. */
  50665. xrSessionManager: WebXRSessionManager,
  50666. /**
  50667. * the WebXR camera for this session. Mainly used for teleportation
  50668. */
  50669. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50670. private _onInputSourcesChange;
  50671. private _addAndRemoveControllers;
  50672. /**
  50673. * Disposes of the object
  50674. */
  50675. dispose(): void;
  50676. }
  50677. }
  50678. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50679. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50680. import { Observable, EventState } from "babylonjs/Misc/observable";
  50681. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50682. /**
  50683. * This is the base class for all WebXR features.
  50684. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50685. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50686. */
  50687. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50688. protected _xrSessionManager: WebXRSessionManager;
  50689. private _attached;
  50690. private _removeOnDetach;
  50691. /**
  50692. * Is this feature disposed?
  50693. */
  50694. isDisposed: boolean;
  50695. /**
  50696. * Should auto-attach be disabled?
  50697. */
  50698. disableAutoAttach: boolean;
  50699. /**
  50700. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50701. */
  50702. xrNativeFeatureName: string;
  50703. /**
  50704. * Construct a new (abstract) WebXR feature
  50705. * @param _xrSessionManager the xr session manager for this feature
  50706. */
  50707. constructor(_xrSessionManager: WebXRSessionManager);
  50708. /**
  50709. * Is this feature attached
  50710. */
  50711. get attached(): boolean;
  50712. /**
  50713. * attach this feature
  50714. *
  50715. * @param force should attachment be forced (even when already attached)
  50716. * @returns true if successful, false is failed or already attached
  50717. */
  50718. attach(force?: boolean): boolean;
  50719. /**
  50720. * detach this feature.
  50721. *
  50722. * @returns true if successful, false if failed or already detached
  50723. */
  50724. detach(): boolean;
  50725. /**
  50726. * Dispose this feature and all of the resources attached
  50727. */
  50728. dispose(): void;
  50729. /**
  50730. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50731. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50732. *
  50733. * @returns whether or not the feature is compatible in this environment
  50734. */
  50735. isCompatible(): boolean;
  50736. /**
  50737. * This is used to register callbacks that will automatically be removed when detach is called.
  50738. * @param observable the observable to which the observer will be attached
  50739. * @param callback the callback to register
  50740. */
  50741. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50742. /**
  50743. * Code in this function will be executed on each xrFrame received from the browser.
  50744. * This function will not execute after the feature is detached.
  50745. * @param _xrFrame the current frame
  50746. */
  50747. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50748. }
  50749. }
  50750. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50751. import { IDisposable, Scene } from "babylonjs/scene";
  50752. import { Nullable } from "babylonjs/types";
  50753. import { Observable } from "babylonjs/Misc/observable";
  50754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50755. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50756. import { Camera } from "babylonjs/Cameras/camera";
  50757. /**
  50758. * Renders a layer on top of an existing scene
  50759. */
  50760. export class UtilityLayerRenderer implements IDisposable {
  50761. /** the original scene that will be rendered on top of */
  50762. originalScene: Scene;
  50763. private _pointerCaptures;
  50764. private _lastPointerEvents;
  50765. private static _DefaultUtilityLayer;
  50766. private static _DefaultKeepDepthUtilityLayer;
  50767. private _sharedGizmoLight;
  50768. private _renderCamera;
  50769. /**
  50770. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50771. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50772. * @returns the camera that is used when rendering the utility layer
  50773. */
  50774. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50775. /**
  50776. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50777. * @param cam the camera that should be used when rendering the utility layer
  50778. */
  50779. setRenderCamera(cam: Nullable<Camera>): void;
  50780. /**
  50781. * @hidden
  50782. * Light which used by gizmos to get light shading
  50783. */
  50784. _getSharedGizmoLight(): HemisphericLight;
  50785. /**
  50786. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50787. */
  50788. pickUtilitySceneFirst: boolean;
  50789. /**
  50790. * 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)
  50791. */
  50792. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50793. /**
  50794. * 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)
  50795. */
  50796. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50797. /**
  50798. * The scene that is rendered on top of the original scene
  50799. */
  50800. utilityLayerScene: Scene;
  50801. /**
  50802. * If the utility layer should automatically be rendered on top of existing scene
  50803. */
  50804. shouldRender: boolean;
  50805. /**
  50806. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50807. */
  50808. onlyCheckPointerDownEvents: boolean;
  50809. /**
  50810. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50811. */
  50812. processAllEvents: boolean;
  50813. /**
  50814. * Observable raised when the pointer move from the utility layer scene to the main scene
  50815. */
  50816. onPointerOutObservable: Observable<number>;
  50817. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50818. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50819. private _afterRenderObserver;
  50820. private _sceneDisposeObserver;
  50821. private _originalPointerObserver;
  50822. /**
  50823. * Instantiates a UtilityLayerRenderer
  50824. * @param originalScene the original scene that will be rendered on top of
  50825. * @param handleEvents boolean indicating if the utility layer should handle events
  50826. */
  50827. constructor(
  50828. /** the original scene that will be rendered on top of */
  50829. originalScene: Scene, handleEvents?: boolean);
  50830. private _notifyObservers;
  50831. /**
  50832. * Renders the utility layers scene on top of the original scene
  50833. */
  50834. render(): void;
  50835. /**
  50836. * Disposes of the renderer
  50837. */
  50838. dispose(): void;
  50839. private _updateCamera;
  50840. }
  50841. }
  50842. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50843. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50845. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50846. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50847. import { Scene } from "babylonjs/scene";
  50848. import { Nullable } from "babylonjs/types";
  50849. import { Color3 } from "babylonjs/Maths/math.color";
  50850. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50851. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50852. /**
  50853. * Options interface for the pointer selection module
  50854. */
  50855. export interface IWebXRControllerPointerSelectionOptions {
  50856. /**
  50857. * if provided, this scene will be used to render meshes.
  50858. */
  50859. customUtilityLayerScene?: Scene;
  50860. /**
  50861. * 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)
  50862. * If not disabled, the last picked point will be used to execute a pointer up event
  50863. * If disabled, pointer up event will be triggered right after the pointer down event.
  50864. * Used in screen and gaze target ray mode only
  50865. */
  50866. disablePointerUpOnTouchOut: boolean;
  50867. /**
  50868. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50869. */
  50870. forceGazeMode: boolean;
  50871. /**
  50872. * 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
  50873. * to start a new countdown to the pointer down event.
  50874. * Defaults to 1.
  50875. */
  50876. gazeModePointerMovedFactor?: number;
  50877. /**
  50878. * Different button type to use instead of the main component
  50879. */
  50880. overrideButtonId?: string;
  50881. /**
  50882. * use this rendering group id for the meshes (optional)
  50883. */
  50884. renderingGroupId?: number;
  50885. /**
  50886. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50887. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50888. * 3000 means 3 seconds between pointing at something and selecting it
  50889. */
  50890. timeToSelect?: number;
  50891. /**
  50892. * Should meshes created here be added to a utility layer or the main scene
  50893. */
  50894. useUtilityLayer?: boolean;
  50895. /**
  50896. * Optional WebXR camera to be used for gaze selection
  50897. */
  50898. gazeCamera?: WebXRCamera;
  50899. /**
  50900. * the xr input to use with this pointer selection
  50901. */
  50902. xrInput: WebXRInput;
  50903. }
  50904. /**
  50905. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50906. */
  50907. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50908. private readonly _options;
  50909. private static _idCounter;
  50910. private _attachController;
  50911. private _controllers;
  50912. private _scene;
  50913. private _tmpVectorForPickCompare;
  50914. /**
  50915. * The module's name
  50916. */
  50917. static readonly Name: string;
  50918. /**
  50919. * The (Babylon) version of this module.
  50920. * This is an integer representing the implementation version.
  50921. * This number does not correspond to the WebXR specs version
  50922. */
  50923. static readonly Version: number;
  50924. /**
  50925. * Disable lighting on the laser pointer (so it will always be visible)
  50926. */
  50927. disablePointerLighting: boolean;
  50928. /**
  50929. * Disable lighting on the selection mesh (so it will always be visible)
  50930. */
  50931. disableSelectionMeshLighting: boolean;
  50932. /**
  50933. * Should the laser pointer be displayed
  50934. */
  50935. displayLaserPointer: boolean;
  50936. /**
  50937. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50938. */
  50939. displaySelectionMesh: boolean;
  50940. /**
  50941. * This color will be set to the laser pointer when selection is triggered
  50942. */
  50943. laserPointerPickedColor: Color3;
  50944. /**
  50945. * Default color of the laser pointer
  50946. */
  50947. laserPointerDefaultColor: Color3;
  50948. /**
  50949. * default color of the selection ring
  50950. */
  50951. selectionMeshDefaultColor: Color3;
  50952. /**
  50953. * This color will be applied to the selection ring when selection is triggered
  50954. */
  50955. selectionMeshPickedColor: Color3;
  50956. /**
  50957. * Optional filter to be used for ray selection. This predicate shares behavior with
  50958. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50959. */
  50960. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50961. /**
  50962. * constructs a new background remover module
  50963. * @param _xrSessionManager the session manager for this module
  50964. * @param _options read-only options to be used in this module
  50965. */
  50966. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50967. /**
  50968. * attach this feature
  50969. * Will usually be called by the features manager
  50970. *
  50971. * @returns true if successful.
  50972. */
  50973. attach(): boolean;
  50974. /**
  50975. * detach this feature.
  50976. * Will usually be called by the features manager
  50977. *
  50978. * @returns true if successful.
  50979. */
  50980. detach(): boolean;
  50981. /**
  50982. * Will get the mesh under a specific pointer.
  50983. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50984. * @param controllerId the controllerId to check
  50985. * @returns The mesh under pointer or null if no mesh is under the pointer
  50986. */
  50987. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50988. /**
  50989. * Get the xr controller that correlates to the pointer id in the pointer event
  50990. *
  50991. * @param id the pointer id to search for
  50992. * @returns the controller that correlates to this id or null if not found
  50993. */
  50994. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50995. protected _onXRFrame(_xrFrame: XRFrame): void;
  50996. private _attachGazeMode;
  50997. private _attachScreenRayMode;
  50998. private _attachTrackedPointerRayMode;
  50999. private _convertNormalToDirectionOfRay;
  51000. private _detachController;
  51001. private _generateNewMeshPair;
  51002. private _pickingMoved;
  51003. private _updatePointerDistance;
  51004. /** @hidden */
  51005. get lasterPointerDefaultColor(): Color3;
  51006. }
  51007. }
  51008. declare module "babylonjs/XR/webXREnterExitUI" {
  51009. import { Nullable } from "babylonjs/types";
  51010. import { Observable } from "babylonjs/Misc/observable";
  51011. import { IDisposable, Scene } from "babylonjs/scene";
  51012. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51013. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51014. /**
  51015. * Button which can be used to enter a different mode of XR
  51016. */
  51017. export class WebXREnterExitUIButton {
  51018. /** button element */
  51019. element: HTMLElement;
  51020. /** XR initialization options for the button */
  51021. sessionMode: XRSessionMode;
  51022. /** Reference space type */
  51023. referenceSpaceType: XRReferenceSpaceType;
  51024. /**
  51025. * Creates a WebXREnterExitUIButton
  51026. * @param element button element
  51027. * @param sessionMode XR initialization session mode
  51028. * @param referenceSpaceType the type of reference space to be used
  51029. */
  51030. constructor(
  51031. /** button element */
  51032. element: HTMLElement,
  51033. /** XR initialization options for the button */
  51034. sessionMode: XRSessionMode,
  51035. /** Reference space type */
  51036. referenceSpaceType: XRReferenceSpaceType);
  51037. /**
  51038. * Extendable function which can be used to update the button's visuals when the state changes
  51039. * @param activeButton the current active button in the UI
  51040. */
  51041. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  51042. }
  51043. /**
  51044. * Options to create the webXR UI
  51045. */
  51046. export class WebXREnterExitUIOptions {
  51047. /**
  51048. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  51049. */
  51050. customButtons?: Array<WebXREnterExitUIButton>;
  51051. /**
  51052. * A reference space type to use when creating the default button.
  51053. * Default is local-floor
  51054. */
  51055. referenceSpaceType?: XRReferenceSpaceType;
  51056. /**
  51057. * Context to enter xr with
  51058. */
  51059. renderTarget?: Nullable<WebXRRenderTarget>;
  51060. /**
  51061. * A session mode to use when creating the default button.
  51062. * Default is immersive-vr
  51063. */
  51064. sessionMode?: XRSessionMode;
  51065. /**
  51066. * A list of optional features to init the session with
  51067. */
  51068. optionalFeatures?: string[];
  51069. /**
  51070. * A list of optional features to init the session with
  51071. */
  51072. requiredFeatures?: string[];
  51073. }
  51074. /**
  51075. * UI to allow the user to enter/exit XR mode
  51076. */
  51077. export class WebXREnterExitUI implements IDisposable {
  51078. private scene;
  51079. /** version of the options passed to this UI */
  51080. options: WebXREnterExitUIOptions;
  51081. private _activeButton;
  51082. private _buttons;
  51083. /**
  51084. * The HTML Div Element to which buttons are added.
  51085. */
  51086. readonly overlay: HTMLDivElement;
  51087. /**
  51088. * Fired every time the active button is changed.
  51089. *
  51090. * When xr is entered via a button that launches xr that button will be the callback parameter
  51091. *
  51092. * When exiting xr the callback parameter will be null)
  51093. */
  51094. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51095. /**
  51096. *
  51097. * @param scene babylon scene object to use
  51098. * @param options (read-only) version of the options passed to this UI
  51099. */
  51100. private constructor();
  51101. /**
  51102. * Creates UI to allow the user to enter/exit XR mode
  51103. * @param scene the scene to add the ui to
  51104. * @param helper the xr experience helper to enter/exit xr with
  51105. * @param options options to configure the UI
  51106. * @returns the created ui
  51107. */
  51108. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51109. /**
  51110. * Disposes of the XR UI component
  51111. */
  51112. dispose(): void;
  51113. private _updateButtons;
  51114. }
  51115. }
  51116. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51117. import { Vector3 } from "babylonjs/Maths/math.vector";
  51118. import { Color4 } from "babylonjs/Maths/math.color";
  51119. import { Nullable } from "babylonjs/types";
  51120. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51121. import { Scene } from "babylonjs/scene";
  51122. /**
  51123. * Class containing static functions to help procedurally build meshes
  51124. */
  51125. export class LinesBuilder {
  51126. /**
  51127. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51128. * * 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
  51129. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51130. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51131. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51132. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51133. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51134. * * 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
  51135. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51138. * @param name defines the name of the new line system
  51139. * @param options defines the options used to create the line system
  51140. * @param scene defines the hosting scene
  51141. * @returns a new line system mesh
  51142. */
  51143. static CreateLineSystem(name: string, options: {
  51144. lines: Vector3[][];
  51145. updatable?: boolean;
  51146. instance?: Nullable<LinesMesh>;
  51147. colors?: Nullable<Color4[][]>;
  51148. useVertexAlpha?: boolean;
  51149. }, scene: Nullable<Scene>): LinesMesh;
  51150. /**
  51151. * Creates a line mesh
  51152. * 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
  51153. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51154. * * The parameter `points` is an array successive Vector3
  51155. * * 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
  51156. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51157. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51158. * * When updating an instance, remember that only point positions can change, not the number of points
  51159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51161. * @param name defines the name of the new line system
  51162. * @param options defines the options used to create the line system
  51163. * @param scene defines the hosting scene
  51164. * @returns a new line mesh
  51165. */
  51166. static CreateLines(name: string, options: {
  51167. points: Vector3[];
  51168. updatable?: boolean;
  51169. instance?: Nullable<LinesMesh>;
  51170. colors?: Color4[];
  51171. useVertexAlpha?: boolean;
  51172. }, scene?: Nullable<Scene>): LinesMesh;
  51173. /**
  51174. * Creates a dashed line mesh
  51175. * * 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
  51176. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51177. * * The parameter `points` is an array successive Vector3
  51178. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51179. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51180. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51181. * * 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
  51182. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51183. * * When updating an instance, remember that only point positions can change, not the number of points
  51184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51185. * @param name defines the name of the mesh
  51186. * @param options defines the options used to create the mesh
  51187. * @param scene defines the hosting scene
  51188. * @returns the dashed line mesh
  51189. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51190. */
  51191. static CreateDashedLines(name: string, options: {
  51192. points: Vector3[];
  51193. dashSize?: number;
  51194. gapSize?: number;
  51195. dashNb?: number;
  51196. updatable?: boolean;
  51197. instance?: LinesMesh;
  51198. useVertexAlpha?: boolean;
  51199. }, scene?: Nullable<Scene>): LinesMesh;
  51200. }
  51201. }
  51202. declare module "babylonjs/Misc/timer" {
  51203. import { Observable, Observer } from "babylonjs/Misc/observable";
  51204. import { Nullable } from "babylonjs/types";
  51205. import { IDisposable } from "babylonjs/scene";
  51206. /**
  51207. * Construction options for a timer
  51208. */
  51209. export interface ITimerOptions<T> {
  51210. /**
  51211. * Time-to-end
  51212. */
  51213. timeout: number;
  51214. /**
  51215. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51216. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51217. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51218. */
  51219. contextObservable: Observable<T>;
  51220. /**
  51221. * Optional parameters when adding an observer to the observable
  51222. */
  51223. observableParameters?: {
  51224. mask?: number;
  51225. insertFirst?: boolean;
  51226. scope?: any;
  51227. };
  51228. /**
  51229. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51230. */
  51231. breakCondition?: (data?: ITimerData<T>) => boolean;
  51232. /**
  51233. * Will be triggered when the time condition has met
  51234. */
  51235. onEnded?: (data: ITimerData<any>) => void;
  51236. /**
  51237. * Will be triggered when the break condition has met (prematurely ended)
  51238. */
  51239. onAborted?: (data: ITimerData<any>) => void;
  51240. /**
  51241. * Optional function to execute on each tick (or count)
  51242. */
  51243. onTick?: (data: ITimerData<any>) => void;
  51244. }
  51245. /**
  51246. * An interface defining the data sent by the timer
  51247. */
  51248. export interface ITimerData<T> {
  51249. /**
  51250. * When did it start
  51251. */
  51252. startTime: number;
  51253. /**
  51254. * Time now
  51255. */
  51256. currentTime: number;
  51257. /**
  51258. * Time passed since started
  51259. */
  51260. deltaTime: number;
  51261. /**
  51262. * How much is completed, in [0.0...1.0].
  51263. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51264. */
  51265. completeRate: number;
  51266. /**
  51267. * What the registered observable sent in the last count
  51268. */
  51269. payload: T;
  51270. }
  51271. /**
  51272. * The current state of the timer
  51273. */
  51274. export enum TimerState {
  51275. /**
  51276. * Timer initialized, not yet started
  51277. */
  51278. INIT = 0,
  51279. /**
  51280. * Timer started and counting
  51281. */
  51282. STARTED = 1,
  51283. /**
  51284. * Timer ended (whether aborted or time reached)
  51285. */
  51286. ENDED = 2
  51287. }
  51288. /**
  51289. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51290. *
  51291. * @param options options with which to initialize this timer
  51292. */
  51293. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51294. /**
  51295. * An advanced implementation of a timer class
  51296. */
  51297. export class AdvancedTimer<T = any> implements IDisposable {
  51298. /**
  51299. * Will notify each time the timer calculates the remaining time
  51300. */
  51301. onEachCountObservable: Observable<ITimerData<T>>;
  51302. /**
  51303. * Will trigger when the timer was aborted due to the break condition
  51304. */
  51305. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51306. /**
  51307. * Will trigger when the timer ended successfully
  51308. */
  51309. onTimerEndedObservable: Observable<ITimerData<T>>;
  51310. /**
  51311. * Will trigger when the timer state has changed
  51312. */
  51313. onStateChangedObservable: Observable<TimerState>;
  51314. private _observer;
  51315. private _contextObservable;
  51316. private _observableParameters;
  51317. private _startTime;
  51318. private _timer;
  51319. private _state;
  51320. private _breakCondition;
  51321. private _timeToEnd;
  51322. private _breakOnNextTick;
  51323. /**
  51324. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51325. * @param options construction options for this advanced timer
  51326. */
  51327. constructor(options: ITimerOptions<T>);
  51328. /**
  51329. * set a breaking condition for this timer. Default is to never break during count
  51330. * @param predicate the new break condition. Returns true to break, false otherwise
  51331. */
  51332. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51333. /**
  51334. * Reset ALL associated observables in this advanced timer
  51335. */
  51336. clearObservables(): void;
  51337. /**
  51338. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51339. *
  51340. * @param timeToEnd how much time to measure until timer ended
  51341. */
  51342. start(timeToEnd?: number): void;
  51343. /**
  51344. * Will force a stop on the next tick.
  51345. */
  51346. stop(): void;
  51347. /**
  51348. * Dispose this timer, clearing all resources
  51349. */
  51350. dispose(): void;
  51351. private _setState;
  51352. private _tick;
  51353. private _stop;
  51354. }
  51355. }
  51356. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51357. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51358. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51359. import { Nullable } from "babylonjs/types";
  51360. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51362. import { Vector3 } from "babylonjs/Maths/math.vector";
  51363. import { Material } from "babylonjs/Materials/material";
  51364. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51365. import { Scene } from "babylonjs/scene";
  51366. /**
  51367. * The options container for the teleportation module
  51368. */
  51369. export interface IWebXRTeleportationOptions {
  51370. /**
  51371. * if provided, this scene will be used to render meshes.
  51372. */
  51373. customUtilityLayerScene?: Scene;
  51374. /**
  51375. * Values to configure the default target mesh
  51376. */
  51377. defaultTargetMeshOptions?: {
  51378. /**
  51379. * Fill color of the teleportation area
  51380. */
  51381. teleportationFillColor?: string;
  51382. /**
  51383. * Border color for the teleportation area
  51384. */
  51385. teleportationBorderColor?: string;
  51386. /**
  51387. * Disable the mesh's animation sequence
  51388. */
  51389. disableAnimation?: boolean;
  51390. /**
  51391. * Disable lighting on the material or the ring and arrow
  51392. */
  51393. disableLighting?: boolean;
  51394. /**
  51395. * Override the default material of the torus and arrow
  51396. */
  51397. torusArrowMaterial?: Material;
  51398. };
  51399. /**
  51400. * A list of meshes to use as floor meshes.
  51401. * Meshes can be added and removed after initializing the feature using the
  51402. * addFloorMesh and removeFloorMesh functions
  51403. * If empty, rotation will still work
  51404. */
  51405. floorMeshes?: AbstractMesh[];
  51406. /**
  51407. * use this rendering group id for the meshes (optional)
  51408. */
  51409. renderingGroupId?: number;
  51410. /**
  51411. * Should teleportation move only to snap points
  51412. */
  51413. snapPointsOnly?: boolean;
  51414. /**
  51415. * An array of points to which the teleportation will snap to.
  51416. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51417. */
  51418. snapPositions?: Vector3[];
  51419. /**
  51420. * How close should the teleportation ray be in order to snap to position.
  51421. * Default to 0.8 units (meters)
  51422. */
  51423. snapToPositionRadius?: number;
  51424. /**
  51425. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51426. * If you want to support rotation, make sure your mesh has a direction indicator.
  51427. *
  51428. * When left untouched, the default mesh will be initialized.
  51429. */
  51430. teleportationTargetMesh?: AbstractMesh;
  51431. /**
  51432. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51433. */
  51434. timeToTeleport?: number;
  51435. /**
  51436. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51437. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51438. */
  51439. useMainComponentOnly?: boolean;
  51440. /**
  51441. * Should meshes created here be added to a utility layer or the main scene
  51442. */
  51443. useUtilityLayer?: boolean;
  51444. /**
  51445. * Babylon XR Input class for controller
  51446. */
  51447. xrInput: WebXRInput;
  51448. /**
  51449. * Meshes that the teleportation ray cannot go through
  51450. */
  51451. pickBlockerMeshes?: AbstractMesh[];
  51452. }
  51453. /**
  51454. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51455. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51456. * the input of the attached controllers.
  51457. */
  51458. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51459. private _options;
  51460. private _controllers;
  51461. private _currentTeleportationControllerId;
  51462. private _floorMeshes;
  51463. private _quadraticBezierCurve;
  51464. private _selectionFeature;
  51465. private _snapToPositions;
  51466. private _snappedToPoint;
  51467. private _teleportationRingMaterial?;
  51468. private _tmpRay;
  51469. private _tmpVector;
  51470. private _tmpQuaternion;
  51471. /**
  51472. * The module's name
  51473. */
  51474. static readonly Name: string;
  51475. /**
  51476. * The (Babylon) version of this module.
  51477. * This is an integer representing the implementation version.
  51478. * This number does not correspond to the webxr specs version
  51479. */
  51480. static readonly Version: number;
  51481. /**
  51482. * Is movement backwards enabled
  51483. */
  51484. backwardsMovementEnabled: boolean;
  51485. /**
  51486. * Distance to travel when moving backwards
  51487. */
  51488. backwardsTeleportationDistance: number;
  51489. /**
  51490. * The distance from the user to the inspection point in the direction of the controller
  51491. * A higher number will allow the user to move further
  51492. * defaults to 5 (meters, in xr units)
  51493. */
  51494. parabolicCheckRadius: number;
  51495. /**
  51496. * Should the module support parabolic ray on top of direct ray
  51497. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51498. * Very helpful when moving between floors / different heights
  51499. */
  51500. parabolicRayEnabled: boolean;
  51501. /**
  51502. * How much rotation should be applied when rotating right and left
  51503. */
  51504. rotationAngle: number;
  51505. /**
  51506. * Is rotation enabled when moving forward?
  51507. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51508. */
  51509. rotationEnabled: boolean;
  51510. /**
  51511. * constructs a new anchor system
  51512. * @param _xrSessionManager an instance of WebXRSessionManager
  51513. * @param _options configuration object for this feature
  51514. */
  51515. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51516. /**
  51517. * Get the snapPointsOnly flag
  51518. */
  51519. get snapPointsOnly(): boolean;
  51520. /**
  51521. * Sets the snapPointsOnly flag
  51522. * @param snapToPoints should teleportation be exclusively to snap points
  51523. */
  51524. set snapPointsOnly(snapToPoints: boolean);
  51525. /**
  51526. * Add a new mesh to the floor meshes array
  51527. * @param mesh the mesh to use as floor mesh
  51528. */
  51529. addFloorMesh(mesh: AbstractMesh): void;
  51530. /**
  51531. * Add a new snap-to point to fix teleportation to this position
  51532. * @param newSnapPoint The new Snap-To point
  51533. */
  51534. addSnapPoint(newSnapPoint: Vector3): void;
  51535. attach(): boolean;
  51536. detach(): boolean;
  51537. dispose(): void;
  51538. /**
  51539. * Remove a mesh from the floor meshes array
  51540. * @param mesh the mesh to remove
  51541. */
  51542. removeFloorMesh(mesh: AbstractMesh): void;
  51543. /**
  51544. * Remove a mesh from the floor meshes array using its name
  51545. * @param name the mesh name to remove
  51546. */
  51547. removeFloorMeshByName(name: string): void;
  51548. /**
  51549. * 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
  51550. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51551. * @returns was the point found and removed or not
  51552. */
  51553. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51554. /**
  51555. * This function sets a selection feature that will be disabled when
  51556. * the forward ray is shown and will be reattached when hidden.
  51557. * This is used to remove the selection rays when moving.
  51558. * @param selectionFeature the feature to disable when forward movement is enabled
  51559. */
  51560. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51561. protected _onXRFrame(_xrFrame: XRFrame): void;
  51562. private _attachController;
  51563. private _createDefaultTargetMesh;
  51564. private _detachController;
  51565. private _findClosestSnapPointWithRadius;
  51566. private _setTargetMeshPosition;
  51567. private _setTargetMeshVisibility;
  51568. private _showParabolicPath;
  51569. private _teleportForward;
  51570. }
  51571. }
  51572. declare module "babylonjs/XR/webXRDefaultExperience" {
  51573. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51574. import { Scene } from "babylonjs/scene";
  51575. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51576. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51577. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51578. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51580. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51581. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51582. /**
  51583. * Options for the default xr helper
  51584. */
  51585. export class WebXRDefaultExperienceOptions {
  51586. /**
  51587. * Enable or disable default UI to enter XR
  51588. */
  51589. disableDefaultUI?: boolean;
  51590. /**
  51591. * Should teleportation not initialize. defaults to false.
  51592. */
  51593. disableTeleportation?: boolean;
  51594. /**
  51595. * Floor meshes that will be used for teleport
  51596. */
  51597. floorMeshes?: Array<AbstractMesh>;
  51598. /**
  51599. * If set to true, the first frame will not be used to reset position
  51600. * The first frame is mainly used when copying transformation from the old camera
  51601. * Mainly used in AR
  51602. */
  51603. ignoreNativeCameraTransformation?: boolean;
  51604. /**
  51605. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51606. */
  51607. inputOptions?: IWebXRInputOptions;
  51608. /**
  51609. * optional configuration for the output canvas
  51610. */
  51611. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51612. /**
  51613. * optional UI options. This can be used among other to change session mode and reference space type
  51614. */
  51615. uiOptions?: WebXREnterExitUIOptions;
  51616. /**
  51617. * When loading teleportation and pointer select, use stable versions instead of latest.
  51618. */
  51619. useStablePlugins?: boolean;
  51620. /**
  51621. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51622. */
  51623. renderingGroupId?: number;
  51624. /**
  51625. * A list of optional features to init the session with
  51626. * If set to true, all features we support will be added
  51627. */
  51628. optionalFeatures?: boolean | string[];
  51629. }
  51630. /**
  51631. * Default experience which provides a similar setup to the previous webVRExperience
  51632. */
  51633. export class WebXRDefaultExperience {
  51634. /**
  51635. * Base experience
  51636. */
  51637. baseExperience: WebXRExperienceHelper;
  51638. /**
  51639. * Enables ui for entering/exiting xr
  51640. */
  51641. enterExitUI: WebXREnterExitUI;
  51642. /**
  51643. * Input experience extension
  51644. */
  51645. input: WebXRInput;
  51646. /**
  51647. * Enables laser pointer and selection
  51648. */
  51649. pointerSelection: WebXRControllerPointerSelection;
  51650. /**
  51651. * Default target xr should render to
  51652. */
  51653. renderTarget: WebXRRenderTarget;
  51654. /**
  51655. * Enables teleportation
  51656. */
  51657. teleportation: WebXRMotionControllerTeleportation;
  51658. private constructor();
  51659. /**
  51660. * Creates the default xr experience
  51661. * @param scene scene
  51662. * @param options options for basic configuration
  51663. * @returns resulting WebXRDefaultExperience
  51664. */
  51665. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51666. /**
  51667. * DIsposes of the experience helper
  51668. */
  51669. dispose(): void;
  51670. }
  51671. }
  51672. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51673. import { Observable } from "babylonjs/Misc/observable";
  51674. import { Nullable } from "babylonjs/types";
  51675. import { Camera } from "babylonjs/Cameras/camera";
  51676. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51677. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51678. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51679. import { Scene } from "babylonjs/scene";
  51680. import { Vector3 } from "babylonjs/Maths/math.vector";
  51681. import { Color3 } from "babylonjs/Maths/math.color";
  51682. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51684. import { Mesh } from "babylonjs/Meshes/mesh";
  51685. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51686. import { EasingFunction } from "babylonjs/Animations/easing";
  51687. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51688. import "babylonjs/Meshes/Builders/groundBuilder";
  51689. import "babylonjs/Meshes/Builders/torusBuilder";
  51690. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51691. import "babylonjs/Gamepads/gamepadSceneComponent";
  51692. import "babylonjs/Animations/animatable";
  51693. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51694. /**
  51695. * Options to modify the vr teleportation behavior.
  51696. */
  51697. export interface VRTeleportationOptions {
  51698. /**
  51699. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51700. */
  51701. floorMeshName?: string;
  51702. /**
  51703. * A list of meshes to be used as the teleportation floor. (default: empty)
  51704. */
  51705. floorMeshes?: Mesh[];
  51706. /**
  51707. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51708. */
  51709. teleportationMode?: number;
  51710. /**
  51711. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51712. */
  51713. teleportationTime?: number;
  51714. /**
  51715. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51716. */
  51717. teleportationSpeed?: number;
  51718. /**
  51719. * The easing function used in the animation or null for Linear. (default CircleEase)
  51720. */
  51721. easingFunction?: EasingFunction;
  51722. }
  51723. /**
  51724. * Options to modify the vr experience helper's behavior.
  51725. */
  51726. export interface VRExperienceHelperOptions extends WebVROptions {
  51727. /**
  51728. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51729. */
  51730. createDeviceOrientationCamera?: boolean;
  51731. /**
  51732. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51733. */
  51734. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51735. /**
  51736. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51737. */
  51738. laserToggle?: boolean;
  51739. /**
  51740. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51741. */
  51742. floorMeshes?: Mesh[];
  51743. /**
  51744. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51745. */
  51746. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51747. /**
  51748. * Defines if WebXR should be used instead of WebVR (if available)
  51749. */
  51750. useXR?: boolean;
  51751. }
  51752. /**
  51753. * Event containing information after VR has been entered
  51754. */
  51755. export class OnAfterEnteringVRObservableEvent {
  51756. /**
  51757. * If entering vr was successful
  51758. */
  51759. success: boolean;
  51760. }
  51761. /**
  51762. * Helps to quickly add VR support to an existing scene.
  51763. * See https://doc.babylonjs.com/how_to/webvr_helper
  51764. */
  51765. export class VRExperienceHelper {
  51766. /** Options to modify the vr experience helper's behavior. */
  51767. webVROptions: VRExperienceHelperOptions;
  51768. private _scene;
  51769. private _position;
  51770. private _btnVR;
  51771. private _btnVRDisplayed;
  51772. private _webVRsupported;
  51773. private _webVRready;
  51774. private _webVRrequesting;
  51775. private _webVRpresenting;
  51776. private _hasEnteredVR;
  51777. private _fullscreenVRpresenting;
  51778. private _inputElement;
  51779. private _webVRCamera;
  51780. private _vrDeviceOrientationCamera;
  51781. private _deviceOrientationCamera;
  51782. private _existingCamera;
  51783. private _onKeyDown;
  51784. private _onVrDisplayPresentChange;
  51785. private _onVRDisplayChanged;
  51786. private _onVRRequestPresentStart;
  51787. private _onVRRequestPresentComplete;
  51788. /**
  51789. * 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)
  51790. */
  51791. enableGazeEvenWhenNoPointerLock: boolean;
  51792. /**
  51793. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51794. */
  51795. exitVROnDoubleTap: boolean;
  51796. /**
  51797. * Observable raised right before entering VR.
  51798. */
  51799. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51800. /**
  51801. * Observable raised when entering VR has completed.
  51802. */
  51803. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51804. /**
  51805. * Observable raised when exiting VR.
  51806. */
  51807. onExitingVRObservable: Observable<VRExperienceHelper>;
  51808. /**
  51809. * Observable raised when controller mesh is loaded.
  51810. */
  51811. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51812. /** Return this.onEnteringVRObservable
  51813. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51814. */
  51815. get onEnteringVR(): Observable<VRExperienceHelper>;
  51816. /** Return this.onExitingVRObservable
  51817. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51818. */
  51819. get onExitingVR(): Observable<VRExperienceHelper>;
  51820. /** Return this.onControllerMeshLoadedObservable
  51821. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51822. */
  51823. get onControllerMeshLoaded(): Observable<WebVRController>;
  51824. private _rayLength;
  51825. private _useCustomVRButton;
  51826. private _teleportationRequested;
  51827. private _teleportActive;
  51828. private _floorMeshName;
  51829. private _floorMeshesCollection;
  51830. private _teleportationMode;
  51831. private _teleportationTime;
  51832. private _teleportationSpeed;
  51833. private _teleportationEasing;
  51834. private _rotationAllowed;
  51835. private _teleportBackwardsVector;
  51836. private _teleportationTarget;
  51837. private _isDefaultTeleportationTarget;
  51838. private _postProcessMove;
  51839. private _teleportationFillColor;
  51840. private _teleportationBorderColor;
  51841. private _rotationAngle;
  51842. private _haloCenter;
  51843. private _cameraGazer;
  51844. private _padSensibilityUp;
  51845. private _padSensibilityDown;
  51846. private _leftController;
  51847. private _rightController;
  51848. private _gazeColor;
  51849. private _laserColor;
  51850. private _pickedLaserColor;
  51851. private _pickedGazeColor;
  51852. /**
  51853. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51854. */
  51855. onNewMeshSelected: Observable<AbstractMesh>;
  51856. /**
  51857. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51858. * This observable will provide the mesh and the controller used to select the mesh
  51859. */
  51860. onMeshSelectedWithController: Observable<{
  51861. mesh: AbstractMesh;
  51862. controller: WebVRController;
  51863. }>;
  51864. /**
  51865. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51866. */
  51867. onNewMeshPicked: Observable<PickingInfo>;
  51868. private _circleEase;
  51869. /**
  51870. * Observable raised before camera teleportation
  51871. */
  51872. onBeforeCameraTeleport: Observable<Vector3>;
  51873. /**
  51874. * Observable raised after camera teleportation
  51875. */
  51876. onAfterCameraTeleport: Observable<Vector3>;
  51877. /**
  51878. * Observable raised when current selected mesh gets unselected
  51879. */
  51880. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51881. private _raySelectionPredicate;
  51882. /**
  51883. * To be optionaly changed by user to define custom ray selection
  51884. */
  51885. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51886. /**
  51887. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51888. */
  51889. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51890. /**
  51891. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51892. */
  51893. teleportationEnabled: boolean;
  51894. private _defaultHeight;
  51895. private _teleportationInitialized;
  51896. private _interactionsEnabled;
  51897. private _interactionsRequested;
  51898. private _displayGaze;
  51899. private _displayLaserPointer;
  51900. /**
  51901. * The mesh used to display where the user is going to teleport.
  51902. */
  51903. get teleportationTarget(): Mesh;
  51904. /**
  51905. * Sets the mesh to be used to display where the user is going to teleport.
  51906. */
  51907. set teleportationTarget(value: Mesh);
  51908. /**
  51909. * 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
  51910. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51911. * See https://doc.babylonjs.com/resources/baking_transformations
  51912. */
  51913. get gazeTrackerMesh(): Mesh;
  51914. set gazeTrackerMesh(value: Mesh);
  51915. /**
  51916. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51917. */
  51918. updateGazeTrackerScale: boolean;
  51919. /**
  51920. * If the gaze trackers color should be updated when selecting meshes
  51921. */
  51922. updateGazeTrackerColor: boolean;
  51923. /**
  51924. * If the controller laser color should be updated when selecting meshes
  51925. */
  51926. updateControllerLaserColor: boolean;
  51927. /**
  51928. * The gaze tracking mesh corresponding to the left controller
  51929. */
  51930. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51931. /**
  51932. * The gaze tracking mesh corresponding to the right controller
  51933. */
  51934. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51935. /**
  51936. * If the ray of the gaze should be displayed.
  51937. */
  51938. get displayGaze(): boolean;
  51939. /**
  51940. * Sets if the ray of the gaze should be displayed.
  51941. */
  51942. set displayGaze(value: boolean);
  51943. /**
  51944. * If the ray of the LaserPointer should be displayed.
  51945. */
  51946. get displayLaserPointer(): boolean;
  51947. /**
  51948. * Sets if the ray of the LaserPointer should be displayed.
  51949. */
  51950. set displayLaserPointer(value: boolean);
  51951. /**
  51952. * The deviceOrientationCamera used as the camera when not in VR.
  51953. */
  51954. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51955. /**
  51956. * Based on the current WebVR support, returns the current VR camera used.
  51957. */
  51958. get currentVRCamera(): Nullable<Camera>;
  51959. /**
  51960. * The webVRCamera which is used when in VR.
  51961. */
  51962. get webVRCamera(): WebVRFreeCamera;
  51963. /**
  51964. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51965. */
  51966. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51967. /**
  51968. * The html button that is used to trigger entering into VR.
  51969. */
  51970. get vrButton(): Nullable<HTMLButtonElement>;
  51971. private get _teleportationRequestInitiated();
  51972. /**
  51973. * Defines whether or not Pointer lock should be requested when switching to
  51974. * full screen.
  51975. */
  51976. requestPointerLockOnFullScreen: boolean;
  51977. /**
  51978. * If asking to force XR, this will be populated with the default xr experience
  51979. */
  51980. xr: WebXRDefaultExperience;
  51981. /**
  51982. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51983. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51984. */
  51985. xrTestDone: boolean;
  51986. /**
  51987. * Instantiates a VRExperienceHelper.
  51988. * Helps to quickly add VR support to an existing scene.
  51989. * @param scene The scene the VRExperienceHelper belongs to.
  51990. * @param webVROptions Options to modify the vr experience helper's behavior.
  51991. */
  51992. constructor(scene: Scene,
  51993. /** Options to modify the vr experience helper's behavior. */
  51994. webVROptions?: VRExperienceHelperOptions);
  51995. private completeVRInit;
  51996. private _onDefaultMeshLoaded;
  51997. private _onResize;
  51998. private _onFullscreenChange;
  51999. /**
  52000. * Gets a value indicating if we are currently in VR mode.
  52001. */
  52002. get isInVRMode(): boolean;
  52003. private onVrDisplayPresentChange;
  52004. private onVRDisplayChanged;
  52005. private moveButtonToBottomRight;
  52006. private displayVRButton;
  52007. private updateButtonVisibility;
  52008. private _cachedAngularSensibility;
  52009. /**
  52010. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  52011. * Otherwise, will use the fullscreen API.
  52012. */
  52013. enterVR(): void;
  52014. /**
  52015. * Attempt to exit VR, or fullscreen.
  52016. */
  52017. exitVR(): void;
  52018. /**
  52019. * The position of the vr experience helper.
  52020. */
  52021. get position(): Vector3;
  52022. /**
  52023. * Sets the position of the vr experience helper.
  52024. */
  52025. set position(value: Vector3);
  52026. /**
  52027. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  52028. */
  52029. enableInteractions(): void;
  52030. private get _noControllerIsActive();
  52031. private beforeRender;
  52032. private _isTeleportationFloor;
  52033. /**
  52034. * Adds a floor mesh to be used for teleportation.
  52035. * @param floorMesh the mesh to be used for teleportation.
  52036. */
  52037. addFloorMesh(floorMesh: Mesh): void;
  52038. /**
  52039. * Removes a floor mesh from being used for teleportation.
  52040. * @param floorMesh the mesh to be removed.
  52041. */
  52042. removeFloorMesh(floorMesh: Mesh): void;
  52043. /**
  52044. * Enables interactions and teleportation using the VR controllers and gaze.
  52045. * @param vrTeleportationOptions options to modify teleportation behavior.
  52046. */
  52047. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  52048. private _onNewGamepadConnected;
  52049. private _tryEnableInteractionOnController;
  52050. private _onNewGamepadDisconnected;
  52051. private _enableInteractionOnController;
  52052. private _checkTeleportWithRay;
  52053. private _checkRotate;
  52054. private _checkTeleportBackwards;
  52055. private _enableTeleportationOnController;
  52056. private _createTeleportationCircles;
  52057. private _displayTeleportationTarget;
  52058. private _hideTeleportationTarget;
  52059. private _rotateCamera;
  52060. private _moveTeleportationSelectorTo;
  52061. private _workingVector;
  52062. private _workingQuaternion;
  52063. private _workingMatrix;
  52064. /**
  52065. * Time Constant Teleportation Mode
  52066. */
  52067. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52068. /**
  52069. * Speed Constant Teleportation Mode
  52070. */
  52071. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52072. /**
  52073. * Teleports the users feet to the desired location
  52074. * @param location The location where the user's feet should be placed
  52075. */
  52076. teleportCamera(location: Vector3): void;
  52077. private _convertNormalToDirectionOfRay;
  52078. private _castRayAndSelectObject;
  52079. private _notifySelectedMeshUnselected;
  52080. /**
  52081. * Permanently set new colors for the laser pointer
  52082. * @param color the new laser color
  52083. * @param pickedColor the new laser color when picked mesh detected
  52084. */
  52085. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52086. /**
  52087. * Set lighting enabled / disabled on the laser pointer of both controllers
  52088. * @param enabled should the lighting be enabled on the laser pointer
  52089. */
  52090. setLaserLightingState(enabled?: boolean): void;
  52091. /**
  52092. * Permanently set new colors for the gaze pointer
  52093. * @param color the new gaze color
  52094. * @param pickedColor the new gaze color when picked mesh detected
  52095. */
  52096. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52097. /**
  52098. * Sets the color of the laser ray from the vr controllers.
  52099. * @param color new color for the ray.
  52100. */
  52101. changeLaserColor(color: Color3): void;
  52102. /**
  52103. * Sets the color of the ray from the vr headsets gaze.
  52104. * @param color new color for the ray.
  52105. */
  52106. changeGazeColor(color: Color3): void;
  52107. /**
  52108. * Exits VR and disposes of the vr experience helper
  52109. */
  52110. dispose(): void;
  52111. /**
  52112. * Gets the name of the VRExperienceHelper class
  52113. * @returns "VRExperienceHelper"
  52114. */
  52115. getClassName(): string;
  52116. }
  52117. }
  52118. declare module "babylonjs/Cameras/VR/index" {
  52119. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52120. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52121. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52122. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52123. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52124. export * from "babylonjs/Cameras/VR/webVRCamera";
  52125. }
  52126. declare module "babylonjs/Cameras/RigModes/index" {
  52127. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52128. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52129. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52130. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52131. }
  52132. declare module "babylonjs/Cameras/index" {
  52133. export * from "babylonjs/Cameras/Inputs/index";
  52134. export * from "babylonjs/Cameras/cameraInputsManager";
  52135. export * from "babylonjs/Cameras/camera";
  52136. export * from "babylonjs/Cameras/targetCamera";
  52137. export * from "babylonjs/Cameras/freeCamera";
  52138. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52139. export * from "babylonjs/Cameras/touchCamera";
  52140. export * from "babylonjs/Cameras/arcRotateCamera";
  52141. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52142. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52143. export * from "babylonjs/Cameras/flyCamera";
  52144. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52145. export * from "babylonjs/Cameras/followCamera";
  52146. export * from "babylonjs/Cameras/followCameraInputsManager";
  52147. export * from "babylonjs/Cameras/gamepadCamera";
  52148. export * from "babylonjs/Cameras/Stereoscopic/index";
  52149. export * from "babylonjs/Cameras/universalCamera";
  52150. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52151. export * from "babylonjs/Cameras/VR/index";
  52152. export * from "babylonjs/Cameras/RigModes/index";
  52153. }
  52154. declare module "babylonjs/Collisions/index" {
  52155. export * from "babylonjs/Collisions/collider";
  52156. export * from "babylonjs/Collisions/collisionCoordinator";
  52157. export * from "babylonjs/Collisions/pickingInfo";
  52158. export * from "babylonjs/Collisions/intersectionInfo";
  52159. export * from "babylonjs/Collisions/meshCollisionData";
  52160. }
  52161. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52162. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52163. import { Vector3 } from "babylonjs/Maths/math.vector";
  52164. import { Ray } from "babylonjs/Culling/ray";
  52165. import { Plane } from "babylonjs/Maths/math.plane";
  52166. /**
  52167. * Contains an array of blocks representing the octree
  52168. */
  52169. export interface IOctreeContainer<T> {
  52170. /**
  52171. * Blocks within the octree
  52172. */
  52173. blocks: Array<OctreeBlock<T>>;
  52174. }
  52175. /**
  52176. * Class used to store a cell in an octree
  52177. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52178. */
  52179. export class OctreeBlock<T> {
  52180. /**
  52181. * Gets the content of the current block
  52182. */
  52183. entries: T[];
  52184. /**
  52185. * Gets the list of block children
  52186. */
  52187. blocks: Array<OctreeBlock<T>>;
  52188. private _depth;
  52189. private _maxDepth;
  52190. private _capacity;
  52191. private _minPoint;
  52192. private _maxPoint;
  52193. private _boundingVectors;
  52194. private _creationFunc;
  52195. /**
  52196. * Creates a new block
  52197. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52198. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52199. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52200. * @param depth defines the current depth of this block in the octree
  52201. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52202. * @param creationFunc defines a callback to call when an element is added to the block
  52203. */
  52204. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52205. /**
  52206. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52207. */
  52208. get capacity(): number;
  52209. /**
  52210. * Gets the minimum vector (in world space) of the block's bounding box
  52211. */
  52212. get minPoint(): Vector3;
  52213. /**
  52214. * Gets the maximum vector (in world space) of the block's bounding box
  52215. */
  52216. get maxPoint(): Vector3;
  52217. /**
  52218. * Add a new element to this block
  52219. * @param entry defines the element to add
  52220. */
  52221. addEntry(entry: T): void;
  52222. /**
  52223. * Remove an element from this block
  52224. * @param entry defines the element to remove
  52225. */
  52226. removeEntry(entry: T): void;
  52227. /**
  52228. * Add an array of elements to this block
  52229. * @param entries defines the array of elements to add
  52230. */
  52231. addEntries(entries: T[]): void;
  52232. /**
  52233. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52234. * @param frustumPlanes defines the frustum planes to test
  52235. * @param selection defines the array to store current content if selection is positive
  52236. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52237. */
  52238. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52239. /**
  52240. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52241. * @param sphereCenter defines the bounding sphere center
  52242. * @param sphereRadius defines the bounding sphere radius
  52243. * @param selection defines the array to store current content if selection is positive
  52244. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52245. */
  52246. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52247. /**
  52248. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52249. * @param ray defines the ray to test with
  52250. * @param selection defines the array to store current content if selection is positive
  52251. */
  52252. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52253. /**
  52254. * Subdivide the content into child blocks (this block will then be empty)
  52255. */
  52256. createInnerBlocks(): void;
  52257. /**
  52258. * @hidden
  52259. */
  52260. 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;
  52261. }
  52262. }
  52263. declare module "babylonjs/Culling/Octrees/octree" {
  52264. import { SmartArray } from "babylonjs/Misc/smartArray";
  52265. import { Vector3 } from "babylonjs/Maths/math.vector";
  52266. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52268. import { Ray } from "babylonjs/Culling/ray";
  52269. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52270. import { Plane } from "babylonjs/Maths/math.plane";
  52271. /**
  52272. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52273. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52274. */
  52275. export class Octree<T> {
  52276. /** 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.) */
  52277. maxDepth: number;
  52278. /**
  52279. * Blocks within the octree containing objects
  52280. */
  52281. blocks: Array<OctreeBlock<T>>;
  52282. /**
  52283. * Content stored in the octree
  52284. */
  52285. dynamicContent: T[];
  52286. private _maxBlockCapacity;
  52287. private _selectionContent;
  52288. private _creationFunc;
  52289. /**
  52290. * Creates a octree
  52291. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52292. * @param creationFunc function to be used to instatiate the octree
  52293. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52294. * @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.)
  52295. */
  52296. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52297. /** 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.) */
  52298. maxDepth?: number);
  52299. /**
  52300. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52301. * @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);
  52302. * @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);
  52303. * @param entries meshes to be added to the octree blocks
  52304. */
  52305. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52306. /**
  52307. * Adds a mesh to the octree
  52308. * @param entry Mesh to add to the octree
  52309. */
  52310. addMesh(entry: T): void;
  52311. /**
  52312. * Remove an element from the octree
  52313. * @param entry defines the element to remove
  52314. */
  52315. removeMesh(entry: T): void;
  52316. /**
  52317. * Selects an array of meshes within the frustum
  52318. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52319. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52320. * @returns array of meshes within the frustum
  52321. */
  52322. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52323. /**
  52324. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52325. * @param sphereCenter defines the bounding sphere center
  52326. * @param sphereRadius defines the bounding sphere radius
  52327. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52328. * @returns an array of objects that intersect the sphere
  52329. */
  52330. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52331. /**
  52332. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52333. * @param ray defines the ray to test with
  52334. * @returns array of intersected objects
  52335. */
  52336. intersectsRay(ray: Ray): SmartArray<T>;
  52337. /**
  52338. * Adds a mesh into the octree block if it intersects the block
  52339. */
  52340. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52341. /**
  52342. * Adds a submesh into the octree block if it intersects the block
  52343. */
  52344. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52345. }
  52346. }
  52347. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52348. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52349. import { Scene } from "babylonjs/scene";
  52350. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52352. import { Ray } from "babylonjs/Culling/ray";
  52353. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52354. import { Collider } from "babylonjs/Collisions/collider";
  52355. module "babylonjs/scene" {
  52356. interface Scene {
  52357. /**
  52358. * @hidden
  52359. * Backing Filed
  52360. */
  52361. _selectionOctree: Octree<AbstractMesh>;
  52362. /**
  52363. * Gets the octree used to boost mesh selection (picking)
  52364. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52365. */
  52366. selectionOctree: Octree<AbstractMesh>;
  52367. /**
  52368. * Creates or updates the octree used to boost selection (picking)
  52369. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52370. * @param maxCapacity defines the maximum capacity per leaf
  52371. * @param maxDepth defines the maximum depth of the octree
  52372. * @returns an octree of AbstractMesh
  52373. */
  52374. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52375. }
  52376. }
  52377. module "babylonjs/Meshes/abstractMesh" {
  52378. interface AbstractMesh {
  52379. /**
  52380. * @hidden
  52381. * Backing Field
  52382. */
  52383. _submeshesOctree: Octree<SubMesh>;
  52384. /**
  52385. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52386. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52387. * @param maxCapacity defines the maximum size of each block (64 by default)
  52388. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52389. * @returns the new octree
  52390. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52391. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52392. */
  52393. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52394. }
  52395. }
  52396. /**
  52397. * Defines the octree scene component responsible to manage any octrees
  52398. * in a given scene.
  52399. */
  52400. export class OctreeSceneComponent {
  52401. /**
  52402. * The component name help to identify the component in the list of scene components.
  52403. */
  52404. readonly name: string;
  52405. /**
  52406. * The scene the component belongs to.
  52407. */
  52408. scene: Scene;
  52409. /**
  52410. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52411. */
  52412. readonly checksIsEnabled: boolean;
  52413. /**
  52414. * Creates a new instance of the component for the given scene
  52415. * @param scene Defines the scene to register the component in
  52416. */
  52417. constructor(scene: Scene);
  52418. /**
  52419. * Registers the component in a given scene
  52420. */
  52421. register(): void;
  52422. /**
  52423. * Return the list of active meshes
  52424. * @returns the list of active meshes
  52425. */
  52426. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52427. /**
  52428. * Return the list of active sub meshes
  52429. * @param mesh The mesh to get the candidates sub meshes from
  52430. * @returns the list of active sub meshes
  52431. */
  52432. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52433. private _tempRay;
  52434. /**
  52435. * Return the list of sub meshes intersecting with a given local ray
  52436. * @param mesh defines the mesh to find the submesh for
  52437. * @param localRay defines the ray in local space
  52438. * @returns the list of intersecting sub meshes
  52439. */
  52440. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52441. /**
  52442. * Return the list of sub meshes colliding with a collider
  52443. * @param mesh defines the mesh to find the submesh for
  52444. * @param collider defines the collider to evaluate the collision against
  52445. * @returns the list of colliding sub meshes
  52446. */
  52447. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52448. /**
  52449. * Rebuilds the elements related to this component in case of
  52450. * context lost for instance.
  52451. */
  52452. rebuild(): void;
  52453. /**
  52454. * Disposes the component and the associated ressources.
  52455. */
  52456. dispose(): void;
  52457. }
  52458. }
  52459. declare module "babylonjs/Culling/Octrees/index" {
  52460. export * from "babylonjs/Culling/Octrees/octree";
  52461. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52462. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52463. }
  52464. declare module "babylonjs/Culling/index" {
  52465. export * from "babylonjs/Culling/boundingBox";
  52466. export * from "babylonjs/Culling/boundingInfo";
  52467. export * from "babylonjs/Culling/boundingSphere";
  52468. export * from "babylonjs/Culling/Octrees/index";
  52469. export * from "babylonjs/Culling/ray";
  52470. }
  52471. declare module "babylonjs/Gizmos/gizmo" {
  52472. import { Nullable } from "babylonjs/types";
  52473. import { IDisposable } from "babylonjs/scene";
  52474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52475. import { Mesh } from "babylonjs/Meshes/mesh";
  52476. import { Node } from "babylonjs/node";
  52477. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52478. /**
  52479. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52480. */
  52481. export class Gizmo implements IDisposable {
  52482. /** The utility layer the gizmo will be added to */
  52483. gizmoLayer: UtilityLayerRenderer;
  52484. /**
  52485. * The root mesh of the gizmo
  52486. */
  52487. _rootMesh: Mesh;
  52488. private _attachedMesh;
  52489. private _attachedNode;
  52490. /**
  52491. * Ratio for the scale of the gizmo (Default: 1)
  52492. */
  52493. protected _scaleRatio: number;
  52494. /**
  52495. * Ratio for the scale of the gizmo (Default: 1)
  52496. */
  52497. set scaleRatio(value: number);
  52498. get scaleRatio(): number;
  52499. /**
  52500. * If a custom mesh has been set (Default: false)
  52501. */
  52502. protected _customMeshSet: boolean;
  52503. /**
  52504. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52505. * * When set, interactions will be enabled
  52506. */
  52507. get attachedMesh(): Nullable<AbstractMesh>;
  52508. set attachedMesh(value: Nullable<AbstractMesh>);
  52509. /**
  52510. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52511. * * When set, interactions will be enabled
  52512. */
  52513. get attachedNode(): Nullable<Node>;
  52514. set attachedNode(value: Nullable<Node>);
  52515. /**
  52516. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52517. * @param mesh The mesh to replace the default mesh of the gizmo
  52518. */
  52519. setCustomMesh(mesh: Mesh): void;
  52520. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52521. /**
  52522. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52523. */
  52524. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52525. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52526. /**
  52527. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52528. */
  52529. updateGizmoPositionToMatchAttachedMesh: boolean;
  52530. /**
  52531. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52532. */
  52533. updateScale: boolean;
  52534. protected _interactionsEnabled: boolean;
  52535. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52536. private _beforeRenderObserver;
  52537. private _tempQuaternion;
  52538. private _tempVector;
  52539. private _tempVector2;
  52540. private _tempMatrix1;
  52541. private _tempMatrix2;
  52542. private _rightHandtoLeftHandMatrix;
  52543. /**
  52544. * Creates a gizmo
  52545. * @param gizmoLayer The utility layer the gizmo will be added to
  52546. */
  52547. constructor(
  52548. /** The utility layer the gizmo will be added to */
  52549. gizmoLayer?: UtilityLayerRenderer);
  52550. /**
  52551. * Updates the gizmo to match the attached mesh's position/rotation
  52552. */
  52553. protected _update(): void;
  52554. /**
  52555. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52556. * @param value Node, TransformNode or mesh
  52557. */
  52558. protected _matrixChanged(): void;
  52559. /**
  52560. * Disposes of the gizmo
  52561. */
  52562. dispose(): void;
  52563. }
  52564. }
  52565. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52566. import { Observable } from "babylonjs/Misc/observable";
  52567. import { Nullable } from "babylonjs/types";
  52568. import { Vector3 } from "babylonjs/Maths/math.vector";
  52569. import { Color3 } from "babylonjs/Maths/math.color";
  52570. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52571. import { Node } from "babylonjs/node";
  52572. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52573. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52574. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52575. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52576. import { Scene } from "babylonjs/scene";
  52577. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52578. /**
  52579. * Single plane drag gizmo
  52580. */
  52581. export class PlaneDragGizmo extends Gizmo {
  52582. /**
  52583. * Drag behavior responsible for the gizmos dragging interactions
  52584. */
  52585. dragBehavior: PointerDragBehavior;
  52586. private _pointerObserver;
  52587. /**
  52588. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52589. */
  52590. snapDistance: number;
  52591. /**
  52592. * Event that fires each time the gizmo snaps to a new location.
  52593. * * snapDistance is the the change in distance
  52594. */
  52595. onSnapObservable: Observable<{
  52596. snapDistance: number;
  52597. }>;
  52598. private _plane;
  52599. private _coloredMaterial;
  52600. private _hoverMaterial;
  52601. private _isEnabled;
  52602. private _parent;
  52603. /** @hidden */
  52604. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52605. /** @hidden */
  52606. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52607. /**
  52608. * Creates a PlaneDragGizmo
  52609. * @param gizmoLayer The utility layer the gizmo will be added to
  52610. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52611. * @param color The color of the gizmo
  52612. */
  52613. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52614. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52615. /**
  52616. * If the gizmo is enabled
  52617. */
  52618. set isEnabled(value: boolean);
  52619. get isEnabled(): boolean;
  52620. /**
  52621. * Disposes of the gizmo
  52622. */
  52623. dispose(): void;
  52624. }
  52625. }
  52626. declare module "babylonjs/Gizmos/positionGizmo" {
  52627. import { Observable } from "babylonjs/Misc/observable";
  52628. import { Nullable } from "babylonjs/types";
  52629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52630. import { Node } from "babylonjs/node";
  52631. import { Mesh } from "babylonjs/Meshes/mesh";
  52632. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52633. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52634. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52635. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52636. /**
  52637. * Gizmo that enables dragging a mesh along 3 axis
  52638. */
  52639. export class PositionGizmo extends Gizmo {
  52640. /**
  52641. * Internal gizmo used for interactions on the x axis
  52642. */
  52643. xGizmo: AxisDragGizmo;
  52644. /**
  52645. * Internal gizmo used for interactions on the y axis
  52646. */
  52647. yGizmo: AxisDragGizmo;
  52648. /**
  52649. * Internal gizmo used for interactions on the z axis
  52650. */
  52651. zGizmo: AxisDragGizmo;
  52652. /**
  52653. * Internal gizmo used for interactions on the yz plane
  52654. */
  52655. xPlaneGizmo: PlaneDragGizmo;
  52656. /**
  52657. * Internal gizmo used for interactions on the xz plane
  52658. */
  52659. yPlaneGizmo: PlaneDragGizmo;
  52660. /**
  52661. * Internal gizmo used for interactions on the xy plane
  52662. */
  52663. zPlaneGizmo: PlaneDragGizmo;
  52664. /**
  52665. * private variables
  52666. */
  52667. private _meshAttached;
  52668. private _nodeAttached;
  52669. private _snapDistance;
  52670. /** Fires an event when any of it's sub gizmos are dragged */
  52671. onDragStartObservable: Observable<unknown>;
  52672. /** Fires an event when any of it's sub gizmos are released from dragging */
  52673. onDragEndObservable: Observable<unknown>;
  52674. /**
  52675. * If set to true, planar drag is enabled
  52676. */
  52677. private _planarGizmoEnabled;
  52678. get attachedMesh(): Nullable<AbstractMesh>;
  52679. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52680. get attachedNode(): Nullable<Node>;
  52681. set attachedNode(node: Nullable<Node>);
  52682. /**
  52683. * Creates a PositionGizmo
  52684. * @param gizmoLayer The utility layer the gizmo will be added to
  52685. @param thickness display gizmo axis thickness
  52686. */
  52687. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52688. /**
  52689. * If the planar drag gizmo is enabled
  52690. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52691. */
  52692. set planarGizmoEnabled(value: boolean);
  52693. get planarGizmoEnabled(): boolean;
  52694. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52695. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52696. /**
  52697. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52698. */
  52699. set snapDistance(value: number);
  52700. get snapDistance(): number;
  52701. /**
  52702. * Ratio for the scale of the gizmo (Default: 1)
  52703. */
  52704. set scaleRatio(value: number);
  52705. get scaleRatio(): number;
  52706. /**
  52707. * Disposes of the gizmo
  52708. */
  52709. dispose(): void;
  52710. /**
  52711. * CustomMeshes are not supported by this gizmo
  52712. * @param mesh The mesh to replace the default mesh of the gizmo
  52713. */
  52714. setCustomMesh(mesh: Mesh): void;
  52715. }
  52716. }
  52717. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52718. import { Observable } from "babylonjs/Misc/observable";
  52719. import { Nullable } from "babylonjs/types";
  52720. import { Vector3 } from "babylonjs/Maths/math.vector";
  52721. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52722. import { Node } from "babylonjs/node";
  52723. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52724. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52725. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52726. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52727. import { Scene } from "babylonjs/scene";
  52728. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52729. import { Color3 } from "babylonjs/Maths/math.color";
  52730. /**
  52731. * Single axis drag gizmo
  52732. */
  52733. export class AxisDragGizmo extends Gizmo {
  52734. /**
  52735. * Drag behavior responsible for the gizmos dragging interactions
  52736. */
  52737. dragBehavior: PointerDragBehavior;
  52738. private _pointerObserver;
  52739. /**
  52740. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52741. */
  52742. snapDistance: number;
  52743. /**
  52744. * Event that fires each time the gizmo snaps to a new location.
  52745. * * snapDistance is the the change in distance
  52746. */
  52747. onSnapObservable: Observable<{
  52748. snapDistance: number;
  52749. }>;
  52750. private _isEnabled;
  52751. private _parent;
  52752. private _arrow;
  52753. private _coloredMaterial;
  52754. private _hoverMaterial;
  52755. /** @hidden */
  52756. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52757. /** @hidden */
  52758. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52759. /**
  52760. * Creates an AxisDragGizmo
  52761. * @param gizmoLayer The utility layer the gizmo will be added to
  52762. * @param dragAxis The axis which the gizmo will be able to drag on
  52763. * @param color The color of the gizmo
  52764. * @param thickness display gizmo axis thickness
  52765. */
  52766. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52767. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52768. /**
  52769. * If the gizmo is enabled
  52770. */
  52771. set isEnabled(value: boolean);
  52772. get isEnabled(): boolean;
  52773. /**
  52774. * Disposes of the gizmo
  52775. */
  52776. dispose(): void;
  52777. }
  52778. }
  52779. declare module "babylonjs/Debug/axesViewer" {
  52780. import { Vector3 } from "babylonjs/Maths/math.vector";
  52781. import { Nullable } from "babylonjs/types";
  52782. import { Scene } from "babylonjs/scene";
  52783. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52784. /**
  52785. * The Axes viewer will show 3 axes in a specific point in space
  52786. */
  52787. export class AxesViewer {
  52788. private _xAxis;
  52789. private _yAxis;
  52790. private _zAxis;
  52791. private _scaleLinesFactor;
  52792. private _instanced;
  52793. /**
  52794. * Gets the hosting scene
  52795. */
  52796. scene: Nullable<Scene>;
  52797. /**
  52798. * Gets or sets a number used to scale line length
  52799. */
  52800. scaleLines: number;
  52801. /** Gets the node hierarchy used to render x-axis */
  52802. get xAxis(): TransformNode;
  52803. /** Gets the node hierarchy used to render y-axis */
  52804. get yAxis(): TransformNode;
  52805. /** Gets the node hierarchy used to render z-axis */
  52806. get zAxis(): TransformNode;
  52807. /**
  52808. * Creates a new AxesViewer
  52809. * @param scene defines the hosting scene
  52810. * @param scaleLines defines a number used to scale line length (1 by default)
  52811. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52812. * @param xAxis defines the node hierarchy used to render the x-axis
  52813. * @param yAxis defines the node hierarchy used to render the y-axis
  52814. * @param zAxis defines the node hierarchy used to render the z-axis
  52815. */
  52816. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52817. /**
  52818. * Force the viewer to update
  52819. * @param position defines the position of the viewer
  52820. * @param xaxis defines the x axis of the viewer
  52821. * @param yaxis defines the y axis of the viewer
  52822. * @param zaxis defines the z axis of the viewer
  52823. */
  52824. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52825. /**
  52826. * Creates an instance of this axes viewer.
  52827. * @returns a new axes viewer with instanced meshes
  52828. */
  52829. createInstance(): AxesViewer;
  52830. /** Releases resources */
  52831. dispose(): void;
  52832. private static _SetRenderingGroupId;
  52833. }
  52834. }
  52835. declare module "babylonjs/Debug/boneAxesViewer" {
  52836. import { Nullable } from "babylonjs/types";
  52837. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52838. import { Vector3 } from "babylonjs/Maths/math.vector";
  52839. import { Mesh } from "babylonjs/Meshes/mesh";
  52840. import { Bone } from "babylonjs/Bones/bone";
  52841. import { Scene } from "babylonjs/scene";
  52842. /**
  52843. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52844. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52845. */
  52846. export class BoneAxesViewer extends AxesViewer {
  52847. /**
  52848. * Gets or sets the target mesh where to display the axes viewer
  52849. */
  52850. mesh: Nullable<Mesh>;
  52851. /**
  52852. * Gets or sets the target bone where to display the axes viewer
  52853. */
  52854. bone: Nullable<Bone>;
  52855. /** Gets current position */
  52856. pos: Vector3;
  52857. /** Gets direction of X axis */
  52858. xaxis: Vector3;
  52859. /** Gets direction of Y axis */
  52860. yaxis: Vector3;
  52861. /** Gets direction of Z axis */
  52862. zaxis: Vector3;
  52863. /**
  52864. * Creates a new BoneAxesViewer
  52865. * @param scene defines the hosting scene
  52866. * @param bone defines the target bone
  52867. * @param mesh defines the target mesh
  52868. * @param scaleLines defines a scaling factor for line length (1 by default)
  52869. */
  52870. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52871. /**
  52872. * Force the viewer to update
  52873. */
  52874. update(): void;
  52875. /** Releases resources */
  52876. dispose(): void;
  52877. }
  52878. }
  52879. declare module "babylonjs/Debug/debugLayer" {
  52880. import { Scene } from "babylonjs/scene";
  52881. /**
  52882. * Interface used to define scene explorer extensibility option
  52883. */
  52884. export interface IExplorerExtensibilityOption {
  52885. /**
  52886. * Define the option label
  52887. */
  52888. label: string;
  52889. /**
  52890. * Defines the action to execute on click
  52891. */
  52892. action: (entity: any) => void;
  52893. }
  52894. /**
  52895. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52896. */
  52897. export interface IExplorerExtensibilityGroup {
  52898. /**
  52899. * Defines a predicate to test if a given type mut be extended
  52900. */
  52901. predicate: (entity: any) => boolean;
  52902. /**
  52903. * Gets the list of options added to a type
  52904. */
  52905. entries: IExplorerExtensibilityOption[];
  52906. }
  52907. /**
  52908. * Interface used to define the options to use to create the Inspector
  52909. */
  52910. export interface IInspectorOptions {
  52911. /**
  52912. * Display in overlay mode (default: false)
  52913. */
  52914. overlay?: boolean;
  52915. /**
  52916. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52917. */
  52918. globalRoot?: HTMLElement;
  52919. /**
  52920. * Display the Scene explorer
  52921. */
  52922. showExplorer?: boolean;
  52923. /**
  52924. * Display the property inspector
  52925. */
  52926. showInspector?: boolean;
  52927. /**
  52928. * Display in embed mode (both panes on the right)
  52929. */
  52930. embedMode?: boolean;
  52931. /**
  52932. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52933. */
  52934. handleResize?: boolean;
  52935. /**
  52936. * Allow the panes to popup (default: true)
  52937. */
  52938. enablePopup?: boolean;
  52939. /**
  52940. * Allow the panes to be closed by users (default: true)
  52941. */
  52942. enableClose?: boolean;
  52943. /**
  52944. * Optional list of extensibility entries
  52945. */
  52946. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52947. /**
  52948. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52949. */
  52950. inspectorURL?: string;
  52951. /**
  52952. * Optional initial tab (default to DebugLayerTab.Properties)
  52953. */
  52954. initialTab?: DebugLayerTab;
  52955. }
  52956. module "babylonjs/scene" {
  52957. interface Scene {
  52958. /**
  52959. * @hidden
  52960. * Backing field
  52961. */
  52962. _debugLayer: DebugLayer;
  52963. /**
  52964. * Gets the debug layer (aka Inspector) associated with the scene
  52965. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52966. */
  52967. debugLayer: DebugLayer;
  52968. }
  52969. }
  52970. /**
  52971. * Enum of inspector action tab
  52972. */
  52973. export enum DebugLayerTab {
  52974. /**
  52975. * Properties tag (default)
  52976. */
  52977. Properties = 0,
  52978. /**
  52979. * Debug tab
  52980. */
  52981. Debug = 1,
  52982. /**
  52983. * Statistics tab
  52984. */
  52985. Statistics = 2,
  52986. /**
  52987. * Tools tab
  52988. */
  52989. Tools = 3,
  52990. /**
  52991. * Settings tab
  52992. */
  52993. Settings = 4
  52994. }
  52995. /**
  52996. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52997. * what is happening in your scene
  52998. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52999. */
  53000. export class DebugLayer {
  53001. /**
  53002. * Define the url to get the inspector script from.
  53003. * By default it uses the babylonjs CDN.
  53004. * @ignoreNaming
  53005. */
  53006. static InspectorURL: string;
  53007. private _scene;
  53008. private BJSINSPECTOR;
  53009. private _onPropertyChangedObservable?;
  53010. /**
  53011. * Observable triggered when a property is changed through the inspector.
  53012. */
  53013. get onPropertyChangedObservable(): any;
  53014. /**
  53015. * Instantiates a new debug layer.
  53016. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53017. * what is happening in your scene
  53018. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53019. * @param scene Defines the scene to inspect
  53020. */
  53021. constructor(scene: Scene);
  53022. /** Creates the inspector window. */
  53023. private _createInspector;
  53024. /**
  53025. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53026. * @param entity defines the entity to select
  53027. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53028. */
  53029. select(entity: any, lineContainerTitles?: string | string[]): void;
  53030. /** Get the inspector from bundle or global */
  53031. private _getGlobalInspector;
  53032. /**
  53033. * Get if the inspector is visible or not.
  53034. * @returns true if visible otherwise, false
  53035. */
  53036. isVisible(): boolean;
  53037. /**
  53038. * Hide the inspector and close its window.
  53039. */
  53040. hide(): void;
  53041. /**
  53042. * Update the scene in the inspector
  53043. */
  53044. setAsActiveScene(): void;
  53045. /**
  53046. * Launch the debugLayer.
  53047. * @param config Define the configuration of the inspector
  53048. * @return a promise fulfilled when the debug layer is visible
  53049. */
  53050. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53051. }
  53052. }
  53053. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  53054. import { Nullable } from "babylonjs/types";
  53055. import { Scene } from "babylonjs/scene";
  53056. import { Vector4 } from "babylonjs/Maths/math.vector";
  53057. import { Color4 } from "babylonjs/Maths/math.color";
  53058. import { Mesh } from "babylonjs/Meshes/mesh";
  53059. /**
  53060. * Class containing static functions to help procedurally build meshes
  53061. */
  53062. export class BoxBuilder {
  53063. /**
  53064. * Creates a box mesh
  53065. * * The parameter `size` sets the size (float) of each box side (default 1)
  53066. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53067. * * 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)
  53068. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53072. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53073. * @param name defines the name of the mesh
  53074. * @param options defines the options used to create the mesh
  53075. * @param scene defines the hosting scene
  53076. * @returns the box mesh
  53077. */
  53078. static CreateBox(name: string, options: {
  53079. size?: number;
  53080. width?: number;
  53081. height?: number;
  53082. depth?: number;
  53083. faceUV?: Vector4[];
  53084. faceColors?: Color4[];
  53085. sideOrientation?: number;
  53086. frontUVs?: Vector4;
  53087. backUVs?: Vector4;
  53088. wrap?: boolean;
  53089. topBaseAt?: number;
  53090. bottomBaseAt?: number;
  53091. updatable?: boolean;
  53092. }, scene?: Nullable<Scene>): Mesh;
  53093. }
  53094. }
  53095. declare module "babylonjs/Debug/physicsViewer" {
  53096. import { Nullable } from "babylonjs/types";
  53097. import { Scene } from "babylonjs/scene";
  53098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53099. import { Mesh } from "babylonjs/Meshes/mesh";
  53100. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53101. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53102. /**
  53103. * Used to show the physics impostor around the specific mesh
  53104. */
  53105. export class PhysicsViewer {
  53106. /** @hidden */
  53107. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53108. /** @hidden */
  53109. protected _meshes: Array<Nullable<AbstractMesh>>;
  53110. /** @hidden */
  53111. protected _scene: Nullable<Scene>;
  53112. /** @hidden */
  53113. protected _numMeshes: number;
  53114. /** @hidden */
  53115. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53116. private _renderFunction;
  53117. private _utilityLayer;
  53118. private _debugBoxMesh;
  53119. private _debugSphereMesh;
  53120. private _debugCylinderMesh;
  53121. private _debugMaterial;
  53122. private _debugMeshMeshes;
  53123. /**
  53124. * Creates a new PhysicsViewer
  53125. * @param scene defines the hosting scene
  53126. */
  53127. constructor(scene: Scene);
  53128. /** @hidden */
  53129. protected _updateDebugMeshes(): void;
  53130. /**
  53131. * Renders a specified physic impostor
  53132. * @param impostor defines the impostor to render
  53133. * @param targetMesh defines the mesh represented by the impostor
  53134. * @returns the new debug mesh used to render the impostor
  53135. */
  53136. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53137. /**
  53138. * Hides a specified physic impostor
  53139. * @param impostor defines the impostor to hide
  53140. */
  53141. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53142. private _getDebugMaterial;
  53143. private _getDebugBoxMesh;
  53144. private _getDebugSphereMesh;
  53145. private _getDebugCylinderMesh;
  53146. private _getDebugMeshMesh;
  53147. private _getDebugMesh;
  53148. /** Releases all resources */
  53149. dispose(): void;
  53150. }
  53151. }
  53152. declare module "babylonjs/Debug/rayHelper" {
  53153. import { Nullable } from "babylonjs/types";
  53154. import { Ray } from "babylonjs/Culling/ray";
  53155. import { Vector3 } from "babylonjs/Maths/math.vector";
  53156. import { Color3 } from "babylonjs/Maths/math.color";
  53157. import { Scene } from "babylonjs/scene";
  53158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53159. import "babylonjs/Meshes/Builders/linesBuilder";
  53160. /**
  53161. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53162. * in order to better appreciate the issue one might have.
  53163. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53164. */
  53165. export class RayHelper {
  53166. /**
  53167. * Defines the ray we are currently tryin to visualize.
  53168. */
  53169. ray: Nullable<Ray>;
  53170. private _renderPoints;
  53171. private _renderLine;
  53172. private _renderFunction;
  53173. private _scene;
  53174. private _onAfterRenderObserver;
  53175. private _onAfterStepObserver;
  53176. private _attachedToMesh;
  53177. private _meshSpaceDirection;
  53178. private _meshSpaceOrigin;
  53179. /**
  53180. * Helper function to create a colored helper in a scene in one line.
  53181. * @param ray Defines the ray we are currently tryin to visualize
  53182. * @param scene Defines the scene the ray is used in
  53183. * @param color Defines the color we want to see the ray in
  53184. * @returns The newly created ray helper.
  53185. */
  53186. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53187. /**
  53188. * Instantiate a new ray helper.
  53189. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53190. * in order to better appreciate the issue one might have.
  53191. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53192. * @param ray Defines the ray we are currently tryin to visualize
  53193. */
  53194. constructor(ray: Ray);
  53195. /**
  53196. * Shows the ray we are willing to debug.
  53197. * @param scene Defines the scene the ray needs to be rendered in
  53198. * @param color Defines the color the ray needs to be rendered in
  53199. */
  53200. show(scene: Scene, color?: Color3): void;
  53201. /**
  53202. * Hides the ray we are debugging.
  53203. */
  53204. hide(): void;
  53205. private _render;
  53206. /**
  53207. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53208. * @param mesh Defines the mesh we want the helper attached to
  53209. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53210. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53211. * @param length Defines the length of the ray
  53212. */
  53213. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53214. /**
  53215. * Detach the ray helper from the mesh it has previously been attached to.
  53216. */
  53217. detachFromMesh(): void;
  53218. private _updateToMesh;
  53219. /**
  53220. * Dispose the helper and release its associated resources.
  53221. */
  53222. dispose(): void;
  53223. }
  53224. }
  53225. declare module "babylonjs/Debug/ISkeletonViewer" {
  53226. import { Skeleton } from "babylonjs/Bones/skeleton";
  53227. import { Color3 } from "babylonjs/Maths/math.color";
  53228. /**
  53229. * Defines the options associated with the creation of a SkeletonViewer.
  53230. */
  53231. export interface ISkeletonViewerOptions {
  53232. /** Should the system pause animations before building the Viewer? */
  53233. pauseAnimations: boolean;
  53234. /** Should the system return the skeleton to rest before building? */
  53235. returnToRest: boolean;
  53236. /** public Display Mode of the Viewer */
  53237. displayMode: number;
  53238. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53239. displayOptions: ISkeletonViewerDisplayOptions;
  53240. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53241. computeBonesUsingShaders: boolean;
  53242. /** Flag ignore non weighted bones */
  53243. useAllBones: boolean;
  53244. }
  53245. /**
  53246. * Defines how to display the various bone meshes for the viewer.
  53247. */
  53248. export interface ISkeletonViewerDisplayOptions {
  53249. /** How far down to start tapering the bone spurs */
  53250. midStep?: number;
  53251. /** How big is the midStep? */
  53252. midStepFactor?: number;
  53253. /** Base for the Sphere Size */
  53254. sphereBaseSize?: number;
  53255. /** The ratio of the sphere to the longest bone in units */
  53256. sphereScaleUnit?: number;
  53257. /** Ratio for the Sphere Size */
  53258. sphereFactor?: number;
  53259. }
  53260. /**
  53261. * Defines the constructor options for the BoneWeight Shader.
  53262. */
  53263. export interface IBoneWeightShaderOptions {
  53264. /** Skeleton to Map */
  53265. skeleton: Skeleton;
  53266. /** Colors for Uninfluenced bones */
  53267. colorBase?: Color3;
  53268. /** Colors for 0.0-0.25 Weight bones */
  53269. colorZero?: Color3;
  53270. /** Color for 0.25-0.5 Weight Influence */
  53271. colorQuarter?: Color3;
  53272. /** Color for 0.5-0.75 Weight Influence */
  53273. colorHalf?: Color3;
  53274. /** Color for 0.75-1 Weight Influence */
  53275. colorFull?: Color3;
  53276. /** Color for Zero Weight Influence */
  53277. targetBoneIndex?: number;
  53278. }
  53279. /**
  53280. * Simple structure of the gradient steps for the Color Map.
  53281. */
  53282. export interface ISkeletonMapShaderColorMapKnot {
  53283. /** Color of the Knot */
  53284. color: Color3;
  53285. /** Location of the Knot */
  53286. location: number;
  53287. }
  53288. /**
  53289. * Defines the constructor options for the SkeletonMap Shader.
  53290. */
  53291. export interface ISkeletonMapShaderOptions {
  53292. /** Skeleton to Map */
  53293. skeleton: Skeleton;
  53294. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53295. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53296. }
  53297. }
  53298. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53299. import { Nullable } from "babylonjs/types";
  53300. import { Scene } from "babylonjs/scene";
  53301. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53302. import { Color4 } from "babylonjs/Maths/math.color";
  53303. import { Mesh } from "babylonjs/Meshes/mesh";
  53304. /**
  53305. * Class containing static functions to help procedurally build meshes
  53306. */
  53307. export class RibbonBuilder {
  53308. /**
  53309. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53310. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53311. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53312. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53313. * * 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
  53314. * * 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
  53315. * * 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
  53316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53319. * * 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
  53320. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53321. * * 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
  53322. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53324. * @param name defines the name of the mesh
  53325. * @param options defines the options used to create the mesh
  53326. * @param scene defines the hosting scene
  53327. * @returns the ribbon mesh
  53328. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53329. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53330. */
  53331. static CreateRibbon(name: string, options: {
  53332. pathArray: Vector3[][];
  53333. closeArray?: boolean;
  53334. closePath?: boolean;
  53335. offset?: number;
  53336. updatable?: boolean;
  53337. sideOrientation?: number;
  53338. frontUVs?: Vector4;
  53339. backUVs?: Vector4;
  53340. instance?: Mesh;
  53341. invertUV?: boolean;
  53342. uvs?: Vector2[];
  53343. colors?: Color4[];
  53344. }, scene?: Nullable<Scene>): Mesh;
  53345. }
  53346. }
  53347. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53348. import { Nullable } from "babylonjs/types";
  53349. import { Scene } from "babylonjs/scene";
  53350. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53351. import { Mesh } from "babylonjs/Meshes/mesh";
  53352. /**
  53353. * Class containing static functions to help procedurally build meshes
  53354. */
  53355. export class ShapeBuilder {
  53356. /**
  53357. * 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.
  53358. * * 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.
  53359. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53360. * * 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.
  53361. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53362. * * 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
  53363. * * 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
  53364. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53367. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53369. * @param name defines the name of the mesh
  53370. * @param options defines the options used to create the mesh
  53371. * @param scene defines the hosting scene
  53372. * @returns the extruded shape mesh
  53373. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53375. */
  53376. static ExtrudeShape(name: string, options: {
  53377. shape: Vector3[];
  53378. path: Vector3[];
  53379. scale?: number;
  53380. rotation?: number;
  53381. cap?: number;
  53382. updatable?: boolean;
  53383. sideOrientation?: number;
  53384. frontUVs?: Vector4;
  53385. backUVs?: Vector4;
  53386. instance?: Mesh;
  53387. invertUV?: boolean;
  53388. }, scene?: Nullable<Scene>): Mesh;
  53389. /**
  53390. * Creates an custom extruded shape mesh.
  53391. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53392. * * 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.
  53393. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53394. * * 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
  53395. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53396. * * 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
  53397. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53398. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53399. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53400. * * 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
  53401. * * 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
  53402. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53407. * @param name defines the name of the mesh
  53408. * @param options defines the options used to create the mesh
  53409. * @param scene defines the hosting scene
  53410. * @returns the custom extruded shape mesh
  53411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53413. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53414. */
  53415. static ExtrudeShapeCustom(name: string, options: {
  53416. shape: Vector3[];
  53417. path: Vector3[];
  53418. scaleFunction?: any;
  53419. rotationFunction?: any;
  53420. ribbonCloseArray?: boolean;
  53421. ribbonClosePath?: boolean;
  53422. cap?: number;
  53423. updatable?: boolean;
  53424. sideOrientation?: number;
  53425. frontUVs?: Vector4;
  53426. backUVs?: Vector4;
  53427. instance?: Mesh;
  53428. invertUV?: boolean;
  53429. }, scene?: Nullable<Scene>): Mesh;
  53430. private static _ExtrudeShapeGeneric;
  53431. }
  53432. }
  53433. declare module "babylonjs/Debug/skeletonViewer" {
  53434. import { Color3 } from "babylonjs/Maths/math.color";
  53435. import { Scene } from "babylonjs/scene";
  53436. import { Nullable } from "babylonjs/types";
  53437. import { Skeleton } from "babylonjs/Bones/skeleton";
  53438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53439. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53440. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53441. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53442. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53443. /**
  53444. * Class used to render a debug view of a given skeleton
  53445. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53446. */
  53447. export class SkeletonViewer {
  53448. /** defines the skeleton to render */
  53449. skeleton: Skeleton;
  53450. /** defines the mesh attached to the skeleton */
  53451. mesh: AbstractMesh;
  53452. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53453. autoUpdateBonesMatrices: boolean;
  53454. /** defines the rendering group id to use with the viewer */
  53455. renderingGroupId: number;
  53456. /** is the options for the viewer */
  53457. options: Partial<ISkeletonViewerOptions>;
  53458. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53459. static readonly DISPLAY_LINES: number;
  53460. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53461. static readonly DISPLAY_SPHERES: number;
  53462. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53463. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53464. /** public static method to create a BoneWeight Shader
  53465. * @param options The constructor options
  53466. * @param scene The scene that the shader is scoped to
  53467. * @returns The created ShaderMaterial
  53468. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53469. */
  53470. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53471. /** public static method to create a BoneWeight Shader
  53472. * @param options The constructor options
  53473. * @param scene The scene that the shader is scoped to
  53474. * @returns The created ShaderMaterial
  53475. */
  53476. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53477. /** private static method to create a BoneWeight Shader
  53478. * @param size The size of the buffer to create (usually the bone count)
  53479. * @param colorMap The gradient data to generate
  53480. * @param scene The scene that the shader is scoped to
  53481. * @returns an Array of floats from the color gradient values
  53482. */
  53483. private static _CreateBoneMapColorBuffer;
  53484. /** If SkeletonViewer scene scope. */
  53485. private _scene;
  53486. /** Gets or sets the color used to render the skeleton */
  53487. color: Color3;
  53488. /** Array of the points of the skeleton fo the line view. */
  53489. private _debugLines;
  53490. /** The SkeletonViewers Mesh. */
  53491. private _debugMesh;
  53492. /** If SkeletonViewer is enabled. */
  53493. private _isEnabled;
  53494. /** If SkeletonViewer is ready. */
  53495. private _ready;
  53496. /** SkeletonViewer render observable. */
  53497. private _obs;
  53498. /** The Utility Layer to render the gizmos in. */
  53499. private _utilityLayer;
  53500. private _boneIndices;
  53501. /** Gets the Scene. */
  53502. get scene(): Scene;
  53503. /** Gets the utilityLayer. */
  53504. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53505. /** Checks Ready Status. */
  53506. get isReady(): Boolean;
  53507. /** Sets Ready Status. */
  53508. set ready(value: boolean);
  53509. /** Gets the debugMesh */
  53510. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53511. /** Sets the debugMesh */
  53512. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53513. /** Gets the displayMode */
  53514. get displayMode(): number;
  53515. /** Sets the displayMode */
  53516. set displayMode(value: number);
  53517. /**
  53518. * Creates a new SkeletonViewer
  53519. * @param skeleton defines the skeleton to render
  53520. * @param mesh defines the mesh attached to the skeleton
  53521. * @param scene defines the hosting scene
  53522. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53523. * @param renderingGroupId defines the rendering group id to use with the viewer
  53524. * @param options All of the extra constructor options for the SkeletonViewer
  53525. */
  53526. constructor(
  53527. /** defines the skeleton to render */
  53528. skeleton: Skeleton,
  53529. /** defines the mesh attached to the skeleton */
  53530. mesh: AbstractMesh,
  53531. /** The Scene scope*/
  53532. scene: Scene,
  53533. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53534. autoUpdateBonesMatrices?: boolean,
  53535. /** defines the rendering group id to use with the viewer */
  53536. renderingGroupId?: number,
  53537. /** is the options for the viewer */
  53538. options?: Partial<ISkeletonViewerOptions>);
  53539. /** The Dynamic bindings for the update functions */
  53540. private _bindObs;
  53541. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53542. update(): void;
  53543. /** Gets or sets a boolean indicating if the viewer is enabled */
  53544. set isEnabled(value: boolean);
  53545. get isEnabled(): boolean;
  53546. private _getBonePosition;
  53547. private _getLinesForBonesWithLength;
  53548. private _getLinesForBonesNoLength;
  53549. /** function to revert the mesh and scene back to the initial state. */
  53550. private _revert;
  53551. /** function to build and bind sphere joint points and spur bone representations. */
  53552. private _buildSpheresAndSpurs;
  53553. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53554. private _displayLinesUpdate;
  53555. /** Changes the displayMode of the skeleton viewer
  53556. * @param mode The displayMode numerical value
  53557. */
  53558. changeDisplayMode(mode: number): void;
  53559. /** Changes the displayMode of the skeleton viewer
  53560. * @param option String of the option name
  53561. * @param value The numerical option value
  53562. */
  53563. changeDisplayOptions(option: string, value: number): void;
  53564. /** Release associated resources */
  53565. dispose(): void;
  53566. }
  53567. }
  53568. declare module "babylonjs/Debug/index" {
  53569. export * from "babylonjs/Debug/axesViewer";
  53570. export * from "babylonjs/Debug/boneAxesViewer";
  53571. export * from "babylonjs/Debug/debugLayer";
  53572. export * from "babylonjs/Debug/physicsViewer";
  53573. export * from "babylonjs/Debug/rayHelper";
  53574. export * from "babylonjs/Debug/skeletonViewer";
  53575. export * from "babylonjs/Debug/ISkeletonViewer";
  53576. }
  53577. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53578. /**
  53579. * Enum for Device Types
  53580. */
  53581. export enum DeviceType {
  53582. /** Generic */
  53583. Generic = 0,
  53584. /** Keyboard */
  53585. Keyboard = 1,
  53586. /** Mouse */
  53587. Mouse = 2,
  53588. /** Touch Pointers */
  53589. Touch = 3,
  53590. /** PS4 Dual Shock */
  53591. DualShock = 4,
  53592. /** Xbox */
  53593. Xbox = 5,
  53594. /** Switch Controller */
  53595. Switch = 6
  53596. }
  53597. /**
  53598. * Enum for All Pointers (Touch/Mouse)
  53599. */
  53600. export enum PointerInput {
  53601. /** Horizontal Axis */
  53602. Horizontal = 0,
  53603. /** Vertical Axis */
  53604. Vertical = 1,
  53605. /** Left Click or Touch */
  53606. LeftClick = 2,
  53607. /** Middle Click */
  53608. MiddleClick = 3,
  53609. /** Right Click */
  53610. RightClick = 4,
  53611. /** Browser Back */
  53612. BrowserBack = 5,
  53613. /** Browser Forward */
  53614. BrowserForward = 6
  53615. }
  53616. /**
  53617. * Enum for Dual Shock Gamepad
  53618. */
  53619. export enum DualShockInput {
  53620. /** Cross */
  53621. Cross = 0,
  53622. /** Circle */
  53623. Circle = 1,
  53624. /** Square */
  53625. Square = 2,
  53626. /** Triangle */
  53627. Triangle = 3,
  53628. /** L1 */
  53629. L1 = 4,
  53630. /** R1 */
  53631. R1 = 5,
  53632. /** L2 */
  53633. L2 = 6,
  53634. /** R2 */
  53635. R2 = 7,
  53636. /** Share */
  53637. Share = 8,
  53638. /** Options */
  53639. Options = 9,
  53640. /** L3 */
  53641. L3 = 10,
  53642. /** R3 */
  53643. R3 = 11,
  53644. /** DPadUp */
  53645. DPadUp = 12,
  53646. /** DPadDown */
  53647. DPadDown = 13,
  53648. /** DPadLeft */
  53649. DPadLeft = 14,
  53650. /** DRight */
  53651. DPadRight = 15,
  53652. /** Home */
  53653. Home = 16,
  53654. /** TouchPad */
  53655. TouchPad = 17,
  53656. /** LStickXAxis */
  53657. LStickXAxis = 18,
  53658. /** LStickYAxis */
  53659. LStickYAxis = 19,
  53660. /** RStickXAxis */
  53661. RStickXAxis = 20,
  53662. /** RStickYAxis */
  53663. RStickYAxis = 21
  53664. }
  53665. /**
  53666. * Enum for Xbox Gamepad
  53667. */
  53668. export enum XboxInput {
  53669. /** A */
  53670. A = 0,
  53671. /** B */
  53672. B = 1,
  53673. /** X */
  53674. X = 2,
  53675. /** Y */
  53676. Y = 3,
  53677. /** LB */
  53678. LB = 4,
  53679. /** RB */
  53680. RB = 5,
  53681. /** LT */
  53682. LT = 6,
  53683. /** RT */
  53684. RT = 7,
  53685. /** Back */
  53686. Back = 8,
  53687. /** Start */
  53688. Start = 9,
  53689. /** LS */
  53690. LS = 10,
  53691. /** RS */
  53692. RS = 11,
  53693. /** DPadUp */
  53694. DPadUp = 12,
  53695. /** DPadDown */
  53696. DPadDown = 13,
  53697. /** DPadLeft */
  53698. DPadLeft = 14,
  53699. /** DRight */
  53700. DPadRight = 15,
  53701. /** Home */
  53702. Home = 16,
  53703. /** LStickXAxis */
  53704. LStickXAxis = 17,
  53705. /** LStickYAxis */
  53706. LStickYAxis = 18,
  53707. /** RStickXAxis */
  53708. RStickXAxis = 19,
  53709. /** RStickYAxis */
  53710. RStickYAxis = 20
  53711. }
  53712. /**
  53713. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53714. */
  53715. export enum SwitchInput {
  53716. /** B */
  53717. B = 0,
  53718. /** A */
  53719. A = 1,
  53720. /** Y */
  53721. Y = 2,
  53722. /** X */
  53723. X = 3,
  53724. /** L */
  53725. L = 4,
  53726. /** R */
  53727. R = 5,
  53728. /** ZL */
  53729. ZL = 6,
  53730. /** ZR */
  53731. ZR = 7,
  53732. /** Minus */
  53733. Minus = 8,
  53734. /** Plus */
  53735. Plus = 9,
  53736. /** LS */
  53737. LS = 10,
  53738. /** RS */
  53739. RS = 11,
  53740. /** DPadUp */
  53741. DPadUp = 12,
  53742. /** DPadDown */
  53743. DPadDown = 13,
  53744. /** DPadLeft */
  53745. DPadLeft = 14,
  53746. /** DRight */
  53747. DPadRight = 15,
  53748. /** Home */
  53749. Home = 16,
  53750. /** Capture */
  53751. Capture = 17,
  53752. /** LStickXAxis */
  53753. LStickXAxis = 18,
  53754. /** LStickYAxis */
  53755. LStickYAxis = 19,
  53756. /** RStickXAxis */
  53757. RStickXAxis = 20,
  53758. /** RStickYAxis */
  53759. RStickYAxis = 21
  53760. }
  53761. }
  53762. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53763. import { Engine } from "babylonjs/Engines/engine";
  53764. import { IDisposable } from "babylonjs/scene";
  53765. import { Nullable } from "babylonjs/types";
  53766. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53767. /**
  53768. * This class will take all inputs from Keyboard, Pointer, and
  53769. * any Gamepads and provide a polling system that all devices
  53770. * will use. This class assumes that there will only be one
  53771. * pointer device and one keyboard.
  53772. */
  53773. export class DeviceInputSystem implements IDisposable {
  53774. /**
  53775. * Callback to be triggered when a device is connected
  53776. */
  53777. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53778. /**
  53779. * Callback to be triggered when a device is disconnected
  53780. */
  53781. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53782. /**
  53783. * Callback to be triggered when event driven input is updated
  53784. */
  53785. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53786. private _inputs;
  53787. private _gamepads;
  53788. private _keyboardActive;
  53789. private _pointerActive;
  53790. private _elementToAttachTo;
  53791. private _keyboardDownEvent;
  53792. private _keyboardUpEvent;
  53793. private _pointerMoveEvent;
  53794. private _pointerDownEvent;
  53795. private _pointerUpEvent;
  53796. private _gamepadConnectedEvent;
  53797. private _gamepadDisconnectedEvent;
  53798. private static _MAX_KEYCODES;
  53799. private static _MAX_POINTER_INPUTS;
  53800. private constructor();
  53801. /**
  53802. * Creates a new DeviceInputSystem instance
  53803. * @param engine Engine to pull input element from
  53804. * @returns The new instance
  53805. */
  53806. static Create(engine: Engine): DeviceInputSystem;
  53807. /**
  53808. * Checks for current device input value, given an id and input index
  53809. * @param deviceName Id of connected device
  53810. * @param inputIndex Index of device input
  53811. * @returns Current value of input
  53812. */
  53813. /**
  53814. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53815. * @param deviceType Enum specifiying device type
  53816. * @param deviceSlot "Slot" or index that device is referenced in
  53817. * @param inputIndex Id of input to be checked
  53818. * @returns Current value of input
  53819. */
  53820. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53821. /**
  53822. * Dispose of all the eventlisteners
  53823. */
  53824. dispose(): void;
  53825. /**
  53826. * Add device and inputs to device array
  53827. * @param deviceType Enum specifiying device type
  53828. * @param deviceSlot "Slot" or index that device is referenced in
  53829. * @param numberOfInputs Number of input entries to create for given device
  53830. */
  53831. private _registerDevice;
  53832. /**
  53833. * Given a specific device name, remove that device from the device map
  53834. * @param deviceType Enum specifiying device type
  53835. * @param deviceSlot "Slot" or index that device is referenced in
  53836. */
  53837. private _unregisterDevice;
  53838. /**
  53839. * Handle all actions that come from keyboard interaction
  53840. */
  53841. private _handleKeyActions;
  53842. /**
  53843. * Handle all actions that come from pointer interaction
  53844. */
  53845. private _handlePointerActions;
  53846. /**
  53847. * Handle all actions that come from gamepad interaction
  53848. */
  53849. private _handleGamepadActions;
  53850. /**
  53851. * Update all non-event based devices with each frame
  53852. * @param deviceType Enum specifiying device type
  53853. * @param deviceSlot "Slot" or index that device is referenced in
  53854. * @param inputIndex Id of input to be checked
  53855. */
  53856. private _updateDevice;
  53857. /**
  53858. * Gets DeviceType from the device name
  53859. * @param deviceName Name of Device from DeviceInputSystem
  53860. * @returns DeviceType enum value
  53861. */
  53862. private _getGamepadDeviceType;
  53863. }
  53864. }
  53865. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53866. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53867. /**
  53868. * Type to handle enforcement of inputs
  53869. */
  53870. 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;
  53871. }
  53872. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53873. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53874. import { Engine } from "babylonjs/Engines/engine";
  53875. import { IDisposable } from "babylonjs/scene";
  53876. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53877. import { Nullable } from "babylonjs/types";
  53878. import { Observable } from "babylonjs/Misc/observable";
  53879. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53880. /**
  53881. * Class that handles all input for a specific device
  53882. */
  53883. export class DeviceSource<T extends DeviceType> {
  53884. /** Type of device */
  53885. readonly deviceType: DeviceType;
  53886. /** "Slot" or index that device is referenced in */
  53887. readonly deviceSlot: number;
  53888. /**
  53889. * Observable to handle device input changes per device
  53890. */
  53891. readonly onInputChangedObservable: Observable<{
  53892. inputIndex: DeviceInput<T>;
  53893. previousState: Nullable<number>;
  53894. currentState: Nullable<number>;
  53895. }>;
  53896. private readonly _deviceInputSystem;
  53897. /**
  53898. * Default Constructor
  53899. * @param deviceInputSystem Reference to DeviceInputSystem
  53900. * @param deviceType Type of device
  53901. * @param deviceSlot "Slot" or index that device is referenced in
  53902. */
  53903. constructor(deviceInputSystem: DeviceInputSystem,
  53904. /** Type of device */
  53905. deviceType: DeviceType,
  53906. /** "Slot" or index that device is referenced in */
  53907. deviceSlot?: number);
  53908. /**
  53909. * Get input for specific input
  53910. * @param inputIndex index of specific input on device
  53911. * @returns Input value from DeviceInputSystem
  53912. */
  53913. getInput(inputIndex: DeviceInput<T>): number;
  53914. }
  53915. /**
  53916. * Class to keep track of devices
  53917. */
  53918. export class DeviceSourceManager implements IDisposable {
  53919. /**
  53920. * Observable to be triggered when before a device is connected
  53921. */
  53922. readonly onBeforeDeviceConnectedObservable: Observable<{
  53923. deviceType: DeviceType;
  53924. deviceSlot: number;
  53925. }>;
  53926. /**
  53927. * Observable to be triggered when before a device is disconnected
  53928. */
  53929. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53930. deviceType: DeviceType;
  53931. deviceSlot: number;
  53932. }>;
  53933. /**
  53934. * Observable to be triggered when after a device is connected
  53935. */
  53936. readonly onAfterDeviceConnectedObservable: Observable<{
  53937. deviceType: DeviceType;
  53938. deviceSlot: number;
  53939. }>;
  53940. /**
  53941. * Observable to be triggered when after a device is disconnected
  53942. */
  53943. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53944. deviceType: DeviceType;
  53945. deviceSlot: number;
  53946. }>;
  53947. private readonly _devices;
  53948. private readonly _firstDevice;
  53949. private readonly _deviceInputSystem;
  53950. /**
  53951. * Default Constructor
  53952. * @param engine engine to pull input element from
  53953. */
  53954. constructor(engine: Engine);
  53955. /**
  53956. * Gets a DeviceSource, given a type and slot
  53957. * @param deviceType Enum specifying device type
  53958. * @param deviceSlot "Slot" or index that device is referenced in
  53959. * @returns DeviceSource object
  53960. */
  53961. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53962. /**
  53963. * Gets an array of DeviceSource objects for a given device type
  53964. * @param deviceType Enum specifying device type
  53965. * @returns Array of DeviceSource objects
  53966. */
  53967. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53968. /**
  53969. * Dispose of DeviceInputSystem and other parts
  53970. */
  53971. dispose(): void;
  53972. /**
  53973. * Function to add device name to device list
  53974. * @param deviceType Enum specifying device type
  53975. * @param deviceSlot "Slot" or index that device is referenced in
  53976. */
  53977. private _addDevice;
  53978. /**
  53979. * Function to remove device name to device list
  53980. * @param deviceType Enum specifying device type
  53981. * @param deviceSlot "Slot" or index that device is referenced in
  53982. */
  53983. private _removeDevice;
  53984. /**
  53985. * Updates array storing first connected device of each type
  53986. * @param type Type of Device
  53987. */
  53988. private _updateFirstDevices;
  53989. }
  53990. }
  53991. declare module "babylonjs/DeviceInput/index" {
  53992. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53993. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53994. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53995. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53996. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53997. }
  53998. declare module "babylonjs/Engines/nullEngine" {
  53999. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  54000. import { Engine } from "babylonjs/Engines/engine";
  54001. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54002. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54003. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54004. import { Effect } from "babylonjs/Materials/effect";
  54005. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54006. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54007. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  54008. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54009. /**
  54010. * Options to create the null engine
  54011. */
  54012. export class NullEngineOptions {
  54013. /**
  54014. * Render width (Default: 512)
  54015. */
  54016. renderWidth: number;
  54017. /**
  54018. * Render height (Default: 256)
  54019. */
  54020. renderHeight: number;
  54021. /**
  54022. * Texture size (Default: 512)
  54023. */
  54024. textureSize: number;
  54025. /**
  54026. * If delta time between frames should be constant
  54027. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54028. */
  54029. deterministicLockstep: boolean;
  54030. /**
  54031. * Maximum about of steps between frames (Default: 4)
  54032. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54033. */
  54034. lockstepMaxSteps: number;
  54035. /**
  54036. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54037. */
  54038. useHighPrecisionMatrix?: boolean;
  54039. }
  54040. /**
  54041. * The null engine class provides support for headless version of babylon.js.
  54042. * This can be used in server side scenario or for testing purposes
  54043. */
  54044. export class NullEngine extends Engine {
  54045. private _options;
  54046. /**
  54047. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54048. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54049. * @returns true if engine is in deterministic lock step mode
  54050. */
  54051. isDeterministicLockStep(): boolean;
  54052. /**
  54053. * Gets the max steps when engine is running in deterministic lock step
  54054. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54055. * @returns the max steps
  54056. */
  54057. getLockstepMaxSteps(): number;
  54058. /**
  54059. * Gets the current hardware scaling level.
  54060. * By default the hardware scaling level is computed from the window device ratio.
  54061. * 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.
  54062. * @returns a number indicating the current hardware scaling level
  54063. */
  54064. getHardwareScalingLevel(): number;
  54065. constructor(options?: NullEngineOptions);
  54066. /**
  54067. * Creates a vertex buffer
  54068. * @param vertices the data for the vertex buffer
  54069. * @returns the new WebGL static buffer
  54070. */
  54071. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54072. /**
  54073. * Creates a new index buffer
  54074. * @param indices defines the content of the index buffer
  54075. * @param updatable defines if the index buffer must be updatable
  54076. * @returns a new webGL buffer
  54077. */
  54078. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54079. /**
  54080. * Clear the current render buffer or the current render target (if any is set up)
  54081. * @param color defines the color to use
  54082. * @param backBuffer defines if the back buffer must be cleared
  54083. * @param depth defines if the depth buffer must be cleared
  54084. * @param stencil defines if the stencil buffer must be cleared
  54085. */
  54086. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54087. /**
  54088. * Gets the current render width
  54089. * @param useScreen defines if screen size must be used (or the current render target if any)
  54090. * @returns a number defining the current render width
  54091. */
  54092. getRenderWidth(useScreen?: boolean): number;
  54093. /**
  54094. * Gets the current render height
  54095. * @param useScreen defines if screen size must be used (or the current render target if any)
  54096. * @returns a number defining the current render height
  54097. */
  54098. getRenderHeight(useScreen?: boolean): number;
  54099. /**
  54100. * Set the WebGL's viewport
  54101. * @param viewport defines the viewport element to be used
  54102. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54103. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54104. */
  54105. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54106. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54107. /**
  54108. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54109. * @param pipelineContext defines the pipeline context to use
  54110. * @param uniformsNames defines the list of uniform names
  54111. * @returns an array of webGL uniform locations
  54112. */
  54113. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54114. /**
  54115. * Gets the lsit of active attributes for a given webGL program
  54116. * @param pipelineContext defines the pipeline context to use
  54117. * @param attributesNames defines the list of attribute names to get
  54118. * @returns an array of indices indicating the offset of each attribute
  54119. */
  54120. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54121. /**
  54122. * Binds an effect to the webGL context
  54123. * @param effect defines the effect to bind
  54124. */
  54125. bindSamplers(effect: Effect): void;
  54126. /**
  54127. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54128. * @param effect defines the effect to activate
  54129. */
  54130. enableEffect(effect: Effect): void;
  54131. /**
  54132. * Set various states to the webGL context
  54133. * @param culling defines backface culling state
  54134. * @param zOffset defines the value to apply to zOffset (0 by default)
  54135. * @param force defines if states must be applied even if cache is up to date
  54136. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54137. */
  54138. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54139. /**
  54140. * Set the value of an uniform to an array of int32
  54141. * @param uniform defines the webGL uniform location where to store the value
  54142. * @param array defines the array of int32 to store
  54143. */
  54144. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54145. /**
  54146. * Set the value of an uniform to an array of int32 (stored as vec2)
  54147. * @param uniform defines the webGL uniform location where to store the value
  54148. * @param array defines the array of int32 to store
  54149. */
  54150. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54151. /**
  54152. * Set the value of an uniform to an array of int32 (stored as vec3)
  54153. * @param uniform defines the webGL uniform location where to store the value
  54154. * @param array defines the array of int32 to store
  54155. */
  54156. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54157. /**
  54158. * Set the value of an uniform to an array of int32 (stored as vec4)
  54159. * @param uniform defines the webGL uniform location where to store the value
  54160. * @param array defines the array of int32 to store
  54161. */
  54162. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54163. /**
  54164. * Set the value of an uniform to an array of float32
  54165. * @param uniform defines the webGL uniform location where to store the value
  54166. * @param array defines the array of float32 to store
  54167. */
  54168. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54169. /**
  54170. * Set the value of an uniform to an array of float32 (stored as vec2)
  54171. * @param uniform defines the webGL uniform location where to store the value
  54172. * @param array defines the array of float32 to store
  54173. */
  54174. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54175. /**
  54176. * Set the value of an uniform to an array of float32 (stored as vec3)
  54177. * @param uniform defines the webGL uniform location where to store the value
  54178. * @param array defines the array of float32 to store
  54179. */
  54180. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54181. /**
  54182. * Set the value of an uniform to an array of float32 (stored as vec4)
  54183. * @param uniform defines the webGL uniform location where to store the value
  54184. * @param array defines the array of float32 to store
  54185. */
  54186. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54187. /**
  54188. * Set the value of an uniform to an array of number
  54189. * @param uniform defines the webGL uniform location where to store the value
  54190. * @param array defines the array of number to store
  54191. */
  54192. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54193. /**
  54194. * Set the value of an uniform to an array of number (stored as vec2)
  54195. * @param uniform defines the webGL uniform location where to store the value
  54196. * @param array defines the array of number to store
  54197. */
  54198. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54199. /**
  54200. * Set the value of an uniform to an array of number (stored as vec3)
  54201. * @param uniform defines the webGL uniform location where to store the value
  54202. * @param array defines the array of number to store
  54203. */
  54204. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54205. /**
  54206. * Set the value of an uniform to an array of number (stored as vec4)
  54207. * @param uniform defines the webGL uniform location where to store the value
  54208. * @param array defines the array of number to store
  54209. */
  54210. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54211. /**
  54212. * Set the value of an uniform to an array of float32 (stored as matrices)
  54213. * @param uniform defines the webGL uniform location where to store the value
  54214. * @param matrices defines the array of float32 to store
  54215. */
  54216. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54217. /**
  54218. * Set the value of an uniform to a matrix (3x3)
  54219. * @param uniform defines the webGL uniform location where to store the value
  54220. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54221. */
  54222. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54223. /**
  54224. * Set the value of an uniform to a matrix (2x2)
  54225. * @param uniform defines the webGL uniform location where to store the value
  54226. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54227. */
  54228. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54229. /**
  54230. * Set the value of an uniform to a number (float)
  54231. * @param uniform defines the webGL uniform location where to store the value
  54232. * @param value defines the float number to store
  54233. */
  54234. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54235. /**
  54236. * Set the value of an uniform to a vec2
  54237. * @param uniform defines the webGL uniform location where to store the value
  54238. * @param x defines the 1st component of the value
  54239. * @param y defines the 2nd component of the value
  54240. */
  54241. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54242. /**
  54243. * Set the value of an uniform to a vec3
  54244. * @param uniform defines the webGL uniform location where to store the value
  54245. * @param x defines the 1st component of the value
  54246. * @param y defines the 2nd component of the value
  54247. * @param z defines the 3rd component of the value
  54248. */
  54249. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54250. /**
  54251. * Set the value of an uniform to a boolean
  54252. * @param uniform defines the webGL uniform location where to store the value
  54253. * @param bool defines the boolean to store
  54254. */
  54255. setBool(uniform: WebGLUniformLocation, bool: number): void;
  54256. /**
  54257. * Set the value of an uniform to a vec4
  54258. * @param uniform defines the webGL uniform location where to store the value
  54259. * @param x defines the 1st component of the value
  54260. * @param y defines the 2nd component of the value
  54261. * @param z defines the 3rd component of the value
  54262. * @param w defines the 4th component of the value
  54263. */
  54264. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54265. /**
  54266. * Sets the current alpha mode
  54267. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54268. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54269. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54270. */
  54271. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54272. /**
  54273. * Bind webGl buffers directly to the webGL context
  54274. * @param vertexBuffers defines the vertex buffer to bind
  54275. * @param indexBuffer defines the index buffer to bind
  54276. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54277. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54278. * @param effect defines the effect associated with the vertex buffer
  54279. */
  54280. bindBuffers(vertexBuffers: {
  54281. [key: string]: VertexBuffer;
  54282. }, indexBuffer: DataBuffer, effect: Effect): void;
  54283. /**
  54284. * Force the entire cache to be cleared
  54285. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54286. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54287. */
  54288. wipeCaches(bruteForce?: boolean): void;
  54289. /**
  54290. * Send a draw order
  54291. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54292. * @param indexStart defines the starting index
  54293. * @param indexCount defines the number of index to draw
  54294. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54295. */
  54296. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54297. /**
  54298. * Draw a list of indexed primitives
  54299. * @param fillMode defines the primitive to use
  54300. * @param indexStart defines the starting index
  54301. * @param indexCount defines the number of index to draw
  54302. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54303. */
  54304. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54305. /**
  54306. * Draw a list of unindexed primitives
  54307. * @param fillMode defines the primitive to use
  54308. * @param verticesStart defines the index of first vertex to draw
  54309. * @param verticesCount defines the count of vertices to draw
  54310. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54311. */
  54312. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54313. /** @hidden */
  54314. _createTexture(): WebGLTexture;
  54315. /** @hidden */
  54316. _releaseTexture(texture: InternalTexture): void;
  54317. /**
  54318. * Usually called from Texture.ts.
  54319. * Passed information to create a WebGLTexture
  54320. * @param urlArg defines a value which contains one of the following:
  54321. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54322. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54323. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54324. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54325. * @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)
  54326. * @param scene needed for loading to the correct scene
  54327. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54328. * @param onLoad optional callback to be called upon successful completion
  54329. * @param onError optional callback to be called upon failure
  54330. * @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
  54331. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54332. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54333. * @param forcedExtension defines the extension to use to pick the right loader
  54334. * @param mimeType defines an optional mime type
  54335. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54336. */
  54337. 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;
  54338. /**
  54339. * Creates a new render target texture
  54340. * @param size defines the size of the texture
  54341. * @param options defines the options used to create the texture
  54342. * @returns a new render target texture stored in an InternalTexture
  54343. */
  54344. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54345. /**
  54346. * Update the sampling mode of a given texture
  54347. * @param samplingMode defines the required sampling mode
  54348. * @param texture defines the texture to update
  54349. */
  54350. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54351. /**
  54352. * Binds the frame buffer to the specified texture.
  54353. * @param texture The texture to render to or null for the default canvas
  54354. * @param faceIndex The face of the texture to render to in case of cube texture
  54355. * @param requiredWidth The width of the target to render to
  54356. * @param requiredHeight The height of the target to render to
  54357. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54358. * @param lodLevel defines le lod level to bind to the frame buffer
  54359. */
  54360. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54361. /**
  54362. * Unbind the current render target texture from the webGL context
  54363. * @param texture defines the render target texture to unbind
  54364. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54365. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54366. */
  54367. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54368. /**
  54369. * Creates a dynamic vertex buffer
  54370. * @param vertices the data for the dynamic vertex buffer
  54371. * @returns the new WebGL dynamic buffer
  54372. */
  54373. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54374. /**
  54375. * Update the content of a dynamic texture
  54376. * @param texture defines the texture to update
  54377. * @param canvas defines the canvas containing the source
  54378. * @param invertY defines if data must be stored with Y axis inverted
  54379. * @param premulAlpha defines if alpha is stored as premultiplied
  54380. * @param format defines the format of the data
  54381. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54382. */
  54383. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54384. /**
  54385. * Gets a boolean indicating if all created effects are ready
  54386. * @returns true if all effects are ready
  54387. */
  54388. areAllEffectsReady(): boolean;
  54389. /**
  54390. * @hidden
  54391. * Get the current error code of the webGL context
  54392. * @returns the error code
  54393. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54394. */
  54395. getError(): number;
  54396. /** @hidden */
  54397. _getUnpackAlignement(): number;
  54398. /** @hidden */
  54399. _unpackFlipY(value: boolean): void;
  54400. /**
  54401. * Update a dynamic index buffer
  54402. * @param indexBuffer defines the target index buffer
  54403. * @param indices defines the data to update
  54404. * @param offset defines the offset in the target index buffer where update should start
  54405. */
  54406. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54407. /**
  54408. * Updates a dynamic vertex buffer.
  54409. * @param vertexBuffer the vertex buffer to update
  54410. * @param vertices the data used to update the vertex buffer
  54411. * @param byteOffset the byte offset of the data (optional)
  54412. * @param byteLength the byte length of the data (optional)
  54413. */
  54414. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54415. /** @hidden */
  54416. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54417. /** @hidden */
  54418. _bindTexture(channel: number, texture: InternalTexture): void;
  54419. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54420. /**
  54421. * 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
  54422. */
  54423. releaseEffects(): void;
  54424. displayLoadingUI(): void;
  54425. hideLoadingUI(): void;
  54426. /** @hidden */
  54427. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54428. /** @hidden */
  54429. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54430. /** @hidden */
  54431. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54432. /** @hidden */
  54433. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54434. }
  54435. }
  54436. declare module "babylonjs/Instrumentation/timeToken" {
  54437. import { Nullable } from "babylonjs/types";
  54438. /**
  54439. * @hidden
  54440. **/
  54441. export class _TimeToken {
  54442. _startTimeQuery: Nullable<WebGLQuery>;
  54443. _endTimeQuery: Nullable<WebGLQuery>;
  54444. _timeElapsedQuery: Nullable<WebGLQuery>;
  54445. _timeElapsedQueryEnded: boolean;
  54446. }
  54447. }
  54448. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54449. import { Nullable, int } from "babylonjs/types";
  54450. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54451. /** @hidden */
  54452. export class _OcclusionDataStorage {
  54453. /** @hidden */
  54454. occlusionInternalRetryCounter: number;
  54455. /** @hidden */
  54456. isOcclusionQueryInProgress: boolean;
  54457. /** @hidden */
  54458. isOccluded: boolean;
  54459. /** @hidden */
  54460. occlusionRetryCount: number;
  54461. /** @hidden */
  54462. occlusionType: number;
  54463. /** @hidden */
  54464. occlusionQueryAlgorithmType: number;
  54465. }
  54466. module "babylonjs/Engines/engine" {
  54467. interface Engine {
  54468. /**
  54469. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54470. * @return the new query
  54471. */
  54472. createQuery(): WebGLQuery;
  54473. /**
  54474. * Delete and release a webGL query
  54475. * @param query defines the query to delete
  54476. * @return the current engine
  54477. */
  54478. deleteQuery(query: WebGLQuery): Engine;
  54479. /**
  54480. * Check if a given query has resolved and got its value
  54481. * @param query defines the query to check
  54482. * @returns true if the query got its value
  54483. */
  54484. isQueryResultAvailable(query: WebGLQuery): boolean;
  54485. /**
  54486. * Gets the value of a given query
  54487. * @param query defines the query to check
  54488. * @returns the value of the query
  54489. */
  54490. getQueryResult(query: WebGLQuery): number;
  54491. /**
  54492. * Initiates an occlusion query
  54493. * @param algorithmType defines the algorithm to use
  54494. * @param query defines the query to use
  54495. * @returns the current engine
  54496. * @see https://doc.babylonjs.com/features/occlusionquery
  54497. */
  54498. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54499. /**
  54500. * Ends an occlusion query
  54501. * @see https://doc.babylonjs.com/features/occlusionquery
  54502. * @param algorithmType defines the algorithm to use
  54503. * @returns the current engine
  54504. */
  54505. endOcclusionQuery(algorithmType: number): Engine;
  54506. /**
  54507. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54508. * Please note that only one query can be issued at a time
  54509. * @returns a time token used to track the time span
  54510. */
  54511. startTimeQuery(): Nullable<_TimeToken>;
  54512. /**
  54513. * Ends a time query
  54514. * @param token defines the token used to measure the time span
  54515. * @returns the time spent (in ns)
  54516. */
  54517. endTimeQuery(token: _TimeToken): int;
  54518. /** @hidden */
  54519. _currentNonTimestampToken: Nullable<_TimeToken>;
  54520. /** @hidden */
  54521. _createTimeQuery(): WebGLQuery;
  54522. /** @hidden */
  54523. _deleteTimeQuery(query: WebGLQuery): void;
  54524. /** @hidden */
  54525. _getGlAlgorithmType(algorithmType: number): number;
  54526. /** @hidden */
  54527. _getTimeQueryResult(query: WebGLQuery): any;
  54528. /** @hidden */
  54529. _getTimeQueryAvailability(query: WebGLQuery): any;
  54530. }
  54531. }
  54532. module "babylonjs/Meshes/abstractMesh" {
  54533. interface AbstractMesh {
  54534. /**
  54535. * Backing filed
  54536. * @hidden
  54537. */
  54538. __occlusionDataStorage: _OcclusionDataStorage;
  54539. /**
  54540. * Access property
  54541. * @hidden
  54542. */
  54543. _occlusionDataStorage: _OcclusionDataStorage;
  54544. /**
  54545. * 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.
  54546. * The default value is -1 which means don't break the query and wait till the result
  54547. * @see https://doc.babylonjs.com/features/occlusionquery
  54548. */
  54549. occlusionRetryCount: number;
  54550. /**
  54551. * 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:
  54552. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54553. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54554. * * 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.
  54555. * @see https://doc.babylonjs.com/features/occlusionquery
  54556. */
  54557. occlusionType: number;
  54558. /**
  54559. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54560. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54561. * * 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.
  54562. * @see https://doc.babylonjs.com/features/occlusionquery
  54563. */
  54564. occlusionQueryAlgorithmType: number;
  54565. /**
  54566. * 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
  54567. * @see https://doc.babylonjs.com/features/occlusionquery
  54568. */
  54569. isOccluded: boolean;
  54570. /**
  54571. * Flag to check the progress status of the query
  54572. * @see https://doc.babylonjs.com/features/occlusionquery
  54573. */
  54574. isOcclusionQueryInProgress: boolean;
  54575. }
  54576. }
  54577. }
  54578. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54579. import { Nullable } from "babylonjs/types";
  54580. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54581. /** @hidden */
  54582. export var _forceTransformFeedbackToBundle: boolean;
  54583. module "babylonjs/Engines/engine" {
  54584. interface Engine {
  54585. /**
  54586. * Creates a webGL transform feedback object
  54587. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54588. * @returns the webGL transform feedback object
  54589. */
  54590. createTransformFeedback(): WebGLTransformFeedback;
  54591. /**
  54592. * Delete a webGL transform feedback object
  54593. * @param value defines the webGL transform feedback object to delete
  54594. */
  54595. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54596. /**
  54597. * Bind a webGL transform feedback object to the webgl context
  54598. * @param value defines the webGL transform feedback object to bind
  54599. */
  54600. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54601. /**
  54602. * Begins a transform feedback operation
  54603. * @param usePoints defines if points or triangles must be used
  54604. */
  54605. beginTransformFeedback(usePoints: boolean): void;
  54606. /**
  54607. * Ends a transform feedback operation
  54608. */
  54609. endTransformFeedback(): void;
  54610. /**
  54611. * Specify the varyings to use with transform feedback
  54612. * @param program defines the associated webGL program
  54613. * @param value defines the list of strings representing the varying names
  54614. */
  54615. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54616. /**
  54617. * Bind a webGL buffer for a transform feedback operation
  54618. * @param value defines the webGL buffer to bind
  54619. */
  54620. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54621. }
  54622. }
  54623. }
  54624. declare module "babylonjs/Engines/Extensions/engine.views" {
  54625. import { Camera } from "babylonjs/Cameras/camera";
  54626. import { Nullable } from "babylonjs/types";
  54627. /**
  54628. * Class used to define an additional view for the engine
  54629. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54630. */
  54631. export class EngineView {
  54632. /** Defines the canvas where to render the view */
  54633. target: HTMLCanvasElement;
  54634. /** Defines an optional camera used to render the view (will use active camera else) */
  54635. camera?: Camera;
  54636. }
  54637. module "babylonjs/Engines/engine" {
  54638. interface Engine {
  54639. /**
  54640. * Gets or sets the HTML element to use for attaching events
  54641. */
  54642. inputElement: Nullable<HTMLElement>;
  54643. /**
  54644. * Gets the current engine view
  54645. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54646. */
  54647. activeView: Nullable<EngineView>;
  54648. /** Gets or sets the list of views */
  54649. views: EngineView[];
  54650. /**
  54651. * Register a new child canvas
  54652. * @param canvas defines the canvas to register
  54653. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54654. * @returns the associated view
  54655. */
  54656. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54657. /**
  54658. * Remove a registered child canvas
  54659. * @param canvas defines the canvas to remove
  54660. * @returns the current engine
  54661. */
  54662. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54663. }
  54664. }
  54665. }
  54666. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54667. import { Nullable } from "babylonjs/types";
  54668. module "babylonjs/Engines/engine" {
  54669. interface Engine {
  54670. /** @hidden */
  54671. _excludedCompressedTextures: string[];
  54672. /** @hidden */
  54673. _textureFormatInUse: string;
  54674. /**
  54675. * Gets the list of texture formats supported
  54676. */
  54677. readonly texturesSupported: Array<string>;
  54678. /**
  54679. * Gets the texture format in use
  54680. */
  54681. readonly textureFormatInUse: Nullable<string>;
  54682. /**
  54683. * Set the compressed texture extensions or file names to skip.
  54684. *
  54685. * @param skippedFiles defines the list of those texture files you want to skip
  54686. * Example: [".dds", ".env", "myfile.png"]
  54687. */
  54688. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54689. /**
  54690. * Set the compressed texture format to use, based on the formats you have, and the formats
  54691. * supported by the hardware / browser.
  54692. *
  54693. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54694. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54695. * to API arguments needed to compressed textures. This puts the burden on the container
  54696. * generator to house the arcane code for determining these for current & future formats.
  54697. *
  54698. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54699. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54700. *
  54701. * Note: The result of this call is not taken into account when a texture is base64.
  54702. *
  54703. * @param formatsAvailable defines the list of those format families you have created
  54704. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54705. *
  54706. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54707. * @returns The extension selected.
  54708. */
  54709. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54710. }
  54711. }
  54712. }
  54713. declare module "babylonjs/Engines/Extensions/index" {
  54714. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54715. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54716. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54717. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54718. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54719. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54720. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54721. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54722. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54723. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54724. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54725. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54726. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54727. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54728. export * from "babylonjs/Engines/Extensions/engine.views";
  54729. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54730. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54731. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54732. }
  54733. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54734. import { Nullable } from "babylonjs/types";
  54735. /**
  54736. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54737. */
  54738. export interface CubeMapInfo {
  54739. /**
  54740. * The pixel array for the front face.
  54741. * This is stored in format, left to right, up to down format.
  54742. */
  54743. front: Nullable<ArrayBufferView>;
  54744. /**
  54745. * The pixel array for the back face.
  54746. * This is stored in format, left to right, up to down format.
  54747. */
  54748. back: Nullable<ArrayBufferView>;
  54749. /**
  54750. * The pixel array for the left face.
  54751. * This is stored in format, left to right, up to down format.
  54752. */
  54753. left: Nullable<ArrayBufferView>;
  54754. /**
  54755. * The pixel array for the right face.
  54756. * This is stored in format, left to right, up to down format.
  54757. */
  54758. right: Nullable<ArrayBufferView>;
  54759. /**
  54760. * The pixel array for the up face.
  54761. * This is stored in format, left to right, up to down format.
  54762. */
  54763. up: Nullable<ArrayBufferView>;
  54764. /**
  54765. * The pixel array for the down face.
  54766. * This is stored in format, left to right, up to down format.
  54767. */
  54768. down: Nullable<ArrayBufferView>;
  54769. /**
  54770. * The size of the cubemap stored.
  54771. *
  54772. * Each faces will be size * size pixels.
  54773. */
  54774. size: number;
  54775. /**
  54776. * The format of the texture.
  54777. *
  54778. * RGBA, RGB.
  54779. */
  54780. format: number;
  54781. /**
  54782. * The type of the texture data.
  54783. *
  54784. * UNSIGNED_INT, FLOAT.
  54785. */
  54786. type: number;
  54787. /**
  54788. * Specifies whether the texture is in gamma space.
  54789. */
  54790. gammaSpace: boolean;
  54791. }
  54792. /**
  54793. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54794. */
  54795. export class PanoramaToCubeMapTools {
  54796. private static FACE_LEFT;
  54797. private static FACE_RIGHT;
  54798. private static FACE_FRONT;
  54799. private static FACE_BACK;
  54800. private static FACE_DOWN;
  54801. private static FACE_UP;
  54802. /**
  54803. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54804. *
  54805. * @param float32Array The source data.
  54806. * @param inputWidth The width of the input panorama.
  54807. * @param inputHeight The height of the input panorama.
  54808. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54809. * @return The cubemap data
  54810. */
  54811. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54812. private static CreateCubemapTexture;
  54813. private static CalcProjectionSpherical;
  54814. }
  54815. }
  54816. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54817. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54819. import { Nullable } from "babylonjs/types";
  54820. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54821. /**
  54822. * Helper class dealing with the extraction of spherical polynomial dataArray
  54823. * from a cube map.
  54824. */
  54825. export class CubeMapToSphericalPolynomialTools {
  54826. private static FileFaces;
  54827. /**
  54828. * Converts a texture to the according Spherical Polynomial data.
  54829. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54830. *
  54831. * @param texture The texture to extract the information from.
  54832. * @return The Spherical Polynomial data.
  54833. */
  54834. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54835. /**
  54836. * Converts a cubemap to the according Spherical Polynomial data.
  54837. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54838. *
  54839. * @param cubeInfo The Cube map to extract the information from.
  54840. * @return The Spherical Polynomial data.
  54841. */
  54842. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54843. }
  54844. }
  54845. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54846. import { Nullable } from "babylonjs/types";
  54847. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54848. module "babylonjs/Materials/Textures/baseTexture" {
  54849. interface BaseTexture {
  54850. /**
  54851. * Get the polynomial representation of the texture data.
  54852. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54853. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54854. */
  54855. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54856. }
  54857. }
  54858. }
  54859. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54860. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54861. /** @hidden */
  54862. export var rgbdEncodePixelShader: {
  54863. name: string;
  54864. shader: string;
  54865. };
  54866. }
  54867. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54868. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54869. /** @hidden */
  54870. export var rgbdDecodePixelShader: {
  54871. name: string;
  54872. shader: string;
  54873. };
  54874. }
  54875. declare module "babylonjs/Misc/environmentTextureTools" {
  54876. import { Nullable } from "babylonjs/types";
  54877. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54878. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54880. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54881. import "babylonjs/Engines/Extensions/engine.readTexture";
  54882. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54883. import "babylonjs/Shaders/rgbdEncode.fragment";
  54884. import "babylonjs/Shaders/rgbdDecode.fragment";
  54885. /**
  54886. * Raw texture data and descriptor sufficient for WebGL texture upload
  54887. */
  54888. export interface EnvironmentTextureInfo {
  54889. /**
  54890. * Version of the environment map
  54891. */
  54892. version: number;
  54893. /**
  54894. * Width of image
  54895. */
  54896. width: number;
  54897. /**
  54898. * Irradiance information stored in the file.
  54899. */
  54900. irradiance: any;
  54901. /**
  54902. * Specular information stored in the file.
  54903. */
  54904. specular: any;
  54905. }
  54906. /**
  54907. * Defines One Image in the file. It requires only the position in the file
  54908. * as well as the length.
  54909. */
  54910. interface BufferImageData {
  54911. /**
  54912. * Length of the image data.
  54913. */
  54914. length: number;
  54915. /**
  54916. * Position of the data from the null terminator delimiting the end of the JSON.
  54917. */
  54918. position: number;
  54919. }
  54920. /**
  54921. * Defines the specular data enclosed in the file.
  54922. * This corresponds to the version 1 of the data.
  54923. */
  54924. export interface EnvironmentTextureSpecularInfoV1 {
  54925. /**
  54926. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54927. */
  54928. specularDataPosition?: number;
  54929. /**
  54930. * This contains all the images data needed to reconstruct the cubemap.
  54931. */
  54932. mipmaps: Array<BufferImageData>;
  54933. /**
  54934. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54935. */
  54936. lodGenerationScale: number;
  54937. }
  54938. /**
  54939. * Sets of helpers addressing the serialization and deserialization of environment texture
  54940. * stored in a BabylonJS env file.
  54941. * Those files are usually stored as .env files.
  54942. */
  54943. export class EnvironmentTextureTools {
  54944. /**
  54945. * Magic number identifying the env file.
  54946. */
  54947. private static _MagicBytes;
  54948. /**
  54949. * Gets the environment info from an env file.
  54950. * @param data The array buffer containing the .env bytes.
  54951. * @returns the environment file info (the json header) if successfully parsed.
  54952. */
  54953. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54954. /**
  54955. * Creates an environment texture from a loaded cube texture.
  54956. * @param texture defines the cube texture to convert in env file
  54957. * @return a promise containing the environment data if succesfull.
  54958. */
  54959. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54960. /**
  54961. * Creates a JSON representation of the spherical data.
  54962. * @param texture defines the texture containing the polynomials
  54963. * @return the JSON representation of the spherical info
  54964. */
  54965. private static _CreateEnvTextureIrradiance;
  54966. /**
  54967. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54968. * @param data the image data
  54969. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54970. * @return the views described by info providing access to the underlying buffer
  54971. */
  54972. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54973. /**
  54974. * Uploads the texture info contained in the env file to the GPU.
  54975. * @param texture defines the internal texture to upload to
  54976. * @param data defines the data to load
  54977. * @param info defines the texture info retrieved through the GetEnvInfo method
  54978. * @returns a promise
  54979. */
  54980. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54981. private static _OnImageReadyAsync;
  54982. /**
  54983. * Uploads the levels of image data to the GPU.
  54984. * @param texture defines the internal texture to upload to
  54985. * @param imageData defines the array buffer views of image data [mipmap][face]
  54986. * @returns a promise
  54987. */
  54988. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54989. /**
  54990. * Uploads spherical polynomials information to the texture.
  54991. * @param texture defines the texture we are trying to upload the information to
  54992. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54993. */
  54994. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54995. /** @hidden */
  54996. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54997. }
  54998. }
  54999. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  55000. /**
  55001. * Class used to inline functions in shader code
  55002. */
  55003. export class ShaderCodeInliner {
  55004. private static readonly _RegexpFindFunctionNameAndType;
  55005. private _sourceCode;
  55006. private _functionDescr;
  55007. private _numMaxIterations;
  55008. /** Gets or sets the token used to mark the functions to inline */
  55009. inlineToken: string;
  55010. /** Gets or sets the debug mode */
  55011. debug: boolean;
  55012. /** Gets the code after the inlining process */
  55013. get code(): string;
  55014. /**
  55015. * Initializes the inliner
  55016. * @param sourceCode shader code source to inline
  55017. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55018. */
  55019. constructor(sourceCode: string, numMaxIterations?: number);
  55020. /**
  55021. * Start the processing of the shader code
  55022. */
  55023. processCode(): void;
  55024. private _collectFunctions;
  55025. private _processInlining;
  55026. private _extractBetweenMarkers;
  55027. private _skipWhitespaces;
  55028. private _removeComments;
  55029. private _replaceFunctionCallsByCode;
  55030. private _findBackward;
  55031. private _escapeRegExp;
  55032. private _replaceNames;
  55033. }
  55034. }
  55035. declare module "babylonjs/Engines/nativeEngine" {
  55036. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55037. import { Engine } from "babylonjs/Engines/engine";
  55038. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55040. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55041. import { Effect } from "babylonjs/Materials/effect";
  55042. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55043. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55044. import { IColor4Like } from "babylonjs/Maths/math.like";
  55045. import { Scene } from "babylonjs/scene";
  55046. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55047. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55048. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55049. /**
  55050. * Container for accessors for natively-stored mesh data buffers.
  55051. */
  55052. class NativeDataBuffer extends DataBuffer {
  55053. /**
  55054. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55055. */
  55056. nativeIndexBuffer?: any;
  55057. /**
  55058. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55059. */
  55060. nativeVertexBuffer?: any;
  55061. }
  55062. /** @hidden */
  55063. class NativeTexture extends InternalTexture {
  55064. getInternalTexture(): InternalTexture;
  55065. getViewCount(): number;
  55066. }
  55067. /** @hidden */
  55068. export class NativeEngine extends Engine {
  55069. private readonly _native;
  55070. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55071. private readonly INVALID_HANDLE;
  55072. private _boundBuffersVertexArray;
  55073. getHardwareScalingLevel(): number;
  55074. constructor();
  55075. dispose(): void;
  55076. /**
  55077. * Can be used to override the current requestAnimationFrame requester.
  55078. * @hidden
  55079. */
  55080. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55081. /**
  55082. * Override default engine behavior.
  55083. * @param color
  55084. * @param backBuffer
  55085. * @param depth
  55086. * @param stencil
  55087. */
  55088. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55089. /**
  55090. * Gets host document
  55091. * @returns the host document object
  55092. */
  55093. getHostDocument(): Nullable<Document>;
  55094. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55095. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55096. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55097. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55098. [key: string]: VertexBuffer;
  55099. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55100. bindBuffers(vertexBuffers: {
  55101. [key: string]: VertexBuffer;
  55102. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55103. recordVertexArrayObject(vertexBuffers: {
  55104. [key: string]: VertexBuffer;
  55105. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55106. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55107. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55108. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55109. /**
  55110. * Draw a list of indexed primitives
  55111. * @param fillMode defines the primitive to use
  55112. * @param indexStart defines the starting index
  55113. * @param indexCount defines the number of index to draw
  55114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55115. */
  55116. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55117. /**
  55118. * Draw a list of unindexed primitives
  55119. * @param fillMode defines the primitive to use
  55120. * @param verticesStart defines the index of first vertex to draw
  55121. * @param verticesCount defines the count of vertices to draw
  55122. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55123. */
  55124. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55125. createPipelineContext(): IPipelineContext;
  55126. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55127. /** @hidden */
  55128. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55129. /** @hidden */
  55130. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55131. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55132. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55133. protected _setProgram(program: WebGLProgram): void;
  55134. _releaseEffect(effect: Effect): void;
  55135. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55136. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55137. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55138. bindSamplers(effect: Effect): void;
  55139. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55140. getRenderWidth(useScreen?: boolean): number;
  55141. getRenderHeight(useScreen?: boolean): number;
  55142. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55143. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55144. /**
  55145. * Set the z offset to apply to current rendering
  55146. * @param value defines the offset to apply
  55147. */
  55148. setZOffset(value: number): void;
  55149. /**
  55150. * Gets the current value of the zOffset
  55151. * @returns the current zOffset state
  55152. */
  55153. getZOffset(): number;
  55154. /**
  55155. * Enable or disable depth buffering
  55156. * @param enable defines the state to set
  55157. */
  55158. setDepthBuffer(enable: boolean): void;
  55159. /**
  55160. * Gets a boolean indicating if depth writing is enabled
  55161. * @returns the current depth writing state
  55162. */
  55163. getDepthWrite(): boolean;
  55164. /**
  55165. * Enable or disable depth writing
  55166. * @param enable defines the state to set
  55167. */
  55168. setDepthWrite(enable: boolean): void;
  55169. /**
  55170. * Enable or disable color writing
  55171. * @param enable defines the state to set
  55172. */
  55173. setColorWrite(enable: boolean): void;
  55174. /**
  55175. * Gets a boolean indicating if color writing is enabled
  55176. * @returns the current color writing state
  55177. */
  55178. getColorWrite(): boolean;
  55179. /**
  55180. * Sets alpha constants used by some alpha blending modes
  55181. * @param r defines the red component
  55182. * @param g defines the green component
  55183. * @param b defines the blue component
  55184. * @param a defines the alpha component
  55185. */
  55186. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55187. /**
  55188. * Sets the current alpha mode
  55189. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55190. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55191. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55192. */
  55193. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55194. /**
  55195. * Gets the current alpha mode
  55196. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55197. * @returns the current alpha mode
  55198. */
  55199. getAlphaMode(): number;
  55200. setInt(uniform: WebGLUniformLocation, int: number): void;
  55201. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  55202. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  55203. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  55204. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  55205. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  55206. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  55207. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  55208. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  55209. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  55210. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  55211. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  55212. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  55213. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  55214. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55215. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55216. setFloat(uniform: WebGLUniformLocation, value: number): void;
  55217. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  55218. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  55219. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  55220. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  55221. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  55222. wipeCaches(bruteForce?: boolean): void;
  55223. _createTexture(): WebGLTexture;
  55224. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55225. /**
  55226. * Usually called from Texture.ts.
  55227. * Passed information to create a WebGLTexture
  55228. * @param url defines a value which contains one of the following:
  55229. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55230. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55231. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55232. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55233. * @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)
  55234. * @param scene needed for loading to the correct scene
  55235. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55236. * @param onLoad optional callback to be called upon successful completion
  55237. * @param onError optional callback to be called upon failure
  55238. * @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
  55239. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55240. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55241. * @param forcedExtension defines the extension to use to pick the right loader
  55242. * @param mimeType defines an optional mime type
  55243. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55244. */
  55245. 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;
  55246. /**
  55247. * Creates a cube texture
  55248. * @param rootUrl defines the url where the files to load is located
  55249. * @param scene defines the current scene
  55250. * @param files defines the list of files to load (1 per face)
  55251. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55252. * @param onLoad defines an optional callback raised when the texture is loaded
  55253. * @param onError defines an optional callback raised if there is an issue to load the texture
  55254. * @param format defines the format of the data
  55255. * @param forcedExtension defines the extension to use to pick the right loader
  55256. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55257. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55258. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55259. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55260. * @returns the cube texture as an InternalTexture
  55261. */
  55262. 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;
  55263. private _getSamplingFilter;
  55264. private static _GetNativeTextureFormat;
  55265. createRenderTargetTexture(size: number | {
  55266. width: number;
  55267. height: number;
  55268. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55269. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55270. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55271. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55272. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55273. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55274. /**
  55275. * Updates a dynamic vertex buffer.
  55276. * @param vertexBuffer the vertex buffer to update
  55277. * @param data the data used to update the vertex buffer
  55278. * @param byteOffset the byte offset of the data (optional)
  55279. * @param byteLength the byte length of the data (optional)
  55280. */
  55281. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55282. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55283. private _updateAnisotropicLevel;
  55284. private _getAddressMode;
  55285. /** @hidden */
  55286. _bindTexture(channel: number, texture: InternalTexture): void;
  55287. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55288. releaseEffects(): void;
  55289. /** @hidden */
  55290. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55291. /** @hidden */
  55292. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55293. /** @hidden */
  55294. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55295. /** @hidden */
  55296. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55297. }
  55298. }
  55299. declare module "babylonjs/Engines/index" {
  55300. export * from "babylonjs/Engines/constants";
  55301. export * from "babylonjs/Engines/engineCapabilities";
  55302. export * from "babylonjs/Engines/instancingAttributeInfo";
  55303. export * from "babylonjs/Engines/thinEngine";
  55304. export * from "babylonjs/Engines/engine";
  55305. export * from "babylonjs/Engines/engineStore";
  55306. export * from "babylonjs/Engines/nullEngine";
  55307. export * from "babylonjs/Engines/Extensions/index";
  55308. export * from "babylonjs/Engines/IPipelineContext";
  55309. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55310. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55311. export * from "babylonjs/Engines/nativeEngine";
  55312. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55313. export * from "babylonjs/Engines/performanceConfigurator";
  55314. }
  55315. declare module "babylonjs/Events/clipboardEvents" {
  55316. /**
  55317. * Gather the list of clipboard event types as constants.
  55318. */
  55319. export class ClipboardEventTypes {
  55320. /**
  55321. * The clipboard event is fired when a copy command is active (pressed).
  55322. */
  55323. static readonly COPY: number;
  55324. /**
  55325. * The clipboard event is fired when a cut command is active (pressed).
  55326. */
  55327. static readonly CUT: number;
  55328. /**
  55329. * The clipboard event is fired when a paste command is active (pressed).
  55330. */
  55331. static readonly PASTE: number;
  55332. }
  55333. /**
  55334. * This class is used to store clipboard related info for the onClipboardObservable event.
  55335. */
  55336. export class ClipboardInfo {
  55337. /**
  55338. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55339. */
  55340. type: number;
  55341. /**
  55342. * Defines the related dom event
  55343. */
  55344. event: ClipboardEvent;
  55345. /**
  55346. *Creates an instance of ClipboardInfo.
  55347. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55348. * @param event Defines the related dom event
  55349. */
  55350. constructor(
  55351. /**
  55352. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55353. */
  55354. type: number,
  55355. /**
  55356. * Defines the related dom event
  55357. */
  55358. event: ClipboardEvent);
  55359. /**
  55360. * Get the clipboard event's type from the keycode.
  55361. * @param keyCode Defines the keyCode for the current keyboard event.
  55362. * @return {number}
  55363. */
  55364. static GetTypeFromCharacter(keyCode: number): number;
  55365. }
  55366. }
  55367. declare module "babylonjs/Events/index" {
  55368. export * from "babylonjs/Events/keyboardEvents";
  55369. export * from "babylonjs/Events/pointerEvents";
  55370. export * from "babylonjs/Events/clipboardEvents";
  55371. }
  55372. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55373. import { Scene } from "babylonjs/scene";
  55374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55375. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55376. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55377. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55378. /**
  55379. * Google Daydream controller
  55380. */
  55381. export class DaydreamController extends WebVRController {
  55382. /**
  55383. * Base Url for the controller model.
  55384. */
  55385. static MODEL_BASE_URL: string;
  55386. /**
  55387. * File name for the controller model.
  55388. */
  55389. static MODEL_FILENAME: string;
  55390. /**
  55391. * Gamepad Id prefix used to identify Daydream Controller.
  55392. */
  55393. static readonly GAMEPAD_ID_PREFIX: string;
  55394. /**
  55395. * Creates a new DaydreamController from a gamepad
  55396. * @param vrGamepad the gamepad that the controller should be created from
  55397. */
  55398. constructor(vrGamepad: any);
  55399. /**
  55400. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55401. * @param scene scene in which to add meshes
  55402. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55403. */
  55404. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55405. /**
  55406. * Called once for each button that changed state since the last frame
  55407. * @param buttonIdx Which button index changed
  55408. * @param state New state of the button
  55409. * @param changes Which properties on the state changed since last frame
  55410. */
  55411. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55412. }
  55413. }
  55414. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55415. import { Scene } from "babylonjs/scene";
  55416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55417. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55418. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55419. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55420. /**
  55421. * Gear VR Controller
  55422. */
  55423. export class GearVRController extends WebVRController {
  55424. /**
  55425. * Base Url for the controller model.
  55426. */
  55427. static MODEL_BASE_URL: string;
  55428. /**
  55429. * File name for the controller model.
  55430. */
  55431. static MODEL_FILENAME: string;
  55432. /**
  55433. * Gamepad Id prefix used to identify this controller.
  55434. */
  55435. static readonly GAMEPAD_ID_PREFIX: string;
  55436. private readonly _buttonIndexToObservableNameMap;
  55437. /**
  55438. * Creates a new GearVRController from a gamepad
  55439. * @param vrGamepad the gamepad that the controller should be created from
  55440. */
  55441. constructor(vrGamepad: any);
  55442. /**
  55443. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55444. * @param scene scene in which to add meshes
  55445. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55446. */
  55447. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55448. /**
  55449. * Called once for each button that changed state since the last frame
  55450. * @param buttonIdx Which button index changed
  55451. * @param state New state of the button
  55452. * @param changes Which properties on the state changed since last frame
  55453. */
  55454. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55455. }
  55456. }
  55457. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55458. import { Scene } from "babylonjs/scene";
  55459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55460. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55461. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55462. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55463. /**
  55464. * Generic Controller
  55465. */
  55466. export class GenericController extends WebVRController {
  55467. /**
  55468. * Base Url for the controller model.
  55469. */
  55470. static readonly MODEL_BASE_URL: string;
  55471. /**
  55472. * File name for the controller model.
  55473. */
  55474. static readonly MODEL_FILENAME: string;
  55475. /**
  55476. * Creates a new GenericController from a gamepad
  55477. * @param vrGamepad the gamepad that the controller should be created from
  55478. */
  55479. constructor(vrGamepad: any);
  55480. /**
  55481. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55482. * @param scene scene in which to add meshes
  55483. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55484. */
  55485. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55486. /**
  55487. * Called once for each button that changed state since the last frame
  55488. * @param buttonIdx Which button index changed
  55489. * @param state New state of the button
  55490. * @param changes Which properties on the state changed since last frame
  55491. */
  55492. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55493. }
  55494. }
  55495. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55496. import { Observable } from "babylonjs/Misc/observable";
  55497. import { Scene } from "babylonjs/scene";
  55498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55499. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55500. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55501. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55502. /**
  55503. * Oculus Touch Controller
  55504. */
  55505. export class OculusTouchController extends WebVRController {
  55506. /**
  55507. * Base Url for the controller model.
  55508. */
  55509. static MODEL_BASE_URL: string;
  55510. /**
  55511. * File name for the left controller model.
  55512. */
  55513. static MODEL_LEFT_FILENAME: string;
  55514. /**
  55515. * File name for the right controller model.
  55516. */
  55517. static MODEL_RIGHT_FILENAME: string;
  55518. /**
  55519. * Base Url for the Quest controller model.
  55520. */
  55521. static QUEST_MODEL_BASE_URL: string;
  55522. /**
  55523. * @hidden
  55524. * If the controllers are running on a device that needs the updated Quest controller models
  55525. */
  55526. static _IsQuest: boolean;
  55527. /**
  55528. * Fired when the secondary trigger on this controller is modified
  55529. */
  55530. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55531. /**
  55532. * Fired when the thumb rest on this controller is modified
  55533. */
  55534. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55535. /**
  55536. * Creates a new OculusTouchController from a gamepad
  55537. * @param vrGamepad the gamepad that the controller should be created from
  55538. */
  55539. constructor(vrGamepad: any);
  55540. /**
  55541. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55542. * @param scene scene in which to add meshes
  55543. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55544. */
  55545. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55546. /**
  55547. * Fired when the A button on this controller is modified
  55548. */
  55549. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55550. /**
  55551. * Fired when the B button on this controller is modified
  55552. */
  55553. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55554. /**
  55555. * Fired when the X button on this controller is modified
  55556. */
  55557. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55558. /**
  55559. * Fired when the Y button on this controller is modified
  55560. */
  55561. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55562. /**
  55563. * Called once for each button that changed state since the last frame
  55564. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55565. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55566. * 2) secondary trigger (same)
  55567. * 3) A (right) X (left), touch, pressed = value
  55568. * 4) B / Y
  55569. * 5) thumb rest
  55570. * @param buttonIdx Which button index changed
  55571. * @param state New state of the button
  55572. * @param changes Which properties on the state changed since last frame
  55573. */
  55574. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55575. }
  55576. }
  55577. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55578. import { Scene } from "babylonjs/scene";
  55579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55580. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55581. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55582. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55583. import { Observable } from "babylonjs/Misc/observable";
  55584. /**
  55585. * Vive Controller
  55586. */
  55587. export class ViveController extends WebVRController {
  55588. /**
  55589. * Base Url for the controller model.
  55590. */
  55591. static MODEL_BASE_URL: string;
  55592. /**
  55593. * File name for the controller model.
  55594. */
  55595. static MODEL_FILENAME: string;
  55596. /**
  55597. * Creates a new ViveController from a gamepad
  55598. * @param vrGamepad the gamepad that the controller should be created from
  55599. */
  55600. constructor(vrGamepad: any);
  55601. /**
  55602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55603. * @param scene scene in which to add meshes
  55604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55605. */
  55606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55607. /**
  55608. * Fired when the left button on this controller is modified
  55609. */
  55610. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55611. /**
  55612. * Fired when the right button on this controller is modified
  55613. */
  55614. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55615. /**
  55616. * Fired when the menu button on this controller is modified
  55617. */
  55618. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55619. /**
  55620. * Called once for each button that changed state since the last frame
  55621. * Vive mapping:
  55622. * 0: touchpad
  55623. * 1: trigger
  55624. * 2: left AND right buttons
  55625. * 3: menu button
  55626. * @param buttonIdx Which button index changed
  55627. * @param state New state of the button
  55628. * @param changes Which properties on the state changed since last frame
  55629. */
  55630. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55631. }
  55632. }
  55633. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55634. import { Observable } from "babylonjs/Misc/observable";
  55635. import { Scene } from "babylonjs/scene";
  55636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55637. import { Ray } from "babylonjs/Culling/ray";
  55638. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55639. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55640. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55641. /**
  55642. * Defines the WindowsMotionController object that the state of the windows motion controller
  55643. */
  55644. export class WindowsMotionController extends WebVRController {
  55645. /**
  55646. * The base url used to load the left and right controller models
  55647. */
  55648. static MODEL_BASE_URL: string;
  55649. /**
  55650. * The name of the left controller model file
  55651. */
  55652. static MODEL_LEFT_FILENAME: string;
  55653. /**
  55654. * The name of the right controller model file
  55655. */
  55656. static MODEL_RIGHT_FILENAME: string;
  55657. /**
  55658. * The controller name prefix for this controller type
  55659. */
  55660. static readonly GAMEPAD_ID_PREFIX: string;
  55661. /**
  55662. * The controller id pattern for this controller type
  55663. */
  55664. private static readonly GAMEPAD_ID_PATTERN;
  55665. private _loadedMeshInfo;
  55666. protected readonly _mapping: {
  55667. buttons: string[];
  55668. buttonMeshNames: {
  55669. trigger: string;
  55670. menu: string;
  55671. grip: string;
  55672. thumbstick: string;
  55673. trackpad: string;
  55674. };
  55675. buttonObservableNames: {
  55676. trigger: string;
  55677. menu: string;
  55678. grip: string;
  55679. thumbstick: string;
  55680. trackpad: string;
  55681. };
  55682. axisMeshNames: string[];
  55683. pointingPoseMeshName: string;
  55684. };
  55685. /**
  55686. * Fired when the trackpad on this controller is clicked
  55687. */
  55688. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55689. /**
  55690. * Fired when the trackpad on this controller is modified
  55691. */
  55692. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55693. /**
  55694. * The current x and y values of this controller's trackpad
  55695. */
  55696. trackpad: StickValues;
  55697. /**
  55698. * Creates a new WindowsMotionController from a gamepad
  55699. * @param vrGamepad the gamepad that the controller should be created from
  55700. */
  55701. constructor(vrGamepad: any);
  55702. /**
  55703. * Fired when the trigger on this controller is modified
  55704. */
  55705. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55706. /**
  55707. * Fired when the menu button on this controller is modified
  55708. */
  55709. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55710. /**
  55711. * Fired when the grip button on this controller is modified
  55712. */
  55713. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55714. /**
  55715. * Fired when the thumbstick button on this controller is modified
  55716. */
  55717. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55718. /**
  55719. * Fired when the touchpad button on this controller is modified
  55720. */
  55721. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55722. /**
  55723. * Fired when the touchpad values on this controller are modified
  55724. */
  55725. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55726. protected _updateTrackpad(): void;
  55727. /**
  55728. * Called once per frame by the engine.
  55729. */
  55730. update(): void;
  55731. /**
  55732. * Called once for each button that changed state since the last frame
  55733. * @param buttonIdx Which button index changed
  55734. * @param state New state of the button
  55735. * @param changes Which properties on the state changed since last frame
  55736. */
  55737. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55738. /**
  55739. * Moves the buttons on the controller mesh based on their current state
  55740. * @param buttonName the name of the button to move
  55741. * @param buttonValue the value of the button which determines the buttons new position
  55742. */
  55743. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55744. /**
  55745. * Moves the axis on the controller mesh based on its current state
  55746. * @param axis the index of the axis
  55747. * @param axisValue the value of the axis which determines the meshes new position
  55748. * @hidden
  55749. */
  55750. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55751. /**
  55752. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55753. * @param scene scene in which to add meshes
  55754. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55755. */
  55756. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55757. /**
  55758. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55759. * can be transformed by button presses and axes values, based on this._mapping.
  55760. *
  55761. * @param scene scene in which the meshes exist
  55762. * @param meshes list of meshes that make up the controller model to process
  55763. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55764. */
  55765. private processModel;
  55766. private createMeshInfo;
  55767. /**
  55768. * Gets the ray of the controller in the direction the controller is pointing
  55769. * @param length the length the resulting ray should be
  55770. * @returns a ray in the direction the controller is pointing
  55771. */
  55772. getForwardRay(length?: number): Ray;
  55773. /**
  55774. * Disposes of the controller
  55775. */
  55776. dispose(): void;
  55777. }
  55778. /**
  55779. * This class represents a new windows motion controller in XR.
  55780. */
  55781. export class XRWindowsMotionController extends WindowsMotionController {
  55782. /**
  55783. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55784. */
  55785. protected readonly _mapping: {
  55786. buttons: string[];
  55787. buttonMeshNames: {
  55788. trigger: string;
  55789. menu: string;
  55790. grip: string;
  55791. thumbstick: string;
  55792. trackpad: string;
  55793. };
  55794. buttonObservableNames: {
  55795. trigger: string;
  55796. menu: string;
  55797. grip: string;
  55798. thumbstick: string;
  55799. trackpad: string;
  55800. };
  55801. axisMeshNames: string[];
  55802. pointingPoseMeshName: string;
  55803. };
  55804. /**
  55805. * Construct a new XR-Based windows motion controller
  55806. *
  55807. * @param gamepadInfo the gamepad object from the browser
  55808. */
  55809. constructor(gamepadInfo: any);
  55810. /**
  55811. * holds the thumbstick values (X,Y)
  55812. */
  55813. thumbstickValues: StickValues;
  55814. /**
  55815. * Fired when the thumbstick on this controller is clicked
  55816. */
  55817. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55818. /**
  55819. * Fired when the thumbstick on this controller is modified
  55820. */
  55821. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55822. /**
  55823. * Fired when the touchpad button on this controller is modified
  55824. */
  55825. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55826. /**
  55827. * Fired when the touchpad values on this controller are modified
  55828. */
  55829. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55830. /**
  55831. * Fired when the thumbstick button on this controller is modified
  55832. * here to prevent breaking changes
  55833. */
  55834. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55835. /**
  55836. * updating the thumbstick(!) and not the trackpad.
  55837. * This is named this way due to the difference between WebVR and XR and to avoid
  55838. * changing the parent class.
  55839. */
  55840. protected _updateTrackpad(): void;
  55841. /**
  55842. * Disposes the class with joy
  55843. */
  55844. dispose(): void;
  55845. }
  55846. }
  55847. declare module "babylonjs/Gamepads/Controllers/index" {
  55848. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55849. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55850. export * from "babylonjs/Gamepads/Controllers/genericController";
  55851. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55852. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55853. export * from "babylonjs/Gamepads/Controllers/viveController";
  55854. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55855. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55856. }
  55857. declare module "babylonjs/Gamepads/index" {
  55858. export * from "babylonjs/Gamepads/Controllers/index";
  55859. export * from "babylonjs/Gamepads/gamepad";
  55860. export * from "babylonjs/Gamepads/gamepadManager";
  55861. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55862. export * from "babylonjs/Gamepads/xboxGamepad";
  55863. export * from "babylonjs/Gamepads/dualShockGamepad";
  55864. }
  55865. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55866. import { Scene } from "babylonjs/scene";
  55867. import { Vector4 } from "babylonjs/Maths/math.vector";
  55868. import { Color4 } from "babylonjs/Maths/math.color";
  55869. import { Mesh } from "babylonjs/Meshes/mesh";
  55870. import { Nullable } from "babylonjs/types";
  55871. /**
  55872. * Class containing static functions to help procedurally build meshes
  55873. */
  55874. export class PolyhedronBuilder {
  55875. /**
  55876. * Creates a polyhedron mesh
  55877. * * 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
  55878. * * The parameter `size` (positive float, default 1) sets the polygon size
  55879. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55880. * * 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`
  55881. * * 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
  55882. * * 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)`)
  55883. * * 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
  55884. * * 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
  55885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55888. * @param name defines the name of the mesh
  55889. * @param options defines the options used to create the mesh
  55890. * @param scene defines the hosting scene
  55891. * @returns the polyhedron mesh
  55892. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55893. */
  55894. static CreatePolyhedron(name: string, options: {
  55895. type?: number;
  55896. size?: number;
  55897. sizeX?: number;
  55898. sizeY?: number;
  55899. sizeZ?: number;
  55900. custom?: any;
  55901. faceUV?: Vector4[];
  55902. faceColors?: Color4[];
  55903. flat?: boolean;
  55904. updatable?: boolean;
  55905. sideOrientation?: number;
  55906. frontUVs?: Vector4;
  55907. backUVs?: Vector4;
  55908. }, scene?: Nullable<Scene>): Mesh;
  55909. }
  55910. }
  55911. declare module "babylonjs/Gizmos/scaleGizmo" {
  55912. import { Observable } from "babylonjs/Misc/observable";
  55913. import { Nullable } from "babylonjs/types";
  55914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55915. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55916. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55917. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55918. import { Node } from "babylonjs/node";
  55919. /**
  55920. * Gizmo that enables scaling a mesh along 3 axis
  55921. */
  55922. export class ScaleGizmo extends Gizmo {
  55923. /**
  55924. * Internal gizmo used for interactions on the x axis
  55925. */
  55926. xGizmo: AxisScaleGizmo;
  55927. /**
  55928. * Internal gizmo used for interactions on the y axis
  55929. */
  55930. yGizmo: AxisScaleGizmo;
  55931. /**
  55932. * Internal gizmo used for interactions on the z axis
  55933. */
  55934. zGizmo: AxisScaleGizmo;
  55935. /**
  55936. * Internal gizmo used to scale all axis equally
  55937. */
  55938. uniformScaleGizmo: AxisScaleGizmo;
  55939. private _meshAttached;
  55940. private _nodeAttached;
  55941. private _snapDistance;
  55942. private _uniformScalingMesh;
  55943. private _octahedron;
  55944. private _sensitivity;
  55945. /** Fires an event when any of it's sub gizmos are dragged */
  55946. onDragStartObservable: Observable<unknown>;
  55947. /** Fires an event when any of it's sub gizmos are released from dragging */
  55948. onDragEndObservable: Observable<unknown>;
  55949. get attachedMesh(): Nullable<AbstractMesh>;
  55950. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55951. get attachedNode(): Nullable<Node>;
  55952. set attachedNode(node: Nullable<Node>);
  55953. /**
  55954. * Creates a ScaleGizmo
  55955. * @param gizmoLayer The utility layer the gizmo will be added to
  55956. * @param thickness display gizmo axis thickness
  55957. */
  55958. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55959. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55960. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55961. /**
  55962. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55963. */
  55964. set snapDistance(value: number);
  55965. get snapDistance(): number;
  55966. /**
  55967. * Ratio for the scale of the gizmo (Default: 1)
  55968. */
  55969. set scaleRatio(value: number);
  55970. get scaleRatio(): number;
  55971. /**
  55972. * Sensitivity factor for dragging (Default: 1)
  55973. */
  55974. set sensitivity(value: number);
  55975. get sensitivity(): number;
  55976. /**
  55977. * Disposes of the gizmo
  55978. */
  55979. dispose(): void;
  55980. }
  55981. }
  55982. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55983. import { Observable } from "babylonjs/Misc/observable";
  55984. import { Nullable } from "babylonjs/types";
  55985. import { Vector3 } from "babylonjs/Maths/math.vector";
  55986. import { Node } from "babylonjs/node";
  55987. import { Mesh } from "babylonjs/Meshes/mesh";
  55988. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55989. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55990. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55991. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55992. import { Color3 } from "babylonjs/Maths/math.color";
  55993. /**
  55994. * Single axis scale gizmo
  55995. */
  55996. export class AxisScaleGizmo extends Gizmo {
  55997. /**
  55998. * Drag behavior responsible for the gizmos dragging interactions
  55999. */
  56000. dragBehavior: PointerDragBehavior;
  56001. private _pointerObserver;
  56002. /**
  56003. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56004. */
  56005. snapDistance: number;
  56006. /**
  56007. * Event that fires each time the gizmo snaps to a new location.
  56008. * * snapDistance is the the change in distance
  56009. */
  56010. onSnapObservable: Observable<{
  56011. snapDistance: number;
  56012. }>;
  56013. /**
  56014. * If the scaling operation should be done on all axis (default: false)
  56015. */
  56016. uniformScaling: boolean;
  56017. /**
  56018. * Custom sensitivity value for the drag strength
  56019. */
  56020. sensitivity: number;
  56021. private _isEnabled;
  56022. private _parent;
  56023. private _arrow;
  56024. private _coloredMaterial;
  56025. private _hoverMaterial;
  56026. /**
  56027. * Creates an AxisScaleGizmo
  56028. * @param gizmoLayer The utility layer the gizmo will be added to
  56029. * @param dragAxis The axis which the gizmo will be able to scale on
  56030. * @param color The color of the gizmo
  56031. * @param thickness display gizmo axis thickness
  56032. */
  56033. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56034. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56035. /**
  56036. * If the gizmo is enabled
  56037. */
  56038. set isEnabled(value: boolean);
  56039. get isEnabled(): boolean;
  56040. /**
  56041. * Disposes of the gizmo
  56042. */
  56043. dispose(): void;
  56044. /**
  56045. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56046. * @param mesh The mesh to replace the default mesh of the gizmo
  56047. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56048. */
  56049. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56050. }
  56051. }
  56052. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56053. import { Observable } from "babylonjs/Misc/observable";
  56054. import { Nullable } from "babylonjs/types";
  56055. import { Vector3 } from "babylonjs/Maths/math.vector";
  56056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56057. import { Mesh } from "babylonjs/Meshes/mesh";
  56058. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56059. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56060. import { Color3 } from "babylonjs/Maths/math.color";
  56061. import "babylonjs/Meshes/Builders/boxBuilder";
  56062. /**
  56063. * Bounding box gizmo
  56064. */
  56065. export class BoundingBoxGizmo extends Gizmo {
  56066. private _lineBoundingBox;
  56067. private _rotateSpheresParent;
  56068. private _scaleBoxesParent;
  56069. private _boundingDimensions;
  56070. private _renderObserver;
  56071. private _pointerObserver;
  56072. private _scaleDragSpeed;
  56073. private _tmpQuaternion;
  56074. private _tmpVector;
  56075. private _tmpRotationMatrix;
  56076. /**
  56077. * 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)
  56078. */
  56079. ignoreChildren: boolean;
  56080. /**
  56081. * 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)
  56082. */
  56083. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56084. /**
  56085. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56086. */
  56087. rotationSphereSize: number;
  56088. /**
  56089. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56090. */
  56091. scaleBoxSize: number;
  56092. /**
  56093. * 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)
  56094. */
  56095. fixedDragMeshScreenSize: boolean;
  56096. /**
  56097. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56098. */
  56099. fixedDragMeshScreenSizeDistanceFactor: number;
  56100. /**
  56101. * Fired when a rotation sphere or scale box is dragged
  56102. */
  56103. onDragStartObservable: Observable<{}>;
  56104. /**
  56105. * Fired when a scale box is dragged
  56106. */
  56107. onScaleBoxDragObservable: Observable<{}>;
  56108. /**
  56109. * Fired when a scale box drag is ended
  56110. */
  56111. onScaleBoxDragEndObservable: Observable<{}>;
  56112. /**
  56113. * Fired when a rotation sphere is dragged
  56114. */
  56115. onRotationSphereDragObservable: Observable<{}>;
  56116. /**
  56117. * Fired when a rotation sphere drag is ended
  56118. */
  56119. onRotationSphereDragEndObservable: Observable<{}>;
  56120. /**
  56121. * 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)
  56122. */
  56123. scalePivot: Nullable<Vector3>;
  56124. /**
  56125. * Mesh used as a pivot to rotate the attached node
  56126. */
  56127. private _anchorMesh;
  56128. private _existingMeshScale;
  56129. private _dragMesh;
  56130. private pointerDragBehavior;
  56131. private coloredMaterial;
  56132. private hoverColoredMaterial;
  56133. /**
  56134. * Sets the color of the bounding box gizmo
  56135. * @param color the color to set
  56136. */
  56137. setColor(color: Color3): void;
  56138. /**
  56139. * Creates an BoundingBoxGizmo
  56140. * @param gizmoLayer The utility layer the gizmo will be added to
  56141. * @param color The color of the gizmo
  56142. */
  56143. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56144. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56145. private _selectNode;
  56146. /**
  56147. * Updates the bounding box information for the Gizmo
  56148. */
  56149. updateBoundingBox(): void;
  56150. private _updateRotationSpheres;
  56151. private _updateScaleBoxes;
  56152. /**
  56153. * Enables rotation on the specified axis and disables rotation on the others
  56154. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56155. */
  56156. setEnabledRotationAxis(axis: string): void;
  56157. /**
  56158. * Enables/disables scaling
  56159. * @param enable if scaling should be enabled
  56160. * @param homogeneousScaling defines if scaling should only be homogeneous
  56161. */
  56162. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56163. private _updateDummy;
  56164. /**
  56165. * Enables a pointer drag behavior on the bounding box of the gizmo
  56166. */
  56167. enableDragBehavior(): void;
  56168. /**
  56169. * Disposes of the gizmo
  56170. */
  56171. dispose(): void;
  56172. /**
  56173. * 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)
  56174. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56175. * @returns the bounding box mesh with the passed in mesh as a child
  56176. */
  56177. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56178. /**
  56179. * CustomMeshes are not supported by this gizmo
  56180. * @param mesh The mesh to replace the default mesh of the gizmo
  56181. */
  56182. setCustomMesh(mesh: Mesh): void;
  56183. }
  56184. }
  56185. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56186. import { Observable } from "babylonjs/Misc/observable";
  56187. import { Nullable } from "babylonjs/types";
  56188. import { Vector3 } from "babylonjs/Maths/math.vector";
  56189. import { Color3 } from "babylonjs/Maths/math.color";
  56190. import { Node } from "babylonjs/node";
  56191. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56192. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56193. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56194. import "babylonjs/Meshes/Builders/linesBuilder";
  56195. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56196. /**
  56197. * Single plane rotation gizmo
  56198. */
  56199. export class PlaneRotationGizmo extends Gizmo {
  56200. /**
  56201. * Drag behavior responsible for the gizmos dragging interactions
  56202. */
  56203. dragBehavior: PointerDragBehavior;
  56204. private _pointerObserver;
  56205. /**
  56206. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56207. */
  56208. snapDistance: number;
  56209. /**
  56210. * Event that fires each time the gizmo snaps to a new location.
  56211. * * snapDistance is the the change in distance
  56212. */
  56213. onSnapObservable: Observable<{
  56214. snapDistance: number;
  56215. }>;
  56216. private _isEnabled;
  56217. private _parent;
  56218. /**
  56219. * Creates a PlaneRotationGizmo
  56220. * @param gizmoLayer The utility layer the gizmo will be added to
  56221. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56222. * @param color The color of the gizmo
  56223. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56224. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56225. * @param thickness display gizmo axis thickness
  56226. */
  56227. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56228. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56229. /**
  56230. * If the gizmo is enabled
  56231. */
  56232. set isEnabled(value: boolean);
  56233. get isEnabled(): boolean;
  56234. /**
  56235. * Disposes of the gizmo
  56236. */
  56237. dispose(): void;
  56238. }
  56239. }
  56240. declare module "babylonjs/Gizmos/rotationGizmo" {
  56241. import { Observable } from "babylonjs/Misc/observable";
  56242. import { Nullable } from "babylonjs/types";
  56243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56244. import { Mesh } from "babylonjs/Meshes/mesh";
  56245. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56246. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56247. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56248. import { Node } from "babylonjs/node";
  56249. /**
  56250. * Gizmo that enables rotating a mesh along 3 axis
  56251. */
  56252. export class RotationGizmo extends Gizmo {
  56253. /**
  56254. * Internal gizmo used for interactions on the x axis
  56255. */
  56256. xGizmo: PlaneRotationGizmo;
  56257. /**
  56258. * Internal gizmo used for interactions on the y axis
  56259. */
  56260. yGizmo: PlaneRotationGizmo;
  56261. /**
  56262. * Internal gizmo used for interactions on the z axis
  56263. */
  56264. zGizmo: PlaneRotationGizmo;
  56265. /** Fires an event when any of it's sub gizmos are dragged */
  56266. onDragStartObservable: Observable<unknown>;
  56267. /** Fires an event when any of it's sub gizmos are released from dragging */
  56268. onDragEndObservable: Observable<unknown>;
  56269. private _meshAttached;
  56270. private _nodeAttached;
  56271. get attachedMesh(): Nullable<AbstractMesh>;
  56272. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56273. get attachedNode(): Nullable<Node>;
  56274. set attachedNode(node: Nullable<Node>);
  56275. /**
  56276. * Creates a RotationGizmo
  56277. * @param gizmoLayer The utility layer the gizmo will be added to
  56278. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56279. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56280. * @param thickness display gizmo axis thickness
  56281. */
  56282. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56283. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56284. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56285. /**
  56286. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56287. */
  56288. set snapDistance(value: number);
  56289. get snapDistance(): number;
  56290. /**
  56291. * Ratio for the scale of the gizmo (Default: 1)
  56292. */
  56293. set scaleRatio(value: number);
  56294. get scaleRatio(): number;
  56295. /**
  56296. * Disposes of the gizmo
  56297. */
  56298. dispose(): void;
  56299. /**
  56300. * CustomMeshes are not supported by this gizmo
  56301. * @param mesh The mesh to replace the default mesh of the gizmo
  56302. */
  56303. setCustomMesh(mesh: Mesh): void;
  56304. }
  56305. }
  56306. declare module "babylonjs/Gizmos/gizmoManager" {
  56307. import { Observable } from "babylonjs/Misc/observable";
  56308. import { Nullable } from "babylonjs/types";
  56309. import { Scene, IDisposable } from "babylonjs/scene";
  56310. import { Node } from "babylonjs/node";
  56311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56312. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56313. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56314. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56315. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56316. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56317. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56318. /**
  56319. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56320. */
  56321. export class GizmoManager implements IDisposable {
  56322. private scene;
  56323. /**
  56324. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56325. */
  56326. gizmos: {
  56327. positionGizmo: Nullable<PositionGizmo>;
  56328. rotationGizmo: Nullable<RotationGizmo>;
  56329. scaleGizmo: Nullable<ScaleGizmo>;
  56330. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56331. };
  56332. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56333. clearGizmoOnEmptyPointerEvent: boolean;
  56334. /** Fires an event when the manager is attached to a mesh */
  56335. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56336. /** Fires an event when the manager is attached to a node */
  56337. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56338. private _gizmosEnabled;
  56339. private _pointerObserver;
  56340. private _attachedMesh;
  56341. private _attachedNode;
  56342. private _boundingBoxColor;
  56343. private _defaultUtilityLayer;
  56344. private _defaultKeepDepthUtilityLayer;
  56345. private _thickness;
  56346. /**
  56347. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56348. */
  56349. boundingBoxDragBehavior: SixDofDragBehavior;
  56350. /**
  56351. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56352. */
  56353. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56354. /**
  56355. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56356. */
  56357. attachableNodes: Nullable<Array<Node>>;
  56358. /**
  56359. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56360. */
  56361. usePointerToAttachGizmos: boolean;
  56362. /**
  56363. * Utility layer that the bounding box gizmo belongs to
  56364. */
  56365. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56366. /**
  56367. * Utility layer that all gizmos besides bounding box belong to
  56368. */
  56369. get utilityLayer(): UtilityLayerRenderer;
  56370. /**
  56371. * Instatiates a gizmo manager
  56372. * @param scene the scene to overlay the gizmos on top of
  56373. * @param thickness display gizmo axis thickness
  56374. */
  56375. constructor(scene: Scene, thickness?: number);
  56376. /**
  56377. * Attaches a set of gizmos to the specified mesh
  56378. * @param mesh The mesh the gizmo's should be attached to
  56379. */
  56380. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56381. /**
  56382. * Attaches a set of gizmos to the specified node
  56383. * @param node The node the gizmo's should be attached to
  56384. */
  56385. attachToNode(node: Nullable<Node>): void;
  56386. /**
  56387. * If the position gizmo is enabled
  56388. */
  56389. set positionGizmoEnabled(value: boolean);
  56390. get positionGizmoEnabled(): boolean;
  56391. /**
  56392. * If the rotation gizmo is enabled
  56393. */
  56394. set rotationGizmoEnabled(value: boolean);
  56395. get rotationGizmoEnabled(): boolean;
  56396. /**
  56397. * If the scale gizmo is enabled
  56398. */
  56399. set scaleGizmoEnabled(value: boolean);
  56400. get scaleGizmoEnabled(): boolean;
  56401. /**
  56402. * If the boundingBox gizmo is enabled
  56403. */
  56404. set boundingBoxGizmoEnabled(value: boolean);
  56405. get boundingBoxGizmoEnabled(): boolean;
  56406. /**
  56407. * Disposes of the gizmo manager
  56408. */
  56409. dispose(): void;
  56410. }
  56411. }
  56412. declare module "babylonjs/Lights/directionalLight" {
  56413. import { Camera } from "babylonjs/Cameras/camera";
  56414. import { Scene } from "babylonjs/scene";
  56415. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56417. import { Light } from "babylonjs/Lights/light";
  56418. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56419. import { Effect } from "babylonjs/Materials/effect";
  56420. /**
  56421. * A directional light is defined by a direction (what a surprise!).
  56422. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56423. * 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.
  56424. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56425. */
  56426. export class DirectionalLight extends ShadowLight {
  56427. private _shadowFrustumSize;
  56428. /**
  56429. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56430. */
  56431. get shadowFrustumSize(): number;
  56432. /**
  56433. * Specifies a fix frustum size for the shadow generation.
  56434. */
  56435. set shadowFrustumSize(value: number);
  56436. private _shadowOrthoScale;
  56437. /**
  56438. * Gets the shadow projection scale against the optimal computed one.
  56439. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56440. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56441. */
  56442. get shadowOrthoScale(): number;
  56443. /**
  56444. * Sets the shadow projection scale against the optimal computed one.
  56445. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56446. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56447. */
  56448. set shadowOrthoScale(value: number);
  56449. /**
  56450. * Automatically compute the projection matrix to best fit (including all the casters)
  56451. * on each frame.
  56452. */
  56453. autoUpdateExtends: boolean;
  56454. /**
  56455. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56456. * on each frame. autoUpdateExtends must be set to true for this to work
  56457. */
  56458. autoCalcShadowZBounds: boolean;
  56459. private _orthoLeft;
  56460. private _orthoRight;
  56461. private _orthoTop;
  56462. private _orthoBottom;
  56463. /**
  56464. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56465. * The directional light is emitted from everywhere in the given direction.
  56466. * It can cast shadows.
  56467. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56468. * @param name The friendly name of the light
  56469. * @param direction The direction of the light
  56470. * @param scene The scene the light belongs to
  56471. */
  56472. constructor(name: string, direction: Vector3, scene: Scene);
  56473. /**
  56474. * Returns the string "DirectionalLight".
  56475. * @return The class name
  56476. */
  56477. getClassName(): string;
  56478. /**
  56479. * Returns the integer 1.
  56480. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56481. */
  56482. getTypeID(): number;
  56483. /**
  56484. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56485. * Returns the DirectionalLight Shadow projection matrix.
  56486. */
  56487. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56488. /**
  56489. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56490. * Returns the DirectionalLight Shadow projection matrix.
  56491. */
  56492. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56493. /**
  56494. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56495. * Returns the DirectionalLight Shadow projection matrix.
  56496. */
  56497. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56498. protected _buildUniformLayout(): void;
  56499. /**
  56500. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56501. * @param effect The effect to update
  56502. * @param lightIndex The index of the light in the effect to update
  56503. * @returns The directional light
  56504. */
  56505. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56506. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56507. /**
  56508. * Gets the minZ used for shadow according to both the scene and the light.
  56509. *
  56510. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56511. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56512. * @param activeCamera The camera we are returning the min for
  56513. * @returns the depth min z
  56514. */
  56515. getDepthMinZ(activeCamera: Camera): number;
  56516. /**
  56517. * Gets the maxZ used for shadow according to both the scene and the light.
  56518. *
  56519. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56520. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56521. * @param activeCamera The camera we are returning the max for
  56522. * @returns the depth max z
  56523. */
  56524. getDepthMaxZ(activeCamera: Camera): number;
  56525. /**
  56526. * Prepares the list of defines specific to the light type.
  56527. * @param defines the list of defines
  56528. * @param lightIndex defines the index of the light for the effect
  56529. */
  56530. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56531. }
  56532. }
  56533. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56534. import { Mesh } from "babylonjs/Meshes/mesh";
  56535. /**
  56536. * Class containing static functions to help procedurally build meshes
  56537. */
  56538. export class HemisphereBuilder {
  56539. /**
  56540. * Creates a hemisphere mesh
  56541. * @param name defines the name of the mesh
  56542. * @param options defines the options used to create the mesh
  56543. * @param scene defines the hosting scene
  56544. * @returns the hemisphere mesh
  56545. */
  56546. static CreateHemisphere(name: string, options: {
  56547. segments?: number;
  56548. diameter?: number;
  56549. sideOrientation?: number;
  56550. }, scene: any): Mesh;
  56551. }
  56552. }
  56553. declare module "babylonjs/Lights/spotLight" {
  56554. import { Nullable } from "babylonjs/types";
  56555. import { Scene } from "babylonjs/scene";
  56556. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56558. import { Effect } from "babylonjs/Materials/effect";
  56559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56560. import { Light } from "babylonjs/Lights/light";
  56561. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56562. /**
  56563. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56564. * These values define a cone of light starting from the position, emitting toward the direction.
  56565. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56566. * and the exponent defines the speed of the decay of the light with distance (reach).
  56567. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56568. */
  56569. export class SpotLight extends ShadowLight {
  56570. private _angle;
  56571. private _innerAngle;
  56572. private _cosHalfAngle;
  56573. private _lightAngleScale;
  56574. private _lightAngleOffset;
  56575. /**
  56576. * Gets the cone angle of the spot light in Radians.
  56577. */
  56578. get angle(): number;
  56579. /**
  56580. * Sets the cone angle of the spot light in Radians.
  56581. */
  56582. set angle(value: number);
  56583. /**
  56584. * Only used in gltf falloff mode, this defines the angle where
  56585. * the directional falloff will start before cutting at angle which could be seen
  56586. * as outer angle.
  56587. */
  56588. get innerAngle(): number;
  56589. /**
  56590. * Only used in gltf falloff mode, this defines the angle where
  56591. * the directional falloff will start before cutting at angle which could be seen
  56592. * as outer angle.
  56593. */
  56594. set innerAngle(value: number);
  56595. private _shadowAngleScale;
  56596. /**
  56597. * Allows scaling the angle of the light for shadow generation only.
  56598. */
  56599. get shadowAngleScale(): number;
  56600. /**
  56601. * Allows scaling the angle of the light for shadow generation only.
  56602. */
  56603. set shadowAngleScale(value: number);
  56604. /**
  56605. * The light decay speed with the distance from the emission spot.
  56606. */
  56607. exponent: number;
  56608. private _projectionTextureMatrix;
  56609. /**
  56610. * Allows reading the projecton texture
  56611. */
  56612. get projectionTextureMatrix(): Matrix;
  56613. protected _projectionTextureLightNear: number;
  56614. /**
  56615. * Gets the near clip of the Spotlight for texture projection.
  56616. */
  56617. get projectionTextureLightNear(): number;
  56618. /**
  56619. * Sets the near clip of the Spotlight for texture projection.
  56620. */
  56621. set projectionTextureLightNear(value: number);
  56622. protected _projectionTextureLightFar: number;
  56623. /**
  56624. * Gets the far clip of the Spotlight for texture projection.
  56625. */
  56626. get projectionTextureLightFar(): number;
  56627. /**
  56628. * Sets the far clip of the Spotlight for texture projection.
  56629. */
  56630. set projectionTextureLightFar(value: number);
  56631. protected _projectionTextureUpDirection: Vector3;
  56632. /**
  56633. * Gets the Up vector of the Spotlight for texture projection.
  56634. */
  56635. get projectionTextureUpDirection(): Vector3;
  56636. /**
  56637. * Sets the Up vector of the Spotlight for texture projection.
  56638. */
  56639. set projectionTextureUpDirection(value: Vector3);
  56640. private _projectionTexture;
  56641. /**
  56642. * Gets the projection texture of the light.
  56643. */
  56644. get projectionTexture(): Nullable<BaseTexture>;
  56645. /**
  56646. * Sets the projection texture of the light.
  56647. */
  56648. set projectionTexture(value: Nullable<BaseTexture>);
  56649. private _projectionTextureViewLightDirty;
  56650. private _projectionTextureProjectionLightDirty;
  56651. private _projectionTextureDirty;
  56652. private _projectionTextureViewTargetVector;
  56653. private _projectionTextureViewLightMatrix;
  56654. private _projectionTextureProjectionLightMatrix;
  56655. private _projectionTextureScalingMatrix;
  56656. /**
  56657. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56658. * It can cast shadows.
  56659. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56660. * @param name The light friendly name
  56661. * @param position The position of the spot light in the scene
  56662. * @param direction The direction of the light in the scene
  56663. * @param angle The cone angle of the light in Radians
  56664. * @param exponent The light decay speed with the distance from the emission spot
  56665. * @param scene The scene the lights belongs to
  56666. */
  56667. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56668. /**
  56669. * Returns the string "SpotLight".
  56670. * @returns the class name
  56671. */
  56672. getClassName(): string;
  56673. /**
  56674. * Returns the integer 2.
  56675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56676. */
  56677. getTypeID(): number;
  56678. /**
  56679. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56680. */
  56681. protected _setDirection(value: Vector3): void;
  56682. /**
  56683. * Overrides the position setter to recompute the projection texture view light Matrix.
  56684. */
  56685. protected _setPosition(value: Vector3): void;
  56686. /**
  56687. * 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.
  56688. * Returns the SpotLight.
  56689. */
  56690. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56691. protected _computeProjectionTextureViewLightMatrix(): void;
  56692. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56693. /**
  56694. * Main function for light texture projection matrix computing.
  56695. */
  56696. protected _computeProjectionTextureMatrix(): void;
  56697. protected _buildUniformLayout(): void;
  56698. private _computeAngleValues;
  56699. /**
  56700. * Sets the passed Effect "effect" with the Light textures.
  56701. * @param effect The effect to update
  56702. * @param lightIndex The index of the light in the effect to update
  56703. * @returns The light
  56704. */
  56705. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56706. /**
  56707. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56708. * @param effect The effect to update
  56709. * @param lightIndex The index of the light in the effect to update
  56710. * @returns The spot light
  56711. */
  56712. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56713. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56714. /**
  56715. * Disposes the light and the associated resources.
  56716. */
  56717. dispose(): void;
  56718. /**
  56719. * Prepares the list of defines specific to the light type.
  56720. * @param defines the list of defines
  56721. * @param lightIndex defines the index of the light for the effect
  56722. */
  56723. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56724. }
  56725. }
  56726. declare module "babylonjs/Gizmos/lightGizmo" {
  56727. import { Nullable } from "babylonjs/types";
  56728. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56729. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56730. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56731. import { Light } from "babylonjs/Lights/light";
  56732. import { Observable } from "babylonjs/Misc/observable";
  56733. /**
  56734. * Gizmo that enables viewing a light
  56735. */
  56736. export class LightGizmo extends Gizmo {
  56737. private _lightMesh;
  56738. private _material;
  56739. private _cachedPosition;
  56740. private _cachedForward;
  56741. private _attachedMeshParent;
  56742. private _pointerObserver;
  56743. /**
  56744. * Event that fires each time the gizmo is clicked
  56745. */
  56746. onClickedObservable: Observable<Light>;
  56747. /**
  56748. * Creates a LightGizmo
  56749. * @param gizmoLayer The utility layer the gizmo will be added to
  56750. */
  56751. constructor(gizmoLayer?: UtilityLayerRenderer);
  56752. private _light;
  56753. /**
  56754. * The light that the gizmo is attached to
  56755. */
  56756. set light(light: Nullable<Light>);
  56757. get light(): Nullable<Light>;
  56758. /**
  56759. * Gets the material used to render the light gizmo
  56760. */
  56761. get material(): StandardMaterial;
  56762. /**
  56763. * @hidden
  56764. * Updates the gizmo to match the attached mesh's position/rotation
  56765. */
  56766. protected _update(): void;
  56767. private static _Scale;
  56768. /**
  56769. * Creates the lines for a light mesh
  56770. */
  56771. private static _CreateLightLines;
  56772. /**
  56773. * Disposes of the light gizmo
  56774. */
  56775. dispose(): void;
  56776. private static _CreateHemisphericLightMesh;
  56777. private static _CreatePointLightMesh;
  56778. private static _CreateSpotLightMesh;
  56779. private static _CreateDirectionalLightMesh;
  56780. }
  56781. }
  56782. declare module "babylonjs/Gizmos/cameraGizmo" {
  56783. import { Nullable } from "babylonjs/types";
  56784. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56785. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56786. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56787. import { Camera } from "babylonjs/Cameras/camera";
  56788. import { Observable } from "babylonjs/Misc/observable";
  56789. /**
  56790. * Gizmo that enables viewing a camera
  56791. */
  56792. export class CameraGizmo extends Gizmo {
  56793. private _cameraMesh;
  56794. private _cameraLinesMesh;
  56795. private _material;
  56796. private _pointerObserver;
  56797. /**
  56798. * Event that fires each time the gizmo is clicked
  56799. */
  56800. onClickedObservable: Observable<Camera>;
  56801. /**
  56802. * Creates a CameraGizmo
  56803. * @param gizmoLayer The utility layer the gizmo will be added to
  56804. */
  56805. constructor(gizmoLayer?: UtilityLayerRenderer);
  56806. private _camera;
  56807. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56808. get displayFrustum(): boolean;
  56809. set displayFrustum(value: boolean);
  56810. /**
  56811. * The camera that the gizmo is attached to
  56812. */
  56813. set camera(camera: Nullable<Camera>);
  56814. get camera(): Nullable<Camera>;
  56815. /**
  56816. * Gets the material used to render the camera gizmo
  56817. */
  56818. get material(): StandardMaterial;
  56819. /**
  56820. * @hidden
  56821. * Updates the gizmo to match the attached mesh's position/rotation
  56822. */
  56823. protected _update(): void;
  56824. private static _Scale;
  56825. private _invProjection;
  56826. /**
  56827. * Disposes of the camera gizmo
  56828. */
  56829. dispose(): void;
  56830. private static _CreateCameraMesh;
  56831. private static _CreateCameraFrustum;
  56832. }
  56833. }
  56834. declare module "babylonjs/Gizmos/index" {
  56835. export * from "babylonjs/Gizmos/axisDragGizmo";
  56836. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56837. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56838. export * from "babylonjs/Gizmos/gizmo";
  56839. export * from "babylonjs/Gizmos/gizmoManager";
  56840. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56841. export * from "babylonjs/Gizmos/positionGizmo";
  56842. export * from "babylonjs/Gizmos/rotationGizmo";
  56843. export * from "babylonjs/Gizmos/scaleGizmo";
  56844. export * from "babylonjs/Gizmos/lightGizmo";
  56845. export * from "babylonjs/Gizmos/cameraGizmo";
  56846. export * from "babylonjs/Gizmos/planeDragGizmo";
  56847. }
  56848. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56849. /** @hidden */
  56850. export var backgroundFragmentDeclaration: {
  56851. name: string;
  56852. shader: string;
  56853. };
  56854. }
  56855. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56856. /** @hidden */
  56857. export var backgroundUboDeclaration: {
  56858. name: string;
  56859. shader: string;
  56860. };
  56861. }
  56862. declare module "babylonjs/Shaders/background.fragment" {
  56863. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56864. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56865. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56866. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56867. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56868. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56869. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56870. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56871. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56872. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56873. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56874. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56875. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56876. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56877. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56878. /** @hidden */
  56879. export var backgroundPixelShader: {
  56880. name: string;
  56881. shader: string;
  56882. };
  56883. }
  56884. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56885. /** @hidden */
  56886. export var backgroundVertexDeclaration: {
  56887. name: string;
  56888. shader: string;
  56889. };
  56890. }
  56891. declare module "babylonjs/Shaders/background.vertex" {
  56892. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56893. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56894. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56895. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56896. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56897. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56898. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56899. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56900. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56901. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56902. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56903. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56904. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56905. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56906. /** @hidden */
  56907. export var backgroundVertexShader: {
  56908. name: string;
  56909. shader: string;
  56910. };
  56911. }
  56912. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56913. import { Nullable, int, float } from "babylonjs/types";
  56914. import { Scene } from "babylonjs/scene";
  56915. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56916. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56918. import { Mesh } from "babylonjs/Meshes/mesh";
  56919. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56920. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56921. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56923. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56924. import { Color3 } from "babylonjs/Maths/math.color";
  56925. import "babylonjs/Shaders/background.fragment";
  56926. import "babylonjs/Shaders/background.vertex";
  56927. /**
  56928. * Background material used to create an efficient environement around your scene.
  56929. */
  56930. export class BackgroundMaterial extends PushMaterial {
  56931. /**
  56932. * Standard reflectance value at parallel view angle.
  56933. */
  56934. static StandardReflectance0: number;
  56935. /**
  56936. * Standard reflectance value at grazing angle.
  56937. */
  56938. static StandardReflectance90: number;
  56939. protected _primaryColor: Color3;
  56940. /**
  56941. * Key light Color (multiply against the environement texture)
  56942. */
  56943. primaryColor: Color3;
  56944. protected __perceptualColor: Nullable<Color3>;
  56945. /**
  56946. * Experimental Internal Use Only.
  56947. *
  56948. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56949. * This acts as a helper to set the primary color to a more "human friendly" value.
  56950. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56951. * output color as close as possible from the chosen value.
  56952. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56953. * part of lighting setup.)
  56954. */
  56955. get _perceptualColor(): Nullable<Color3>;
  56956. set _perceptualColor(value: Nullable<Color3>);
  56957. protected _primaryColorShadowLevel: float;
  56958. /**
  56959. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56960. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56961. */
  56962. get primaryColorShadowLevel(): float;
  56963. set primaryColorShadowLevel(value: float);
  56964. protected _primaryColorHighlightLevel: float;
  56965. /**
  56966. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56967. * The primary color is used at the level chosen to define what the white area would look.
  56968. */
  56969. get primaryColorHighlightLevel(): float;
  56970. set primaryColorHighlightLevel(value: float);
  56971. protected _reflectionTexture: Nullable<BaseTexture>;
  56972. /**
  56973. * Reflection Texture used in the material.
  56974. * Should be author in a specific way for the best result (refer to the documentation).
  56975. */
  56976. reflectionTexture: Nullable<BaseTexture>;
  56977. protected _reflectionBlur: float;
  56978. /**
  56979. * Reflection Texture level of blur.
  56980. *
  56981. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56982. * texture twice.
  56983. */
  56984. reflectionBlur: float;
  56985. protected _diffuseTexture: Nullable<BaseTexture>;
  56986. /**
  56987. * Diffuse Texture used in the material.
  56988. * Should be author in a specific way for the best result (refer to the documentation).
  56989. */
  56990. diffuseTexture: Nullable<BaseTexture>;
  56991. protected _shadowLights: Nullable<IShadowLight[]>;
  56992. /**
  56993. * Specify the list of lights casting shadow on the material.
  56994. * All scene shadow lights will be included if null.
  56995. */
  56996. shadowLights: Nullable<IShadowLight[]>;
  56997. protected _shadowLevel: float;
  56998. /**
  56999. * Helps adjusting the shadow to a softer level if required.
  57000. * 0 means black shadows and 1 means no shadows.
  57001. */
  57002. shadowLevel: float;
  57003. protected _sceneCenter: Vector3;
  57004. /**
  57005. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57006. * It is usually zero but might be interesting to modify according to your setup.
  57007. */
  57008. sceneCenter: Vector3;
  57009. protected _opacityFresnel: boolean;
  57010. /**
  57011. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57012. * This helps ensuring a nice transition when the camera goes under the ground.
  57013. */
  57014. opacityFresnel: boolean;
  57015. protected _reflectionFresnel: boolean;
  57016. /**
  57017. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57018. * This helps adding a mirror texture on the ground.
  57019. */
  57020. reflectionFresnel: boolean;
  57021. protected _reflectionFalloffDistance: number;
  57022. /**
  57023. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57024. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57025. */
  57026. reflectionFalloffDistance: number;
  57027. protected _reflectionAmount: number;
  57028. /**
  57029. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57030. */
  57031. reflectionAmount: number;
  57032. protected _reflectionReflectance0: number;
  57033. /**
  57034. * This specifies the weight of the reflection at grazing angle.
  57035. */
  57036. reflectionReflectance0: number;
  57037. protected _reflectionReflectance90: number;
  57038. /**
  57039. * This specifies the weight of the reflection at a perpendicular point of view.
  57040. */
  57041. reflectionReflectance90: number;
  57042. /**
  57043. * Sets the reflection reflectance fresnel values according to the default standard
  57044. * empirically know to work well :-)
  57045. */
  57046. set reflectionStandardFresnelWeight(value: number);
  57047. protected _useRGBColor: boolean;
  57048. /**
  57049. * Helps to directly use the maps channels instead of their level.
  57050. */
  57051. useRGBColor: boolean;
  57052. protected _enableNoise: boolean;
  57053. /**
  57054. * This helps reducing the banding effect that could occur on the background.
  57055. */
  57056. enableNoise: boolean;
  57057. /**
  57058. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57059. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57060. * Recommended to be keep at 1.0 except for special cases.
  57061. */
  57062. get fovMultiplier(): number;
  57063. set fovMultiplier(value: number);
  57064. private _fovMultiplier;
  57065. /**
  57066. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57067. */
  57068. useEquirectangularFOV: boolean;
  57069. private _maxSimultaneousLights;
  57070. /**
  57071. * Number of Simultaneous lights allowed on the material.
  57072. */
  57073. maxSimultaneousLights: int;
  57074. private _shadowOnly;
  57075. /**
  57076. * Make the material only render shadows
  57077. */
  57078. shadowOnly: boolean;
  57079. /**
  57080. * Default configuration related to image processing available in the Background Material.
  57081. */
  57082. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57083. /**
  57084. * Keep track of the image processing observer to allow dispose and replace.
  57085. */
  57086. private _imageProcessingObserver;
  57087. /**
  57088. * Attaches a new image processing configuration to the PBR Material.
  57089. * @param configuration (if null the scene configuration will be use)
  57090. */
  57091. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57092. /**
  57093. * Gets the image processing configuration used either in this material.
  57094. */
  57095. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57096. /**
  57097. * Sets the Default image processing configuration used either in the this material.
  57098. *
  57099. * If sets to null, the scene one is in use.
  57100. */
  57101. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57102. /**
  57103. * Gets wether the color curves effect is enabled.
  57104. */
  57105. get cameraColorCurvesEnabled(): boolean;
  57106. /**
  57107. * Sets wether the color curves effect is enabled.
  57108. */
  57109. set cameraColorCurvesEnabled(value: boolean);
  57110. /**
  57111. * Gets wether the color grading effect is enabled.
  57112. */
  57113. get cameraColorGradingEnabled(): boolean;
  57114. /**
  57115. * Gets wether the color grading effect is enabled.
  57116. */
  57117. set cameraColorGradingEnabled(value: boolean);
  57118. /**
  57119. * Gets wether tonemapping is enabled or not.
  57120. */
  57121. get cameraToneMappingEnabled(): boolean;
  57122. /**
  57123. * Sets wether tonemapping is enabled or not
  57124. */
  57125. set cameraToneMappingEnabled(value: boolean);
  57126. /**
  57127. * The camera exposure used on this material.
  57128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57129. * This corresponds to a photographic exposure.
  57130. */
  57131. get cameraExposure(): float;
  57132. /**
  57133. * The camera exposure used on this material.
  57134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57135. * This corresponds to a photographic exposure.
  57136. */
  57137. set cameraExposure(value: float);
  57138. /**
  57139. * Gets The camera contrast used on this material.
  57140. */
  57141. get cameraContrast(): float;
  57142. /**
  57143. * Sets The camera contrast used on this material.
  57144. */
  57145. set cameraContrast(value: float);
  57146. /**
  57147. * Gets the Color Grading 2D Lookup Texture.
  57148. */
  57149. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57150. /**
  57151. * Sets the Color Grading 2D Lookup Texture.
  57152. */
  57153. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57154. /**
  57155. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57157. * 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;
  57158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57159. */
  57160. get cameraColorCurves(): Nullable<ColorCurves>;
  57161. /**
  57162. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57163. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57164. * 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;
  57165. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57166. */
  57167. set cameraColorCurves(value: Nullable<ColorCurves>);
  57168. /**
  57169. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57170. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57171. */
  57172. switchToBGR: boolean;
  57173. private _renderTargets;
  57174. private _reflectionControls;
  57175. private _white;
  57176. private _primaryShadowColor;
  57177. private _primaryHighlightColor;
  57178. /**
  57179. * Instantiates a Background Material in the given scene
  57180. * @param name The friendly name of the material
  57181. * @param scene The scene to add the material to
  57182. */
  57183. constructor(name: string, scene: Scene);
  57184. /**
  57185. * Gets a boolean indicating that current material needs to register RTT
  57186. */
  57187. get hasRenderTargetTextures(): boolean;
  57188. /**
  57189. * The entire material has been created in order to prevent overdraw.
  57190. * @returns false
  57191. */
  57192. needAlphaTesting(): boolean;
  57193. /**
  57194. * The entire material has been created in order to prevent overdraw.
  57195. * @returns true if blending is enable
  57196. */
  57197. needAlphaBlending(): boolean;
  57198. /**
  57199. * Checks wether the material is ready to be rendered for a given mesh.
  57200. * @param mesh The mesh to render
  57201. * @param subMesh The submesh to check against
  57202. * @param useInstances Specify wether or not the material is used with instances
  57203. * @returns true if all the dependencies are ready (Textures, Effects...)
  57204. */
  57205. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57206. /**
  57207. * Compute the primary color according to the chosen perceptual color.
  57208. */
  57209. private _computePrimaryColorFromPerceptualColor;
  57210. /**
  57211. * Compute the highlights and shadow colors according to their chosen levels.
  57212. */
  57213. private _computePrimaryColors;
  57214. /**
  57215. * Build the uniform buffer used in the material.
  57216. */
  57217. buildUniformLayout(): void;
  57218. /**
  57219. * Unbind the material.
  57220. */
  57221. unbind(): void;
  57222. /**
  57223. * Bind only the world matrix to the material.
  57224. * @param world The world matrix to bind.
  57225. */
  57226. bindOnlyWorldMatrix(world: Matrix): void;
  57227. /**
  57228. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57229. * @param world The world matrix to bind.
  57230. * @param subMesh The submesh to bind for.
  57231. */
  57232. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57233. /**
  57234. * Checks to see if a texture is used in the material.
  57235. * @param texture - Base texture to use.
  57236. * @returns - Boolean specifying if a texture is used in the material.
  57237. */
  57238. hasTexture(texture: BaseTexture): boolean;
  57239. /**
  57240. * Dispose the material.
  57241. * @param forceDisposeEffect Force disposal of the associated effect.
  57242. * @param forceDisposeTextures Force disposal of the associated textures.
  57243. */
  57244. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57245. /**
  57246. * Clones the material.
  57247. * @param name The cloned name.
  57248. * @returns The cloned material.
  57249. */
  57250. clone(name: string): BackgroundMaterial;
  57251. /**
  57252. * Serializes the current material to its JSON representation.
  57253. * @returns The JSON representation.
  57254. */
  57255. serialize(): any;
  57256. /**
  57257. * Gets the class name of the material
  57258. * @returns "BackgroundMaterial"
  57259. */
  57260. getClassName(): string;
  57261. /**
  57262. * Parse a JSON input to create back a background material.
  57263. * @param source The JSON data to parse
  57264. * @param scene The scene to create the parsed material in
  57265. * @param rootUrl The root url of the assets the material depends upon
  57266. * @returns the instantiated BackgroundMaterial.
  57267. */
  57268. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57269. }
  57270. }
  57271. declare module "babylonjs/Helpers/environmentHelper" {
  57272. import { Observable } from "babylonjs/Misc/observable";
  57273. import { Nullable } from "babylonjs/types";
  57274. import { Scene } from "babylonjs/scene";
  57275. import { Vector3 } from "babylonjs/Maths/math.vector";
  57276. import { Color3 } from "babylonjs/Maths/math.color";
  57277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57278. import { Mesh } from "babylonjs/Meshes/mesh";
  57279. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57280. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57281. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57282. import "babylonjs/Meshes/Builders/planeBuilder";
  57283. import "babylonjs/Meshes/Builders/boxBuilder";
  57284. /**
  57285. * Represents the different options available during the creation of
  57286. * a Environment helper.
  57287. *
  57288. * This can control the default ground, skybox and image processing setup of your scene.
  57289. */
  57290. export interface IEnvironmentHelperOptions {
  57291. /**
  57292. * Specifies whether or not to create a ground.
  57293. * True by default.
  57294. */
  57295. createGround: boolean;
  57296. /**
  57297. * Specifies the ground size.
  57298. * 15 by default.
  57299. */
  57300. groundSize: number;
  57301. /**
  57302. * The texture used on the ground for the main color.
  57303. * Comes from the BabylonJS CDN by default.
  57304. *
  57305. * Remarks: Can be either a texture or a url.
  57306. */
  57307. groundTexture: string | BaseTexture;
  57308. /**
  57309. * The color mixed in the ground texture by default.
  57310. * BabylonJS clearColor by default.
  57311. */
  57312. groundColor: Color3;
  57313. /**
  57314. * Specifies the ground opacity.
  57315. * 1 by default.
  57316. */
  57317. groundOpacity: number;
  57318. /**
  57319. * Enables the ground to receive shadows.
  57320. * True by default.
  57321. */
  57322. enableGroundShadow: boolean;
  57323. /**
  57324. * Helps preventing the shadow to be fully black on the ground.
  57325. * 0.5 by default.
  57326. */
  57327. groundShadowLevel: number;
  57328. /**
  57329. * Creates a mirror texture attach to the ground.
  57330. * false by default.
  57331. */
  57332. enableGroundMirror: boolean;
  57333. /**
  57334. * Specifies the ground mirror size ratio.
  57335. * 0.3 by default as the default kernel is 64.
  57336. */
  57337. groundMirrorSizeRatio: number;
  57338. /**
  57339. * Specifies the ground mirror blur kernel size.
  57340. * 64 by default.
  57341. */
  57342. groundMirrorBlurKernel: number;
  57343. /**
  57344. * Specifies the ground mirror visibility amount.
  57345. * 1 by default
  57346. */
  57347. groundMirrorAmount: number;
  57348. /**
  57349. * Specifies the ground mirror reflectance weight.
  57350. * This uses the standard weight of the background material to setup the fresnel effect
  57351. * of the mirror.
  57352. * 1 by default.
  57353. */
  57354. groundMirrorFresnelWeight: number;
  57355. /**
  57356. * Specifies the ground mirror Falloff distance.
  57357. * This can helps reducing the size of the reflection.
  57358. * 0 by Default.
  57359. */
  57360. groundMirrorFallOffDistance: number;
  57361. /**
  57362. * Specifies the ground mirror texture type.
  57363. * Unsigned Int by Default.
  57364. */
  57365. groundMirrorTextureType: number;
  57366. /**
  57367. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57368. * the shown objects.
  57369. */
  57370. groundYBias: number;
  57371. /**
  57372. * Specifies whether or not to create a skybox.
  57373. * True by default.
  57374. */
  57375. createSkybox: boolean;
  57376. /**
  57377. * Specifies the skybox size.
  57378. * 20 by default.
  57379. */
  57380. skyboxSize: number;
  57381. /**
  57382. * The texture used on the skybox for the main color.
  57383. * Comes from the BabylonJS CDN by default.
  57384. *
  57385. * Remarks: Can be either a texture or a url.
  57386. */
  57387. skyboxTexture: string | BaseTexture;
  57388. /**
  57389. * The color mixed in the skybox texture by default.
  57390. * BabylonJS clearColor by default.
  57391. */
  57392. skyboxColor: Color3;
  57393. /**
  57394. * The background rotation around the Y axis of the scene.
  57395. * This helps aligning the key lights of your scene with the background.
  57396. * 0 by default.
  57397. */
  57398. backgroundYRotation: number;
  57399. /**
  57400. * Compute automatically the size of the elements to best fit with the scene.
  57401. */
  57402. sizeAuto: boolean;
  57403. /**
  57404. * Default position of the rootMesh if autoSize is not true.
  57405. */
  57406. rootPosition: Vector3;
  57407. /**
  57408. * Sets up the image processing in the scene.
  57409. * true by default.
  57410. */
  57411. setupImageProcessing: boolean;
  57412. /**
  57413. * The texture used as your environment texture in the scene.
  57414. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57415. *
  57416. * Remarks: Can be either a texture or a url.
  57417. */
  57418. environmentTexture: string | BaseTexture;
  57419. /**
  57420. * The value of the exposure to apply to the scene.
  57421. * 0.6 by default if setupImageProcessing is true.
  57422. */
  57423. cameraExposure: number;
  57424. /**
  57425. * The value of the contrast to apply to the scene.
  57426. * 1.6 by default if setupImageProcessing is true.
  57427. */
  57428. cameraContrast: number;
  57429. /**
  57430. * Specifies whether or not tonemapping should be enabled in the scene.
  57431. * true by default if setupImageProcessing is true.
  57432. */
  57433. toneMappingEnabled: boolean;
  57434. }
  57435. /**
  57436. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57437. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57438. * It also helps with the default setup of your imageProcessing configuration.
  57439. */
  57440. export class EnvironmentHelper {
  57441. /**
  57442. * Default ground texture URL.
  57443. */
  57444. private static _groundTextureCDNUrl;
  57445. /**
  57446. * Default skybox texture URL.
  57447. */
  57448. private static _skyboxTextureCDNUrl;
  57449. /**
  57450. * Default environment texture URL.
  57451. */
  57452. private static _environmentTextureCDNUrl;
  57453. /**
  57454. * Creates the default options for the helper.
  57455. */
  57456. private static _getDefaultOptions;
  57457. private _rootMesh;
  57458. /**
  57459. * Gets the root mesh created by the helper.
  57460. */
  57461. get rootMesh(): Mesh;
  57462. private _skybox;
  57463. /**
  57464. * Gets the skybox created by the helper.
  57465. */
  57466. get skybox(): Nullable<Mesh>;
  57467. private _skyboxTexture;
  57468. /**
  57469. * Gets the skybox texture created by the helper.
  57470. */
  57471. get skyboxTexture(): Nullable<BaseTexture>;
  57472. private _skyboxMaterial;
  57473. /**
  57474. * Gets the skybox material created by the helper.
  57475. */
  57476. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57477. private _ground;
  57478. /**
  57479. * Gets the ground mesh created by the helper.
  57480. */
  57481. get ground(): Nullable<Mesh>;
  57482. private _groundTexture;
  57483. /**
  57484. * Gets the ground texture created by the helper.
  57485. */
  57486. get groundTexture(): Nullable<BaseTexture>;
  57487. private _groundMirror;
  57488. /**
  57489. * Gets the ground mirror created by the helper.
  57490. */
  57491. get groundMirror(): Nullable<MirrorTexture>;
  57492. /**
  57493. * Gets the ground mirror render list to helps pushing the meshes
  57494. * you wish in the ground reflection.
  57495. */
  57496. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57497. private _groundMaterial;
  57498. /**
  57499. * Gets the ground material created by the helper.
  57500. */
  57501. get groundMaterial(): Nullable<BackgroundMaterial>;
  57502. /**
  57503. * Stores the creation options.
  57504. */
  57505. private readonly _scene;
  57506. private _options;
  57507. /**
  57508. * This observable will be notified with any error during the creation of the environment,
  57509. * mainly texture creation errors.
  57510. */
  57511. onErrorObservable: Observable<{
  57512. message?: string;
  57513. exception?: any;
  57514. }>;
  57515. /**
  57516. * constructor
  57517. * @param options Defines the options we want to customize the helper
  57518. * @param scene The scene to add the material to
  57519. */
  57520. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57521. /**
  57522. * Updates the background according to the new options
  57523. * @param options
  57524. */
  57525. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57526. /**
  57527. * Sets the primary color of all the available elements.
  57528. * @param color the main color to affect to the ground and the background
  57529. */
  57530. setMainColor(color: Color3): void;
  57531. /**
  57532. * Setup the image processing according to the specified options.
  57533. */
  57534. private _setupImageProcessing;
  57535. /**
  57536. * Setup the environment texture according to the specified options.
  57537. */
  57538. private _setupEnvironmentTexture;
  57539. /**
  57540. * Setup the background according to the specified options.
  57541. */
  57542. private _setupBackground;
  57543. /**
  57544. * Get the scene sizes according to the setup.
  57545. */
  57546. private _getSceneSize;
  57547. /**
  57548. * Setup the ground according to the specified options.
  57549. */
  57550. private _setupGround;
  57551. /**
  57552. * Setup the ground material according to the specified options.
  57553. */
  57554. private _setupGroundMaterial;
  57555. /**
  57556. * Setup the ground diffuse texture according to the specified options.
  57557. */
  57558. private _setupGroundDiffuseTexture;
  57559. /**
  57560. * Setup the ground mirror texture according to the specified options.
  57561. */
  57562. private _setupGroundMirrorTexture;
  57563. /**
  57564. * Setup the ground to receive the mirror texture.
  57565. */
  57566. private _setupMirrorInGroundMaterial;
  57567. /**
  57568. * Setup the skybox according to the specified options.
  57569. */
  57570. private _setupSkybox;
  57571. /**
  57572. * Setup the skybox material according to the specified options.
  57573. */
  57574. private _setupSkyboxMaterial;
  57575. /**
  57576. * Setup the skybox reflection texture according to the specified options.
  57577. */
  57578. private _setupSkyboxReflectionTexture;
  57579. private _errorHandler;
  57580. /**
  57581. * Dispose all the elements created by the Helper.
  57582. */
  57583. dispose(): void;
  57584. }
  57585. }
  57586. declare module "babylonjs/Helpers/textureDome" {
  57587. import { Scene } from "babylonjs/scene";
  57588. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57589. import { Mesh } from "babylonjs/Meshes/mesh";
  57590. import { Texture } from "babylonjs/Materials/Textures/texture";
  57591. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57592. import "babylonjs/Meshes/Builders/sphereBuilder";
  57593. import { Nullable } from "babylonjs/types";
  57594. import { Observable } from "babylonjs/Misc/observable";
  57595. /**
  57596. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57597. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57598. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57599. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57600. */
  57601. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57602. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57603. /**
  57604. * Define the source as a Monoscopic panoramic 360/180.
  57605. */
  57606. static readonly MODE_MONOSCOPIC: number;
  57607. /**
  57608. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57609. */
  57610. static readonly MODE_TOPBOTTOM: number;
  57611. /**
  57612. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57613. */
  57614. static readonly MODE_SIDEBYSIDE: number;
  57615. private _halfDome;
  57616. protected _useDirectMapping: boolean;
  57617. /**
  57618. * The texture being displayed on the sphere
  57619. */
  57620. protected _texture: T;
  57621. /**
  57622. * Gets the texture being displayed on the sphere
  57623. */
  57624. get texture(): T;
  57625. /**
  57626. * Sets the texture being displayed on the sphere
  57627. */
  57628. set texture(newTexture: T);
  57629. /**
  57630. * The skybox material
  57631. */
  57632. protected _material: BackgroundMaterial;
  57633. /**
  57634. * The surface used for the dome
  57635. */
  57636. protected _mesh: Mesh;
  57637. /**
  57638. * Gets the mesh used for the dome.
  57639. */
  57640. get mesh(): Mesh;
  57641. /**
  57642. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57643. */
  57644. private _halfDomeMask;
  57645. /**
  57646. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57647. * Also see the options.resolution property.
  57648. */
  57649. get fovMultiplier(): number;
  57650. set fovMultiplier(value: number);
  57651. protected _textureMode: number;
  57652. /**
  57653. * Gets or set the current texture mode for the texture. It can be:
  57654. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57655. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57656. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57657. */
  57658. get textureMode(): number;
  57659. /**
  57660. * Sets the current texture mode for the texture. It can be:
  57661. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57662. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57663. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57664. */
  57665. set textureMode(value: number);
  57666. /**
  57667. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57668. */
  57669. get halfDome(): boolean;
  57670. /**
  57671. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57672. */
  57673. set halfDome(enabled: boolean);
  57674. /**
  57675. * Oberserver used in Stereoscopic VR Mode.
  57676. */
  57677. private _onBeforeCameraRenderObserver;
  57678. /**
  57679. * Observable raised when an error occured while loading the 360 image
  57680. */
  57681. onLoadErrorObservable: Observable<string>;
  57682. /**
  57683. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57684. * @param name Element's name, child elements will append suffixes for their own names.
  57685. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57686. * @param options An object containing optional or exposed sub element properties
  57687. */
  57688. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57689. resolution?: number;
  57690. clickToPlay?: boolean;
  57691. autoPlay?: boolean;
  57692. loop?: boolean;
  57693. size?: number;
  57694. poster?: string;
  57695. faceForward?: boolean;
  57696. useDirectMapping?: boolean;
  57697. halfDomeMode?: boolean;
  57698. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57699. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57700. protected _changeTextureMode(value: number): void;
  57701. /**
  57702. * Releases resources associated with this node.
  57703. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57704. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57705. */
  57706. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57707. }
  57708. }
  57709. declare module "babylonjs/Helpers/photoDome" {
  57710. import { Scene } from "babylonjs/scene";
  57711. import { Texture } from "babylonjs/Materials/Textures/texture";
  57712. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57713. /**
  57714. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57715. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57716. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57717. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57718. */
  57719. export class PhotoDome extends TextureDome<Texture> {
  57720. /**
  57721. * Define the image as a Monoscopic panoramic 360 image.
  57722. */
  57723. static readonly MODE_MONOSCOPIC: number;
  57724. /**
  57725. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57726. */
  57727. static readonly MODE_TOPBOTTOM: number;
  57728. /**
  57729. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57730. */
  57731. static readonly MODE_SIDEBYSIDE: number;
  57732. /**
  57733. * Gets or sets the texture being displayed on the sphere
  57734. */
  57735. get photoTexture(): Texture;
  57736. /**
  57737. * sets the texture being displayed on the sphere
  57738. */
  57739. set photoTexture(value: Texture);
  57740. /**
  57741. * Gets the current video mode for the video. It can be:
  57742. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57743. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57744. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57745. */
  57746. get imageMode(): number;
  57747. /**
  57748. * Sets the current video mode for the video. It can be:
  57749. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57750. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57751. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57752. */
  57753. set imageMode(value: number);
  57754. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57755. }
  57756. }
  57757. declare module "babylonjs/Misc/rgbdTextureTools" {
  57758. import "babylonjs/Shaders/rgbdDecode.fragment";
  57759. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57760. import { Texture } from "babylonjs/Materials/Textures/texture";
  57761. /**
  57762. * Class used to host RGBD texture specific utilities
  57763. */
  57764. export class RGBDTextureTools {
  57765. /**
  57766. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57767. * @param texture the texture to expand.
  57768. */
  57769. static ExpandRGBDTexture(texture: Texture): void;
  57770. }
  57771. }
  57772. declare module "babylonjs/Misc/brdfTextureTools" {
  57773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57774. import { Scene } from "babylonjs/scene";
  57775. /**
  57776. * Class used to host texture specific utilities
  57777. */
  57778. export class BRDFTextureTools {
  57779. /**
  57780. * Prevents texture cache collision
  57781. */
  57782. private static _instanceNumber;
  57783. /**
  57784. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57785. * @param scene defines the hosting scene
  57786. * @returns the environment BRDF texture
  57787. */
  57788. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57789. private static _environmentBRDFBase64Texture;
  57790. }
  57791. }
  57792. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57793. import { Nullable } from "babylonjs/types";
  57794. import { Color3 } from "babylonjs/Maths/math.color";
  57795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57796. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57797. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57798. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57799. import { Engine } from "babylonjs/Engines/engine";
  57800. import { Scene } from "babylonjs/scene";
  57801. /**
  57802. * @hidden
  57803. */
  57804. export interface IMaterialClearCoatDefines {
  57805. CLEARCOAT: boolean;
  57806. CLEARCOAT_DEFAULTIOR: boolean;
  57807. CLEARCOAT_TEXTURE: boolean;
  57808. CLEARCOAT_TEXTUREDIRECTUV: number;
  57809. CLEARCOAT_BUMP: boolean;
  57810. CLEARCOAT_BUMPDIRECTUV: number;
  57811. CLEARCOAT_TINT: boolean;
  57812. CLEARCOAT_TINT_TEXTURE: boolean;
  57813. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57814. /** @hidden */
  57815. _areTexturesDirty: boolean;
  57816. }
  57817. /**
  57818. * Define the code related to the clear coat parameters of the pbr material.
  57819. */
  57820. export class PBRClearCoatConfiguration {
  57821. /**
  57822. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57823. * The default fits with a polyurethane material.
  57824. */
  57825. private static readonly _DefaultIndexOfRefraction;
  57826. private _isEnabled;
  57827. /**
  57828. * Defines if the clear coat is enabled in the material.
  57829. */
  57830. isEnabled: boolean;
  57831. /**
  57832. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57833. */
  57834. intensity: number;
  57835. /**
  57836. * Defines the clear coat layer roughness.
  57837. */
  57838. roughness: number;
  57839. private _indexOfRefraction;
  57840. /**
  57841. * Defines the index of refraction of the clear coat.
  57842. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57843. * The default fits with a polyurethane material.
  57844. * Changing the default value is more performance intensive.
  57845. */
  57846. indexOfRefraction: number;
  57847. private _texture;
  57848. /**
  57849. * Stores the clear coat values in a texture.
  57850. */
  57851. texture: Nullable<BaseTexture>;
  57852. private _bumpTexture;
  57853. /**
  57854. * Define the clear coat specific bump texture.
  57855. */
  57856. bumpTexture: Nullable<BaseTexture>;
  57857. private _isTintEnabled;
  57858. /**
  57859. * Defines if the clear coat tint is enabled in the material.
  57860. */
  57861. isTintEnabled: boolean;
  57862. /**
  57863. * Defines the clear coat tint of the material.
  57864. * This is only use if tint is enabled
  57865. */
  57866. tintColor: Color3;
  57867. /**
  57868. * Defines the distance at which the tint color should be found in the
  57869. * clear coat media.
  57870. * This is only use if tint is enabled
  57871. */
  57872. tintColorAtDistance: number;
  57873. /**
  57874. * Defines the clear coat layer thickness.
  57875. * This is only use if tint is enabled
  57876. */
  57877. tintThickness: number;
  57878. private _tintTexture;
  57879. /**
  57880. * Stores the clear tint values in a texture.
  57881. * rgb is tint
  57882. * a is a thickness factor
  57883. */
  57884. tintTexture: Nullable<BaseTexture>;
  57885. /** @hidden */
  57886. private _internalMarkAllSubMeshesAsTexturesDirty;
  57887. /** @hidden */
  57888. _markAllSubMeshesAsTexturesDirty(): void;
  57889. /**
  57890. * Instantiate a new istance of clear coat configuration.
  57891. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57892. */
  57893. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57894. /**
  57895. * Gets wehter the submesh is ready to be used or not.
  57896. * @param defines the list of "defines" to update.
  57897. * @param scene defines the scene the material belongs to.
  57898. * @param engine defines the engine the material belongs to.
  57899. * @param disableBumpMap defines wether the material disables bump or not.
  57900. * @returns - boolean indicating that the submesh is ready or not.
  57901. */
  57902. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57903. /**
  57904. * Checks to see if a texture is used in the material.
  57905. * @param defines the list of "defines" to update.
  57906. * @param scene defines the scene to the material belongs to.
  57907. */
  57908. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57909. /**
  57910. * Binds the material data.
  57911. * @param uniformBuffer defines the Uniform buffer to fill in.
  57912. * @param scene defines the scene the material belongs to.
  57913. * @param engine defines the engine the material belongs to.
  57914. * @param disableBumpMap defines wether the material disables bump or not.
  57915. * @param isFrozen defines wether the material is frozen or not.
  57916. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57917. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57918. */
  57919. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57920. /**
  57921. * Checks to see if a texture is used in the material.
  57922. * @param texture - Base texture to use.
  57923. * @returns - Boolean specifying if a texture is used in the material.
  57924. */
  57925. hasTexture(texture: BaseTexture): boolean;
  57926. /**
  57927. * Returns an array of the actively used textures.
  57928. * @param activeTextures Array of BaseTextures
  57929. */
  57930. getActiveTextures(activeTextures: BaseTexture[]): void;
  57931. /**
  57932. * Returns the animatable textures.
  57933. * @param animatables Array of animatable textures.
  57934. */
  57935. getAnimatables(animatables: IAnimatable[]): void;
  57936. /**
  57937. * Disposes the resources of the material.
  57938. * @param forceDisposeTextures - Forces the disposal of all textures.
  57939. */
  57940. dispose(forceDisposeTextures?: boolean): void;
  57941. /**
  57942. * Get the current class name of the texture useful for serialization or dynamic coding.
  57943. * @returns "PBRClearCoatConfiguration"
  57944. */
  57945. getClassName(): string;
  57946. /**
  57947. * Add fallbacks to the effect fallbacks list.
  57948. * @param defines defines the Base texture to use.
  57949. * @param fallbacks defines the current fallback list.
  57950. * @param currentRank defines the current fallback rank.
  57951. * @returns the new fallback rank.
  57952. */
  57953. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57954. /**
  57955. * Add the required uniforms to the current list.
  57956. * @param uniforms defines the current uniform list.
  57957. */
  57958. static AddUniforms(uniforms: string[]): void;
  57959. /**
  57960. * Add the required samplers to the current list.
  57961. * @param samplers defines the current sampler list.
  57962. */
  57963. static AddSamplers(samplers: string[]): void;
  57964. /**
  57965. * Add the required uniforms to the current buffer.
  57966. * @param uniformBuffer defines the current uniform buffer.
  57967. */
  57968. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57969. /**
  57970. * Makes a duplicate of the current configuration into another one.
  57971. * @param clearCoatConfiguration define the config where to copy the info
  57972. */
  57973. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57974. /**
  57975. * Serializes this clear coat configuration.
  57976. * @returns - An object with the serialized config.
  57977. */
  57978. serialize(): any;
  57979. /**
  57980. * Parses a anisotropy Configuration from a serialized object.
  57981. * @param source - Serialized object.
  57982. * @param scene Defines the scene we are parsing for
  57983. * @param rootUrl Defines the rootUrl to load from
  57984. */
  57985. parse(source: any, scene: Scene, rootUrl: string): void;
  57986. }
  57987. }
  57988. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57989. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57991. import { Vector2 } from "babylonjs/Maths/math.vector";
  57992. import { Scene } from "babylonjs/scene";
  57993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57994. import { Nullable } from "babylonjs/types";
  57995. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57996. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57997. /**
  57998. * @hidden
  57999. */
  58000. export interface IMaterialAnisotropicDefines {
  58001. ANISOTROPIC: boolean;
  58002. ANISOTROPIC_TEXTURE: boolean;
  58003. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58004. MAINUV1: boolean;
  58005. _areTexturesDirty: boolean;
  58006. _needUVs: boolean;
  58007. }
  58008. /**
  58009. * Define the code related to the anisotropic parameters of the pbr material.
  58010. */
  58011. export class PBRAnisotropicConfiguration {
  58012. private _isEnabled;
  58013. /**
  58014. * Defines if the anisotropy is enabled in the material.
  58015. */
  58016. isEnabled: boolean;
  58017. /**
  58018. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  58019. */
  58020. intensity: number;
  58021. /**
  58022. * Defines if the effect is along the tangents, bitangents or in between.
  58023. * By default, the effect is "strectching" the highlights along the tangents.
  58024. */
  58025. direction: Vector2;
  58026. private _texture;
  58027. /**
  58028. * Stores the anisotropy values in a texture.
  58029. * rg is direction (like normal from -1 to 1)
  58030. * b is a intensity
  58031. */
  58032. texture: Nullable<BaseTexture>;
  58033. /** @hidden */
  58034. private _internalMarkAllSubMeshesAsTexturesDirty;
  58035. /** @hidden */
  58036. _markAllSubMeshesAsTexturesDirty(): void;
  58037. /**
  58038. * Instantiate a new istance of anisotropy configuration.
  58039. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58040. */
  58041. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58042. /**
  58043. * Specifies that the submesh is ready to be used.
  58044. * @param defines the list of "defines" to update.
  58045. * @param scene defines the scene the material belongs to.
  58046. * @returns - boolean indicating that the submesh is ready or not.
  58047. */
  58048. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58049. /**
  58050. * Checks to see if a texture is used in the material.
  58051. * @param defines the list of "defines" to update.
  58052. * @param mesh the mesh we are preparing the defines for.
  58053. * @param scene defines the scene the material belongs to.
  58054. */
  58055. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58056. /**
  58057. * Binds the material data.
  58058. * @param uniformBuffer defines the Uniform buffer to fill in.
  58059. * @param scene defines the scene the material belongs to.
  58060. * @param isFrozen defines wether the material is frozen or not.
  58061. */
  58062. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58063. /**
  58064. * Checks to see if a texture is used in the material.
  58065. * @param texture - Base texture to use.
  58066. * @returns - Boolean specifying if a texture is used in the material.
  58067. */
  58068. hasTexture(texture: BaseTexture): boolean;
  58069. /**
  58070. * Returns an array of the actively used textures.
  58071. * @param activeTextures Array of BaseTextures
  58072. */
  58073. getActiveTextures(activeTextures: BaseTexture[]): void;
  58074. /**
  58075. * Returns the animatable textures.
  58076. * @param animatables Array of animatable textures.
  58077. */
  58078. getAnimatables(animatables: IAnimatable[]): void;
  58079. /**
  58080. * Disposes the resources of the material.
  58081. * @param forceDisposeTextures - Forces the disposal of all textures.
  58082. */
  58083. dispose(forceDisposeTextures?: boolean): void;
  58084. /**
  58085. * Get the current class name of the texture useful for serialization or dynamic coding.
  58086. * @returns "PBRAnisotropicConfiguration"
  58087. */
  58088. getClassName(): string;
  58089. /**
  58090. * Add fallbacks to the effect fallbacks list.
  58091. * @param defines defines the Base texture to use.
  58092. * @param fallbacks defines the current fallback list.
  58093. * @param currentRank defines the current fallback rank.
  58094. * @returns the new fallback rank.
  58095. */
  58096. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58097. /**
  58098. * Add the required uniforms to the current list.
  58099. * @param uniforms defines the current uniform list.
  58100. */
  58101. static AddUniforms(uniforms: string[]): void;
  58102. /**
  58103. * Add the required uniforms to the current buffer.
  58104. * @param uniformBuffer defines the current uniform buffer.
  58105. */
  58106. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58107. /**
  58108. * Add the required samplers to the current list.
  58109. * @param samplers defines the current sampler list.
  58110. */
  58111. static AddSamplers(samplers: string[]): void;
  58112. /**
  58113. * Makes a duplicate of the current configuration into another one.
  58114. * @param anisotropicConfiguration define the config where to copy the info
  58115. */
  58116. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58117. /**
  58118. * Serializes this anisotropy configuration.
  58119. * @returns - An object with the serialized config.
  58120. */
  58121. serialize(): any;
  58122. /**
  58123. * Parses a anisotropy Configuration from a serialized object.
  58124. * @param source - Serialized object.
  58125. * @param scene Defines the scene we are parsing for
  58126. * @param rootUrl Defines the rootUrl to load from
  58127. */
  58128. parse(source: any, scene: Scene, rootUrl: string): void;
  58129. }
  58130. }
  58131. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58132. import { Scene } from "babylonjs/scene";
  58133. /**
  58134. * @hidden
  58135. */
  58136. export interface IMaterialBRDFDefines {
  58137. BRDF_V_HEIGHT_CORRELATED: boolean;
  58138. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58139. SPHERICAL_HARMONICS: boolean;
  58140. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58141. /** @hidden */
  58142. _areMiscDirty: boolean;
  58143. }
  58144. /**
  58145. * Define the code related to the BRDF parameters of the pbr material.
  58146. */
  58147. export class PBRBRDFConfiguration {
  58148. /**
  58149. * Default value used for the energy conservation.
  58150. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58151. */
  58152. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58153. /**
  58154. * Default value used for the Smith Visibility Height Correlated mode.
  58155. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58156. */
  58157. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58158. /**
  58159. * Default value used for the IBL diffuse part.
  58160. * This can help switching back to the polynomials mode globally which is a tiny bit
  58161. * less GPU intensive at the drawback of a lower quality.
  58162. */
  58163. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58164. /**
  58165. * Default value used for activating energy conservation for the specular workflow.
  58166. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58167. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58168. */
  58169. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58170. private _useEnergyConservation;
  58171. /**
  58172. * Defines if the material uses energy conservation.
  58173. */
  58174. useEnergyConservation: boolean;
  58175. private _useSmithVisibilityHeightCorrelated;
  58176. /**
  58177. * LEGACY Mode set to false
  58178. * Defines if the material uses height smith correlated visibility term.
  58179. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58180. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58181. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58182. * Not relying on height correlated will also disable energy conservation.
  58183. */
  58184. useSmithVisibilityHeightCorrelated: boolean;
  58185. private _useSphericalHarmonics;
  58186. /**
  58187. * LEGACY Mode set to false
  58188. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58189. * diffuse part of the IBL.
  58190. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58191. * to the ground truth.
  58192. */
  58193. useSphericalHarmonics: boolean;
  58194. private _useSpecularGlossinessInputEnergyConservation;
  58195. /**
  58196. * Defines if the material uses energy conservation, when the specular workflow is active.
  58197. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58198. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58199. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58200. */
  58201. useSpecularGlossinessInputEnergyConservation: boolean;
  58202. /** @hidden */
  58203. private _internalMarkAllSubMeshesAsMiscDirty;
  58204. /** @hidden */
  58205. _markAllSubMeshesAsMiscDirty(): void;
  58206. /**
  58207. * Instantiate a new istance of clear coat configuration.
  58208. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58209. */
  58210. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58211. /**
  58212. * Checks to see if a texture is used in the material.
  58213. * @param defines the list of "defines" to update.
  58214. */
  58215. prepareDefines(defines: IMaterialBRDFDefines): void;
  58216. /**
  58217. * Get the current class name of the texture useful for serialization or dynamic coding.
  58218. * @returns "PBRClearCoatConfiguration"
  58219. */
  58220. getClassName(): string;
  58221. /**
  58222. * Makes a duplicate of the current configuration into another one.
  58223. * @param brdfConfiguration define the config where to copy the info
  58224. */
  58225. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58226. /**
  58227. * Serializes this BRDF configuration.
  58228. * @returns - An object with the serialized config.
  58229. */
  58230. serialize(): any;
  58231. /**
  58232. * Parses a anisotropy Configuration from a serialized object.
  58233. * @param source - Serialized object.
  58234. * @param scene Defines the scene we are parsing for
  58235. * @param rootUrl Defines the rootUrl to load from
  58236. */
  58237. parse(source: any, scene: Scene, rootUrl: string): void;
  58238. }
  58239. }
  58240. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58241. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58242. import { Color3 } from "babylonjs/Maths/math.color";
  58243. import { Scene } from "babylonjs/scene";
  58244. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58245. import { Nullable } from "babylonjs/types";
  58246. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58247. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58248. /**
  58249. * @hidden
  58250. */
  58251. export interface IMaterialSheenDefines {
  58252. SHEEN: boolean;
  58253. SHEEN_TEXTURE: boolean;
  58254. SHEEN_TEXTUREDIRECTUV: number;
  58255. SHEEN_LINKWITHALBEDO: boolean;
  58256. SHEEN_ROUGHNESS: boolean;
  58257. SHEEN_ALBEDOSCALING: boolean;
  58258. /** @hidden */
  58259. _areTexturesDirty: boolean;
  58260. }
  58261. /**
  58262. * Define the code related to the Sheen parameters of the pbr material.
  58263. */
  58264. export class PBRSheenConfiguration {
  58265. private _isEnabled;
  58266. /**
  58267. * Defines if the material uses sheen.
  58268. */
  58269. isEnabled: boolean;
  58270. private _linkSheenWithAlbedo;
  58271. /**
  58272. * Defines if the sheen is linked to the sheen color.
  58273. */
  58274. linkSheenWithAlbedo: boolean;
  58275. /**
  58276. * Defines the sheen intensity.
  58277. */
  58278. intensity: number;
  58279. /**
  58280. * Defines the sheen color.
  58281. */
  58282. color: Color3;
  58283. private _texture;
  58284. /**
  58285. * Stores the sheen tint values in a texture.
  58286. * rgb is tint
  58287. * a is a intensity or roughness if roughness has been defined
  58288. */
  58289. texture: Nullable<BaseTexture>;
  58290. private _roughness;
  58291. /**
  58292. * Defines the sheen roughness.
  58293. * It is not taken into account if linkSheenWithAlbedo is true.
  58294. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58295. */
  58296. roughness: Nullable<number>;
  58297. private _albedoScaling;
  58298. /**
  58299. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58300. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58301. * making it easier to setup and tweak the effect
  58302. */
  58303. albedoScaling: boolean;
  58304. /** @hidden */
  58305. private _internalMarkAllSubMeshesAsTexturesDirty;
  58306. /** @hidden */
  58307. _markAllSubMeshesAsTexturesDirty(): void;
  58308. /**
  58309. * Instantiate a new istance of clear coat configuration.
  58310. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58311. */
  58312. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58313. /**
  58314. * Specifies that the submesh is ready to be used.
  58315. * @param defines the list of "defines" to update.
  58316. * @param scene defines the scene the material belongs to.
  58317. * @returns - boolean indicating that the submesh is ready or not.
  58318. */
  58319. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58320. /**
  58321. * Checks to see if a texture is used in the material.
  58322. * @param defines the list of "defines" to update.
  58323. * @param scene defines the scene the material belongs to.
  58324. */
  58325. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58326. /**
  58327. * Binds the material data.
  58328. * @param uniformBuffer defines the Uniform buffer to fill in.
  58329. * @param scene defines the scene the material belongs to.
  58330. * @param isFrozen defines wether the material is frozen or not.
  58331. */
  58332. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58333. /**
  58334. * Checks to see if a texture is used in the material.
  58335. * @param texture - Base texture to use.
  58336. * @returns - Boolean specifying if a texture is used in the material.
  58337. */
  58338. hasTexture(texture: BaseTexture): boolean;
  58339. /**
  58340. * Returns an array of the actively used textures.
  58341. * @param activeTextures Array of BaseTextures
  58342. */
  58343. getActiveTextures(activeTextures: BaseTexture[]): void;
  58344. /**
  58345. * Returns the animatable textures.
  58346. * @param animatables Array of animatable textures.
  58347. */
  58348. getAnimatables(animatables: IAnimatable[]): void;
  58349. /**
  58350. * Disposes the resources of the material.
  58351. * @param forceDisposeTextures - Forces the disposal of all textures.
  58352. */
  58353. dispose(forceDisposeTextures?: boolean): void;
  58354. /**
  58355. * Get the current class name of the texture useful for serialization or dynamic coding.
  58356. * @returns "PBRSheenConfiguration"
  58357. */
  58358. getClassName(): string;
  58359. /**
  58360. * Add fallbacks to the effect fallbacks list.
  58361. * @param defines defines the Base texture to use.
  58362. * @param fallbacks defines the current fallback list.
  58363. * @param currentRank defines the current fallback rank.
  58364. * @returns the new fallback rank.
  58365. */
  58366. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58367. /**
  58368. * Add the required uniforms to the current list.
  58369. * @param uniforms defines the current uniform list.
  58370. */
  58371. static AddUniforms(uniforms: string[]): void;
  58372. /**
  58373. * Add the required uniforms to the current buffer.
  58374. * @param uniformBuffer defines the current uniform buffer.
  58375. */
  58376. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58377. /**
  58378. * Add the required samplers to the current list.
  58379. * @param samplers defines the current sampler list.
  58380. */
  58381. static AddSamplers(samplers: string[]): void;
  58382. /**
  58383. * Makes a duplicate of the current configuration into another one.
  58384. * @param sheenConfiguration define the config where to copy the info
  58385. */
  58386. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58387. /**
  58388. * Serializes this BRDF configuration.
  58389. * @returns - An object with the serialized config.
  58390. */
  58391. serialize(): any;
  58392. /**
  58393. * Parses a anisotropy Configuration from a serialized object.
  58394. * @param source - Serialized object.
  58395. * @param scene Defines the scene we are parsing for
  58396. * @param rootUrl Defines the rootUrl to load from
  58397. */
  58398. parse(source: any, scene: Scene, rootUrl: string): void;
  58399. }
  58400. }
  58401. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58402. import { Nullable } from "babylonjs/types";
  58403. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58404. import { Color3 } from "babylonjs/Maths/math.color";
  58405. import { SmartArray } from "babylonjs/Misc/smartArray";
  58406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58407. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58408. import { Effect } from "babylonjs/Materials/effect";
  58409. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58410. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58411. import { Engine } from "babylonjs/Engines/engine";
  58412. import { Scene } from "babylonjs/scene";
  58413. /**
  58414. * @hidden
  58415. */
  58416. export interface IMaterialSubSurfaceDefines {
  58417. SUBSURFACE: boolean;
  58418. SS_REFRACTION: boolean;
  58419. SS_TRANSLUCENCY: boolean;
  58420. SS_SCATTERING: boolean;
  58421. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58422. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58423. SS_REFRACTIONMAP_3D: boolean;
  58424. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58425. SS_LODINREFRACTIONALPHA: boolean;
  58426. SS_GAMMAREFRACTION: boolean;
  58427. SS_RGBDREFRACTION: boolean;
  58428. SS_LINEARSPECULARREFRACTION: boolean;
  58429. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58430. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58431. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58432. /** @hidden */
  58433. _areTexturesDirty: boolean;
  58434. }
  58435. /**
  58436. * Define the code related to the sub surface parameters of the pbr material.
  58437. */
  58438. export class PBRSubSurfaceConfiguration {
  58439. private _isRefractionEnabled;
  58440. /**
  58441. * Defines if the refraction is enabled in the material.
  58442. */
  58443. isRefractionEnabled: boolean;
  58444. private _isTranslucencyEnabled;
  58445. /**
  58446. * Defines if the translucency is enabled in the material.
  58447. */
  58448. isTranslucencyEnabled: boolean;
  58449. private _isScatteringEnabled;
  58450. /**
  58451. * Defines if the sub surface scattering is enabled in the material.
  58452. */
  58453. isScatteringEnabled: boolean;
  58454. private _scatteringDiffusionProfileIndex;
  58455. /**
  58456. * Diffusion profile for subsurface scattering.
  58457. * Useful for better scattering in the skins or foliages.
  58458. */
  58459. get scatteringDiffusionProfile(): Nullable<Color3>;
  58460. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58461. /**
  58462. * Defines the refraction intensity of the material.
  58463. * The refraction when enabled replaces the Diffuse part of the material.
  58464. * The intensity helps transitionning between diffuse and refraction.
  58465. */
  58466. refractionIntensity: number;
  58467. /**
  58468. * Defines the translucency intensity of the material.
  58469. * When translucency has been enabled, this defines how much of the "translucency"
  58470. * is addded to the diffuse part of the material.
  58471. */
  58472. translucencyIntensity: number;
  58473. /**
  58474. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58475. */
  58476. useAlbedoToTintRefraction: boolean;
  58477. private _thicknessTexture;
  58478. /**
  58479. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58480. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58481. * 0 would mean minimumThickness
  58482. * 1 would mean maximumThickness
  58483. * The other channels might be use as a mask to vary the different effects intensity.
  58484. */
  58485. thicknessTexture: Nullable<BaseTexture>;
  58486. private _refractionTexture;
  58487. /**
  58488. * Defines the texture to use for refraction.
  58489. */
  58490. refractionTexture: Nullable<BaseTexture>;
  58491. private _indexOfRefraction;
  58492. /**
  58493. * Index of refraction of the material base layer.
  58494. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58495. *
  58496. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58497. *
  58498. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58499. */
  58500. indexOfRefraction: number;
  58501. private _volumeIndexOfRefraction;
  58502. /**
  58503. * Index of refraction of the material's volume.
  58504. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58505. *
  58506. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58507. * the volume will use the same IOR as the surface.
  58508. */
  58509. get volumeIndexOfRefraction(): number;
  58510. set volumeIndexOfRefraction(value: number);
  58511. private _invertRefractionY;
  58512. /**
  58513. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58514. */
  58515. invertRefractionY: boolean;
  58516. private _linkRefractionWithTransparency;
  58517. /**
  58518. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58519. * Materials half opaque for instance using refraction could benefit from this control.
  58520. */
  58521. linkRefractionWithTransparency: boolean;
  58522. /**
  58523. * Defines the minimum thickness stored in the thickness map.
  58524. * If no thickness map is defined, this value will be used to simulate thickness.
  58525. */
  58526. minimumThickness: number;
  58527. /**
  58528. * Defines the maximum thickness stored in the thickness map.
  58529. */
  58530. maximumThickness: number;
  58531. /**
  58532. * Defines the volume tint of the material.
  58533. * This is used for both translucency and scattering.
  58534. */
  58535. tintColor: Color3;
  58536. /**
  58537. * Defines the distance at which the tint color should be found in the media.
  58538. * This is used for refraction only.
  58539. */
  58540. tintColorAtDistance: number;
  58541. /**
  58542. * Defines how far each channel transmit through the media.
  58543. * It is defined as a color to simplify it selection.
  58544. */
  58545. diffusionDistance: Color3;
  58546. private _useMaskFromThicknessTexture;
  58547. /**
  58548. * Stores the intensity of the different subsurface effects in the thickness texture.
  58549. * * the green channel is the translucency intensity.
  58550. * * the blue channel is the scattering intensity.
  58551. * * the alpha channel is the refraction intensity.
  58552. */
  58553. useMaskFromThicknessTexture: boolean;
  58554. private _scene;
  58555. /** @hidden */
  58556. private _internalMarkAllSubMeshesAsTexturesDirty;
  58557. private _internalMarkScenePrePassDirty;
  58558. /** @hidden */
  58559. _markAllSubMeshesAsTexturesDirty(): void;
  58560. /** @hidden */
  58561. _markScenePrePassDirty(): void;
  58562. /**
  58563. * Instantiate a new istance of sub surface configuration.
  58564. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58565. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58566. * @param scene The scene
  58567. */
  58568. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58569. /**
  58570. * Gets wehter the submesh is ready to be used or not.
  58571. * @param defines the list of "defines" to update.
  58572. * @param scene defines the scene the material belongs to.
  58573. * @returns - boolean indicating that the submesh is ready or not.
  58574. */
  58575. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58576. /**
  58577. * Checks to see if a texture is used in the material.
  58578. * @param defines the list of "defines" to update.
  58579. * @param scene defines the scene to the material belongs to.
  58580. */
  58581. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58582. /**
  58583. * Binds the material data.
  58584. * @param uniformBuffer defines the Uniform buffer to fill in.
  58585. * @param scene defines the scene the material belongs to.
  58586. * @param engine defines the engine the material belongs to.
  58587. * @param isFrozen defines whether the material is frozen or not.
  58588. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58589. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58590. */
  58591. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58592. /**
  58593. * Unbinds the material from the mesh.
  58594. * @param activeEffect defines the effect that should be unbound from.
  58595. * @returns true if unbound, otherwise false
  58596. */
  58597. unbind(activeEffect: Effect): boolean;
  58598. /**
  58599. * Returns the texture used for refraction or null if none is used.
  58600. * @param scene defines the scene the material belongs to.
  58601. * @returns - Refraction texture if present. If no refraction texture and refraction
  58602. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58603. */
  58604. private _getRefractionTexture;
  58605. /**
  58606. * Returns true if alpha blending should be disabled.
  58607. */
  58608. get disableAlphaBlending(): boolean;
  58609. /**
  58610. * Fills the list of render target textures.
  58611. * @param renderTargets the list of render targets to update
  58612. */
  58613. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58614. /**
  58615. * Checks to see if a texture is used in the material.
  58616. * @param texture - Base texture to use.
  58617. * @returns - Boolean specifying if a texture is used in the material.
  58618. */
  58619. hasTexture(texture: BaseTexture): boolean;
  58620. /**
  58621. * Gets a boolean indicating that current material needs to register RTT
  58622. * @returns true if this uses a render target otherwise false.
  58623. */
  58624. hasRenderTargetTextures(): boolean;
  58625. /**
  58626. * Returns an array of the actively used textures.
  58627. * @param activeTextures Array of BaseTextures
  58628. */
  58629. getActiveTextures(activeTextures: BaseTexture[]): void;
  58630. /**
  58631. * Returns the animatable textures.
  58632. * @param animatables Array of animatable textures.
  58633. */
  58634. getAnimatables(animatables: IAnimatable[]): void;
  58635. /**
  58636. * Disposes the resources of the material.
  58637. * @param forceDisposeTextures - Forces the disposal of all textures.
  58638. */
  58639. dispose(forceDisposeTextures?: boolean): void;
  58640. /**
  58641. * Get the current class name of the texture useful for serialization or dynamic coding.
  58642. * @returns "PBRSubSurfaceConfiguration"
  58643. */
  58644. getClassName(): string;
  58645. /**
  58646. * Add fallbacks to the effect fallbacks list.
  58647. * @param defines defines the Base texture to use.
  58648. * @param fallbacks defines the current fallback list.
  58649. * @param currentRank defines the current fallback rank.
  58650. * @returns the new fallback rank.
  58651. */
  58652. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58653. /**
  58654. * Add the required uniforms to the current list.
  58655. * @param uniforms defines the current uniform list.
  58656. */
  58657. static AddUniforms(uniforms: string[]): void;
  58658. /**
  58659. * Add the required samplers to the current list.
  58660. * @param samplers defines the current sampler list.
  58661. */
  58662. static AddSamplers(samplers: string[]): void;
  58663. /**
  58664. * Add the required uniforms to the current buffer.
  58665. * @param uniformBuffer defines the current uniform buffer.
  58666. */
  58667. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58668. /**
  58669. * Makes a duplicate of the current configuration into another one.
  58670. * @param configuration define the config where to copy the info
  58671. */
  58672. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58673. /**
  58674. * Serializes this Sub Surface configuration.
  58675. * @returns - An object with the serialized config.
  58676. */
  58677. serialize(): any;
  58678. /**
  58679. * Parses a anisotropy Configuration from a serialized object.
  58680. * @param source - Serialized object.
  58681. * @param scene Defines the scene we are parsing for
  58682. * @param rootUrl Defines the rootUrl to load from
  58683. */
  58684. parse(source: any, scene: Scene, rootUrl: string): void;
  58685. }
  58686. }
  58687. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58688. /** @hidden */
  58689. export var pbrFragmentDeclaration: {
  58690. name: string;
  58691. shader: string;
  58692. };
  58693. }
  58694. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58695. /** @hidden */
  58696. export var pbrUboDeclaration: {
  58697. name: string;
  58698. shader: string;
  58699. };
  58700. }
  58701. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58702. /** @hidden */
  58703. export var pbrFragmentExtraDeclaration: {
  58704. name: string;
  58705. shader: string;
  58706. };
  58707. }
  58708. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58709. /** @hidden */
  58710. export var pbrFragmentSamplersDeclaration: {
  58711. name: string;
  58712. shader: string;
  58713. };
  58714. }
  58715. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58716. /** @hidden */
  58717. export var importanceSampling: {
  58718. name: string;
  58719. shader: string;
  58720. };
  58721. }
  58722. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58723. /** @hidden */
  58724. export var pbrHelperFunctions: {
  58725. name: string;
  58726. shader: string;
  58727. };
  58728. }
  58729. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58730. /** @hidden */
  58731. export var harmonicsFunctions: {
  58732. name: string;
  58733. shader: string;
  58734. };
  58735. }
  58736. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58737. /** @hidden */
  58738. export var pbrDirectLightingSetupFunctions: {
  58739. name: string;
  58740. shader: string;
  58741. };
  58742. }
  58743. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58744. /** @hidden */
  58745. export var pbrDirectLightingFalloffFunctions: {
  58746. name: string;
  58747. shader: string;
  58748. };
  58749. }
  58750. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58751. /** @hidden */
  58752. export var pbrBRDFFunctions: {
  58753. name: string;
  58754. shader: string;
  58755. };
  58756. }
  58757. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58758. /** @hidden */
  58759. export var hdrFilteringFunctions: {
  58760. name: string;
  58761. shader: string;
  58762. };
  58763. }
  58764. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58765. /** @hidden */
  58766. export var pbrDirectLightingFunctions: {
  58767. name: string;
  58768. shader: string;
  58769. };
  58770. }
  58771. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58772. /** @hidden */
  58773. export var pbrIBLFunctions: {
  58774. name: string;
  58775. shader: string;
  58776. };
  58777. }
  58778. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58779. /** @hidden */
  58780. export var pbrBlockAlbedoOpacity: {
  58781. name: string;
  58782. shader: string;
  58783. };
  58784. }
  58785. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58786. /** @hidden */
  58787. export var pbrBlockReflectivity: {
  58788. name: string;
  58789. shader: string;
  58790. };
  58791. }
  58792. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58793. /** @hidden */
  58794. export var pbrBlockAmbientOcclusion: {
  58795. name: string;
  58796. shader: string;
  58797. };
  58798. }
  58799. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58800. /** @hidden */
  58801. export var pbrBlockAlphaFresnel: {
  58802. name: string;
  58803. shader: string;
  58804. };
  58805. }
  58806. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58807. /** @hidden */
  58808. export var pbrBlockAnisotropic: {
  58809. name: string;
  58810. shader: string;
  58811. };
  58812. }
  58813. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58814. /** @hidden */
  58815. export var pbrBlockReflection: {
  58816. name: string;
  58817. shader: string;
  58818. };
  58819. }
  58820. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58821. /** @hidden */
  58822. export var pbrBlockSheen: {
  58823. name: string;
  58824. shader: string;
  58825. };
  58826. }
  58827. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58828. /** @hidden */
  58829. export var pbrBlockClearcoat: {
  58830. name: string;
  58831. shader: string;
  58832. };
  58833. }
  58834. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58835. /** @hidden */
  58836. export var pbrBlockSubSurface: {
  58837. name: string;
  58838. shader: string;
  58839. };
  58840. }
  58841. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58842. /** @hidden */
  58843. export var pbrBlockNormalGeometric: {
  58844. name: string;
  58845. shader: string;
  58846. };
  58847. }
  58848. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58849. /** @hidden */
  58850. export var pbrBlockNormalFinal: {
  58851. name: string;
  58852. shader: string;
  58853. };
  58854. }
  58855. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58856. /** @hidden */
  58857. export var pbrBlockLightmapInit: {
  58858. name: string;
  58859. shader: string;
  58860. };
  58861. }
  58862. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58863. /** @hidden */
  58864. export var pbrBlockGeometryInfo: {
  58865. name: string;
  58866. shader: string;
  58867. };
  58868. }
  58869. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58870. /** @hidden */
  58871. export var pbrBlockReflectance0: {
  58872. name: string;
  58873. shader: string;
  58874. };
  58875. }
  58876. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58877. /** @hidden */
  58878. export var pbrBlockReflectance: {
  58879. name: string;
  58880. shader: string;
  58881. };
  58882. }
  58883. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58884. /** @hidden */
  58885. export var pbrBlockDirectLighting: {
  58886. name: string;
  58887. shader: string;
  58888. };
  58889. }
  58890. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58891. /** @hidden */
  58892. export var pbrBlockFinalLitComponents: {
  58893. name: string;
  58894. shader: string;
  58895. };
  58896. }
  58897. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58898. /** @hidden */
  58899. export var pbrBlockFinalUnlitComponents: {
  58900. name: string;
  58901. shader: string;
  58902. };
  58903. }
  58904. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58905. /** @hidden */
  58906. export var pbrBlockFinalColorComposition: {
  58907. name: string;
  58908. shader: string;
  58909. };
  58910. }
  58911. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58912. /** @hidden */
  58913. export var pbrBlockImageProcessing: {
  58914. name: string;
  58915. shader: string;
  58916. };
  58917. }
  58918. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58919. /** @hidden */
  58920. export var pbrDebug: {
  58921. name: string;
  58922. shader: string;
  58923. };
  58924. }
  58925. declare module "babylonjs/Shaders/pbr.fragment" {
  58926. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58927. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58928. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58929. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58930. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58931. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58932. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58933. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58934. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58935. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58936. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58937. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58938. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58939. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58940. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58941. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58942. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58943. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58944. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58945. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58946. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58947. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58948. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58949. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58950. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58951. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58952. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58953. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58954. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58955. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58956. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58957. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58958. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58959. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58960. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58961. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58962. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58963. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58964. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58965. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58966. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58967. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58968. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58969. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58970. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58971. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58972. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58973. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58974. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58975. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58976. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58977. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58978. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58979. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58980. /** @hidden */
  58981. export var pbrPixelShader: {
  58982. name: string;
  58983. shader: string;
  58984. };
  58985. }
  58986. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58987. /** @hidden */
  58988. export var pbrVertexDeclaration: {
  58989. name: string;
  58990. shader: string;
  58991. };
  58992. }
  58993. declare module "babylonjs/Shaders/pbr.vertex" {
  58994. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58995. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58996. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58997. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58998. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58999. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59000. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  59001. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59002. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59003. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59004. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59005. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59006. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59007. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59009. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59010. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59011. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59012. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59013. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59014. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59015. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59016. /** @hidden */
  59017. export var pbrVertexShader: {
  59018. name: string;
  59019. shader: string;
  59020. };
  59021. }
  59022. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59023. import { Nullable } from "babylonjs/types";
  59024. import { Scene } from "babylonjs/scene";
  59025. import { Matrix } from "babylonjs/Maths/math.vector";
  59026. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59028. import { Mesh } from "babylonjs/Meshes/mesh";
  59029. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59030. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59031. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59032. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59033. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59034. import { Color3 } from "babylonjs/Maths/math.color";
  59035. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59036. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59037. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59038. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59039. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59040. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59041. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59042. import "babylonjs/Shaders/pbr.fragment";
  59043. import "babylonjs/Shaders/pbr.vertex";
  59044. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59045. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59046. /**
  59047. * Manages the defines for the PBR Material.
  59048. * @hidden
  59049. */
  59050. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59051. PBR: boolean;
  59052. NUM_SAMPLES: string;
  59053. REALTIME_FILTERING: boolean;
  59054. MAINUV1: boolean;
  59055. MAINUV2: boolean;
  59056. UV1: boolean;
  59057. UV2: boolean;
  59058. ALBEDO: boolean;
  59059. GAMMAALBEDO: boolean;
  59060. ALBEDODIRECTUV: number;
  59061. VERTEXCOLOR: boolean;
  59062. DETAIL: boolean;
  59063. DETAILDIRECTUV: number;
  59064. DETAIL_NORMALBLENDMETHOD: number;
  59065. AMBIENT: boolean;
  59066. AMBIENTDIRECTUV: number;
  59067. AMBIENTINGRAYSCALE: boolean;
  59068. OPACITY: boolean;
  59069. VERTEXALPHA: boolean;
  59070. OPACITYDIRECTUV: number;
  59071. OPACITYRGB: boolean;
  59072. ALPHATEST: boolean;
  59073. DEPTHPREPASS: boolean;
  59074. ALPHABLEND: boolean;
  59075. ALPHAFROMALBEDO: boolean;
  59076. ALPHATESTVALUE: string;
  59077. SPECULAROVERALPHA: boolean;
  59078. RADIANCEOVERALPHA: boolean;
  59079. ALPHAFRESNEL: boolean;
  59080. LINEARALPHAFRESNEL: boolean;
  59081. PREMULTIPLYALPHA: boolean;
  59082. EMISSIVE: boolean;
  59083. EMISSIVEDIRECTUV: number;
  59084. REFLECTIVITY: boolean;
  59085. REFLECTIVITYDIRECTUV: number;
  59086. SPECULARTERM: boolean;
  59087. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59088. MICROSURFACEAUTOMATIC: boolean;
  59089. LODBASEDMICROSFURACE: boolean;
  59090. MICROSURFACEMAP: boolean;
  59091. MICROSURFACEMAPDIRECTUV: number;
  59092. METALLICWORKFLOW: boolean;
  59093. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59094. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59095. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59096. AOSTOREINMETALMAPRED: boolean;
  59097. METALLIC_REFLECTANCE: boolean;
  59098. METALLIC_REFLECTANCEDIRECTUV: number;
  59099. ENVIRONMENTBRDF: boolean;
  59100. ENVIRONMENTBRDF_RGBD: boolean;
  59101. NORMAL: boolean;
  59102. TANGENT: boolean;
  59103. BUMP: boolean;
  59104. BUMPDIRECTUV: number;
  59105. OBJECTSPACE_NORMALMAP: boolean;
  59106. PARALLAX: boolean;
  59107. PARALLAXOCCLUSION: boolean;
  59108. NORMALXYSCALE: boolean;
  59109. LIGHTMAP: boolean;
  59110. LIGHTMAPDIRECTUV: number;
  59111. USELIGHTMAPASSHADOWMAP: boolean;
  59112. GAMMALIGHTMAP: boolean;
  59113. RGBDLIGHTMAP: boolean;
  59114. REFLECTION: boolean;
  59115. REFLECTIONMAP_3D: boolean;
  59116. REFLECTIONMAP_SPHERICAL: boolean;
  59117. REFLECTIONMAP_PLANAR: boolean;
  59118. REFLECTIONMAP_CUBIC: boolean;
  59119. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59120. REFLECTIONMAP_PROJECTION: boolean;
  59121. REFLECTIONMAP_SKYBOX: boolean;
  59122. REFLECTIONMAP_EXPLICIT: boolean;
  59123. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59124. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59125. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59126. INVERTCUBICMAP: boolean;
  59127. USESPHERICALFROMREFLECTIONMAP: boolean;
  59128. USEIRRADIANCEMAP: boolean;
  59129. SPHERICAL_HARMONICS: boolean;
  59130. USESPHERICALINVERTEX: boolean;
  59131. REFLECTIONMAP_OPPOSITEZ: boolean;
  59132. LODINREFLECTIONALPHA: boolean;
  59133. GAMMAREFLECTION: boolean;
  59134. RGBDREFLECTION: boolean;
  59135. LINEARSPECULARREFLECTION: boolean;
  59136. RADIANCEOCCLUSION: boolean;
  59137. HORIZONOCCLUSION: boolean;
  59138. INSTANCES: boolean;
  59139. THIN_INSTANCES: boolean;
  59140. PREPASS: boolean;
  59141. SCENE_MRT_COUNT: number;
  59142. NUM_BONE_INFLUENCERS: number;
  59143. BonesPerMesh: number;
  59144. BONETEXTURE: boolean;
  59145. NONUNIFORMSCALING: boolean;
  59146. MORPHTARGETS: boolean;
  59147. MORPHTARGETS_NORMAL: boolean;
  59148. MORPHTARGETS_TANGENT: boolean;
  59149. MORPHTARGETS_UV: boolean;
  59150. NUM_MORPH_INFLUENCERS: number;
  59151. IMAGEPROCESSING: boolean;
  59152. VIGNETTE: boolean;
  59153. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59154. VIGNETTEBLENDMODEOPAQUE: boolean;
  59155. TONEMAPPING: boolean;
  59156. TONEMAPPING_ACES: boolean;
  59157. CONTRAST: boolean;
  59158. COLORCURVES: boolean;
  59159. COLORGRADING: boolean;
  59160. COLORGRADING3D: boolean;
  59161. SAMPLER3DGREENDEPTH: boolean;
  59162. SAMPLER3DBGRMAP: boolean;
  59163. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59164. EXPOSURE: boolean;
  59165. MULTIVIEW: boolean;
  59166. USEPHYSICALLIGHTFALLOFF: boolean;
  59167. USEGLTFLIGHTFALLOFF: boolean;
  59168. TWOSIDEDLIGHTING: boolean;
  59169. SHADOWFLOAT: boolean;
  59170. CLIPPLANE: boolean;
  59171. CLIPPLANE2: boolean;
  59172. CLIPPLANE3: boolean;
  59173. CLIPPLANE4: boolean;
  59174. CLIPPLANE5: boolean;
  59175. CLIPPLANE6: boolean;
  59176. POINTSIZE: boolean;
  59177. FOG: boolean;
  59178. LOGARITHMICDEPTH: boolean;
  59179. FORCENORMALFORWARD: boolean;
  59180. SPECULARAA: boolean;
  59181. CLEARCOAT: boolean;
  59182. CLEARCOAT_DEFAULTIOR: boolean;
  59183. CLEARCOAT_TEXTURE: boolean;
  59184. CLEARCOAT_TEXTUREDIRECTUV: number;
  59185. CLEARCOAT_BUMP: boolean;
  59186. CLEARCOAT_BUMPDIRECTUV: number;
  59187. CLEARCOAT_TINT: boolean;
  59188. CLEARCOAT_TINT_TEXTURE: boolean;
  59189. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59190. ANISOTROPIC: boolean;
  59191. ANISOTROPIC_TEXTURE: boolean;
  59192. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59193. BRDF_V_HEIGHT_CORRELATED: boolean;
  59194. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59195. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59196. SHEEN: boolean;
  59197. SHEEN_TEXTURE: boolean;
  59198. SHEEN_TEXTUREDIRECTUV: number;
  59199. SHEEN_LINKWITHALBEDO: boolean;
  59200. SHEEN_ROUGHNESS: boolean;
  59201. SHEEN_ALBEDOSCALING: boolean;
  59202. SUBSURFACE: boolean;
  59203. SS_REFRACTION: boolean;
  59204. SS_TRANSLUCENCY: boolean;
  59205. SS_SCATTERING: boolean;
  59206. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59207. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59208. SS_REFRACTIONMAP_3D: boolean;
  59209. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59210. SS_LODINREFRACTIONALPHA: boolean;
  59211. SS_GAMMAREFRACTION: boolean;
  59212. SS_RGBDREFRACTION: boolean;
  59213. SS_LINEARSPECULARREFRACTION: boolean;
  59214. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59215. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59216. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59217. UNLIT: boolean;
  59218. DEBUGMODE: number;
  59219. /**
  59220. * Initializes the PBR Material defines.
  59221. */
  59222. constructor();
  59223. /**
  59224. * Resets the PBR Material defines.
  59225. */
  59226. reset(): void;
  59227. }
  59228. /**
  59229. * The Physically based material base class of BJS.
  59230. *
  59231. * This offers the main features of a standard PBR material.
  59232. * For more information, please refer to the documentation :
  59233. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59234. */
  59235. export abstract class PBRBaseMaterial extends PushMaterial {
  59236. /**
  59237. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59238. */
  59239. static readonly PBRMATERIAL_OPAQUE: number;
  59240. /**
  59241. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59242. */
  59243. static readonly PBRMATERIAL_ALPHATEST: number;
  59244. /**
  59245. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59246. */
  59247. static readonly PBRMATERIAL_ALPHABLEND: number;
  59248. /**
  59249. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59250. * They are also discarded below the alpha cutoff threshold to improve performances.
  59251. */
  59252. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59253. /**
  59254. * Defines the default value of how much AO map is occluding the analytical lights
  59255. * (point spot...).
  59256. */
  59257. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59258. /**
  59259. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59260. */
  59261. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59262. /**
  59263. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59264. * to enhance interoperability with other engines.
  59265. */
  59266. static readonly LIGHTFALLOFF_GLTF: number;
  59267. /**
  59268. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59269. * to enhance interoperability with other materials.
  59270. */
  59271. static readonly LIGHTFALLOFF_STANDARD: number;
  59272. /**
  59273. * Intensity of the direct lights e.g. the four lights available in your scene.
  59274. * This impacts both the direct diffuse and specular highlights.
  59275. */
  59276. protected _directIntensity: number;
  59277. /**
  59278. * Intensity of the emissive part of the material.
  59279. * This helps controlling the emissive effect without modifying the emissive color.
  59280. */
  59281. protected _emissiveIntensity: number;
  59282. /**
  59283. * Intensity of the environment e.g. how much the environment will light the object
  59284. * either through harmonics for rough material or through the refelction for shiny ones.
  59285. */
  59286. protected _environmentIntensity: number;
  59287. /**
  59288. * This is a special control allowing the reduction of the specular highlights coming from the
  59289. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59290. */
  59291. protected _specularIntensity: number;
  59292. /**
  59293. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59294. */
  59295. private _lightingInfos;
  59296. /**
  59297. * Debug Control allowing disabling the bump map on this material.
  59298. */
  59299. protected _disableBumpMap: boolean;
  59300. /**
  59301. * AKA Diffuse Texture in standard nomenclature.
  59302. */
  59303. protected _albedoTexture: Nullable<BaseTexture>;
  59304. /**
  59305. * AKA Occlusion Texture in other nomenclature.
  59306. */
  59307. protected _ambientTexture: Nullable<BaseTexture>;
  59308. /**
  59309. * AKA Occlusion Texture Intensity in other nomenclature.
  59310. */
  59311. protected _ambientTextureStrength: number;
  59312. /**
  59313. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59314. * 1 means it completely occludes it
  59315. * 0 mean it has no impact
  59316. */
  59317. protected _ambientTextureImpactOnAnalyticalLights: number;
  59318. /**
  59319. * Stores the alpha values in a texture.
  59320. */
  59321. protected _opacityTexture: Nullable<BaseTexture>;
  59322. /**
  59323. * Stores the reflection values in a texture.
  59324. */
  59325. protected _reflectionTexture: Nullable<BaseTexture>;
  59326. /**
  59327. * Stores the emissive values in a texture.
  59328. */
  59329. protected _emissiveTexture: Nullable<BaseTexture>;
  59330. /**
  59331. * AKA Specular texture in other nomenclature.
  59332. */
  59333. protected _reflectivityTexture: Nullable<BaseTexture>;
  59334. /**
  59335. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59336. */
  59337. protected _metallicTexture: Nullable<BaseTexture>;
  59338. /**
  59339. * Specifies the metallic scalar of the metallic/roughness workflow.
  59340. * Can also be used to scale the metalness values of the metallic texture.
  59341. */
  59342. protected _metallic: Nullable<number>;
  59343. /**
  59344. * Specifies the roughness scalar of the metallic/roughness workflow.
  59345. * Can also be used to scale the roughness values of the metallic texture.
  59346. */
  59347. protected _roughness: Nullable<number>;
  59348. /**
  59349. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59350. * By default the indexOfrefraction is used to compute F0;
  59351. *
  59352. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59353. *
  59354. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59355. * F90 = metallicReflectanceColor;
  59356. */
  59357. protected _metallicF0Factor: number;
  59358. /**
  59359. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59360. * By default the F90 is always 1;
  59361. *
  59362. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59363. *
  59364. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59365. * F90 = metallicReflectanceColor;
  59366. */
  59367. protected _metallicReflectanceColor: Color3;
  59368. /**
  59369. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59370. * This is multiply against the scalar values defined in the material.
  59371. */
  59372. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59373. /**
  59374. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59375. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59376. */
  59377. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59378. /**
  59379. * Stores surface normal data used to displace a mesh in a texture.
  59380. */
  59381. protected _bumpTexture: Nullable<BaseTexture>;
  59382. /**
  59383. * Stores the pre-calculated light information of a mesh in a texture.
  59384. */
  59385. protected _lightmapTexture: Nullable<BaseTexture>;
  59386. /**
  59387. * The color of a material in ambient lighting.
  59388. */
  59389. protected _ambientColor: Color3;
  59390. /**
  59391. * AKA Diffuse Color in other nomenclature.
  59392. */
  59393. protected _albedoColor: Color3;
  59394. /**
  59395. * AKA Specular Color in other nomenclature.
  59396. */
  59397. protected _reflectivityColor: Color3;
  59398. /**
  59399. * The color applied when light is reflected from a material.
  59400. */
  59401. protected _reflectionColor: Color3;
  59402. /**
  59403. * The color applied when light is emitted from a material.
  59404. */
  59405. protected _emissiveColor: Color3;
  59406. /**
  59407. * AKA Glossiness in other nomenclature.
  59408. */
  59409. protected _microSurface: number;
  59410. /**
  59411. * Specifies that the material will use the light map as a show map.
  59412. */
  59413. protected _useLightmapAsShadowmap: boolean;
  59414. /**
  59415. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59416. * makes the reflect vector face the model (under horizon).
  59417. */
  59418. protected _useHorizonOcclusion: boolean;
  59419. /**
  59420. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59421. * too much the area relying on ambient texture to define their ambient occlusion.
  59422. */
  59423. protected _useRadianceOcclusion: boolean;
  59424. /**
  59425. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59426. */
  59427. protected _useAlphaFromAlbedoTexture: boolean;
  59428. /**
  59429. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59430. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59431. */
  59432. protected _useSpecularOverAlpha: boolean;
  59433. /**
  59434. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59435. */
  59436. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59437. /**
  59438. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59439. */
  59440. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59441. /**
  59442. * Specifies if the metallic texture contains the roughness information in its green channel.
  59443. */
  59444. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59445. /**
  59446. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59447. */
  59448. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59449. /**
  59450. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59451. */
  59452. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59453. /**
  59454. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59455. */
  59456. protected _useAmbientInGrayScale: boolean;
  59457. /**
  59458. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59459. * The material will try to infer what glossiness each pixel should be.
  59460. */
  59461. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59462. /**
  59463. * Defines the falloff type used in this material.
  59464. * It by default is Physical.
  59465. */
  59466. protected _lightFalloff: number;
  59467. /**
  59468. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59469. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59470. */
  59471. protected _useRadianceOverAlpha: boolean;
  59472. /**
  59473. * Allows using an object space normal map (instead of tangent space).
  59474. */
  59475. protected _useObjectSpaceNormalMap: boolean;
  59476. /**
  59477. * Allows using the bump map in parallax mode.
  59478. */
  59479. protected _useParallax: boolean;
  59480. /**
  59481. * Allows using the bump map in parallax occlusion mode.
  59482. */
  59483. protected _useParallaxOcclusion: boolean;
  59484. /**
  59485. * Controls the scale bias of the parallax mode.
  59486. */
  59487. protected _parallaxScaleBias: number;
  59488. /**
  59489. * If sets to true, disables all the lights affecting the material.
  59490. */
  59491. protected _disableLighting: boolean;
  59492. /**
  59493. * Number of Simultaneous lights allowed on the material.
  59494. */
  59495. protected _maxSimultaneousLights: number;
  59496. /**
  59497. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59498. */
  59499. protected _invertNormalMapX: boolean;
  59500. /**
  59501. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59502. */
  59503. protected _invertNormalMapY: boolean;
  59504. /**
  59505. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59506. */
  59507. protected _twoSidedLighting: boolean;
  59508. /**
  59509. * Defines the alpha limits in alpha test mode.
  59510. */
  59511. protected _alphaCutOff: number;
  59512. /**
  59513. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59514. */
  59515. protected _forceAlphaTest: boolean;
  59516. /**
  59517. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59518. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59519. */
  59520. protected _useAlphaFresnel: boolean;
  59521. /**
  59522. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59523. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59524. */
  59525. protected _useLinearAlphaFresnel: boolean;
  59526. /**
  59527. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59528. * from cos thetav and roughness:
  59529. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59530. */
  59531. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59532. /**
  59533. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59534. */
  59535. protected _forceIrradianceInFragment: boolean;
  59536. private _realTimeFiltering;
  59537. /**
  59538. * Enables realtime filtering on the texture.
  59539. */
  59540. get realTimeFiltering(): boolean;
  59541. set realTimeFiltering(b: boolean);
  59542. private _realTimeFilteringQuality;
  59543. /**
  59544. * Quality switch for realtime filtering
  59545. */
  59546. get realTimeFilteringQuality(): number;
  59547. set realTimeFilteringQuality(n: number);
  59548. /**
  59549. * Can this material render to several textures at once
  59550. */
  59551. get canRenderToMRT(): boolean;
  59552. /**
  59553. * Force normal to face away from face.
  59554. */
  59555. protected _forceNormalForward: boolean;
  59556. /**
  59557. * Enables specular anti aliasing in the PBR shader.
  59558. * It will both interacts on the Geometry for analytical and IBL lighting.
  59559. * It also prefilter the roughness map based on the bump values.
  59560. */
  59561. protected _enableSpecularAntiAliasing: boolean;
  59562. /**
  59563. * Default configuration related to image processing available in the PBR Material.
  59564. */
  59565. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59566. /**
  59567. * Keep track of the image processing observer to allow dispose and replace.
  59568. */
  59569. private _imageProcessingObserver;
  59570. /**
  59571. * Attaches a new image processing configuration to the PBR Material.
  59572. * @param configuration
  59573. */
  59574. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59575. /**
  59576. * Stores the available render targets.
  59577. */
  59578. private _renderTargets;
  59579. /**
  59580. * Sets the global ambient color for the material used in lighting calculations.
  59581. */
  59582. private _globalAmbientColor;
  59583. /**
  59584. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59585. */
  59586. private _useLogarithmicDepth;
  59587. /**
  59588. * If set to true, no lighting calculations will be applied.
  59589. */
  59590. private _unlit;
  59591. private _debugMode;
  59592. /**
  59593. * @hidden
  59594. * This is reserved for the inspector.
  59595. * Defines the material debug mode.
  59596. * It helps seeing only some components of the material while troubleshooting.
  59597. */
  59598. debugMode: number;
  59599. /**
  59600. * @hidden
  59601. * This is reserved for the inspector.
  59602. * Specify from where on screen the debug mode should start.
  59603. * The value goes from -1 (full screen) to 1 (not visible)
  59604. * It helps with side by side comparison against the final render
  59605. * This defaults to -1
  59606. */
  59607. private debugLimit;
  59608. /**
  59609. * @hidden
  59610. * This is reserved for the inspector.
  59611. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59612. * You can use the factor to better multiply the final value.
  59613. */
  59614. private debugFactor;
  59615. /**
  59616. * Defines the clear coat layer parameters for the material.
  59617. */
  59618. readonly clearCoat: PBRClearCoatConfiguration;
  59619. /**
  59620. * Defines the anisotropic parameters for the material.
  59621. */
  59622. readonly anisotropy: PBRAnisotropicConfiguration;
  59623. /**
  59624. * Defines the BRDF parameters for the material.
  59625. */
  59626. readonly brdf: PBRBRDFConfiguration;
  59627. /**
  59628. * Defines the Sheen parameters for the material.
  59629. */
  59630. readonly sheen: PBRSheenConfiguration;
  59631. /**
  59632. * Defines the SubSurface parameters for the material.
  59633. */
  59634. readonly subSurface: PBRSubSurfaceConfiguration;
  59635. /**
  59636. * Defines the detail map parameters for the material.
  59637. */
  59638. readonly detailMap: DetailMapConfiguration;
  59639. protected _rebuildInParallel: boolean;
  59640. /**
  59641. * Instantiates a new PBRMaterial instance.
  59642. *
  59643. * @param name The material name
  59644. * @param scene The scene the material will be use in.
  59645. */
  59646. constructor(name: string, scene: Scene);
  59647. /**
  59648. * Gets a boolean indicating that current material needs to register RTT
  59649. */
  59650. get hasRenderTargetTextures(): boolean;
  59651. /**
  59652. * Gets the name of the material class.
  59653. */
  59654. getClassName(): string;
  59655. /**
  59656. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59657. */
  59658. get useLogarithmicDepth(): boolean;
  59659. /**
  59660. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59661. */
  59662. set useLogarithmicDepth(value: boolean);
  59663. /**
  59664. * Returns true if alpha blending should be disabled.
  59665. */
  59666. protected get _disableAlphaBlending(): boolean;
  59667. /**
  59668. * Specifies whether or not this material should be rendered in alpha blend mode.
  59669. */
  59670. needAlphaBlending(): boolean;
  59671. /**
  59672. * Specifies whether or not this material should be rendered in alpha test mode.
  59673. */
  59674. needAlphaTesting(): boolean;
  59675. /**
  59676. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59677. */
  59678. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59679. /**
  59680. * Gets the texture used for the alpha test.
  59681. */
  59682. getAlphaTestTexture(): Nullable<BaseTexture>;
  59683. /**
  59684. * Specifies that the submesh is ready to be used.
  59685. * @param mesh - BJS mesh.
  59686. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59687. * @param useInstances - Specifies that instances should be used.
  59688. * @returns - boolean indicating that the submesh is ready or not.
  59689. */
  59690. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59691. /**
  59692. * Specifies if the material uses metallic roughness workflow.
  59693. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59694. */
  59695. isMetallicWorkflow(): boolean;
  59696. private _prepareEffect;
  59697. private _prepareDefines;
  59698. /**
  59699. * Force shader compilation
  59700. */
  59701. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59702. /**
  59703. * Initializes the uniform buffer layout for the shader.
  59704. */
  59705. buildUniformLayout(): void;
  59706. /**
  59707. * Unbinds the material from the mesh
  59708. */
  59709. unbind(): void;
  59710. /**
  59711. * Binds the submesh data.
  59712. * @param world - The world matrix.
  59713. * @param mesh - The BJS mesh.
  59714. * @param subMesh - A submesh of the BJS mesh.
  59715. */
  59716. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59717. /**
  59718. * Returns the animatable textures.
  59719. * @returns - Array of animatable textures.
  59720. */
  59721. getAnimatables(): IAnimatable[];
  59722. /**
  59723. * Returns the texture used for reflections.
  59724. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59725. */
  59726. private _getReflectionTexture;
  59727. /**
  59728. * Returns an array of the actively used textures.
  59729. * @returns - Array of BaseTextures
  59730. */
  59731. getActiveTextures(): BaseTexture[];
  59732. /**
  59733. * Checks to see if a texture is used in the material.
  59734. * @param texture - Base texture to use.
  59735. * @returns - Boolean specifying if a texture is used in the material.
  59736. */
  59737. hasTexture(texture: BaseTexture): boolean;
  59738. /**
  59739. * Sets the required values to the prepass renderer.
  59740. * @param prePassRenderer defines the prepass renderer to setup
  59741. */
  59742. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59743. /**
  59744. * Disposes the resources of the material.
  59745. * @param forceDisposeEffect - Forces the disposal of effects.
  59746. * @param forceDisposeTextures - Forces the disposal of all textures.
  59747. */
  59748. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59749. }
  59750. }
  59751. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59752. import { Nullable } from "babylonjs/types";
  59753. import { Scene } from "babylonjs/scene";
  59754. import { Color3 } from "babylonjs/Maths/math.color";
  59755. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59756. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59758. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59759. /**
  59760. * The Physically based material of BJS.
  59761. *
  59762. * This offers the main features of a standard PBR material.
  59763. * For more information, please refer to the documentation :
  59764. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59765. */
  59766. export class PBRMaterial extends PBRBaseMaterial {
  59767. /**
  59768. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59769. */
  59770. static readonly PBRMATERIAL_OPAQUE: number;
  59771. /**
  59772. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59773. */
  59774. static readonly PBRMATERIAL_ALPHATEST: number;
  59775. /**
  59776. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59777. */
  59778. static readonly PBRMATERIAL_ALPHABLEND: number;
  59779. /**
  59780. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59781. * They are also discarded below the alpha cutoff threshold to improve performances.
  59782. */
  59783. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59784. /**
  59785. * Defines the default value of how much AO map is occluding the analytical lights
  59786. * (point spot...).
  59787. */
  59788. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59789. /**
  59790. * Intensity of the direct lights e.g. the four lights available in your scene.
  59791. * This impacts both the direct diffuse and specular highlights.
  59792. */
  59793. directIntensity: number;
  59794. /**
  59795. * Intensity of the emissive part of the material.
  59796. * This helps controlling the emissive effect without modifying the emissive color.
  59797. */
  59798. emissiveIntensity: number;
  59799. /**
  59800. * Intensity of the environment e.g. how much the environment will light the object
  59801. * either through harmonics for rough material or through the refelction for shiny ones.
  59802. */
  59803. environmentIntensity: number;
  59804. /**
  59805. * This is a special control allowing the reduction of the specular highlights coming from the
  59806. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59807. */
  59808. specularIntensity: number;
  59809. /**
  59810. * Debug Control allowing disabling the bump map on this material.
  59811. */
  59812. disableBumpMap: boolean;
  59813. /**
  59814. * AKA Diffuse Texture in standard nomenclature.
  59815. */
  59816. albedoTexture: BaseTexture;
  59817. /**
  59818. * AKA Occlusion Texture in other nomenclature.
  59819. */
  59820. ambientTexture: BaseTexture;
  59821. /**
  59822. * AKA Occlusion Texture Intensity in other nomenclature.
  59823. */
  59824. ambientTextureStrength: number;
  59825. /**
  59826. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59827. * 1 means it completely occludes it
  59828. * 0 mean it has no impact
  59829. */
  59830. ambientTextureImpactOnAnalyticalLights: number;
  59831. /**
  59832. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59833. */
  59834. opacityTexture: BaseTexture;
  59835. /**
  59836. * Stores the reflection values in a texture.
  59837. */
  59838. reflectionTexture: Nullable<BaseTexture>;
  59839. /**
  59840. * Stores the emissive values in a texture.
  59841. */
  59842. emissiveTexture: BaseTexture;
  59843. /**
  59844. * AKA Specular texture in other nomenclature.
  59845. */
  59846. reflectivityTexture: BaseTexture;
  59847. /**
  59848. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59849. */
  59850. metallicTexture: BaseTexture;
  59851. /**
  59852. * Specifies the metallic scalar of the metallic/roughness workflow.
  59853. * Can also be used to scale the metalness values of the metallic texture.
  59854. */
  59855. metallic: Nullable<number>;
  59856. /**
  59857. * Specifies the roughness scalar of the metallic/roughness workflow.
  59858. * Can also be used to scale the roughness values of the metallic texture.
  59859. */
  59860. roughness: Nullable<number>;
  59861. /**
  59862. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59863. * By default the indexOfrefraction is used to compute F0;
  59864. *
  59865. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59866. *
  59867. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59868. * F90 = metallicReflectanceColor;
  59869. */
  59870. metallicF0Factor: number;
  59871. /**
  59872. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59873. * By default the F90 is always 1;
  59874. *
  59875. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59876. *
  59877. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59878. * F90 = metallicReflectanceColor;
  59879. */
  59880. metallicReflectanceColor: Color3;
  59881. /**
  59882. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59883. * This is multiply against the scalar values defined in the material.
  59884. */
  59885. metallicReflectanceTexture: Nullable<BaseTexture>;
  59886. /**
  59887. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59888. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59889. */
  59890. microSurfaceTexture: BaseTexture;
  59891. /**
  59892. * Stores surface normal data used to displace a mesh in a texture.
  59893. */
  59894. bumpTexture: BaseTexture;
  59895. /**
  59896. * Stores the pre-calculated light information of a mesh in a texture.
  59897. */
  59898. lightmapTexture: BaseTexture;
  59899. /**
  59900. * Stores the refracted light information in a texture.
  59901. */
  59902. get refractionTexture(): Nullable<BaseTexture>;
  59903. set refractionTexture(value: Nullable<BaseTexture>);
  59904. /**
  59905. * The color of a material in ambient lighting.
  59906. */
  59907. ambientColor: Color3;
  59908. /**
  59909. * AKA Diffuse Color in other nomenclature.
  59910. */
  59911. albedoColor: Color3;
  59912. /**
  59913. * AKA Specular Color in other nomenclature.
  59914. */
  59915. reflectivityColor: Color3;
  59916. /**
  59917. * The color reflected from the material.
  59918. */
  59919. reflectionColor: Color3;
  59920. /**
  59921. * The color emitted from the material.
  59922. */
  59923. emissiveColor: Color3;
  59924. /**
  59925. * AKA Glossiness in other nomenclature.
  59926. */
  59927. microSurface: number;
  59928. /**
  59929. * Index of refraction of the material base layer.
  59930. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59931. *
  59932. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59933. *
  59934. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59935. */
  59936. get indexOfRefraction(): number;
  59937. set indexOfRefraction(value: number);
  59938. /**
  59939. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59940. */
  59941. get invertRefractionY(): boolean;
  59942. set invertRefractionY(value: boolean);
  59943. /**
  59944. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59945. * Materials half opaque for instance using refraction could benefit from this control.
  59946. */
  59947. get linkRefractionWithTransparency(): boolean;
  59948. set linkRefractionWithTransparency(value: boolean);
  59949. /**
  59950. * If true, the light map contains occlusion information instead of lighting info.
  59951. */
  59952. useLightmapAsShadowmap: boolean;
  59953. /**
  59954. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59955. */
  59956. useAlphaFromAlbedoTexture: boolean;
  59957. /**
  59958. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59959. */
  59960. forceAlphaTest: boolean;
  59961. /**
  59962. * Defines the alpha limits in alpha test mode.
  59963. */
  59964. alphaCutOff: number;
  59965. /**
  59966. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59967. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59968. */
  59969. useSpecularOverAlpha: boolean;
  59970. /**
  59971. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59972. */
  59973. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59974. /**
  59975. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59976. */
  59977. useRoughnessFromMetallicTextureAlpha: boolean;
  59978. /**
  59979. * Specifies if the metallic texture contains the roughness information in its green channel.
  59980. */
  59981. useRoughnessFromMetallicTextureGreen: boolean;
  59982. /**
  59983. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59984. */
  59985. useMetallnessFromMetallicTextureBlue: boolean;
  59986. /**
  59987. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59988. */
  59989. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59990. /**
  59991. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59992. */
  59993. useAmbientInGrayScale: boolean;
  59994. /**
  59995. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59996. * The material will try to infer what glossiness each pixel should be.
  59997. */
  59998. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59999. /**
  60000. * BJS is using an harcoded light falloff based on a manually sets up range.
  60001. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60002. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60003. */
  60004. get usePhysicalLightFalloff(): boolean;
  60005. /**
  60006. * BJS is using an harcoded light falloff based on a manually sets up range.
  60007. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60008. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60009. */
  60010. set usePhysicalLightFalloff(value: boolean);
  60011. /**
  60012. * In order to support the falloff compatibility with gltf, a special mode has been added
  60013. * to reproduce the gltf light falloff.
  60014. */
  60015. get useGLTFLightFalloff(): boolean;
  60016. /**
  60017. * In order to support the falloff compatibility with gltf, a special mode has been added
  60018. * to reproduce the gltf light falloff.
  60019. */
  60020. set useGLTFLightFalloff(value: boolean);
  60021. /**
  60022. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60023. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60024. */
  60025. useRadianceOverAlpha: boolean;
  60026. /**
  60027. * Allows using an object space normal map (instead of tangent space).
  60028. */
  60029. useObjectSpaceNormalMap: boolean;
  60030. /**
  60031. * Allows using the bump map in parallax mode.
  60032. */
  60033. useParallax: boolean;
  60034. /**
  60035. * Allows using the bump map in parallax occlusion mode.
  60036. */
  60037. useParallaxOcclusion: boolean;
  60038. /**
  60039. * Controls the scale bias of the parallax mode.
  60040. */
  60041. parallaxScaleBias: number;
  60042. /**
  60043. * If sets to true, disables all the lights affecting the material.
  60044. */
  60045. disableLighting: boolean;
  60046. /**
  60047. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60048. */
  60049. forceIrradianceInFragment: boolean;
  60050. /**
  60051. * Number of Simultaneous lights allowed on the material.
  60052. */
  60053. maxSimultaneousLights: number;
  60054. /**
  60055. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60056. */
  60057. invertNormalMapX: boolean;
  60058. /**
  60059. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60060. */
  60061. invertNormalMapY: boolean;
  60062. /**
  60063. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60064. */
  60065. twoSidedLighting: boolean;
  60066. /**
  60067. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60068. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60069. */
  60070. useAlphaFresnel: boolean;
  60071. /**
  60072. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60073. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60074. */
  60075. useLinearAlphaFresnel: boolean;
  60076. /**
  60077. * Let user defines the brdf lookup texture used for IBL.
  60078. * A default 8bit version is embedded but you could point at :
  60079. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60080. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60081. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60082. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60083. */
  60084. environmentBRDFTexture: Nullable<BaseTexture>;
  60085. /**
  60086. * Force normal to face away from face.
  60087. */
  60088. forceNormalForward: boolean;
  60089. /**
  60090. * Enables specular anti aliasing in the PBR shader.
  60091. * It will both interacts on the Geometry for analytical and IBL lighting.
  60092. * It also prefilter the roughness map based on the bump values.
  60093. */
  60094. enableSpecularAntiAliasing: boolean;
  60095. /**
  60096. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60097. * makes the reflect vector face the model (under horizon).
  60098. */
  60099. useHorizonOcclusion: boolean;
  60100. /**
  60101. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60102. * too much the area relying on ambient texture to define their ambient occlusion.
  60103. */
  60104. useRadianceOcclusion: boolean;
  60105. /**
  60106. * If set to true, no lighting calculations will be applied.
  60107. */
  60108. unlit: boolean;
  60109. /**
  60110. * Gets the image processing configuration used either in this material.
  60111. */
  60112. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60113. /**
  60114. * Sets the Default image processing configuration used either in the this material.
  60115. *
  60116. * If sets to null, the scene one is in use.
  60117. */
  60118. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60119. /**
  60120. * Gets wether the color curves effect is enabled.
  60121. */
  60122. get cameraColorCurvesEnabled(): boolean;
  60123. /**
  60124. * Sets wether the color curves effect is enabled.
  60125. */
  60126. set cameraColorCurvesEnabled(value: boolean);
  60127. /**
  60128. * Gets wether the color grading effect is enabled.
  60129. */
  60130. get cameraColorGradingEnabled(): boolean;
  60131. /**
  60132. * Gets wether the color grading effect is enabled.
  60133. */
  60134. set cameraColorGradingEnabled(value: boolean);
  60135. /**
  60136. * Gets wether tonemapping is enabled or not.
  60137. */
  60138. get cameraToneMappingEnabled(): boolean;
  60139. /**
  60140. * Sets wether tonemapping is enabled or not
  60141. */
  60142. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): number;
  60149. /**
  60150. * The camera exposure used on this material.
  60151. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60152. * This corresponds to a photographic exposure.
  60153. */
  60154. set cameraExposure(value: number);
  60155. /**
  60156. * Gets The camera contrast used on this material.
  60157. */
  60158. get cameraContrast(): number;
  60159. /**
  60160. * Sets The camera contrast used on this material.
  60161. */
  60162. set cameraContrast(value: number);
  60163. /**
  60164. * Gets the Color Grading 2D Lookup Texture.
  60165. */
  60166. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60167. /**
  60168. * Sets the Color Grading 2D Lookup Texture.
  60169. */
  60170. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60171. /**
  60172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60174. * 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;
  60175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60176. */
  60177. get cameraColorCurves(): Nullable<ColorCurves>;
  60178. /**
  60179. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60180. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60181. * 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;
  60182. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60183. */
  60184. set cameraColorCurves(value: Nullable<ColorCurves>);
  60185. /**
  60186. * Instantiates a new PBRMaterial instance.
  60187. *
  60188. * @param name The material name
  60189. * @param scene The scene the material will be use in.
  60190. */
  60191. constructor(name: string, scene: Scene);
  60192. /**
  60193. * Returns the name of this material class.
  60194. */
  60195. getClassName(): string;
  60196. /**
  60197. * Makes a duplicate of the current material.
  60198. * @param name - name to use for the new material.
  60199. */
  60200. clone(name: string): PBRMaterial;
  60201. /**
  60202. * Serializes this PBR Material.
  60203. * @returns - An object with the serialized material.
  60204. */
  60205. serialize(): any;
  60206. /**
  60207. * Parses a PBR Material from a serialized object.
  60208. * @param source - Serialized object.
  60209. * @param scene - BJS scene instance.
  60210. * @param rootUrl - url for the scene object
  60211. * @returns - PBRMaterial
  60212. */
  60213. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60214. }
  60215. }
  60216. declare module "babylonjs/Misc/dds" {
  60217. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60218. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60219. import { Nullable } from "babylonjs/types";
  60220. import { Scene } from "babylonjs/scene";
  60221. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60222. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60223. /**
  60224. * Direct draw surface info
  60225. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60226. */
  60227. export interface DDSInfo {
  60228. /**
  60229. * Width of the texture
  60230. */
  60231. width: number;
  60232. /**
  60233. * Width of the texture
  60234. */
  60235. height: number;
  60236. /**
  60237. * Number of Mipmaps for the texture
  60238. * @see https://en.wikipedia.org/wiki/Mipmap
  60239. */
  60240. mipmapCount: number;
  60241. /**
  60242. * If the textures format is a known fourCC format
  60243. * @see https://www.fourcc.org/
  60244. */
  60245. isFourCC: boolean;
  60246. /**
  60247. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60248. */
  60249. isRGB: boolean;
  60250. /**
  60251. * If the texture is a lumincance format
  60252. */
  60253. isLuminance: boolean;
  60254. /**
  60255. * If this is a cube texture
  60256. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60257. */
  60258. isCube: boolean;
  60259. /**
  60260. * If the texture is a compressed format eg. FOURCC_DXT1
  60261. */
  60262. isCompressed: boolean;
  60263. /**
  60264. * The dxgiFormat of the texture
  60265. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60266. */
  60267. dxgiFormat: number;
  60268. /**
  60269. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60270. */
  60271. textureType: number;
  60272. /**
  60273. * Sphericle polynomial created for the dds texture
  60274. */
  60275. sphericalPolynomial?: SphericalPolynomial;
  60276. }
  60277. /**
  60278. * Class used to provide DDS decompression tools
  60279. */
  60280. export class DDSTools {
  60281. /**
  60282. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60283. */
  60284. static StoreLODInAlphaChannel: boolean;
  60285. /**
  60286. * Gets DDS information from an array buffer
  60287. * @param data defines the array buffer view to read data from
  60288. * @returns the DDS information
  60289. */
  60290. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60291. private static _FloatView;
  60292. private static _Int32View;
  60293. private static _ToHalfFloat;
  60294. private static _FromHalfFloat;
  60295. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60296. private static _GetHalfFloatRGBAArrayBuffer;
  60297. private static _GetFloatRGBAArrayBuffer;
  60298. private static _GetFloatAsUIntRGBAArrayBuffer;
  60299. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60300. private static _GetRGBAArrayBuffer;
  60301. private static _ExtractLongWordOrder;
  60302. private static _GetRGBArrayBuffer;
  60303. private static _GetLuminanceArrayBuffer;
  60304. /**
  60305. * Uploads DDS Levels to a Babylon Texture
  60306. * @hidden
  60307. */
  60308. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60309. }
  60310. module "babylonjs/Engines/thinEngine" {
  60311. interface ThinEngine {
  60312. /**
  60313. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60314. * @param rootUrl defines the url where the file to load is located
  60315. * @param scene defines the current scene
  60316. * @param lodScale defines scale to apply to the mip map selection
  60317. * @param lodOffset defines offset to apply to the mip map selection
  60318. * @param onLoad defines an optional callback raised when the texture is loaded
  60319. * @param onError defines an optional callback raised if there is an issue to load the texture
  60320. * @param format defines the format of the data
  60321. * @param forcedExtension defines the extension to use to pick the right loader
  60322. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60323. * @returns the cube texture as an InternalTexture
  60324. */
  60325. 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;
  60326. }
  60327. }
  60328. }
  60329. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60330. import { Nullable } from "babylonjs/types";
  60331. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60332. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60333. /**
  60334. * Implementation of the DDS Texture Loader.
  60335. * @hidden
  60336. */
  60337. export class _DDSTextureLoader implements IInternalTextureLoader {
  60338. /**
  60339. * Defines wether the loader supports cascade loading the different faces.
  60340. */
  60341. readonly supportCascades: boolean;
  60342. /**
  60343. * This returns if the loader support the current file information.
  60344. * @param extension defines the file extension of the file being loaded
  60345. * @returns true if the loader can load the specified file
  60346. */
  60347. canLoad(extension: string): boolean;
  60348. /**
  60349. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60350. * @param data contains the texture data
  60351. * @param texture defines the BabylonJS internal texture
  60352. * @param createPolynomials will be true if polynomials have been requested
  60353. * @param onLoad defines the callback to trigger once the texture is ready
  60354. * @param onError defines the callback to trigger in case of error
  60355. */
  60356. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60357. /**
  60358. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60359. * @param data contains the texture data
  60360. * @param texture defines the BabylonJS internal texture
  60361. * @param callback defines the method to call once ready to upload
  60362. */
  60363. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60364. }
  60365. }
  60366. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60367. import { Nullable } from "babylonjs/types";
  60368. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60369. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60370. /**
  60371. * Implementation of the ENV Texture Loader.
  60372. * @hidden
  60373. */
  60374. export class _ENVTextureLoader implements IInternalTextureLoader {
  60375. /**
  60376. * Defines wether the loader supports cascade loading the different faces.
  60377. */
  60378. readonly supportCascades: boolean;
  60379. /**
  60380. * This returns if the loader support the current file information.
  60381. * @param extension defines the file extension of the file being loaded
  60382. * @returns true if the loader can load the specified file
  60383. */
  60384. canLoad(extension: string): boolean;
  60385. /**
  60386. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60387. * @param data contains the texture data
  60388. * @param texture defines the BabylonJS internal texture
  60389. * @param createPolynomials will be true if polynomials have been requested
  60390. * @param onLoad defines the callback to trigger once the texture is ready
  60391. * @param onError defines the callback to trigger in case of error
  60392. */
  60393. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60394. /**
  60395. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60396. * @param data contains the texture data
  60397. * @param texture defines the BabylonJS internal texture
  60398. * @param callback defines the method to call once ready to upload
  60399. */
  60400. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60401. }
  60402. }
  60403. declare module "babylonjs/Misc/khronosTextureContainer" {
  60404. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60405. /**
  60406. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60407. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60408. */
  60409. export class KhronosTextureContainer {
  60410. /** contents of the KTX container file */
  60411. data: ArrayBufferView;
  60412. private static HEADER_LEN;
  60413. private static COMPRESSED_2D;
  60414. private static COMPRESSED_3D;
  60415. private static TEX_2D;
  60416. private static TEX_3D;
  60417. /**
  60418. * Gets the openGL type
  60419. */
  60420. glType: number;
  60421. /**
  60422. * Gets the openGL type size
  60423. */
  60424. glTypeSize: number;
  60425. /**
  60426. * Gets the openGL format
  60427. */
  60428. glFormat: number;
  60429. /**
  60430. * Gets the openGL internal format
  60431. */
  60432. glInternalFormat: number;
  60433. /**
  60434. * Gets the base internal format
  60435. */
  60436. glBaseInternalFormat: number;
  60437. /**
  60438. * Gets image width in pixel
  60439. */
  60440. pixelWidth: number;
  60441. /**
  60442. * Gets image height in pixel
  60443. */
  60444. pixelHeight: number;
  60445. /**
  60446. * Gets image depth in pixels
  60447. */
  60448. pixelDepth: number;
  60449. /**
  60450. * Gets the number of array elements
  60451. */
  60452. numberOfArrayElements: number;
  60453. /**
  60454. * Gets the number of faces
  60455. */
  60456. numberOfFaces: number;
  60457. /**
  60458. * Gets the number of mipmap levels
  60459. */
  60460. numberOfMipmapLevels: number;
  60461. /**
  60462. * Gets the bytes of key value data
  60463. */
  60464. bytesOfKeyValueData: number;
  60465. /**
  60466. * Gets the load type
  60467. */
  60468. loadType: number;
  60469. /**
  60470. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60471. */
  60472. isInvalid: boolean;
  60473. /**
  60474. * Creates a new KhronosTextureContainer
  60475. * @param data contents of the KTX container file
  60476. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60477. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60478. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60479. */
  60480. constructor(
  60481. /** contents of the KTX container file */
  60482. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60483. /**
  60484. * Uploads KTX content to a Babylon Texture.
  60485. * It is assumed that the texture has already been created & is currently bound
  60486. * @hidden
  60487. */
  60488. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60489. private _upload2DCompressedLevels;
  60490. /**
  60491. * Checks if the given data starts with a KTX file identifier.
  60492. * @param data the data to check
  60493. * @returns true if the data is a KTX file or false otherwise
  60494. */
  60495. static IsValid(data: ArrayBufferView): boolean;
  60496. }
  60497. }
  60498. declare module "babylonjs/Misc/workerPool" {
  60499. import { IDisposable } from "babylonjs/scene";
  60500. /**
  60501. * Helper class to push actions to a pool of workers.
  60502. */
  60503. export class WorkerPool implements IDisposable {
  60504. private _workerInfos;
  60505. private _pendingActions;
  60506. /**
  60507. * Constructor
  60508. * @param workers Array of workers to use for actions
  60509. */
  60510. constructor(workers: Array<Worker>);
  60511. /**
  60512. * Terminates all workers and clears any pending actions.
  60513. */
  60514. dispose(): void;
  60515. /**
  60516. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60517. * pended until a worker has completed its action.
  60518. * @param action The action to perform. Call onComplete when the action is complete.
  60519. */
  60520. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60521. private _execute;
  60522. }
  60523. }
  60524. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60525. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60526. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60527. /**
  60528. * Class for loading KTX2 files
  60529. * @hidden
  60530. */
  60531. export class KhronosTextureContainer2 {
  60532. private static _WorkerPoolPromise?;
  60533. private static _Initialized;
  60534. private static _Ktx2Decoder;
  60535. /**
  60536. * URL to use when loading the KTX2 decoder module
  60537. */
  60538. static JSModuleURL: string;
  60539. /**
  60540. * Default number of workers used to handle data decoding
  60541. */
  60542. static DefaultNumWorkers: number;
  60543. private static GetDefaultNumWorkers;
  60544. private _engine;
  60545. private static _CreateWorkerPool;
  60546. /**
  60547. * Constructor
  60548. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60549. */
  60550. constructor(engine: ThinEngine, numWorkers?: number);
  60551. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60552. /**
  60553. * Stop all async operations and release resources.
  60554. */
  60555. dispose(): void;
  60556. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60557. /**
  60558. * Checks if the given data starts with a KTX2 file identifier.
  60559. * @param data the data to check
  60560. * @returns true if the data is a KTX2 file or false otherwise
  60561. */
  60562. static IsValid(data: ArrayBufferView): boolean;
  60563. }
  60564. export function workerFunc(): void;
  60565. }
  60566. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60567. import { Nullable } from "babylonjs/types";
  60568. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60569. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60570. /**
  60571. * Implementation of the KTX Texture Loader.
  60572. * @hidden
  60573. */
  60574. export class _KTXTextureLoader implements IInternalTextureLoader {
  60575. /**
  60576. * Defines wether the loader supports cascade loading the different faces.
  60577. */
  60578. readonly supportCascades: boolean;
  60579. /**
  60580. * This returns if the loader support the current file information.
  60581. * @param extension defines the file extension of the file being loaded
  60582. * @param mimeType defines the optional mime type of the file being loaded
  60583. * @returns true if the loader can load the specified file
  60584. */
  60585. canLoad(extension: string, mimeType?: string): boolean;
  60586. /**
  60587. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60588. * @param data contains the texture data
  60589. * @param texture defines the BabylonJS internal texture
  60590. * @param createPolynomials will be true if polynomials have been requested
  60591. * @param onLoad defines the callback to trigger once the texture is ready
  60592. * @param onError defines the callback to trigger in case of error
  60593. */
  60594. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60595. /**
  60596. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60597. * @param data contains the texture data
  60598. * @param texture defines the BabylonJS internal texture
  60599. * @param callback defines the method to call once ready to upload
  60600. */
  60601. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60602. }
  60603. }
  60604. declare module "babylonjs/Helpers/sceneHelpers" {
  60605. import { Nullable } from "babylonjs/types";
  60606. import { Mesh } from "babylonjs/Meshes/mesh";
  60607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60608. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60609. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60610. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60611. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60612. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60613. import "babylonjs/Meshes/Builders/boxBuilder";
  60614. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60615. /** @hidden */
  60616. export var _forceSceneHelpersToBundle: boolean;
  60617. module "babylonjs/scene" {
  60618. interface Scene {
  60619. /**
  60620. * Creates a default light for the scene.
  60621. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60622. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60623. */
  60624. createDefaultLight(replace?: boolean): void;
  60625. /**
  60626. * Creates a default camera for the scene.
  60627. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60628. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60629. * @param replace has default false, when true replaces the active camera in the scene
  60630. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60631. */
  60632. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60633. /**
  60634. * Creates a default camera and a default light.
  60635. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60636. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60637. * @param replace has the default false, when true replaces the active camera/light in the scene
  60638. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60639. */
  60640. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60641. /**
  60642. * Creates a new sky box
  60643. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60644. * @param environmentTexture defines the texture to use as environment texture
  60645. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60646. * @param scale defines the overall scale of the skybox
  60647. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60648. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60649. * @returns a new mesh holding the sky box
  60650. */
  60651. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60652. /**
  60653. * Creates a new environment
  60654. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60655. * @param options defines the options you can use to configure the environment
  60656. * @returns the new EnvironmentHelper
  60657. */
  60658. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60659. /**
  60660. * Creates a new VREXperienceHelper
  60661. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60662. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60663. * @returns a new VREXperienceHelper
  60664. */
  60665. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60666. /**
  60667. * Creates a new WebXRDefaultExperience
  60668. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60669. * @param options experience options
  60670. * @returns a promise for a new WebXRDefaultExperience
  60671. */
  60672. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60673. }
  60674. }
  60675. }
  60676. declare module "babylonjs/Helpers/videoDome" {
  60677. import { Scene } from "babylonjs/scene";
  60678. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60679. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60680. /**
  60681. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60682. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60683. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60684. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60685. */
  60686. export class VideoDome extends TextureDome<VideoTexture> {
  60687. /**
  60688. * Define the video source as a Monoscopic panoramic 360 video.
  60689. */
  60690. static readonly MODE_MONOSCOPIC: number;
  60691. /**
  60692. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60693. */
  60694. static readonly MODE_TOPBOTTOM: number;
  60695. /**
  60696. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60697. */
  60698. static readonly MODE_SIDEBYSIDE: number;
  60699. /**
  60700. * Get the video texture associated with this video dome
  60701. */
  60702. get videoTexture(): VideoTexture;
  60703. /**
  60704. * Get the video mode of this dome
  60705. */
  60706. get videoMode(): number;
  60707. /**
  60708. * Set the video mode of this dome.
  60709. * @see textureMode
  60710. */
  60711. set videoMode(value: number);
  60712. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60713. }
  60714. }
  60715. declare module "babylonjs/Helpers/index" {
  60716. export * from "babylonjs/Helpers/environmentHelper";
  60717. export * from "babylonjs/Helpers/photoDome";
  60718. export * from "babylonjs/Helpers/sceneHelpers";
  60719. export * from "babylonjs/Helpers/videoDome";
  60720. }
  60721. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60722. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60723. import { IDisposable } from "babylonjs/scene";
  60724. import { Engine } from "babylonjs/Engines/engine";
  60725. /**
  60726. * This class can be used to get instrumentation data from a Babylon engine
  60727. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60728. */
  60729. export class EngineInstrumentation implements IDisposable {
  60730. /**
  60731. * Define the instrumented engine.
  60732. */
  60733. engine: Engine;
  60734. private _captureGPUFrameTime;
  60735. private _gpuFrameTimeToken;
  60736. private _gpuFrameTime;
  60737. private _captureShaderCompilationTime;
  60738. private _shaderCompilationTime;
  60739. private _onBeginFrameObserver;
  60740. private _onEndFrameObserver;
  60741. private _onBeforeShaderCompilationObserver;
  60742. private _onAfterShaderCompilationObserver;
  60743. /**
  60744. * Gets the perf counter used for GPU frame time
  60745. */
  60746. get gpuFrameTimeCounter(): PerfCounter;
  60747. /**
  60748. * Gets the GPU frame time capture status
  60749. */
  60750. get captureGPUFrameTime(): boolean;
  60751. /**
  60752. * Enable or disable the GPU frame time capture
  60753. */
  60754. set captureGPUFrameTime(value: boolean);
  60755. /**
  60756. * Gets the perf counter used for shader compilation time
  60757. */
  60758. get shaderCompilationTimeCounter(): PerfCounter;
  60759. /**
  60760. * Gets the shader compilation time capture status
  60761. */
  60762. get captureShaderCompilationTime(): boolean;
  60763. /**
  60764. * Enable or disable the shader compilation time capture
  60765. */
  60766. set captureShaderCompilationTime(value: boolean);
  60767. /**
  60768. * Instantiates a new engine instrumentation.
  60769. * This class can be used to get instrumentation data from a Babylon engine
  60770. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60771. * @param engine Defines the engine to instrument
  60772. */
  60773. constructor(
  60774. /**
  60775. * Define the instrumented engine.
  60776. */
  60777. engine: Engine);
  60778. /**
  60779. * Dispose and release associated resources.
  60780. */
  60781. dispose(): void;
  60782. }
  60783. }
  60784. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60785. import { Scene, IDisposable } from "babylonjs/scene";
  60786. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60787. /**
  60788. * This class can be used to get instrumentation data from a Babylon engine
  60789. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60790. */
  60791. export class SceneInstrumentation implements IDisposable {
  60792. /**
  60793. * Defines the scene to instrument
  60794. */
  60795. scene: Scene;
  60796. private _captureActiveMeshesEvaluationTime;
  60797. private _activeMeshesEvaluationTime;
  60798. private _captureRenderTargetsRenderTime;
  60799. private _renderTargetsRenderTime;
  60800. private _captureFrameTime;
  60801. private _frameTime;
  60802. private _captureRenderTime;
  60803. private _renderTime;
  60804. private _captureInterFrameTime;
  60805. private _interFrameTime;
  60806. private _captureParticlesRenderTime;
  60807. private _particlesRenderTime;
  60808. private _captureSpritesRenderTime;
  60809. private _spritesRenderTime;
  60810. private _capturePhysicsTime;
  60811. private _physicsTime;
  60812. private _captureAnimationsTime;
  60813. private _animationsTime;
  60814. private _captureCameraRenderTime;
  60815. private _cameraRenderTime;
  60816. private _onBeforeActiveMeshesEvaluationObserver;
  60817. private _onAfterActiveMeshesEvaluationObserver;
  60818. private _onBeforeRenderTargetsRenderObserver;
  60819. private _onAfterRenderTargetsRenderObserver;
  60820. private _onAfterRenderObserver;
  60821. private _onBeforeDrawPhaseObserver;
  60822. private _onAfterDrawPhaseObserver;
  60823. private _onBeforeAnimationsObserver;
  60824. private _onBeforeParticlesRenderingObserver;
  60825. private _onAfterParticlesRenderingObserver;
  60826. private _onBeforeSpritesRenderingObserver;
  60827. private _onAfterSpritesRenderingObserver;
  60828. private _onBeforePhysicsObserver;
  60829. private _onAfterPhysicsObserver;
  60830. private _onAfterAnimationsObserver;
  60831. private _onBeforeCameraRenderObserver;
  60832. private _onAfterCameraRenderObserver;
  60833. /**
  60834. * Gets the perf counter used for active meshes evaluation time
  60835. */
  60836. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60837. /**
  60838. * Gets the active meshes evaluation time capture status
  60839. */
  60840. get captureActiveMeshesEvaluationTime(): boolean;
  60841. /**
  60842. * Enable or disable the active meshes evaluation time capture
  60843. */
  60844. set captureActiveMeshesEvaluationTime(value: boolean);
  60845. /**
  60846. * Gets the perf counter used for render targets render time
  60847. */
  60848. get renderTargetsRenderTimeCounter(): PerfCounter;
  60849. /**
  60850. * Gets the render targets render time capture status
  60851. */
  60852. get captureRenderTargetsRenderTime(): boolean;
  60853. /**
  60854. * Enable or disable the render targets render time capture
  60855. */
  60856. set captureRenderTargetsRenderTime(value: boolean);
  60857. /**
  60858. * Gets the perf counter used for particles render time
  60859. */
  60860. get particlesRenderTimeCounter(): PerfCounter;
  60861. /**
  60862. * Gets the particles render time capture status
  60863. */
  60864. get captureParticlesRenderTime(): boolean;
  60865. /**
  60866. * Enable or disable the particles render time capture
  60867. */
  60868. set captureParticlesRenderTime(value: boolean);
  60869. /**
  60870. * Gets the perf counter used for sprites render time
  60871. */
  60872. get spritesRenderTimeCounter(): PerfCounter;
  60873. /**
  60874. * Gets the sprites render time capture status
  60875. */
  60876. get captureSpritesRenderTime(): boolean;
  60877. /**
  60878. * Enable or disable the sprites render time capture
  60879. */
  60880. set captureSpritesRenderTime(value: boolean);
  60881. /**
  60882. * Gets the perf counter used for physics time
  60883. */
  60884. get physicsTimeCounter(): PerfCounter;
  60885. /**
  60886. * Gets the physics time capture status
  60887. */
  60888. get capturePhysicsTime(): boolean;
  60889. /**
  60890. * Enable or disable the physics time capture
  60891. */
  60892. set capturePhysicsTime(value: boolean);
  60893. /**
  60894. * Gets the perf counter used for animations time
  60895. */
  60896. get animationsTimeCounter(): PerfCounter;
  60897. /**
  60898. * Gets the animations time capture status
  60899. */
  60900. get captureAnimationsTime(): boolean;
  60901. /**
  60902. * Enable or disable the animations time capture
  60903. */
  60904. set captureAnimationsTime(value: boolean);
  60905. /**
  60906. * Gets the perf counter used for frame time capture
  60907. */
  60908. get frameTimeCounter(): PerfCounter;
  60909. /**
  60910. * Gets the frame time capture status
  60911. */
  60912. get captureFrameTime(): boolean;
  60913. /**
  60914. * Enable or disable the frame time capture
  60915. */
  60916. set captureFrameTime(value: boolean);
  60917. /**
  60918. * Gets the perf counter used for inter-frames time capture
  60919. */
  60920. get interFrameTimeCounter(): PerfCounter;
  60921. /**
  60922. * Gets the inter-frames time capture status
  60923. */
  60924. get captureInterFrameTime(): boolean;
  60925. /**
  60926. * Enable or disable the inter-frames time capture
  60927. */
  60928. set captureInterFrameTime(value: boolean);
  60929. /**
  60930. * Gets the perf counter used for render time capture
  60931. */
  60932. get renderTimeCounter(): PerfCounter;
  60933. /**
  60934. * Gets the render time capture status
  60935. */
  60936. get captureRenderTime(): boolean;
  60937. /**
  60938. * Enable or disable the render time capture
  60939. */
  60940. set captureRenderTime(value: boolean);
  60941. /**
  60942. * Gets the perf counter used for camera render time capture
  60943. */
  60944. get cameraRenderTimeCounter(): PerfCounter;
  60945. /**
  60946. * Gets the camera render time capture status
  60947. */
  60948. get captureCameraRenderTime(): boolean;
  60949. /**
  60950. * Enable or disable the camera render time capture
  60951. */
  60952. set captureCameraRenderTime(value: boolean);
  60953. /**
  60954. * Gets the perf counter used for draw calls
  60955. */
  60956. get drawCallsCounter(): PerfCounter;
  60957. /**
  60958. * Instantiates a new scene instrumentation.
  60959. * This class can be used to get instrumentation data from a Babylon engine
  60960. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60961. * @param scene Defines the scene to instrument
  60962. */
  60963. constructor(
  60964. /**
  60965. * Defines the scene to instrument
  60966. */
  60967. scene: Scene);
  60968. /**
  60969. * Dispose and release associated resources.
  60970. */
  60971. dispose(): void;
  60972. }
  60973. }
  60974. declare module "babylonjs/Instrumentation/index" {
  60975. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60976. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60977. export * from "babylonjs/Instrumentation/timeToken";
  60978. }
  60979. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60980. /** @hidden */
  60981. export var glowMapGenerationPixelShader: {
  60982. name: string;
  60983. shader: string;
  60984. };
  60985. }
  60986. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60987. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60989. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60990. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60992. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60993. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60994. /** @hidden */
  60995. export var glowMapGenerationVertexShader: {
  60996. name: string;
  60997. shader: string;
  60998. };
  60999. }
  61000. declare module "babylonjs/Layers/effectLayer" {
  61001. import { Observable } from "babylonjs/Misc/observable";
  61002. import { Nullable } from "babylonjs/types";
  61003. import { Camera } from "babylonjs/Cameras/camera";
  61004. import { Scene } from "babylonjs/scene";
  61005. import { ISize } from "babylonjs/Maths/math.size";
  61006. import { Color4 } from "babylonjs/Maths/math.color";
  61007. import { Engine } from "babylonjs/Engines/engine";
  61008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61010. import { Mesh } from "babylonjs/Meshes/mesh";
  61011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61014. import { Effect } from "babylonjs/Materials/effect";
  61015. import { Material } from "babylonjs/Materials/material";
  61016. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61017. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61018. /**
  61019. * Effect layer options. This helps customizing the behaviour
  61020. * of the effect layer.
  61021. */
  61022. export interface IEffectLayerOptions {
  61023. /**
  61024. * Multiplication factor apply to the canvas size to compute the render target size
  61025. * used to generated the objects (the smaller the faster).
  61026. */
  61027. mainTextureRatio: number;
  61028. /**
  61029. * Enforces a fixed size texture to ensure effect stability across devices.
  61030. */
  61031. mainTextureFixedSize?: number;
  61032. /**
  61033. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61034. */
  61035. alphaBlendingMode: number;
  61036. /**
  61037. * The camera attached to the layer.
  61038. */
  61039. camera: Nullable<Camera>;
  61040. /**
  61041. * The rendering group to draw the layer in.
  61042. */
  61043. renderingGroupId: number;
  61044. }
  61045. /**
  61046. * The effect layer Helps adding post process effect blended with the main pass.
  61047. *
  61048. * This can be for instance use to generate glow or higlight effects on the scene.
  61049. *
  61050. * The effect layer class can not be used directly and is intented to inherited from to be
  61051. * customized per effects.
  61052. */
  61053. export abstract class EffectLayer {
  61054. private _vertexBuffers;
  61055. private _indexBuffer;
  61056. private _cachedDefines;
  61057. private _effectLayerMapGenerationEffect;
  61058. private _effectLayerOptions;
  61059. private _mergeEffect;
  61060. protected _scene: Scene;
  61061. protected _engine: Engine;
  61062. protected _maxSize: number;
  61063. protected _mainTextureDesiredSize: ISize;
  61064. protected _mainTexture: RenderTargetTexture;
  61065. protected _shouldRender: boolean;
  61066. protected _postProcesses: PostProcess[];
  61067. protected _textures: BaseTexture[];
  61068. protected _emissiveTextureAndColor: {
  61069. texture: Nullable<BaseTexture>;
  61070. color: Color4;
  61071. };
  61072. /**
  61073. * The name of the layer
  61074. */
  61075. name: string;
  61076. /**
  61077. * The clear color of the texture used to generate the glow map.
  61078. */
  61079. neutralColor: Color4;
  61080. /**
  61081. * Specifies whether the highlight layer is enabled or not.
  61082. */
  61083. isEnabled: boolean;
  61084. /**
  61085. * Gets the camera attached to the layer.
  61086. */
  61087. get camera(): Nullable<Camera>;
  61088. /**
  61089. * Gets the rendering group id the layer should render in.
  61090. */
  61091. get renderingGroupId(): number;
  61092. set renderingGroupId(renderingGroupId: number);
  61093. /**
  61094. * An event triggered when the effect layer has been disposed.
  61095. */
  61096. onDisposeObservable: Observable<EffectLayer>;
  61097. /**
  61098. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61099. */
  61100. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61101. /**
  61102. * An event triggered when the generated texture is being merged in the scene.
  61103. */
  61104. onBeforeComposeObservable: Observable<EffectLayer>;
  61105. /**
  61106. * An event triggered when the mesh is rendered into the effect render target.
  61107. */
  61108. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61109. /**
  61110. * An event triggered after the mesh has been rendered into the effect render target.
  61111. */
  61112. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61113. /**
  61114. * An event triggered when the generated texture has been merged in the scene.
  61115. */
  61116. onAfterComposeObservable: Observable<EffectLayer>;
  61117. /**
  61118. * An event triggered when the efffect layer changes its size.
  61119. */
  61120. onSizeChangedObservable: Observable<EffectLayer>;
  61121. /** @hidden */
  61122. static _SceneComponentInitialization: (scene: Scene) => void;
  61123. /**
  61124. * Instantiates a new effect Layer and references it in the scene.
  61125. * @param name The name of the layer
  61126. * @param scene The scene to use the layer in
  61127. */
  61128. constructor(
  61129. /** The Friendly of the effect in the scene */
  61130. name: string, scene: Scene);
  61131. /**
  61132. * Get the effect name of the layer.
  61133. * @return The effect name
  61134. */
  61135. abstract getEffectName(): string;
  61136. /**
  61137. * Checks for the readiness of the element composing the layer.
  61138. * @param subMesh the mesh to check for
  61139. * @param useInstances specify whether or not to use instances to render the mesh
  61140. * @return true if ready otherwise, false
  61141. */
  61142. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61143. /**
  61144. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61145. * @returns true if the effect requires stencil during the main canvas render pass.
  61146. */
  61147. abstract needStencil(): boolean;
  61148. /**
  61149. * Create the merge effect. This is the shader use to blit the information back
  61150. * to the main canvas at the end of the scene rendering.
  61151. * @returns The effect containing the shader used to merge the effect on the main canvas
  61152. */
  61153. protected abstract _createMergeEffect(): Effect;
  61154. /**
  61155. * Creates the render target textures and post processes used in the effect layer.
  61156. */
  61157. protected abstract _createTextureAndPostProcesses(): void;
  61158. /**
  61159. * Implementation specific of rendering the generating effect on the main canvas.
  61160. * @param effect The effect used to render through
  61161. */
  61162. protected abstract _internalRender(effect: Effect): void;
  61163. /**
  61164. * Sets the required values for both the emissive texture and and the main color.
  61165. */
  61166. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61167. /**
  61168. * Free any resources and references associated to a mesh.
  61169. * Internal use
  61170. * @param mesh The mesh to free.
  61171. */
  61172. abstract _disposeMesh(mesh: Mesh): void;
  61173. /**
  61174. * Serializes this layer (Glow or Highlight for example)
  61175. * @returns a serialized layer object
  61176. */
  61177. abstract serialize?(): any;
  61178. /**
  61179. * Initializes the effect layer with the required options.
  61180. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61181. */
  61182. protected _init(options: Partial<IEffectLayerOptions>): void;
  61183. /**
  61184. * Generates the index buffer of the full screen quad blending to the main canvas.
  61185. */
  61186. private _generateIndexBuffer;
  61187. /**
  61188. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61189. */
  61190. private _generateVertexBuffer;
  61191. /**
  61192. * Sets the main texture desired size which is the closest power of two
  61193. * of the engine canvas size.
  61194. */
  61195. private _setMainTextureSize;
  61196. /**
  61197. * Creates the main texture for the effect layer.
  61198. */
  61199. protected _createMainTexture(): void;
  61200. /**
  61201. * Adds specific effects defines.
  61202. * @param defines The defines to add specifics to.
  61203. */
  61204. protected _addCustomEffectDefines(defines: string[]): void;
  61205. /**
  61206. * Checks for the readiness of the element composing the layer.
  61207. * @param subMesh the mesh to check for
  61208. * @param useInstances specify whether or not to use instances to render the mesh
  61209. * @param emissiveTexture the associated emissive texture used to generate the glow
  61210. * @return true if ready otherwise, false
  61211. */
  61212. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61213. /**
  61214. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61215. */
  61216. render(): void;
  61217. /**
  61218. * Determine if a given mesh will be used in the current effect.
  61219. * @param mesh mesh to test
  61220. * @returns true if the mesh will be used
  61221. */
  61222. hasMesh(mesh: AbstractMesh): boolean;
  61223. /**
  61224. * Returns true if the layer contains information to display, otherwise false.
  61225. * @returns true if the glow layer should be rendered
  61226. */
  61227. shouldRender(): boolean;
  61228. /**
  61229. * Returns true if the mesh should render, otherwise false.
  61230. * @param mesh The mesh to render
  61231. * @returns true if it should render otherwise false
  61232. */
  61233. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61234. /**
  61235. * Returns true if the mesh can be rendered, otherwise false.
  61236. * @param mesh The mesh to render
  61237. * @param material The material used on the mesh
  61238. * @returns true if it can be rendered otherwise false
  61239. */
  61240. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61241. /**
  61242. * Returns true if the mesh should render, otherwise false.
  61243. * @param mesh The mesh to render
  61244. * @returns true if it should render otherwise false
  61245. */
  61246. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61247. /**
  61248. * Renders the submesh passed in parameter to the generation map.
  61249. */
  61250. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61251. /**
  61252. * Defines whether the current material of the mesh should be use to render the effect.
  61253. * @param mesh defines the current mesh to render
  61254. */
  61255. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61256. /**
  61257. * Rebuild the required buffers.
  61258. * @hidden Internal use only.
  61259. */
  61260. _rebuild(): void;
  61261. /**
  61262. * Dispose only the render target textures and post process.
  61263. */
  61264. private _disposeTextureAndPostProcesses;
  61265. /**
  61266. * Dispose the highlight layer and free resources.
  61267. */
  61268. dispose(): void;
  61269. /**
  61270. * Gets the class name of the effect layer
  61271. * @returns the string with the class name of the effect layer
  61272. */
  61273. getClassName(): string;
  61274. /**
  61275. * Creates an effect layer from parsed effect layer data
  61276. * @param parsedEffectLayer defines effect layer data
  61277. * @param scene defines the current scene
  61278. * @param rootUrl defines the root URL containing the effect layer information
  61279. * @returns a parsed effect Layer
  61280. */
  61281. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61282. }
  61283. }
  61284. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61285. import { Scene } from "babylonjs/scene";
  61286. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61287. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61288. import { AbstractScene } from "babylonjs/abstractScene";
  61289. module "babylonjs/abstractScene" {
  61290. interface AbstractScene {
  61291. /**
  61292. * The list of effect layers (highlights/glow) added to the scene
  61293. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61294. * @see https://doc.babylonjs.com/how_to/glow_layer
  61295. */
  61296. effectLayers: Array<EffectLayer>;
  61297. /**
  61298. * Removes the given effect layer from this scene.
  61299. * @param toRemove defines the effect layer to remove
  61300. * @returns the index of the removed effect layer
  61301. */
  61302. removeEffectLayer(toRemove: EffectLayer): number;
  61303. /**
  61304. * Adds the given effect layer to this scene
  61305. * @param newEffectLayer defines the effect layer to add
  61306. */
  61307. addEffectLayer(newEffectLayer: EffectLayer): void;
  61308. }
  61309. }
  61310. /**
  61311. * Defines the layer scene component responsible to manage any effect layers
  61312. * in a given scene.
  61313. */
  61314. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61315. /**
  61316. * The component name helpfull to identify the component in the list of scene components.
  61317. */
  61318. readonly name: string;
  61319. /**
  61320. * The scene the component belongs to.
  61321. */
  61322. scene: Scene;
  61323. private _engine;
  61324. private _renderEffects;
  61325. private _needStencil;
  61326. private _previousStencilState;
  61327. /**
  61328. * Creates a new instance of the component for the given scene
  61329. * @param scene Defines the scene to register the component in
  61330. */
  61331. constructor(scene: Scene);
  61332. /**
  61333. * Registers the component in a given scene
  61334. */
  61335. register(): void;
  61336. /**
  61337. * Rebuilds the elements related to this component in case of
  61338. * context lost for instance.
  61339. */
  61340. rebuild(): void;
  61341. /**
  61342. * Serializes the component data to the specified json object
  61343. * @param serializationObject The object to serialize to
  61344. */
  61345. serialize(serializationObject: any): void;
  61346. /**
  61347. * Adds all the elements from the container to the scene
  61348. * @param container the container holding the elements
  61349. */
  61350. addFromContainer(container: AbstractScene): void;
  61351. /**
  61352. * Removes all the elements in the container from the scene
  61353. * @param container contains the elements to remove
  61354. * @param dispose if the removed element should be disposed (default: false)
  61355. */
  61356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61357. /**
  61358. * Disposes the component and the associated ressources.
  61359. */
  61360. dispose(): void;
  61361. private _isReadyForMesh;
  61362. private _renderMainTexture;
  61363. private _setStencil;
  61364. private _setStencilBack;
  61365. private _draw;
  61366. private _drawCamera;
  61367. private _drawRenderingGroup;
  61368. }
  61369. }
  61370. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61371. /** @hidden */
  61372. export var glowMapMergePixelShader: {
  61373. name: string;
  61374. shader: string;
  61375. };
  61376. }
  61377. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61378. /** @hidden */
  61379. export var glowMapMergeVertexShader: {
  61380. name: string;
  61381. shader: string;
  61382. };
  61383. }
  61384. declare module "babylonjs/Layers/glowLayer" {
  61385. import { Nullable } from "babylonjs/types";
  61386. import { Camera } from "babylonjs/Cameras/camera";
  61387. import { Scene } from "babylonjs/scene";
  61388. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61390. import { Mesh } from "babylonjs/Meshes/mesh";
  61391. import { Texture } from "babylonjs/Materials/Textures/texture";
  61392. import { Effect } from "babylonjs/Materials/effect";
  61393. import { Material } from "babylonjs/Materials/material";
  61394. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61395. import { Color4 } from "babylonjs/Maths/math.color";
  61396. import "babylonjs/Shaders/glowMapMerge.fragment";
  61397. import "babylonjs/Shaders/glowMapMerge.vertex";
  61398. import "babylonjs/Layers/effectLayerSceneComponent";
  61399. module "babylonjs/abstractScene" {
  61400. interface AbstractScene {
  61401. /**
  61402. * Return a the first highlight layer of the scene with a given name.
  61403. * @param name The name of the highlight layer to look for.
  61404. * @return The highlight layer if found otherwise null.
  61405. */
  61406. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61407. }
  61408. }
  61409. /**
  61410. * Glow layer options. This helps customizing the behaviour
  61411. * of the glow layer.
  61412. */
  61413. export interface IGlowLayerOptions {
  61414. /**
  61415. * Multiplication factor apply to the canvas size to compute the render target size
  61416. * used to generated the glowing objects (the smaller the faster).
  61417. */
  61418. mainTextureRatio: number;
  61419. /**
  61420. * Enforces a fixed size texture to ensure resize independant blur.
  61421. */
  61422. mainTextureFixedSize?: number;
  61423. /**
  61424. * How big is the kernel of the blur texture.
  61425. */
  61426. blurKernelSize: number;
  61427. /**
  61428. * The camera attached to the layer.
  61429. */
  61430. camera: Nullable<Camera>;
  61431. /**
  61432. * Enable MSAA by chosing the number of samples.
  61433. */
  61434. mainTextureSamples?: number;
  61435. /**
  61436. * The rendering group to draw the layer in.
  61437. */
  61438. renderingGroupId: number;
  61439. }
  61440. /**
  61441. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61442. *
  61443. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61444. *
  61445. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61446. */
  61447. export class GlowLayer extends EffectLayer {
  61448. /**
  61449. * Effect Name of the layer.
  61450. */
  61451. static readonly EffectName: string;
  61452. /**
  61453. * The default blur kernel size used for the glow.
  61454. */
  61455. static DefaultBlurKernelSize: number;
  61456. /**
  61457. * The default texture size ratio used for the glow.
  61458. */
  61459. static DefaultTextureRatio: number;
  61460. /**
  61461. * Sets the kernel size of the blur.
  61462. */
  61463. set blurKernelSize(value: number);
  61464. /**
  61465. * Gets the kernel size of the blur.
  61466. */
  61467. get blurKernelSize(): number;
  61468. /**
  61469. * Sets the glow intensity.
  61470. */
  61471. set intensity(value: number);
  61472. /**
  61473. * Gets the glow intensity.
  61474. */
  61475. get intensity(): number;
  61476. private _options;
  61477. private _intensity;
  61478. private _horizontalBlurPostprocess1;
  61479. private _verticalBlurPostprocess1;
  61480. private _horizontalBlurPostprocess2;
  61481. private _verticalBlurPostprocess2;
  61482. private _blurTexture1;
  61483. private _blurTexture2;
  61484. private _postProcesses1;
  61485. private _postProcesses2;
  61486. private _includedOnlyMeshes;
  61487. private _excludedMeshes;
  61488. private _meshesUsingTheirOwnMaterials;
  61489. /**
  61490. * Callback used to let the user override the color selection on a per mesh basis
  61491. */
  61492. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61493. /**
  61494. * Callback used to let the user override the texture selection on a per mesh basis
  61495. */
  61496. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61497. /**
  61498. * Instantiates a new glow Layer and references it to the scene.
  61499. * @param name The name of the layer
  61500. * @param scene The scene to use the layer in
  61501. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61502. */
  61503. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61504. /**
  61505. * Get the effect name of the layer.
  61506. * @return The effect name
  61507. */
  61508. getEffectName(): string;
  61509. /**
  61510. * Create the merge effect. This is the shader use to blit the information back
  61511. * to the main canvas at the end of the scene rendering.
  61512. */
  61513. protected _createMergeEffect(): Effect;
  61514. /**
  61515. * Creates the render target textures and post processes used in the glow layer.
  61516. */
  61517. protected _createTextureAndPostProcesses(): void;
  61518. /**
  61519. * Checks for the readiness of the element composing the layer.
  61520. * @param subMesh the mesh to check for
  61521. * @param useInstances specify wether or not to use instances to render the mesh
  61522. * @param emissiveTexture the associated emissive texture used to generate the glow
  61523. * @return true if ready otherwise, false
  61524. */
  61525. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61526. /**
  61527. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61528. */
  61529. needStencil(): boolean;
  61530. /**
  61531. * Returns true if the mesh can be rendered, otherwise false.
  61532. * @param mesh The mesh to render
  61533. * @param material The material used on the mesh
  61534. * @returns true if it can be rendered otherwise false
  61535. */
  61536. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61537. /**
  61538. * Implementation specific of rendering the generating effect on the main canvas.
  61539. * @param effect The effect used to render through
  61540. */
  61541. protected _internalRender(effect: Effect): void;
  61542. /**
  61543. * Sets the required values for both the emissive texture and and the main color.
  61544. */
  61545. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61546. /**
  61547. * Returns true if the mesh should render, otherwise false.
  61548. * @param mesh The mesh to render
  61549. * @returns true if it should render otherwise false
  61550. */
  61551. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61552. /**
  61553. * Adds specific effects defines.
  61554. * @param defines The defines to add specifics to.
  61555. */
  61556. protected _addCustomEffectDefines(defines: string[]): void;
  61557. /**
  61558. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61559. * @param mesh The mesh to exclude from the glow layer
  61560. */
  61561. addExcludedMesh(mesh: Mesh): void;
  61562. /**
  61563. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61564. * @param mesh The mesh to remove
  61565. */
  61566. removeExcludedMesh(mesh: Mesh): void;
  61567. /**
  61568. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61569. * @param mesh The mesh to include in the glow layer
  61570. */
  61571. addIncludedOnlyMesh(mesh: Mesh): void;
  61572. /**
  61573. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61574. * @param mesh The mesh to remove
  61575. */
  61576. removeIncludedOnlyMesh(mesh: Mesh): void;
  61577. /**
  61578. * Determine if a given mesh will be used in the glow layer
  61579. * @param mesh The mesh to test
  61580. * @returns true if the mesh will be highlighted by the current glow layer
  61581. */
  61582. hasMesh(mesh: AbstractMesh): boolean;
  61583. /**
  61584. * Defines whether the current material of the mesh should be use to render the effect.
  61585. * @param mesh defines the current mesh to render
  61586. */
  61587. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61588. /**
  61589. * Add a mesh to be rendered through its own material and not with emissive only.
  61590. * @param mesh The mesh for which we need to use its material
  61591. */
  61592. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61593. /**
  61594. * Remove a mesh from being rendered through its own material and not with emissive only.
  61595. * @param mesh The mesh for which we need to not use its material
  61596. */
  61597. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61598. /**
  61599. * Free any resources and references associated to a mesh.
  61600. * Internal use
  61601. * @param mesh The mesh to free.
  61602. * @hidden
  61603. */
  61604. _disposeMesh(mesh: Mesh): void;
  61605. /**
  61606. * Gets the class name of the effect layer
  61607. * @returns the string with the class name of the effect layer
  61608. */
  61609. getClassName(): string;
  61610. /**
  61611. * Serializes this glow layer
  61612. * @returns a serialized glow layer object
  61613. */
  61614. serialize(): any;
  61615. /**
  61616. * Creates a Glow Layer from parsed glow layer data
  61617. * @param parsedGlowLayer defines glow layer data
  61618. * @param scene defines the current scene
  61619. * @param rootUrl defines the root URL containing the glow layer information
  61620. * @returns a parsed Glow Layer
  61621. */
  61622. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61623. }
  61624. }
  61625. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61626. /** @hidden */
  61627. export var glowBlurPostProcessPixelShader: {
  61628. name: string;
  61629. shader: string;
  61630. };
  61631. }
  61632. declare module "babylonjs/Layers/highlightLayer" {
  61633. import { Observable } from "babylonjs/Misc/observable";
  61634. import { Nullable } from "babylonjs/types";
  61635. import { Camera } from "babylonjs/Cameras/camera";
  61636. import { Scene } from "babylonjs/scene";
  61637. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61639. import { Mesh } from "babylonjs/Meshes/mesh";
  61640. import { Effect } from "babylonjs/Materials/effect";
  61641. import { Material } from "babylonjs/Materials/material";
  61642. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61643. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61644. import "babylonjs/Shaders/glowMapMerge.fragment";
  61645. import "babylonjs/Shaders/glowMapMerge.vertex";
  61646. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61647. module "babylonjs/abstractScene" {
  61648. interface AbstractScene {
  61649. /**
  61650. * Return a the first highlight layer of the scene with a given name.
  61651. * @param name The name of the highlight layer to look for.
  61652. * @return The highlight layer if found otherwise null.
  61653. */
  61654. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61655. }
  61656. }
  61657. /**
  61658. * Highlight layer options. This helps customizing the behaviour
  61659. * of the highlight layer.
  61660. */
  61661. export interface IHighlightLayerOptions {
  61662. /**
  61663. * Multiplication factor apply to the canvas size to compute the render target size
  61664. * used to generated the glowing objects (the smaller the faster).
  61665. */
  61666. mainTextureRatio: number;
  61667. /**
  61668. * Enforces a fixed size texture to ensure resize independant blur.
  61669. */
  61670. mainTextureFixedSize?: number;
  61671. /**
  61672. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61673. * of the picture to blur (the smaller the faster).
  61674. */
  61675. blurTextureSizeRatio: number;
  61676. /**
  61677. * How big in texel of the blur texture is the vertical blur.
  61678. */
  61679. blurVerticalSize: number;
  61680. /**
  61681. * How big in texel of the blur texture is the horizontal blur.
  61682. */
  61683. blurHorizontalSize: number;
  61684. /**
  61685. * Alpha blending mode used to apply the blur. Default is combine.
  61686. */
  61687. alphaBlendingMode: number;
  61688. /**
  61689. * The camera attached to the layer.
  61690. */
  61691. camera: Nullable<Camera>;
  61692. /**
  61693. * Should we display highlight as a solid stroke?
  61694. */
  61695. isStroke?: boolean;
  61696. /**
  61697. * The rendering group to draw the layer in.
  61698. */
  61699. renderingGroupId: number;
  61700. }
  61701. /**
  61702. * The highlight layer Helps adding a glow effect around a mesh.
  61703. *
  61704. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61705. * glowy meshes to your scene.
  61706. *
  61707. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61708. */
  61709. export class HighlightLayer extends EffectLayer {
  61710. name: string;
  61711. /**
  61712. * Effect Name of the highlight layer.
  61713. */
  61714. static readonly EffectName: string;
  61715. /**
  61716. * The neutral color used during the preparation of the glow effect.
  61717. * This is black by default as the blend operation is a blend operation.
  61718. */
  61719. static NeutralColor: Color4;
  61720. /**
  61721. * Stencil value used for glowing meshes.
  61722. */
  61723. static GlowingMeshStencilReference: number;
  61724. /**
  61725. * Stencil value used for the other meshes in the scene.
  61726. */
  61727. static NormalMeshStencilReference: number;
  61728. /**
  61729. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61730. */
  61731. innerGlow: boolean;
  61732. /**
  61733. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61734. */
  61735. outerGlow: boolean;
  61736. /**
  61737. * Specifies the horizontal size of the blur.
  61738. */
  61739. set blurHorizontalSize(value: number);
  61740. /**
  61741. * Specifies the vertical size of the blur.
  61742. */
  61743. set blurVerticalSize(value: number);
  61744. /**
  61745. * Gets the horizontal size of the blur.
  61746. */
  61747. get blurHorizontalSize(): number;
  61748. /**
  61749. * Gets the vertical size of the blur.
  61750. */
  61751. get blurVerticalSize(): number;
  61752. /**
  61753. * An event triggered when the highlight layer is being blurred.
  61754. */
  61755. onBeforeBlurObservable: Observable<HighlightLayer>;
  61756. /**
  61757. * An event triggered when the highlight layer has been blurred.
  61758. */
  61759. onAfterBlurObservable: Observable<HighlightLayer>;
  61760. private _instanceGlowingMeshStencilReference;
  61761. private _options;
  61762. private _downSamplePostprocess;
  61763. private _horizontalBlurPostprocess;
  61764. private _verticalBlurPostprocess;
  61765. private _blurTexture;
  61766. private _meshes;
  61767. private _excludedMeshes;
  61768. /**
  61769. * Instantiates a new highlight Layer and references it to the scene..
  61770. * @param name The name of the layer
  61771. * @param scene The scene to use the layer in
  61772. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61773. */
  61774. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61775. /**
  61776. * Get the effect name of the layer.
  61777. * @return The effect name
  61778. */
  61779. getEffectName(): string;
  61780. /**
  61781. * Create the merge effect. This is the shader use to blit the information back
  61782. * to the main canvas at the end of the scene rendering.
  61783. */
  61784. protected _createMergeEffect(): Effect;
  61785. /**
  61786. * Creates the render target textures and post processes used in the highlight layer.
  61787. */
  61788. protected _createTextureAndPostProcesses(): void;
  61789. /**
  61790. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61791. */
  61792. needStencil(): boolean;
  61793. /**
  61794. * Checks for the readiness of the element composing the layer.
  61795. * @param subMesh the mesh to check for
  61796. * @param useInstances specify wether or not to use instances to render the mesh
  61797. * @param emissiveTexture the associated emissive texture used to generate the glow
  61798. * @return true if ready otherwise, false
  61799. */
  61800. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61801. /**
  61802. * Implementation specific of rendering the generating effect on the main canvas.
  61803. * @param effect The effect used to render through
  61804. */
  61805. protected _internalRender(effect: Effect): void;
  61806. /**
  61807. * Returns true if the layer contains information to display, otherwise false.
  61808. */
  61809. shouldRender(): boolean;
  61810. /**
  61811. * Returns true if the mesh should render, otherwise false.
  61812. * @param mesh The mesh to render
  61813. * @returns true if it should render otherwise false
  61814. */
  61815. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61816. /**
  61817. * Returns true if the mesh can be rendered, otherwise false.
  61818. * @param mesh The mesh to render
  61819. * @param material The material used on the mesh
  61820. * @returns true if it can be rendered otherwise false
  61821. */
  61822. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61823. /**
  61824. * Adds specific effects defines.
  61825. * @param defines The defines to add specifics to.
  61826. */
  61827. protected _addCustomEffectDefines(defines: string[]): void;
  61828. /**
  61829. * Sets the required values for both the emissive texture and and the main color.
  61830. */
  61831. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61832. /**
  61833. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61834. * @param mesh The mesh to exclude from the highlight layer
  61835. */
  61836. addExcludedMesh(mesh: Mesh): void;
  61837. /**
  61838. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61839. * @param mesh The mesh to highlight
  61840. */
  61841. removeExcludedMesh(mesh: Mesh): void;
  61842. /**
  61843. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61844. * @param mesh mesh to test
  61845. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61846. */
  61847. hasMesh(mesh: AbstractMesh): boolean;
  61848. /**
  61849. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61850. * @param mesh The mesh to highlight
  61851. * @param color The color of the highlight
  61852. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61853. */
  61854. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61855. /**
  61856. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61857. * @param mesh The mesh to highlight
  61858. */
  61859. removeMesh(mesh: Mesh): void;
  61860. /**
  61861. * Remove all the meshes currently referenced in the highlight layer
  61862. */
  61863. removeAllMeshes(): void;
  61864. /**
  61865. * Force the stencil to the normal expected value for none glowing parts
  61866. */
  61867. private _defaultStencilReference;
  61868. /**
  61869. * Free any resources and references associated to a mesh.
  61870. * Internal use
  61871. * @param mesh The mesh to free.
  61872. * @hidden
  61873. */
  61874. _disposeMesh(mesh: Mesh): void;
  61875. /**
  61876. * Dispose the highlight layer and free resources.
  61877. */
  61878. dispose(): void;
  61879. /**
  61880. * Gets the class name of the effect layer
  61881. * @returns the string with the class name of the effect layer
  61882. */
  61883. getClassName(): string;
  61884. /**
  61885. * Serializes this Highlight layer
  61886. * @returns a serialized Highlight layer object
  61887. */
  61888. serialize(): any;
  61889. /**
  61890. * Creates a Highlight layer from parsed Highlight layer data
  61891. * @param parsedHightlightLayer defines the Highlight layer data
  61892. * @param scene defines the current scene
  61893. * @param rootUrl defines the root URL containing the Highlight layer information
  61894. * @returns a parsed Highlight layer
  61895. */
  61896. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61897. }
  61898. }
  61899. declare module "babylonjs/Layers/layerSceneComponent" {
  61900. import { Scene } from "babylonjs/scene";
  61901. import { ISceneComponent } from "babylonjs/sceneComponent";
  61902. import { Layer } from "babylonjs/Layers/layer";
  61903. import { AbstractScene } from "babylonjs/abstractScene";
  61904. module "babylonjs/abstractScene" {
  61905. interface AbstractScene {
  61906. /**
  61907. * The list of layers (background and foreground) of the scene
  61908. */
  61909. layers: Array<Layer>;
  61910. }
  61911. }
  61912. /**
  61913. * Defines the layer scene component responsible to manage any layers
  61914. * in a given scene.
  61915. */
  61916. export class LayerSceneComponent implements ISceneComponent {
  61917. /**
  61918. * The component name helpfull to identify the component in the list of scene components.
  61919. */
  61920. readonly name: string;
  61921. /**
  61922. * The scene the component belongs to.
  61923. */
  61924. scene: Scene;
  61925. private _engine;
  61926. /**
  61927. * Creates a new instance of the component for the given scene
  61928. * @param scene Defines the scene to register the component in
  61929. */
  61930. constructor(scene: Scene);
  61931. /**
  61932. * Registers the component in a given scene
  61933. */
  61934. register(): void;
  61935. /**
  61936. * Rebuilds the elements related to this component in case of
  61937. * context lost for instance.
  61938. */
  61939. rebuild(): void;
  61940. /**
  61941. * Disposes the component and the associated ressources.
  61942. */
  61943. dispose(): void;
  61944. private _draw;
  61945. private _drawCameraPredicate;
  61946. private _drawCameraBackground;
  61947. private _drawCameraForeground;
  61948. private _drawRenderTargetPredicate;
  61949. private _drawRenderTargetBackground;
  61950. private _drawRenderTargetForeground;
  61951. /**
  61952. * Adds all the elements from the container to the scene
  61953. * @param container the container holding the elements
  61954. */
  61955. addFromContainer(container: AbstractScene): void;
  61956. /**
  61957. * Removes all the elements in the container from the scene
  61958. * @param container contains the elements to remove
  61959. * @param dispose if the removed element should be disposed (default: false)
  61960. */
  61961. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61962. }
  61963. }
  61964. declare module "babylonjs/Shaders/layer.fragment" {
  61965. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61966. /** @hidden */
  61967. export var layerPixelShader: {
  61968. name: string;
  61969. shader: string;
  61970. };
  61971. }
  61972. declare module "babylonjs/Shaders/layer.vertex" {
  61973. /** @hidden */
  61974. export var layerVertexShader: {
  61975. name: string;
  61976. shader: string;
  61977. };
  61978. }
  61979. declare module "babylonjs/Layers/layer" {
  61980. import { Observable } from "babylonjs/Misc/observable";
  61981. import { Nullable } from "babylonjs/types";
  61982. import { Scene } from "babylonjs/scene";
  61983. import { Vector2 } from "babylonjs/Maths/math.vector";
  61984. import { Color4 } from "babylonjs/Maths/math.color";
  61985. import { Texture } from "babylonjs/Materials/Textures/texture";
  61986. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61987. import "babylonjs/Shaders/layer.fragment";
  61988. import "babylonjs/Shaders/layer.vertex";
  61989. /**
  61990. * This represents a full screen 2d layer.
  61991. * This can be useful to display a picture in the background of your scene for instance.
  61992. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61993. */
  61994. export class Layer {
  61995. /**
  61996. * Define the name of the layer.
  61997. */
  61998. name: string;
  61999. /**
  62000. * Define the texture the layer should display.
  62001. */
  62002. texture: Nullable<Texture>;
  62003. /**
  62004. * Is the layer in background or foreground.
  62005. */
  62006. isBackground: boolean;
  62007. /**
  62008. * Define the color of the layer (instead of texture).
  62009. */
  62010. color: Color4;
  62011. /**
  62012. * Define the scale of the layer in order to zoom in out of the texture.
  62013. */
  62014. scale: Vector2;
  62015. /**
  62016. * Define an offset for the layer in order to shift the texture.
  62017. */
  62018. offset: Vector2;
  62019. /**
  62020. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62021. */
  62022. alphaBlendingMode: number;
  62023. /**
  62024. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62025. * Alpha test will not mix with the background color in case of transparency.
  62026. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62027. */
  62028. alphaTest: boolean;
  62029. /**
  62030. * Define a mask to restrict the layer to only some of the scene cameras.
  62031. */
  62032. layerMask: number;
  62033. /**
  62034. * Define the list of render target the layer is visible into.
  62035. */
  62036. renderTargetTextures: RenderTargetTexture[];
  62037. /**
  62038. * Define if the layer is only used in renderTarget or if it also
  62039. * renders in the main frame buffer of the canvas.
  62040. */
  62041. renderOnlyInRenderTargetTextures: boolean;
  62042. private _scene;
  62043. private _vertexBuffers;
  62044. private _indexBuffer;
  62045. private _effect;
  62046. private _previousDefines;
  62047. /**
  62048. * An event triggered when the layer is disposed.
  62049. */
  62050. onDisposeObservable: Observable<Layer>;
  62051. private _onDisposeObserver;
  62052. /**
  62053. * Back compatibility with callback before the onDisposeObservable existed.
  62054. * The set callback will be triggered when the layer has been disposed.
  62055. */
  62056. set onDispose(callback: () => void);
  62057. /**
  62058. * An event triggered before rendering the scene
  62059. */
  62060. onBeforeRenderObservable: Observable<Layer>;
  62061. private _onBeforeRenderObserver;
  62062. /**
  62063. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62064. * The set callback will be triggered just before rendering the layer.
  62065. */
  62066. set onBeforeRender(callback: () => void);
  62067. /**
  62068. * An event triggered after rendering the scene
  62069. */
  62070. onAfterRenderObservable: Observable<Layer>;
  62071. private _onAfterRenderObserver;
  62072. /**
  62073. * Back compatibility with callback before the onAfterRenderObservable existed.
  62074. * The set callback will be triggered just after rendering the layer.
  62075. */
  62076. set onAfterRender(callback: () => void);
  62077. /**
  62078. * Instantiates a new layer.
  62079. * This represents a full screen 2d layer.
  62080. * This can be useful to display a picture in the background of your scene for instance.
  62081. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62082. * @param name Define the name of the layer in the scene
  62083. * @param imgUrl Define the url of the texture to display in the layer
  62084. * @param scene Define the scene the layer belongs to
  62085. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62086. * @param color Defines a color for the layer
  62087. */
  62088. constructor(
  62089. /**
  62090. * Define the name of the layer.
  62091. */
  62092. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62093. private _createIndexBuffer;
  62094. /** @hidden */
  62095. _rebuild(): void;
  62096. /**
  62097. * Renders the layer in the scene.
  62098. */
  62099. render(): void;
  62100. /**
  62101. * Disposes and releases the associated ressources.
  62102. */
  62103. dispose(): void;
  62104. }
  62105. }
  62106. declare module "babylonjs/Layers/index" {
  62107. export * from "babylonjs/Layers/effectLayer";
  62108. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62109. export * from "babylonjs/Layers/glowLayer";
  62110. export * from "babylonjs/Layers/highlightLayer";
  62111. export * from "babylonjs/Layers/layer";
  62112. export * from "babylonjs/Layers/layerSceneComponent";
  62113. }
  62114. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62115. /** @hidden */
  62116. export var lensFlarePixelShader: {
  62117. name: string;
  62118. shader: string;
  62119. };
  62120. }
  62121. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62122. /** @hidden */
  62123. export var lensFlareVertexShader: {
  62124. name: string;
  62125. shader: string;
  62126. };
  62127. }
  62128. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62129. import { Scene } from "babylonjs/scene";
  62130. import { Vector3 } from "babylonjs/Maths/math.vector";
  62131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62132. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62133. import "babylonjs/Shaders/lensFlare.fragment";
  62134. import "babylonjs/Shaders/lensFlare.vertex";
  62135. import { Viewport } from "babylonjs/Maths/math.viewport";
  62136. /**
  62137. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62138. * It is usually composed of several `lensFlare`.
  62139. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62140. */
  62141. export class LensFlareSystem {
  62142. /**
  62143. * Define the name of the lens flare system
  62144. */
  62145. name: string;
  62146. /**
  62147. * List of lens flares used in this system.
  62148. */
  62149. lensFlares: LensFlare[];
  62150. /**
  62151. * Define a limit from the border the lens flare can be visible.
  62152. */
  62153. borderLimit: number;
  62154. /**
  62155. * Define a viewport border we do not want to see the lens flare in.
  62156. */
  62157. viewportBorder: number;
  62158. /**
  62159. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62160. */
  62161. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62162. /**
  62163. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62164. */
  62165. layerMask: number;
  62166. /**
  62167. * Define the id of the lens flare system in the scene.
  62168. * (equal to name by default)
  62169. */
  62170. id: string;
  62171. private _scene;
  62172. private _emitter;
  62173. private _vertexBuffers;
  62174. private _indexBuffer;
  62175. private _effect;
  62176. private _positionX;
  62177. private _positionY;
  62178. private _isEnabled;
  62179. /** @hidden */
  62180. static _SceneComponentInitialization: (scene: Scene) => void;
  62181. /**
  62182. * Instantiates a lens flare system.
  62183. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62184. * It is usually composed of several `lensFlare`.
  62185. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62186. * @param name Define the name of the lens flare system in the scene
  62187. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62188. * @param scene Define the scene the lens flare system belongs to
  62189. */
  62190. constructor(
  62191. /**
  62192. * Define the name of the lens flare system
  62193. */
  62194. name: string, emitter: any, scene: Scene);
  62195. /**
  62196. * Define if the lens flare system is enabled.
  62197. */
  62198. get isEnabled(): boolean;
  62199. set isEnabled(value: boolean);
  62200. /**
  62201. * Get the scene the effects belongs to.
  62202. * @returns the scene holding the lens flare system
  62203. */
  62204. getScene(): Scene;
  62205. /**
  62206. * Get the emitter of the lens flare system.
  62207. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62208. * @returns the emitter of the lens flare system
  62209. */
  62210. getEmitter(): any;
  62211. /**
  62212. * Set the emitter of the lens flare system.
  62213. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62214. * @param newEmitter Define the new emitter of the system
  62215. */
  62216. setEmitter(newEmitter: any): void;
  62217. /**
  62218. * Get the lens flare system emitter position.
  62219. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62220. * @returns the position
  62221. */
  62222. getEmitterPosition(): Vector3;
  62223. /**
  62224. * @hidden
  62225. */
  62226. computeEffectivePosition(globalViewport: Viewport): boolean;
  62227. /** @hidden */
  62228. _isVisible(): boolean;
  62229. /**
  62230. * @hidden
  62231. */
  62232. render(): boolean;
  62233. /**
  62234. * Dispose and release the lens flare with its associated resources.
  62235. */
  62236. dispose(): void;
  62237. /**
  62238. * Parse a lens flare system from a JSON repressentation
  62239. * @param parsedLensFlareSystem Define the JSON to parse
  62240. * @param scene Define the scene the parsed system should be instantiated in
  62241. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62242. * @returns the parsed system
  62243. */
  62244. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62245. /**
  62246. * Serialize the current Lens Flare System into a JSON representation.
  62247. * @returns the serialized JSON
  62248. */
  62249. serialize(): any;
  62250. }
  62251. }
  62252. declare module "babylonjs/LensFlares/lensFlare" {
  62253. import { Nullable } from "babylonjs/types";
  62254. import { Color3 } from "babylonjs/Maths/math.color";
  62255. import { Texture } from "babylonjs/Materials/Textures/texture";
  62256. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62257. /**
  62258. * This represents one of the lens effect in a `lensFlareSystem`.
  62259. * It controls one of the indiviual texture used in the effect.
  62260. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62261. */
  62262. export class LensFlare {
  62263. /**
  62264. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62265. */
  62266. size: number;
  62267. /**
  62268. * 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.
  62269. */
  62270. position: number;
  62271. /**
  62272. * Define the lens color.
  62273. */
  62274. color: Color3;
  62275. /**
  62276. * Define the lens texture.
  62277. */
  62278. texture: Nullable<Texture>;
  62279. /**
  62280. * Define the alpha mode to render this particular lens.
  62281. */
  62282. alphaMode: number;
  62283. private _system;
  62284. /**
  62285. * Creates a new Lens Flare.
  62286. * This represents one of the lens effect in a `lensFlareSystem`.
  62287. * It controls one of the indiviual texture used in the effect.
  62288. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62289. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62290. * @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.
  62291. * @param color Define the lens color
  62292. * @param imgUrl Define the lens texture url
  62293. * @param system Define the `lensFlareSystem` this flare is part of
  62294. * @returns The newly created Lens Flare
  62295. */
  62296. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62297. /**
  62298. * Instantiates a new Lens Flare.
  62299. * This represents one of the lens effect in a `lensFlareSystem`.
  62300. * It controls one of the indiviual texture used in the effect.
  62301. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62302. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62303. * @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.
  62304. * @param color Define the lens color
  62305. * @param imgUrl Define the lens texture url
  62306. * @param system Define the `lensFlareSystem` this flare is part of
  62307. */
  62308. constructor(
  62309. /**
  62310. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62311. */
  62312. size: number,
  62313. /**
  62314. * 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.
  62315. */
  62316. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62317. /**
  62318. * Dispose and release the lens flare with its associated resources.
  62319. */
  62320. dispose(): void;
  62321. }
  62322. }
  62323. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62324. import { Nullable } from "babylonjs/types";
  62325. import { Scene } from "babylonjs/scene";
  62326. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62327. import { AbstractScene } from "babylonjs/abstractScene";
  62328. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62329. module "babylonjs/abstractScene" {
  62330. interface AbstractScene {
  62331. /**
  62332. * The list of lens flare system added to the scene
  62333. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62334. */
  62335. lensFlareSystems: Array<LensFlareSystem>;
  62336. /**
  62337. * Removes the given lens flare system from this scene.
  62338. * @param toRemove The lens flare system to remove
  62339. * @returns The index of the removed lens flare system
  62340. */
  62341. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62342. /**
  62343. * Adds the given lens flare system to this scene
  62344. * @param newLensFlareSystem The lens flare system to add
  62345. */
  62346. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62347. /**
  62348. * Gets a lens flare system using its name
  62349. * @param name defines the name to look for
  62350. * @returns the lens flare system or null if not found
  62351. */
  62352. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62353. /**
  62354. * Gets a lens flare system using its id
  62355. * @param id defines the id to look for
  62356. * @returns the lens flare system or null if not found
  62357. */
  62358. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62359. }
  62360. }
  62361. /**
  62362. * Defines the lens flare scene component responsible to manage any lens flares
  62363. * in a given scene.
  62364. */
  62365. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62366. /**
  62367. * The component name helpfull to identify the component in the list of scene components.
  62368. */
  62369. readonly name: string;
  62370. /**
  62371. * The scene the component belongs to.
  62372. */
  62373. scene: Scene;
  62374. /**
  62375. * Creates a new instance of the component for the given scene
  62376. * @param scene Defines the scene to register the component in
  62377. */
  62378. constructor(scene: Scene);
  62379. /**
  62380. * Registers the component in a given scene
  62381. */
  62382. register(): void;
  62383. /**
  62384. * Rebuilds the elements related to this component in case of
  62385. * context lost for instance.
  62386. */
  62387. rebuild(): void;
  62388. /**
  62389. * Adds all the elements from the container to the scene
  62390. * @param container the container holding the elements
  62391. */
  62392. addFromContainer(container: AbstractScene): void;
  62393. /**
  62394. * Removes all the elements in the container from the scene
  62395. * @param container contains the elements to remove
  62396. * @param dispose if the removed element should be disposed (default: false)
  62397. */
  62398. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62399. /**
  62400. * Serializes the component data to the specified json object
  62401. * @param serializationObject The object to serialize to
  62402. */
  62403. serialize(serializationObject: any): void;
  62404. /**
  62405. * Disposes the component and the associated ressources.
  62406. */
  62407. dispose(): void;
  62408. private _draw;
  62409. }
  62410. }
  62411. declare module "babylonjs/LensFlares/index" {
  62412. export * from "babylonjs/LensFlares/lensFlare";
  62413. export * from "babylonjs/LensFlares/lensFlareSystem";
  62414. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62415. }
  62416. declare module "babylonjs/Shaders/depth.fragment" {
  62417. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62418. /** @hidden */
  62419. export var depthPixelShader: {
  62420. name: string;
  62421. shader: string;
  62422. };
  62423. }
  62424. declare module "babylonjs/Shaders/depth.vertex" {
  62425. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62427. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62428. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62429. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62430. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62431. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62432. /** @hidden */
  62433. export var depthVertexShader: {
  62434. name: string;
  62435. shader: string;
  62436. };
  62437. }
  62438. declare module "babylonjs/Rendering/depthRenderer" {
  62439. import { Nullable } from "babylonjs/types";
  62440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62441. import { Scene } from "babylonjs/scene";
  62442. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62443. import { Camera } from "babylonjs/Cameras/camera";
  62444. import "babylonjs/Shaders/depth.fragment";
  62445. import "babylonjs/Shaders/depth.vertex";
  62446. /**
  62447. * This represents a depth renderer in Babylon.
  62448. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62449. */
  62450. export class DepthRenderer {
  62451. private _scene;
  62452. private _depthMap;
  62453. private _effect;
  62454. private readonly _storeNonLinearDepth;
  62455. private readonly _clearColor;
  62456. /** Get if the depth renderer is using packed depth or not */
  62457. readonly isPacked: boolean;
  62458. private _cachedDefines;
  62459. private _camera;
  62460. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62461. enabled: boolean;
  62462. /**
  62463. * Specifiess that the depth renderer will only be used within
  62464. * the camera it is created for.
  62465. * This can help forcing its rendering during the camera processing.
  62466. */
  62467. useOnlyInActiveCamera: boolean;
  62468. /** @hidden */
  62469. static _SceneComponentInitialization: (scene: Scene) => void;
  62470. /**
  62471. * Instantiates a depth renderer
  62472. * @param scene The scene the renderer belongs to
  62473. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62474. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62475. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62476. */
  62477. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62478. /**
  62479. * Creates the depth rendering effect and checks if the effect is ready.
  62480. * @param subMesh The submesh to be used to render the depth map of
  62481. * @param useInstances If multiple world instances should be used
  62482. * @returns if the depth renderer is ready to render the depth map
  62483. */
  62484. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62485. /**
  62486. * Gets the texture which the depth map will be written to.
  62487. * @returns The depth map texture
  62488. */
  62489. getDepthMap(): RenderTargetTexture;
  62490. /**
  62491. * Disposes of the depth renderer.
  62492. */
  62493. dispose(): void;
  62494. }
  62495. }
  62496. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62497. /** @hidden */
  62498. export var minmaxReduxPixelShader: {
  62499. name: string;
  62500. shader: string;
  62501. };
  62502. }
  62503. declare module "babylonjs/Misc/minMaxReducer" {
  62504. import { Nullable } from "babylonjs/types";
  62505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62506. import { Camera } from "babylonjs/Cameras/camera";
  62507. import { Observer } from "babylonjs/Misc/observable";
  62508. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62509. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62510. import { Observable } from "babylonjs/Misc/observable";
  62511. import "babylonjs/Shaders/minmaxRedux.fragment";
  62512. /**
  62513. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62514. * and maximum values from all values of the texture.
  62515. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62516. * The source values are read from the red channel of the texture.
  62517. */
  62518. export class MinMaxReducer {
  62519. /**
  62520. * Observable triggered when the computation has been performed
  62521. */
  62522. onAfterReductionPerformed: Observable<{
  62523. min: number;
  62524. max: number;
  62525. }>;
  62526. protected _camera: Camera;
  62527. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62528. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62529. protected _postProcessManager: PostProcessManager;
  62530. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62531. protected _forceFullscreenViewport: boolean;
  62532. /**
  62533. * Creates a min/max reducer
  62534. * @param camera The camera to use for the post processes
  62535. */
  62536. constructor(camera: Camera);
  62537. /**
  62538. * Gets the texture used to read the values from.
  62539. */
  62540. get sourceTexture(): Nullable<RenderTargetTexture>;
  62541. /**
  62542. * Sets the source texture to read the values from.
  62543. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62544. * because in such textures '1' value must not be taken into account to compute the maximum
  62545. * as this value is used to clear the texture.
  62546. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62547. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62548. * @param depthRedux Indicates if the texture is a depth texture or not
  62549. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62550. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62551. */
  62552. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62553. /**
  62554. * Defines the refresh rate of the computation.
  62555. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62556. */
  62557. get refreshRate(): number;
  62558. set refreshRate(value: number);
  62559. protected _activated: boolean;
  62560. /**
  62561. * Gets the activation status of the reducer
  62562. */
  62563. get activated(): boolean;
  62564. /**
  62565. * Activates the reduction computation.
  62566. * When activated, the observers registered in onAfterReductionPerformed are
  62567. * called after the compuation is performed
  62568. */
  62569. activate(): void;
  62570. /**
  62571. * Deactivates the reduction computation.
  62572. */
  62573. deactivate(): void;
  62574. /**
  62575. * Disposes the min/max reducer
  62576. * @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.
  62577. */
  62578. dispose(disposeAll?: boolean): void;
  62579. }
  62580. }
  62581. declare module "babylonjs/Misc/depthReducer" {
  62582. import { Nullable } from "babylonjs/types";
  62583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62584. import { Camera } from "babylonjs/Cameras/camera";
  62585. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62586. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62587. /**
  62588. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62589. */
  62590. export class DepthReducer extends MinMaxReducer {
  62591. private _depthRenderer;
  62592. private _depthRendererId;
  62593. /**
  62594. * Gets the depth renderer used for the computation.
  62595. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62596. */
  62597. get depthRenderer(): Nullable<DepthRenderer>;
  62598. /**
  62599. * Creates a depth reducer
  62600. * @param camera The camera used to render the depth texture
  62601. */
  62602. constructor(camera: Camera);
  62603. /**
  62604. * Sets the depth renderer to use to generate the depth map
  62605. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62606. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62607. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62608. */
  62609. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62610. /** @hidden */
  62611. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62612. /**
  62613. * Activates the reduction computation.
  62614. * When activated, the observers registered in onAfterReductionPerformed are
  62615. * called after the compuation is performed
  62616. */
  62617. activate(): void;
  62618. /**
  62619. * Deactivates the reduction computation.
  62620. */
  62621. deactivate(): void;
  62622. /**
  62623. * Disposes the depth reducer
  62624. * @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.
  62625. */
  62626. dispose(disposeAll?: boolean): void;
  62627. }
  62628. }
  62629. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62630. import { Nullable } from "babylonjs/types";
  62631. import { Scene } from "babylonjs/scene";
  62632. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62633. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62635. import { Effect } from "babylonjs/Materials/effect";
  62636. import "babylonjs/Shaders/shadowMap.fragment";
  62637. import "babylonjs/Shaders/shadowMap.vertex";
  62638. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62639. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62640. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62641. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62642. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62643. /**
  62644. * A CSM implementation allowing casting shadows on large scenes.
  62645. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62646. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62647. */
  62648. export class CascadedShadowGenerator extends ShadowGenerator {
  62649. private static readonly frustumCornersNDCSpace;
  62650. /**
  62651. * Name of the CSM class
  62652. */
  62653. static CLASSNAME: string;
  62654. /**
  62655. * Defines the default number of cascades used by the CSM.
  62656. */
  62657. static readonly DEFAULT_CASCADES_COUNT: number;
  62658. /**
  62659. * Defines the minimum number of cascades used by the CSM.
  62660. */
  62661. static readonly MIN_CASCADES_COUNT: number;
  62662. /**
  62663. * Defines the maximum number of cascades used by the CSM.
  62664. */
  62665. static readonly MAX_CASCADES_COUNT: number;
  62666. protected _validateFilter(filter: number): number;
  62667. /**
  62668. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62669. */
  62670. penumbraDarkness: number;
  62671. private _numCascades;
  62672. /**
  62673. * Gets or set the number of cascades used by the CSM.
  62674. */
  62675. get numCascades(): number;
  62676. set numCascades(value: number);
  62677. /**
  62678. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62679. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62680. */
  62681. stabilizeCascades: boolean;
  62682. private _freezeShadowCastersBoundingInfo;
  62683. private _freezeShadowCastersBoundingInfoObservable;
  62684. /**
  62685. * Enables or disables the shadow casters bounding info computation.
  62686. * If your shadow casters don't move, you can disable this feature.
  62687. * If it is enabled, the bounding box computation is done every frame.
  62688. */
  62689. get freezeShadowCastersBoundingInfo(): boolean;
  62690. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62691. private _scbiMin;
  62692. private _scbiMax;
  62693. protected _computeShadowCastersBoundingInfo(): void;
  62694. protected _shadowCastersBoundingInfo: BoundingInfo;
  62695. /**
  62696. * Gets or sets the shadow casters bounding info.
  62697. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62698. * so that the system won't overwrite the bounds you provide
  62699. */
  62700. get shadowCastersBoundingInfo(): BoundingInfo;
  62701. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62702. protected _breaksAreDirty: boolean;
  62703. protected _minDistance: number;
  62704. protected _maxDistance: number;
  62705. /**
  62706. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62707. *
  62708. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62709. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62710. * @param min minimal distance for the breaks (default to 0.)
  62711. * @param max maximal distance for the breaks (default to 1.)
  62712. */
  62713. setMinMaxDistance(min: number, max: number): void;
  62714. /** Gets the minimal distance used in the cascade break computation */
  62715. get minDistance(): number;
  62716. /** Gets the maximal distance used in the cascade break computation */
  62717. get maxDistance(): number;
  62718. /**
  62719. * Gets the class name of that object
  62720. * @returns "CascadedShadowGenerator"
  62721. */
  62722. getClassName(): string;
  62723. private _cascadeMinExtents;
  62724. private _cascadeMaxExtents;
  62725. /**
  62726. * Gets a cascade minimum extents
  62727. * @param cascadeIndex index of the cascade
  62728. * @returns the minimum cascade extents
  62729. */
  62730. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62731. /**
  62732. * Gets a cascade maximum extents
  62733. * @param cascadeIndex index of the cascade
  62734. * @returns the maximum cascade extents
  62735. */
  62736. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62737. private _cascades;
  62738. private _currentLayer;
  62739. private _viewSpaceFrustumsZ;
  62740. private _viewMatrices;
  62741. private _projectionMatrices;
  62742. private _transformMatrices;
  62743. private _transformMatricesAsArray;
  62744. private _frustumLengths;
  62745. private _lightSizeUVCorrection;
  62746. private _depthCorrection;
  62747. private _frustumCornersWorldSpace;
  62748. private _frustumCenter;
  62749. private _shadowCameraPos;
  62750. private _shadowMaxZ;
  62751. /**
  62752. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62753. * It defaults to camera.maxZ
  62754. */
  62755. get shadowMaxZ(): number;
  62756. /**
  62757. * Sets the shadow max z distance.
  62758. */
  62759. set shadowMaxZ(value: number);
  62760. protected _debug: boolean;
  62761. /**
  62762. * Gets or sets the debug flag.
  62763. * When enabled, the cascades are materialized by different colors on the screen.
  62764. */
  62765. get debug(): boolean;
  62766. set debug(dbg: boolean);
  62767. private _depthClamp;
  62768. /**
  62769. * Gets or sets the depth clamping value.
  62770. *
  62771. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62772. * to account for the shadow casters far away.
  62773. *
  62774. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62775. */
  62776. get depthClamp(): boolean;
  62777. set depthClamp(value: boolean);
  62778. private _cascadeBlendPercentage;
  62779. /**
  62780. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62781. * It defaults to 0.1 (10% blending).
  62782. */
  62783. get cascadeBlendPercentage(): number;
  62784. set cascadeBlendPercentage(value: number);
  62785. private _lambda;
  62786. /**
  62787. * Gets or set the lambda parameter.
  62788. * This parameter is used to split the camera frustum and create the cascades.
  62789. * 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.
  62790. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62791. */
  62792. get lambda(): number;
  62793. set lambda(value: number);
  62794. /**
  62795. * Gets the view matrix corresponding to a given cascade
  62796. * @param cascadeNum cascade to retrieve the view matrix from
  62797. * @returns the cascade view matrix
  62798. */
  62799. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62800. /**
  62801. * Gets the projection matrix corresponding to a given cascade
  62802. * @param cascadeNum cascade to retrieve the projection matrix from
  62803. * @returns the cascade projection matrix
  62804. */
  62805. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62806. /**
  62807. * Gets the transformation matrix corresponding to a given cascade
  62808. * @param cascadeNum cascade to retrieve the transformation matrix from
  62809. * @returns the cascade transformation matrix
  62810. */
  62811. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62812. private _depthRenderer;
  62813. /**
  62814. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62815. *
  62816. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62817. *
  62818. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62819. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62820. * @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
  62821. */
  62822. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62823. private _depthReducer;
  62824. private _autoCalcDepthBounds;
  62825. /**
  62826. * Gets or sets the autoCalcDepthBounds property.
  62827. *
  62828. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62829. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62830. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62831. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62832. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62833. */
  62834. get autoCalcDepthBounds(): boolean;
  62835. set autoCalcDepthBounds(value: boolean);
  62836. /**
  62837. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62838. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62839. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62840. * for setting the refresh rate on the renderer yourself!
  62841. */
  62842. get autoCalcDepthBoundsRefreshRate(): number;
  62843. set autoCalcDepthBoundsRefreshRate(value: number);
  62844. /**
  62845. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62846. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62847. * you change the camera near/far planes!
  62848. */
  62849. splitFrustum(): void;
  62850. private _splitFrustum;
  62851. private _computeMatrices;
  62852. private _computeFrustumInWorldSpace;
  62853. private _computeCascadeFrustum;
  62854. /**
  62855. * Support test.
  62856. */
  62857. static get IsSupported(): boolean;
  62858. /** @hidden */
  62859. static _SceneComponentInitialization: (scene: Scene) => void;
  62860. /**
  62861. * Creates a Cascaded Shadow Generator object.
  62862. * A ShadowGenerator is the required tool to use the shadows.
  62863. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62864. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62865. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62866. * @param light The directional light object generating the shadows.
  62867. * @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.
  62868. */
  62869. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62870. protected _initializeGenerator(): void;
  62871. protected _createTargetRenderTexture(): void;
  62872. protected _initializeShadowMap(): void;
  62873. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62874. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62875. /**
  62876. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62877. * @param defines Defines of the material we want to update
  62878. * @param lightIndex Index of the light in the enabled light list of the material
  62879. */
  62880. prepareDefines(defines: any, lightIndex: number): void;
  62881. /**
  62882. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62883. * defined in the generator but impacting the effect).
  62884. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62885. * @param effect The effect we are binfing the information for
  62886. */
  62887. bindShadowLight(lightIndex: string, effect: Effect): void;
  62888. /**
  62889. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62890. * (eq to view projection * shadow projection matrices)
  62891. * @returns The transform matrix used to create the shadow map
  62892. */
  62893. getTransformMatrix(): Matrix;
  62894. /**
  62895. * Disposes the ShadowGenerator.
  62896. * Returns nothing.
  62897. */
  62898. dispose(): void;
  62899. /**
  62900. * Serializes the shadow generator setup to a json object.
  62901. * @returns The serialized JSON object
  62902. */
  62903. serialize(): any;
  62904. /**
  62905. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62906. * @param parsedShadowGenerator The JSON object to parse
  62907. * @param scene The scene to create the shadow map for
  62908. * @returns The parsed shadow generator
  62909. */
  62910. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62911. }
  62912. }
  62913. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62914. import { Scene } from "babylonjs/scene";
  62915. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62916. import { AbstractScene } from "babylonjs/abstractScene";
  62917. /**
  62918. * Defines the shadow generator component responsible to manage any shadow generators
  62919. * in a given scene.
  62920. */
  62921. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62922. /**
  62923. * The component name helpfull to identify the component in the list of scene components.
  62924. */
  62925. readonly name: string;
  62926. /**
  62927. * The scene the component belongs to.
  62928. */
  62929. scene: Scene;
  62930. /**
  62931. * Creates a new instance of the component for the given scene
  62932. * @param scene Defines the scene to register the component in
  62933. */
  62934. constructor(scene: Scene);
  62935. /**
  62936. * Registers the component in a given scene
  62937. */
  62938. register(): void;
  62939. /**
  62940. * Rebuilds the elements related to this component in case of
  62941. * context lost for instance.
  62942. */
  62943. rebuild(): void;
  62944. /**
  62945. * Serializes the component data to the specified json object
  62946. * @param serializationObject The object to serialize to
  62947. */
  62948. serialize(serializationObject: any): void;
  62949. /**
  62950. * Adds all the elements from the container to the scene
  62951. * @param container the container holding the elements
  62952. */
  62953. addFromContainer(container: AbstractScene): void;
  62954. /**
  62955. * Removes all the elements in the container from the scene
  62956. * @param container contains the elements to remove
  62957. * @param dispose if the removed element should be disposed (default: false)
  62958. */
  62959. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62960. /**
  62961. * Rebuilds the elements related to this component in case of
  62962. * context lost for instance.
  62963. */
  62964. dispose(): void;
  62965. private _gatherRenderTargets;
  62966. }
  62967. }
  62968. declare module "babylonjs/Lights/Shadows/index" {
  62969. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62970. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62971. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62972. }
  62973. declare module "babylonjs/Lights/pointLight" {
  62974. import { Scene } from "babylonjs/scene";
  62975. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62977. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62978. import { Effect } from "babylonjs/Materials/effect";
  62979. /**
  62980. * A point light is a light defined by an unique point in world space.
  62981. * The light is emitted in every direction from this point.
  62982. * A good example of a point light is a standard light bulb.
  62983. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62984. */
  62985. export class PointLight extends ShadowLight {
  62986. private _shadowAngle;
  62987. /**
  62988. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62989. * This specifies what angle the shadow will use to be created.
  62990. *
  62991. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62992. */
  62993. get shadowAngle(): number;
  62994. /**
  62995. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62996. * This specifies what angle the shadow will use to be created.
  62997. *
  62998. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62999. */
  63000. set shadowAngle(value: number);
  63001. /**
  63002. * Gets the direction if it has been set.
  63003. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63004. */
  63005. get direction(): Vector3;
  63006. /**
  63007. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63008. */
  63009. set direction(value: Vector3);
  63010. /**
  63011. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63012. * A PointLight emits the light in every direction.
  63013. * It can cast shadows.
  63014. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63015. * ```javascript
  63016. * var pointLight = new PointLight("pl", camera.position, scene);
  63017. * ```
  63018. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63019. * @param name The light friendly name
  63020. * @param position The position of the point light in the scene
  63021. * @param scene The scene the lights belongs to
  63022. */
  63023. constructor(name: string, position: Vector3, scene: Scene);
  63024. /**
  63025. * Returns the string "PointLight"
  63026. * @returns the class name
  63027. */
  63028. getClassName(): string;
  63029. /**
  63030. * Returns the integer 0.
  63031. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63032. */
  63033. getTypeID(): number;
  63034. /**
  63035. * Specifies wether or not the shadowmap should be a cube texture.
  63036. * @returns true if the shadowmap needs to be a cube texture.
  63037. */
  63038. needCube(): boolean;
  63039. /**
  63040. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63041. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63042. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63043. */
  63044. getShadowDirection(faceIndex?: number): Vector3;
  63045. /**
  63046. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63047. * - fov = PI / 2
  63048. * - aspect ratio : 1.0
  63049. * - z-near and far equal to the active camera minZ and maxZ.
  63050. * Returns the PointLight.
  63051. */
  63052. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63053. protected _buildUniformLayout(): void;
  63054. /**
  63055. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63056. * @param effect The effect to update
  63057. * @param lightIndex The index of the light in the effect to update
  63058. * @returns The point light
  63059. */
  63060. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63061. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63062. /**
  63063. * Prepares the list of defines specific to the light type.
  63064. * @param defines the list of defines
  63065. * @param lightIndex defines the index of the light for the effect
  63066. */
  63067. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63068. }
  63069. }
  63070. declare module "babylonjs/Lights/index" {
  63071. export * from "babylonjs/Lights/light";
  63072. export * from "babylonjs/Lights/shadowLight";
  63073. export * from "babylonjs/Lights/Shadows/index";
  63074. export * from "babylonjs/Lights/directionalLight";
  63075. export * from "babylonjs/Lights/hemisphericLight";
  63076. export * from "babylonjs/Lights/pointLight";
  63077. export * from "babylonjs/Lights/spotLight";
  63078. }
  63079. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63080. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63081. /**
  63082. * Header information of HDR texture files.
  63083. */
  63084. export interface HDRInfo {
  63085. /**
  63086. * The height of the texture in pixels.
  63087. */
  63088. height: number;
  63089. /**
  63090. * The width of the texture in pixels.
  63091. */
  63092. width: number;
  63093. /**
  63094. * The index of the beginning of the data in the binary file.
  63095. */
  63096. dataPosition: number;
  63097. }
  63098. /**
  63099. * This groups tools to convert HDR texture to native colors array.
  63100. */
  63101. export class HDRTools {
  63102. private static Ldexp;
  63103. private static Rgbe2float;
  63104. private static readStringLine;
  63105. /**
  63106. * Reads header information from an RGBE texture stored in a native array.
  63107. * More information on this format are available here:
  63108. * https://en.wikipedia.org/wiki/RGBE_image_format
  63109. *
  63110. * @param uint8array The binary file stored in native array.
  63111. * @return The header information.
  63112. */
  63113. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63114. /**
  63115. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63116. * This RGBE texture needs to store the information as a panorama.
  63117. *
  63118. * More information on this format are available here:
  63119. * https://en.wikipedia.org/wiki/RGBE_image_format
  63120. *
  63121. * @param buffer The binary file stored in an array buffer.
  63122. * @param size The expected size of the extracted cubemap.
  63123. * @return The Cube Map information.
  63124. */
  63125. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63126. /**
  63127. * Returns the pixels data extracted from an RGBE texture.
  63128. * This pixels will be stored left to right up to down in the R G B order in one array.
  63129. *
  63130. * More information on this format are available here:
  63131. * https://en.wikipedia.org/wiki/RGBE_image_format
  63132. *
  63133. * @param uint8array The binary file stored in an array buffer.
  63134. * @param hdrInfo The header information of the file.
  63135. * @return The pixels data in RGB right to left up to down order.
  63136. */
  63137. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63138. private static RGBE_ReadPixels_RLE;
  63139. private static RGBE_ReadPixels_NOT_RLE;
  63140. }
  63141. }
  63142. declare module "babylonjs/Materials/effectRenderer" {
  63143. import { Nullable } from "babylonjs/types";
  63144. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63145. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63146. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63147. import { Viewport } from "babylonjs/Maths/math.viewport";
  63148. import { Observable } from "babylonjs/Misc/observable";
  63149. import { Effect } from "babylonjs/Materials/effect";
  63150. import "babylonjs/Shaders/postprocess.vertex";
  63151. /**
  63152. * Effect Render Options
  63153. */
  63154. export interface IEffectRendererOptions {
  63155. /**
  63156. * Defines the vertices positions.
  63157. */
  63158. positions?: number[];
  63159. /**
  63160. * Defines the indices.
  63161. */
  63162. indices?: number[];
  63163. }
  63164. /**
  63165. * Helper class to render one or more effects.
  63166. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63167. */
  63168. export class EffectRenderer {
  63169. private engine;
  63170. private static _DefaultOptions;
  63171. private _vertexBuffers;
  63172. private _indexBuffer;
  63173. private _fullscreenViewport;
  63174. /**
  63175. * Creates an effect renderer
  63176. * @param engine the engine to use for rendering
  63177. * @param options defines the options of the effect renderer
  63178. */
  63179. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63180. /**
  63181. * Sets the current viewport in normalized coordinates 0-1
  63182. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63183. */
  63184. setViewport(viewport?: Viewport): void;
  63185. /**
  63186. * Binds the embedded attributes buffer to the effect.
  63187. * @param effect Defines the effect to bind the attributes for
  63188. */
  63189. bindBuffers(effect: Effect): void;
  63190. /**
  63191. * Sets the current effect wrapper to use during draw.
  63192. * The effect needs to be ready before calling this api.
  63193. * This also sets the default full screen position attribute.
  63194. * @param effectWrapper Defines the effect to draw with
  63195. */
  63196. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63197. /**
  63198. * Restores engine states
  63199. */
  63200. restoreStates(): void;
  63201. /**
  63202. * Draws a full screen quad.
  63203. */
  63204. draw(): void;
  63205. private isRenderTargetTexture;
  63206. /**
  63207. * renders one or more effects to a specified texture
  63208. * @param effectWrapper the effect to renderer
  63209. * @param outputTexture texture to draw to, if null it will render to the screen.
  63210. */
  63211. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63212. /**
  63213. * Disposes of the effect renderer
  63214. */
  63215. dispose(): void;
  63216. }
  63217. /**
  63218. * Options to create an EffectWrapper
  63219. */
  63220. interface EffectWrapperCreationOptions {
  63221. /**
  63222. * Engine to use to create the effect
  63223. */
  63224. engine: ThinEngine;
  63225. /**
  63226. * Fragment shader for the effect
  63227. */
  63228. fragmentShader: string;
  63229. /**
  63230. * Use the shader store instead of direct source code
  63231. */
  63232. useShaderStore?: boolean;
  63233. /**
  63234. * Vertex shader for the effect
  63235. */
  63236. vertexShader?: string;
  63237. /**
  63238. * Attributes to use in the shader
  63239. */
  63240. attributeNames?: Array<string>;
  63241. /**
  63242. * Uniforms to use in the shader
  63243. */
  63244. uniformNames?: Array<string>;
  63245. /**
  63246. * Texture sampler names to use in the shader
  63247. */
  63248. samplerNames?: Array<string>;
  63249. /**
  63250. * Defines to use in the shader
  63251. */
  63252. defines?: Array<string>;
  63253. /**
  63254. * Callback when effect is compiled
  63255. */
  63256. onCompiled?: Nullable<(effect: Effect) => void>;
  63257. /**
  63258. * The friendly name of the effect displayed in Spector.
  63259. */
  63260. name?: string;
  63261. }
  63262. /**
  63263. * Wraps an effect to be used for rendering
  63264. */
  63265. export class EffectWrapper {
  63266. /**
  63267. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63268. */
  63269. onApplyObservable: Observable<{}>;
  63270. /**
  63271. * The underlying effect
  63272. */
  63273. effect: Effect;
  63274. /**
  63275. * Creates an effect to be renderer
  63276. * @param creationOptions options to create the effect
  63277. */
  63278. constructor(creationOptions: EffectWrapperCreationOptions);
  63279. /**
  63280. * Disposes of the effect wrapper
  63281. */
  63282. dispose(): void;
  63283. }
  63284. }
  63285. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63286. /** @hidden */
  63287. export var hdrFilteringVertexShader: {
  63288. name: string;
  63289. shader: string;
  63290. };
  63291. }
  63292. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63293. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63294. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63295. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63296. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63297. /** @hidden */
  63298. export var hdrFilteringPixelShader: {
  63299. name: string;
  63300. shader: string;
  63301. };
  63302. }
  63303. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63305. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63306. import { Nullable } from "babylonjs/types";
  63307. import "babylonjs/Shaders/hdrFiltering.vertex";
  63308. import "babylonjs/Shaders/hdrFiltering.fragment";
  63309. /**
  63310. * Options for texture filtering
  63311. */
  63312. interface IHDRFilteringOptions {
  63313. /**
  63314. * Scales pixel intensity for the input HDR map.
  63315. */
  63316. hdrScale?: number;
  63317. /**
  63318. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63319. */
  63320. quality?: number;
  63321. }
  63322. /**
  63323. * Filters HDR maps to get correct renderings of PBR reflections
  63324. */
  63325. export class HDRFiltering {
  63326. private _engine;
  63327. private _effectRenderer;
  63328. private _effectWrapper;
  63329. private _lodGenerationOffset;
  63330. private _lodGenerationScale;
  63331. /**
  63332. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63333. * you care about baking speed.
  63334. */
  63335. quality: number;
  63336. /**
  63337. * Scales pixel intensity for the input HDR map.
  63338. */
  63339. hdrScale: number;
  63340. /**
  63341. * Instantiates HDR filter for reflection maps
  63342. *
  63343. * @param engine Thin engine
  63344. * @param options Options
  63345. */
  63346. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63347. private _createRenderTarget;
  63348. private _prefilterInternal;
  63349. private _createEffect;
  63350. /**
  63351. * Get a value indicating if the filter is ready to be used
  63352. * @param texture Texture to filter
  63353. * @returns true if the filter is ready
  63354. */
  63355. isReady(texture: BaseTexture): boolean;
  63356. /**
  63357. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63358. * Prefiltering will be invoked at the end of next rendering pass.
  63359. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63360. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63361. * @param texture Texture to filter
  63362. * @param onFinished Callback when filtering is done
  63363. * @return Promise called when prefiltering is done
  63364. */
  63365. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63366. }
  63367. }
  63368. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63369. import { Nullable } from "babylonjs/types";
  63370. import { Scene } from "babylonjs/scene";
  63371. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63372. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63373. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63374. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63375. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63376. /**
  63377. * This represents a texture coming from an HDR input.
  63378. *
  63379. * The only supported format is currently panorama picture stored in RGBE format.
  63380. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63381. */
  63382. export class HDRCubeTexture extends BaseTexture {
  63383. private static _facesMapping;
  63384. private _generateHarmonics;
  63385. private _noMipmap;
  63386. private _prefilterOnLoad;
  63387. private _textureMatrix;
  63388. private _size;
  63389. private _onLoad;
  63390. private _onError;
  63391. /**
  63392. * The texture URL.
  63393. */
  63394. url: string;
  63395. protected _isBlocking: boolean;
  63396. /**
  63397. * Sets wether or not the texture is blocking during loading.
  63398. */
  63399. set isBlocking(value: boolean);
  63400. /**
  63401. * Gets wether or not the texture is blocking during loading.
  63402. */
  63403. get isBlocking(): boolean;
  63404. protected _rotationY: number;
  63405. /**
  63406. * Sets texture matrix rotation angle around Y axis in radians.
  63407. */
  63408. set rotationY(value: number);
  63409. /**
  63410. * Gets texture matrix rotation angle around Y axis radians.
  63411. */
  63412. get rotationY(): number;
  63413. /**
  63414. * Gets or sets the center of the bounding box associated with the cube texture
  63415. * It must define where the camera used to render the texture was set
  63416. */
  63417. boundingBoxPosition: Vector3;
  63418. private _boundingBoxSize;
  63419. /**
  63420. * Gets or sets the size of the bounding box associated with the cube texture
  63421. * When defined, the cubemap will switch to local mode
  63422. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63423. * @example https://www.babylonjs-playground.com/#RNASML
  63424. */
  63425. set boundingBoxSize(value: Vector3);
  63426. get boundingBoxSize(): Vector3;
  63427. /**
  63428. * Instantiates an HDRTexture from the following parameters.
  63429. *
  63430. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63431. * @param sceneOrEngine The scene or engine the texture will be used in
  63432. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63433. * @param noMipmap Forces to not generate the mipmap if true
  63434. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63435. * @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)
  63436. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63437. */
  63438. 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>);
  63439. /**
  63440. * Get the current class name of the texture useful for serialization or dynamic coding.
  63441. * @returns "HDRCubeTexture"
  63442. */
  63443. getClassName(): string;
  63444. /**
  63445. * Occurs when the file is raw .hdr file.
  63446. */
  63447. private loadTexture;
  63448. clone(): HDRCubeTexture;
  63449. delayLoad(): void;
  63450. /**
  63451. * Get the texture reflection matrix used to rotate/transform the reflection.
  63452. * @returns the reflection matrix
  63453. */
  63454. getReflectionTextureMatrix(): Matrix;
  63455. /**
  63456. * Set the texture reflection matrix used to rotate/transform the reflection.
  63457. * @param value Define the reflection matrix to set
  63458. */
  63459. setReflectionTextureMatrix(value: Matrix): void;
  63460. /**
  63461. * Parses a JSON representation of an HDR Texture in order to create the texture
  63462. * @param parsedTexture Define the JSON representation
  63463. * @param scene Define the scene the texture should be created in
  63464. * @param rootUrl Define the root url in case we need to load relative dependencies
  63465. * @returns the newly created texture after parsing
  63466. */
  63467. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63468. serialize(): any;
  63469. }
  63470. }
  63471. declare module "babylonjs/Physics/physicsEngine" {
  63472. import { Nullable } from "babylonjs/types";
  63473. import { Vector3 } from "babylonjs/Maths/math.vector";
  63474. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63475. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63476. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63477. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63478. /**
  63479. * Class used to control physics engine
  63480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63481. */
  63482. export class PhysicsEngine implements IPhysicsEngine {
  63483. private _physicsPlugin;
  63484. /**
  63485. * Global value used to control the smallest number supported by the simulation
  63486. */
  63487. static Epsilon: number;
  63488. private _impostors;
  63489. private _joints;
  63490. private _subTimeStep;
  63491. /**
  63492. * Gets the gravity vector used by the simulation
  63493. */
  63494. gravity: Vector3;
  63495. /**
  63496. * Factory used to create the default physics plugin.
  63497. * @returns The default physics plugin
  63498. */
  63499. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63500. /**
  63501. * Creates a new Physics Engine
  63502. * @param gravity defines the gravity vector used by the simulation
  63503. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63504. */
  63505. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63506. /**
  63507. * Sets the gravity vector used by the simulation
  63508. * @param gravity defines the gravity vector to use
  63509. */
  63510. setGravity(gravity: Vector3): void;
  63511. /**
  63512. * Set the time step of the physics engine.
  63513. * Default is 1/60.
  63514. * To slow it down, enter 1/600 for example.
  63515. * To speed it up, 1/30
  63516. * @param newTimeStep defines the new timestep to apply to this world.
  63517. */
  63518. setTimeStep(newTimeStep?: number): void;
  63519. /**
  63520. * Get the time step of the physics engine.
  63521. * @returns the current time step
  63522. */
  63523. getTimeStep(): number;
  63524. /**
  63525. * Set the sub time step of the physics engine.
  63526. * Default is 0 meaning there is no sub steps
  63527. * To increase physics resolution precision, set a small value (like 1 ms)
  63528. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63529. */
  63530. setSubTimeStep(subTimeStep?: number): void;
  63531. /**
  63532. * Get the sub time step of the physics engine.
  63533. * @returns the current sub time step
  63534. */
  63535. getSubTimeStep(): number;
  63536. /**
  63537. * Release all resources
  63538. */
  63539. dispose(): void;
  63540. /**
  63541. * Gets the name of the current physics plugin
  63542. * @returns the name of the plugin
  63543. */
  63544. getPhysicsPluginName(): string;
  63545. /**
  63546. * Adding a new impostor for the impostor tracking.
  63547. * This will be done by the impostor itself.
  63548. * @param impostor the impostor to add
  63549. */
  63550. addImpostor(impostor: PhysicsImpostor): void;
  63551. /**
  63552. * Remove an impostor from the engine.
  63553. * This impostor and its mesh will not longer be updated by the physics engine.
  63554. * @param impostor the impostor to remove
  63555. */
  63556. removeImpostor(impostor: PhysicsImpostor): void;
  63557. /**
  63558. * Add a joint to the physics engine
  63559. * @param mainImpostor defines the main impostor to which the joint is added.
  63560. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63561. * @param joint defines the joint that will connect both impostors.
  63562. */
  63563. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63564. /**
  63565. * Removes a joint from the simulation
  63566. * @param mainImpostor defines the impostor used with the joint
  63567. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63568. * @param joint defines the joint to remove
  63569. */
  63570. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63571. /**
  63572. * Called by the scene. No need to call it.
  63573. * @param delta defines the timespam between frames
  63574. */
  63575. _step(delta: number): void;
  63576. /**
  63577. * Gets the current plugin used to run the simulation
  63578. * @returns current plugin
  63579. */
  63580. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63581. /**
  63582. * Gets the list of physic impostors
  63583. * @returns an array of PhysicsImpostor
  63584. */
  63585. getImpostors(): Array<PhysicsImpostor>;
  63586. /**
  63587. * Gets the impostor for a physics enabled object
  63588. * @param object defines the object impersonated by the impostor
  63589. * @returns the PhysicsImpostor or null if not found
  63590. */
  63591. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63592. /**
  63593. * Gets the impostor for a physics body object
  63594. * @param body defines physics body used by the impostor
  63595. * @returns the PhysicsImpostor or null if not found
  63596. */
  63597. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63598. /**
  63599. * Does a raycast in the physics world
  63600. * @param from when should the ray start?
  63601. * @param to when should the ray end?
  63602. * @returns PhysicsRaycastResult
  63603. */
  63604. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63605. }
  63606. }
  63607. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63608. import { Nullable } from "babylonjs/types";
  63609. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63611. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63612. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63613. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63614. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63615. /** @hidden */
  63616. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63617. private _useDeltaForWorldStep;
  63618. world: any;
  63619. name: string;
  63620. private _physicsMaterials;
  63621. private _fixedTimeStep;
  63622. private _cannonRaycastResult;
  63623. private _raycastResult;
  63624. private _physicsBodysToRemoveAfterStep;
  63625. private _firstFrame;
  63626. BJSCANNON: any;
  63627. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63628. setGravity(gravity: Vector3): void;
  63629. setTimeStep(timeStep: number): void;
  63630. getTimeStep(): number;
  63631. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63632. private _removeMarkedPhysicsBodiesFromWorld;
  63633. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63634. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63635. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63636. private _processChildMeshes;
  63637. removePhysicsBody(impostor: PhysicsImpostor): void;
  63638. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63639. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63640. private _addMaterial;
  63641. private _checkWithEpsilon;
  63642. private _createShape;
  63643. private _createHeightmap;
  63644. private _minus90X;
  63645. private _plus90X;
  63646. private _tmpPosition;
  63647. private _tmpDeltaPosition;
  63648. private _tmpUnityRotation;
  63649. private _updatePhysicsBodyTransformation;
  63650. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63651. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63652. isSupported(): boolean;
  63653. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63654. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63655. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63656. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63657. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63658. getBodyMass(impostor: PhysicsImpostor): number;
  63659. getBodyFriction(impostor: PhysicsImpostor): number;
  63660. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63661. getBodyRestitution(impostor: PhysicsImpostor): number;
  63662. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63663. sleepBody(impostor: PhysicsImpostor): void;
  63664. wakeUpBody(impostor: PhysicsImpostor): void;
  63665. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63666. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63667. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63668. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63669. getRadius(impostor: PhysicsImpostor): number;
  63670. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63671. dispose(): void;
  63672. private _extendNamespace;
  63673. /**
  63674. * Does a raycast in the physics world
  63675. * @param from when should the ray start?
  63676. * @param to when should the ray end?
  63677. * @returns PhysicsRaycastResult
  63678. */
  63679. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63680. }
  63681. }
  63682. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63683. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63684. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63685. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63687. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63688. import { Nullable } from "babylonjs/types";
  63689. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63690. /** @hidden */
  63691. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63692. private _useDeltaForWorldStep;
  63693. world: any;
  63694. name: string;
  63695. BJSOIMO: any;
  63696. private _raycastResult;
  63697. private _fixedTimeStep;
  63698. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63699. setGravity(gravity: Vector3): void;
  63700. setTimeStep(timeStep: number): void;
  63701. getTimeStep(): number;
  63702. private _tmpImpostorsArray;
  63703. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63704. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63705. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63706. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63707. private _tmpPositionVector;
  63708. removePhysicsBody(impostor: PhysicsImpostor): void;
  63709. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63710. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63711. isSupported(): boolean;
  63712. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63713. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63714. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63715. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63716. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63717. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63718. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63719. getBodyMass(impostor: PhysicsImpostor): number;
  63720. getBodyFriction(impostor: PhysicsImpostor): number;
  63721. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63722. getBodyRestitution(impostor: PhysicsImpostor): number;
  63723. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63724. sleepBody(impostor: PhysicsImpostor): void;
  63725. wakeUpBody(impostor: PhysicsImpostor): void;
  63726. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63727. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63728. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63729. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63730. getRadius(impostor: PhysicsImpostor): number;
  63731. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63732. dispose(): void;
  63733. /**
  63734. * Does a raycast in the physics world
  63735. * @param from when should the ray start?
  63736. * @param to when should the ray end?
  63737. * @returns PhysicsRaycastResult
  63738. */
  63739. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63740. }
  63741. }
  63742. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63743. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63744. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63745. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63746. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63747. import { Nullable } from "babylonjs/types";
  63748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63749. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63750. /**
  63751. * AmmoJS Physics plugin
  63752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63753. * @see https://github.com/kripken/ammo.js/
  63754. */
  63755. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63756. private _useDeltaForWorldStep;
  63757. /**
  63758. * Reference to the Ammo library
  63759. */
  63760. bjsAMMO: any;
  63761. /**
  63762. * Created ammoJS world which physics bodies are added to
  63763. */
  63764. world: any;
  63765. /**
  63766. * Name of the plugin
  63767. */
  63768. name: string;
  63769. private _timeStep;
  63770. private _fixedTimeStep;
  63771. private _maxSteps;
  63772. private _tmpQuaternion;
  63773. private _tmpAmmoTransform;
  63774. private _tmpAmmoQuaternion;
  63775. private _tmpAmmoConcreteContactResultCallback;
  63776. private _collisionConfiguration;
  63777. private _dispatcher;
  63778. private _overlappingPairCache;
  63779. private _solver;
  63780. private _softBodySolver;
  63781. private _tmpAmmoVectorA;
  63782. private _tmpAmmoVectorB;
  63783. private _tmpAmmoVectorC;
  63784. private _tmpAmmoVectorD;
  63785. private _tmpContactCallbackResult;
  63786. private _tmpAmmoVectorRCA;
  63787. private _tmpAmmoVectorRCB;
  63788. private _raycastResult;
  63789. private static readonly DISABLE_COLLISION_FLAG;
  63790. private static readonly KINEMATIC_FLAG;
  63791. private static readonly DISABLE_DEACTIVATION_FLAG;
  63792. /**
  63793. * Initializes the ammoJS plugin
  63794. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63795. * @param ammoInjection can be used to inject your own ammo reference
  63796. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63797. */
  63798. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63799. /**
  63800. * Sets the gravity of the physics world (m/(s^2))
  63801. * @param gravity Gravity to set
  63802. */
  63803. setGravity(gravity: Vector3): void;
  63804. /**
  63805. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63806. * @param timeStep timestep to use in seconds
  63807. */
  63808. setTimeStep(timeStep: number): void;
  63809. /**
  63810. * 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)
  63811. * @param fixedTimeStep fixedTimeStep to use in seconds
  63812. */
  63813. setFixedTimeStep(fixedTimeStep: number): void;
  63814. /**
  63815. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63816. * @param maxSteps the maximum number of steps by the physics engine per frame
  63817. */
  63818. setMaxSteps(maxSteps: number): void;
  63819. /**
  63820. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63821. * @returns the current timestep in seconds
  63822. */
  63823. getTimeStep(): number;
  63824. /**
  63825. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63826. */
  63827. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63828. private _isImpostorInContact;
  63829. private _isImpostorPairInContact;
  63830. private _stepSimulation;
  63831. /**
  63832. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63833. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63834. * After the step the babylon meshes are set to the position of the physics imposters
  63835. * @param delta amount of time to step forward
  63836. * @param impostors array of imposters to update before/after the step
  63837. */
  63838. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63839. /**
  63840. * Update babylon mesh to match physics world object
  63841. * @param impostor imposter to match
  63842. */
  63843. private _afterSoftStep;
  63844. /**
  63845. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63846. * @param impostor imposter to match
  63847. */
  63848. private _ropeStep;
  63849. /**
  63850. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63851. * @param impostor imposter to match
  63852. */
  63853. private _softbodyOrClothStep;
  63854. private _tmpMatrix;
  63855. /**
  63856. * Applies an impulse on the imposter
  63857. * @param impostor imposter to apply impulse to
  63858. * @param force amount of force to be applied to the imposter
  63859. * @param contactPoint the location to apply the impulse on the imposter
  63860. */
  63861. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63862. /**
  63863. * Applies a force on the imposter
  63864. * @param impostor imposter to apply force
  63865. * @param force amount of force to be applied to the imposter
  63866. * @param contactPoint the location to apply the force on the imposter
  63867. */
  63868. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63869. /**
  63870. * Creates a physics body using the plugin
  63871. * @param impostor the imposter to create the physics body on
  63872. */
  63873. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63874. /**
  63875. * Removes the physics body from the imposter and disposes of the body's memory
  63876. * @param impostor imposter to remove the physics body from
  63877. */
  63878. removePhysicsBody(impostor: PhysicsImpostor): void;
  63879. /**
  63880. * Generates a joint
  63881. * @param impostorJoint the imposter joint to create the joint with
  63882. */
  63883. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63884. /**
  63885. * Removes a joint
  63886. * @param impostorJoint the imposter joint to remove the joint from
  63887. */
  63888. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63889. private _addMeshVerts;
  63890. /**
  63891. * Initialise the soft body vertices to match its object's (mesh) vertices
  63892. * Softbody vertices (nodes) are in world space and to match this
  63893. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63894. * @param impostor to create the softbody for
  63895. */
  63896. private _softVertexData;
  63897. /**
  63898. * Create an impostor's soft body
  63899. * @param impostor to create the softbody for
  63900. */
  63901. private _createSoftbody;
  63902. /**
  63903. * Create cloth for an impostor
  63904. * @param impostor to create the softbody for
  63905. */
  63906. private _createCloth;
  63907. /**
  63908. * Create rope for an impostor
  63909. * @param impostor to create the softbody for
  63910. */
  63911. private _createRope;
  63912. /**
  63913. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63914. * @param impostor to create the custom physics shape for
  63915. */
  63916. private _createCustom;
  63917. private _addHullVerts;
  63918. private _createShape;
  63919. /**
  63920. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63921. * @param impostor imposter containing the physics body and babylon object
  63922. */
  63923. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63924. /**
  63925. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63926. * @param impostor imposter containing the physics body and babylon object
  63927. * @param newPosition new position
  63928. * @param newRotation new rotation
  63929. */
  63930. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63931. /**
  63932. * If this plugin is supported
  63933. * @returns true if its supported
  63934. */
  63935. isSupported(): boolean;
  63936. /**
  63937. * Sets the linear velocity of the physics body
  63938. * @param impostor imposter to set the velocity on
  63939. * @param velocity velocity to set
  63940. */
  63941. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63942. /**
  63943. * Sets the angular velocity of the physics body
  63944. * @param impostor imposter to set the velocity on
  63945. * @param velocity velocity to set
  63946. */
  63947. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63948. /**
  63949. * gets the linear velocity
  63950. * @param impostor imposter to get linear velocity from
  63951. * @returns linear velocity
  63952. */
  63953. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63954. /**
  63955. * gets the angular velocity
  63956. * @param impostor imposter to get angular velocity from
  63957. * @returns angular velocity
  63958. */
  63959. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63960. /**
  63961. * Sets the mass of physics body
  63962. * @param impostor imposter to set the mass on
  63963. * @param mass mass to set
  63964. */
  63965. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63966. /**
  63967. * Gets the mass of the physics body
  63968. * @param impostor imposter to get the mass from
  63969. * @returns mass
  63970. */
  63971. getBodyMass(impostor: PhysicsImpostor): number;
  63972. /**
  63973. * Gets friction of the impostor
  63974. * @param impostor impostor to get friction from
  63975. * @returns friction value
  63976. */
  63977. getBodyFriction(impostor: PhysicsImpostor): number;
  63978. /**
  63979. * Sets friction of the impostor
  63980. * @param impostor impostor to set friction on
  63981. * @param friction friction value
  63982. */
  63983. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63984. /**
  63985. * Gets restitution of the impostor
  63986. * @param impostor impostor to get restitution from
  63987. * @returns restitution value
  63988. */
  63989. getBodyRestitution(impostor: PhysicsImpostor): number;
  63990. /**
  63991. * Sets resitution of the impostor
  63992. * @param impostor impostor to set resitution on
  63993. * @param restitution resitution value
  63994. */
  63995. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63996. /**
  63997. * Gets pressure inside the impostor
  63998. * @param impostor impostor to get pressure from
  63999. * @returns pressure value
  64000. */
  64001. getBodyPressure(impostor: PhysicsImpostor): number;
  64002. /**
  64003. * Sets pressure inside a soft body impostor
  64004. * Cloth and rope must remain 0 pressure
  64005. * @param impostor impostor to set pressure on
  64006. * @param pressure pressure value
  64007. */
  64008. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64009. /**
  64010. * Gets stiffness of the impostor
  64011. * @param impostor impostor to get stiffness from
  64012. * @returns pressure value
  64013. */
  64014. getBodyStiffness(impostor: PhysicsImpostor): number;
  64015. /**
  64016. * Sets stiffness of the impostor
  64017. * @param impostor impostor to set stiffness on
  64018. * @param stiffness stiffness value from 0 to 1
  64019. */
  64020. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64021. /**
  64022. * Gets velocityIterations of the impostor
  64023. * @param impostor impostor to get velocity iterations from
  64024. * @returns velocityIterations value
  64025. */
  64026. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64027. /**
  64028. * Sets velocityIterations of the impostor
  64029. * @param impostor impostor to set velocity iterations on
  64030. * @param velocityIterations velocityIterations value
  64031. */
  64032. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64033. /**
  64034. * Gets positionIterations of the impostor
  64035. * @param impostor impostor to get position iterations from
  64036. * @returns positionIterations value
  64037. */
  64038. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64039. /**
  64040. * Sets positionIterations of the impostor
  64041. * @param impostor impostor to set position on
  64042. * @param positionIterations positionIterations value
  64043. */
  64044. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64045. /**
  64046. * Append an anchor to a cloth object
  64047. * @param impostor is the cloth impostor to add anchor to
  64048. * @param otherImpostor is the rigid impostor to anchor to
  64049. * @param width ratio across width from 0 to 1
  64050. * @param height ratio up height from 0 to 1
  64051. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64052. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64053. */
  64054. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64055. /**
  64056. * Append an hook to a rope object
  64057. * @param impostor is the rope impostor to add hook to
  64058. * @param otherImpostor is the rigid impostor to hook to
  64059. * @param length ratio along the rope from 0 to 1
  64060. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64061. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64062. */
  64063. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64064. /**
  64065. * Sleeps the physics body and stops it from being active
  64066. * @param impostor impostor to sleep
  64067. */
  64068. sleepBody(impostor: PhysicsImpostor): void;
  64069. /**
  64070. * Activates the physics body
  64071. * @param impostor impostor to activate
  64072. */
  64073. wakeUpBody(impostor: PhysicsImpostor): void;
  64074. /**
  64075. * Updates the distance parameters of the joint
  64076. * @param joint joint to update
  64077. * @param maxDistance maximum distance of the joint
  64078. * @param minDistance minimum distance of the joint
  64079. */
  64080. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64081. /**
  64082. * Sets a motor on the joint
  64083. * @param joint joint to set motor on
  64084. * @param speed speed of the motor
  64085. * @param maxForce maximum force of the motor
  64086. * @param motorIndex index of the motor
  64087. */
  64088. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64089. /**
  64090. * Sets the motors limit
  64091. * @param joint joint to set limit on
  64092. * @param upperLimit upper limit
  64093. * @param lowerLimit lower limit
  64094. */
  64095. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64096. /**
  64097. * Syncs the position and rotation of a mesh with the impostor
  64098. * @param mesh mesh to sync
  64099. * @param impostor impostor to update the mesh with
  64100. */
  64101. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64102. /**
  64103. * Gets the radius of the impostor
  64104. * @param impostor impostor to get radius from
  64105. * @returns the radius
  64106. */
  64107. getRadius(impostor: PhysicsImpostor): number;
  64108. /**
  64109. * Gets the box size of the impostor
  64110. * @param impostor impostor to get box size from
  64111. * @param result the resulting box size
  64112. */
  64113. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64114. /**
  64115. * Disposes of the impostor
  64116. */
  64117. dispose(): void;
  64118. /**
  64119. * Does a raycast in the physics world
  64120. * @param from when should the ray start?
  64121. * @param to when should the ray end?
  64122. * @returns PhysicsRaycastResult
  64123. */
  64124. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64125. }
  64126. }
  64127. declare module "babylonjs/Probes/reflectionProbe" {
  64128. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64129. import { Vector3 } from "babylonjs/Maths/math.vector";
  64130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64131. import { Nullable } from "babylonjs/types";
  64132. import { Scene } from "babylonjs/scene";
  64133. module "babylonjs/abstractScene" {
  64134. interface AbstractScene {
  64135. /**
  64136. * The list of reflection probes added to the scene
  64137. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64138. */
  64139. reflectionProbes: Array<ReflectionProbe>;
  64140. /**
  64141. * Removes the given reflection probe from this scene.
  64142. * @param toRemove The reflection probe to remove
  64143. * @returns The index of the removed reflection probe
  64144. */
  64145. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64146. /**
  64147. * Adds the given reflection probe to this scene.
  64148. * @param newReflectionProbe The reflection probe to add
  64149. */
  64150. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64151. }
  64152. }
  64153. /**
  64154. * Class used to generate realtime reflection / refraction cube textures
  64155. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64156. */
  64157. export class ReflectionProbe {
  64158. /** defines the name of the probe */
  64159. name: string;
  64160. private _scene;
  64161. private _renderTargetTexture;
  64162. private _projectionMatrix;
  64163. private _viewMatrix;
  64164. private _target;
  64165. private _add;
  64166. private _attachedMesh;
  64167. private _invertYAxis;
  64168. /** Gets or sets probe position (center of the cube map) */
  64169. position: Vector3;
  64170. /**
  64171. * Creates a new reflection probe
  64172. * @param name defines the name of the probe
  64173. * @param size defines the texture resolution (for each face)
  64174. * @param scene defines the hosting scene
  64175. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64176. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64177. */
  64178. constructor(
  64179. /** defines the name of the probe */
  64180. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64181. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64182. get samples(): number;
  64183. set samples(value: number);
  64184. /** Gets or sets the refresh rate to use (on every frame by default) */
  64185. get refreshRate(): number;
  64186. set refreshRate(value: number);
  64187. /**
  64188. * Gets the hosting scene
  64189. * @returns a Scene
  64190. */
  64191. getScene(): Scene;
  64192. /** Gets the internal CubeTexture used to render to */
  64193. get cubeTexture(): RenderTargetTexture;
  64194. /** Gets the list of meshes to render */
  64195. get renderList(): Nullable<AbstractMesh[]>;
  64196. /**
  64197. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64198. * @param mesh defines the mesh to attach to
  64199. */
  64200. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64201. /**
  64202. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64203. * @param renderingGroupId The rendering group id corresponding to its index
  64204. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64205. */
  64206. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64207. /**
  64208. * Clean all associated resources
  64209. */
  64210. dispose(): void;
  64211. /**
  64212. * Converts the reflection probe information to a readable string for debug purpose.
  64213. * @param fullDetails Supports for multiple levels of logging within scene loading
  64214. * @returns the human readable reflection probe info
  64215. */
  64216. toString(fullDetails?: boolean): string;
  64217. /**
  64218. * Get the class name of the relfection probe.
  64219. * @returns "ReflectionProbe"
  64220. */
  64221. getClassName(): string;
  64222. /**
  64223. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64224. * @returns The JSON representation of the texture
  64225. */
  64226. serialize(): any;
  64227. /**
  64228. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64229. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64230. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64231. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64232. * @returns The parsed reflection probe if successful
  64233. */
  64234. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64235. }
  64236. }
  64237. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64238. /** @hidden */
  64239. export var _BabylonLoaderRegistered: boolean;
  64240. /**
  64241. * Helps setting up some configuration for the babylon file loader.
  64242. */
  64243. export class BabylonFileLoaderConfiguration {
  64244. /**
  64245. * The loader does not allow injecting custom physix engine into the plugins.
  64246. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64247. * So you could set this variable to your engine import to make it work.
  64248. */
  64249. static LoaderInjectedPhysicsEngine: any;
  64250. }
  64251. }
  64252. declare module "babylonjs/Loading/Plugins/index" {
  64253. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64254. }
  64255. declare module "babylonjs/Loading/index" {
  64256. export * from "babylonjs/Loading/loadingScreen";
  64257. export * from "babylonjs/Loading/Plugins/index";
  64258. export * from "babylonjs/Loading/sceneLoader";
  64259. export * from "babylonjs/Loading/sceneLoaderFlags";
  64260. }
  64261. declare module "babylonjs/Materials/Background/index" {
  64262. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64263. }
  64264. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64265. import { Scene } from "babylonjs/scene";
  64266. import { Color3 } from "babylonjs/Maths/math.color";
  64267. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64268. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64269. /**
  64270. * The Physically based simple base material of BJS.
  64271. *
  64272. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64273. * It is used as the base class for both the specGloss and metalRough conventions.
  64274. */
  64275. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64276. /**
  64277. * Number of Simultaneous lights allowed on the material.
  64278. */
  64279. maxSimultaneousLights: number;
  64280. /**
  64281. * If sets to true, disables all the lights affecting the material.
  64282. */
  64283. disableLighting: boolean;
  64284. /**
  64285. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64286. */
  64287. environmentTexture: BaseTexture;
  64288. /**
  64289. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64290. */
  64291. invertNormalMapX: boolean;
  64292. /**
  64293. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64294. */
  64295. invertNormalMapY: boolean;
  64296. /**
  64297. * Normal map used in the model.
  64298. */
  64299. normalTexture: BaseTexture;
  64300. /**
  64301. * Emissivie color used to self-illuminate the model.
  64302. */
  64303. emissiveColor: Color3;
  64304. /**
  64305. * Emissivie texture used to self-illuminate the model.
  64306. */
  64307. emissiveTexture: BaseTexture;
  64308. /**
  64309. * Occlusion Channel Strenght.
  64310. */
  64311. occlusionStrength: number;
  64312. /**
  64313. * Occlusion Texture of the material (adding extra occlusion effects).
  64314. */
  64315. occlusionTexture: BaseTexture;
  64316. /**
  64317. * Defines the alpha limits in alpha test mode.
  64318. */
  64319. alphaCutOff: number;
  64320. /**
  64321. * Gets the current double sided mode.
  64322. */
  64323. get doubleSided(): boolean;
  64324. /**
  64325. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64326. */
  64327. set doubleSided(value: boolean);
  64328. /**
  64329. * Stores the pre-calculated light information of a mesh in a texture.
  64330. */
  64331. lightmapTexture: BaseTexture;
  64332. /**
  64333. * If true, the light map contains occlusion information instead of lighting info.
  64334. */
  64335. useLightmapAsShadowmap: boolean;
  64336. /**
  64337. * Instantiates a new PBRMaterial instance.
  64338. *
  64339. * @param name The material name
  64340. * @param scene The scene the material will be use in.
  64341. */
  64342. constructor(name: string, scene: Scene);
  64343. getClassName(): string;
  64344. }
  64345. }
  64346. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64347. import { Scene } from "babylonjs/scene";
  64348. import { Color3 } from "babylonjs/Maths/math.color";
  64349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64350. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64351. /**
  64352. * The PBR material of BJS following the metal roughness convention.
  64353. *
  64354. * This fits to the PBR convention in the GLTF definition:
  64355. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64356. */
  64357. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64358. /**
  64359. * The base color has two different interpretations depending on the value of metalness.
  64360. * When the material is a metal, the base color is the specific measured reflectance value
  64361. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64362. * of the material.
  64363. */
  64364. baseColor: Color3;
  64365. /**
  64366. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64367. * well as opacity information in the alpha channel.
  64368. */
  64369. baseTexture: BaseTexture;
  64370. /**
  64371. * Specifies the metallic scalar value of the material.
  64372. * Can also be used to scale the metalness values of the metallic texture.
  64373. */
  64374. metallic: number;
  64375. /**
  64376. * Specifies the roughness scalar value of the material.
  64377. * Can also be used to scale the roughness values of the metallic texture.
  64378. */
  64379. roughness: number;
  64380. /**
  64381. * Texture containing both the metallic value in the B channel and the
  64382. * roughness value in the G channel to keep better precision.
  64383. */
  64384. metallicRoughnessTexture: BaseTexture;
  64385. /**
  64386. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64387. *
  64388. * @param name The material name
  64389. * @param scene The scene the material will be use in.
  64390. */
  64391. constructor(name: string, scene: Scene);
  64392. /**
  64393. * Return the currrent class name of the material.
  64394. */
  64395. getClassName(): string;
  64396. /**
  64397. * Makes a duplicate of the current material.
  64398. * @param name - name to use for the new material.
  64399. */
  64400. clone(name: string): PBRMetallicRoughnessMaterial;
  64401. /**
  64402. * Serialize the material to a parsable JSON object.
  64403. */
  64404. serialize(): any;
  64405. /**
  64406. * Parses a JSON object correponding to the serialize function.
  64407. */
  64408. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64409. }
  64410. }
  64411. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64412. import { Scene } from "babylonjs/scene";
  64413. import { Color3 } from "babylonjs/Maths/math.color";
  64414. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64415. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64416. /**
  64417. * The PBR material of BJS following the specular glossiness convention.
  64418. *
  64419. * This fits to the PBR convention in the GLTF definition:
  64420. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64421. */
  64422. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64423. /**
  64424. * Specifies the diffuse color of the material.
  64425. */
  64426. diffuseColor: Color3;
  64427. /**
  64428. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64429. * channel.
  64430. */
  64431. diffuseTexture: BaseTexture;
  64432. /**
  64433. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64434. */
  64435. specularColor: Color3;
  64436. /**
  64437. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64438. */
  64439. glossiness: number;
  64440. /**
  64441. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64442. */
  64443. specularGlossinessTexture: BaseTexture;
  64444. /**
  64445. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64446. *
  64447. * @param name The material name
  64448. * @param scene The scene the material will be use in.
  64449. */
  64450. constructor(name: string, scene: Scene);
  64451. /**
  64452. * Return the currrent class name of the material.
  64453. */
  64454. getClassName(): string;
  64455. /**
  64456. * Makes a duplicate of the current material.
  64457. * @param name - name to use for the new material.
  64458. */
  64459. clone(name: string): PBRSpecularGlossinessMaterial;
  64460. /**
  64461. * Serialize the material to a parsable JSON object.
  64462. */
  64463. serialize(): any;
  64464. /**
  64465. * Parses a JSON object correponding to the serialize function.
  64466. */
  64467. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64468. }
  64469. }
  64470. declare module "babylonjs/Materials/PBR/index" {
  64471. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64472. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64473. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64474. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64475. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64476. }
  64477. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64478. import { Nullable } from "babylonjs/types";
  64479. import { Scene } from "babylonjs/scene";
  64480. import { Matrix } from "babylonjs/Maths/math.vector";
  64481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64482. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64483. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64484. /**
  64485. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64486. * It can help converting any input color in a desired output one. This can then be used to create effects
  64487. * from sepia, black and white to sixties or futuristic rendering...
  64488. *
  64489. * The only supported format is currently 3dl.
  64490. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64491. */
  64492. export class ColorGradingTexture extends BaseTexture {
  64493. /**
  64494. * The texture URL.
  64495. */
  64496. url: string;
  64497. /**
  64498. * Empty line regex stored for GC.
  64499. */
  64500. private static _noneEmptyLineRegex;
  64501. private _textureMatrix;
  64502. private _onLoad;
  64503. /**
  64504. * Instantiates a ColorGradingTexture from the following parameters.
  64505. *
  64506. * @param url The location of the color gradind data (currently only supporting 3dl)
  64507. * @param sceneOrEngine The scene or engine the texture will be used in
  64508. * @param onLoad defines a callback triggered when the texture has been loaded
  64509. */
  64510. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64511. /**
  64512. * Fires the onload event from the constructor if requested.
  64513. */
  64514. private _triggerOnLoad;
  64515. /**
  64516. * Returns the texture matrix used in most of the material.
  64517. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64518. */
  64519. getTextureMatrix(): Matrix;
  64520. /**
  64521. * Occurs when the file being loaded is a .3dl LUT file.
  64522. */
  64523. private load3dlTexture;
  64524. /**
  64525. * Starts the loading process of the texture.
  64526. */
  64527. private loadTexture;
  64528. /**
  64529. * Clones the color gradind texture.
  64530. */
  64531. clone(): ColorGradingTexture;
  64532. /**
  64533. * Called during delayed load for textures.
  64534. */
  64535. delayLoad(): void;
  64536. /**
  64537. * Parses a color grading texture serialized by Babylon.
  64538. * @param parsedTexture The texture information being parsedTexture
  64539. * @param scene The scene to load the texture in
  64540. * @param rootUrl The root url of the data assets to load
  64541. * @return A color gradind texture
  64542. */
  64543. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64544. /**
  64545. * Serializes the LUT texture to json format.
  64546. */
  64547. serialize(): any;
  64548. }
  64549. }
  64550. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64552. import { Scene } from "babylonjs/scene";
  64553. import { Nullable } from "babylonjs/types";
  64554. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64555. /**
  64556. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64557. */
  64558. export class EquiRectangularCubeTexture extends BaseTexture {
  64559. /** The six faces of the cube. */
  64560. private static _FacesMapping;
  64561. private _noMipmap;
  64562. private _onLoad;
  64563. private _onError;
  64564. /** The size of the cubemap. */
  64565. private _size;
  64566. /** The buffer of the image. */
  64567. private _buffer;
  64568. /** The width of the input image. */
  64569. private _width;
  64570. /** The height of the input image. */
  64571. private _height;
  64572. /** The URL to the image. */
  64573. url: string;
  64574. /**
  64575. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64576. * @param url The location of the image
  64577. * @param scene The scene the texture will be used in
  64578. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64579. * @param noMipmap Forces to not generate the mipmap if true
  64580. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64581. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64582. * @param onLoad — defines a callback called when texture is loaded
  64583. * @param onError — defines a callback called if there is an error
  64584. */
  64585. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64586. /**
  64587. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64588. */
  64589. private loadImage;
  64590. /**
  64591. * Convert the image buffer into a cubemap and create a CubeTexture.
  64592. */
  64593. private loadTexture;
  64594. /**
  64595. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64596. * @param buffer The ArrayBuffer that should be converted.
  64597. * @returns The buffer as Float32Array.
  64598. */
  64599. private getFloat32ArrayFromArrayBuffer;
  64600. /**
  64601. * Get the current class name of the texture useful for serialization or dynamic coding.
  64602. * @returns "EquiRectangularCubeTexture"
  64603. */
  64604. getClassName(): string;
  64605. /**
  64606. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64607. * @returns A clone of the current EquiRectangularCubeTexture.
  64608. */
  64609. clone(): EquiRectangularCubeTexture;
  64610. }
  64611. }
  64612. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64613. import { Nullable } from "babylonjs/types";
  64614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64615. import { Matrix } from "babylonjs/Maths/math.vector";
  64616. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64617. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64618. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64619. import { Scene } from "babylonjs/scene";
  64620. /**
  64621. * Defines the options related to the creation of an HtmlElementTexture
  64622. */
  64623. export interface IHtmlElementTextureOptions {
  64624. /**
  64625. * Defines wether mip maps should be created or not.
  64626. */
  64627. generateMipMaps?: boolean;
  64628. /**
  64629. * Defines the sampling mode of the texture.
  64630. */
  64631. samplingMode?: number;
  64632. /**
  64633. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64634. */
  64635. engine: Nullable<ThinEngine>;
  64636. /**
  64637. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64638. */
  64639. scene: Nullable<Scene>;
  64640. }
  64641. /**
  64642. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64643. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64644. * is automatically managed.
  64645. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64646. * in your application.
  64647. *
  64648. * As the update is not automatic, you need to call them manually.
  64649. */
  64650. export class HtmlElementTexture extends BaseTexture {
  64651. /**
  64652. * The texture URL.
  64653. */
  64654. element: HTMLVideoElement | HTMLCanvasElement;
  64655. private static readonly DefaultOptions;
  64656. private _textureMatrix;
  64657. private _isVideo;
  64658. private _generateMipMaps;
  64659. private _samplingMode;
  64660. /**
  64661. * Instantiates a HtmlElementTexture from the following parameters.
  64662. *
  64663. * @param name Defines the name of the texture
  64664. * @param element Defines the video or canvas the texture is filled with
  64665. * @param options Defines the other none mandatory texture creation options
  64666. */
  64667. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64668. private _createInternalTexture;
  64669. /**
  64670. * Returns the texture matrix used in most of the material.
  64671. */
  64672. getTextureMatrix(): Matrix;
  64673. /**
  64674. * Updates the content of the texture.
  64675. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64676. */
  64677. update(invertY?: Nullable<boolean>): void;
  64678. }
  64679. }
  64680. declare module "babylonjs/Misc/tga" {
  64681. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64682. /**
  64683. * Based on jsTGALoader - Javascript loader for TGA file
  64684. * By Vincent Thibault
  64685. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64686. */
  64687. export class TGATools {
  64688. private static _TYPE_INDEXED;
  64689. private static _TYPE_RGB;
  64690. private static _TYPE_GREY;
  64691. private static _TYPE_RLE_INDEXED;
  64692. private static _TYPE_RLE_RGB;
  64693. private static _TYPE_RLE_GREY;
  64694. private static _ORIGIN_MASK;
  64695. private static _ORIGIN_SHIFT;
  64696. private static _ORIGIN_BL;
  64697. private static _ORIGIN_BR;
  64698. private static _ORIGIN_UL;
  64699. private static _ORIGIN_UR;
  64700. /**
  64701. * Gets the header of a TGA file
  64702. * @param data defines the TGA data
  64703. * @returns the header
  64704. */
  64705. static GetTGAHeader(data: Uint8Array): any;
  64706. /**
  64707. * Uploads TGA content to a Babylon Texture
  64708. * @hidden
  64709. */
  64710. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64711. /** @hidden */
  64712. 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;
  64713. /** @hidden */
  64714. 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;
  64715. /** @hidden */
  64716. 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;
  64717. /** @hidden */
  64718. 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;
  64719. /** @hidden */
  64720. 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;
  64721. /** @hidden */
  64722. 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;
  64723. }
  64724. }
  64725. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64726. import { Nullable } from "babylonjs/types";
  64727. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64728. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64729. /**
  64730. * Implementation of the TGA Texture Loader.
  64731. * @hidden
  64732. */
  64733. export class _TGATextureLoader implements IInternalTextureLoader {
  64734. /**
  64735. * Defines wether the loader supports cascade loading the different faces.
  64736. */
  64737. readonly supportCascades: boolean;
  64738. /**
  64739. * This returns if the loader support the current file information.
  64740. * @param extension defines the file extension of the file being loaded
  64741. * @returns true if the loader can load the specified file
  64742. */
  64743. canLoad(extension: string): boolean;
  64744. /**
  64745. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64746. * @param data contains the texture data
  64747. * @param texture defines the BabylonJS internal texture
  64748. * @param createPolynomials will be true if polynomials have been requested
  64749. * @param onLoad defines the callback to trigger once the texture is ready
  64750. * @param onError defines the callback to trigger in case of error
  64751. */
  64752. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64753. /**
  64754. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64755. * @param data contains the texture data
  64756. * @param texture defines the BabylonJS internal texture
  64757. * @param callback defines the method to call once ready to upload
  64758. */
  64759. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64760. }
  64761. }
  64762. declare module "babylonjs/Misc/basis" {
  64763. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64764. /**
  64765. * Info about the .basis files
  64766. */
  64767. class BasisFileInfo {
  64768. /**
  64769. * If the file has alpha
  64770. */
  64771. hasAlpha: boolean;
  64772. /**
  64773. * Info about each image of the basis file
  64774. */
  64775. images: Array<{
  64776. levels: Array<{
  64777. width: number;
  64778. height: number;
  64779. transcodedPixels: ArrayBufferView;
  64780. }>;
  64781. }>;
  64782. }
  64783. /**
  64784. * Result of transcoding a basis file
  64785. */
  64786. class TranscodeResult {
  64787. /**
  64788. * Info about the .basis file
  64789. */
  64790. fileInfo: BasisFileInfo;
  64791. /**
  64792. * Format to use when loading the file
  64793. */
  64794. format: number;
  64795. }
  64796. /**
  64797. * Configuration options for the Basis transcoder
  64798. */
  64799. export class BasisTranscodeConfiguration {
  64800. /**
  64801. * Supported compression formats used to determine the supported output format of the transcoder
  64802. */
  64803. supportedCompressionFormats?: {
  64804. /**
  64805. * etc1 compression format
  64806. */
  64807. etc1?: boolean;
  64808. /**
  64809. * s3tc compression format
  64810. */
  64811. s3tc?: boolean;
  64812. /**
  64813. * pvrtc compression format
  64814. */
  64815. pvrtc?: boolean;
  64816. /**
  64817. * etc2 compression format
  64818. */
  64819. etc2?: boolean;
  64820. };
  64821. /**
  64822. * If mipmap levels should be loaded for transcoded images (Default: true)
  64823. */
  64824. loadMipmapLevels?: boolean;
  64825. /**
  64826. * Index of a single image to load (Default: all images)
  64827. */
  64828. loadSingleImage?: number;
  64829. }
  64830. /**
  64831. * Used to load .Basis files
  64832. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64833. */
  64834. export class BasisTools {
  64835. private static _IgnoreSupportedFormats;
  64836. /**
  64837. * URL to use when loading the basis transcoder
  64838. */
  64839. static JSModuleURL: string;
  64840. /**
  64841. * URL to use when loading the wasm module for the transcoder
  64842. */
  64843. static WasmModuleURL: string;
  64844. /**
  64845. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64846. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64847. * @returns internal format corresponding to the Basis format
  64848. */
  64849. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64850. private static _WorkerPromise;
  64851. private static _Worker;
  64852. private static _actionId;
  64853. private static _CreateWorkerAsync;
  64854. /**
  64855. * Transcodes a loaded image file to compressed pixel data
  64856. * @param data image data to transcode
  64857. * @param config configuration options for the transcoding
  64858. * @returns a promise resulting in the transcoded image
  64859. */
  64860. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64861. /**
  64862. * Loads a texture from the transcode result
  64863. * @param texture texture load to
  64864. * @param transcodeResult the result of transcoding the basis file to load from
  64865. */
  64866. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64867. }
  64868. }
  64869. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64870. import { Nullable } from "babylonjs/types";
  64871. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64872. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64873. /**
  64874. * Loader for .basis file format
  64875. */
  64876. export class _BasisTextureLoader implements IInternalTextureLoader {
  64877. /**
  64878. * Defines whether the loader supports cascade loading the different faces.
  64879. */
  64880. readonly supportCascades: boolean;
  64881. /**
  64882. * This returns if the loader support the current file information.
  64883. * @param extension defines the file extension of the file being loaded
  64884. * @returns true if the loader can load the specified file
  64885. */
  64886. canLoad(extension: string): boolean;
  64887. /**
  64888. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64889. * @param data contains the texture data
  64890. * @param texture defines the BabylonJS internal texture
  64891. * @param createPolynomials will be true if polynomials have been requested
  64892. * @param onLoad defines the callback to trigger once the texture is ready
  64893. * @param onError defines the callback to trigger in case of error
  64894. */
  64895. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64896. /**
  64897. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64898. * @param data contains the texture data
  64899. * @param texture defines the BabylonJS internal texture
  64900. * @param callback defines the method to call once ready to upload
  64901. */
  64902. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64903. }
  64904. }
  64905. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64906. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64907. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64908. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64909. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64910. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64911. }
  64912. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64913. import { Vector2 } from "babylonjs/Maths/math.vector";
  64914. /**
  64915. * Defines the basic options interface of a TexturePacker Frame
  64916. */
  64917. export interface ITexturePackerFrame {
  64918. /**
  64919. * The frame ID
  64920. */
  64921. id: number;
  64922. /**
  64923. * The frames Scale
  64924. */
  64925. scale: Vector2;
  64926. /**
  64927. * The Frames offset
  64928. */
  64929. offset: Vector2;
  64930. }
  64931. /**
  64932. * This is a support class for frame Data on texture packer sets.
  64933. */
  64934. export class TexturePackerFrame implements ITexturePackerFrame {
  64935. /**
  64936. * The frame ID
  64937. */
  64938. id: number;
  64939. /**
  64940. * The frames Scale
  64941. */
  64942. scale: Vector2;
  64943. /**
  64944. * The Frames offset
  64945. */
  64946. offset: Vector2;
  64947. /**
  64948. * Initializes a texture package frame.
  64949. * @param id The numerical frame identifier
  64950. * @param scale Scalar Vector2 for UV frame
  64951. * @param offset Vector2 for the frame position in UV units.
  64952. * @returns TexturePackerFrame
  64953. */
  64954. constructor(id: number, scale: Vector2, offset: Vector2);
  64955. }
  64956. }
  64957. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64959. import { Scene } from "babylonjs/scene";
  64960. import { Nullable } from "babylonjs/types";
  64961. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64962. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64963. /**
  64964. * Defines the basic options interface of a TexturePacker
  64965. */
  64966. export interface ITexturePackerOptions {
  64967. /**
  64968. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64969. */
  64970. map?: string[];
  64971. /**
  64972. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64973. */
  64974. uvsIn?: string;
  64975. /**
  64976. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64977. */
  64978. uvsOut?: string;
  64979. /**
  64980. * number representing the layout style. Defaults to LAYOUT_STRIP
  64981. */
  64982. layout?: number;
  64983. /**
  64984. * number of columns if using custom column count layout(2). This defaults to 4.
  64985. */
  64986. colnum?: number;
  64987. /**
  64988. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64989. */
  64990. updateInputMeshes?: boolean;
  64991. /**
  64992. * boolean flag to dispose all the source textures. Defaults to true.
  64993. */
  64994. disposeSources?: boolean;
  64995. /**
  64996. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64997. */
  64998. fillBlanks?: boolean;
  64999. /**
  65000. * string value representing the context fill style color. Defaults to 'black'.
  65001. */
  65002. customFillColor?: string;
  65003. /**
  65004. * Width and Height Value of each Frame in the TexturePacker Sets
  65005. */
  65006. frameSize?: number;
  65007. /**
  65008. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65009. */
  65010. paddingRatio?: number;
  65011. /**
  65012. * Number that declares the fill method for the padding gutter.
  65013. */
  65014. paddingMode?: number;
  65015. /**
  65016. * If in SUBUV_COLOR padding mode what color to use.
  65017. */
  65018. paddingColor?: Color3 | Color4;
  65019. }
  65020. /**
  65021. * Defines the basic interface of a TexturePacker JSON File
  65022. */
  65023. export interface ITexturePackerJSON {
  65024. /**
  65025. * The frame ID
  65026. */
  65027. name: string;
  65028. /**
  65029. * The base64 channel data
  65030. */
  65031. sets: any;
  65032. /**
  65033. * The options of the Packer
  65034. */
  65035. options: ITexturePackerOptions;
  65036. /**
  65037. * The frame data of the Packer
  65038. */
  65039. frames: Array<number>;
  65040. }
  65041. /**
  65042. * This is a support class that generates a series of packed texture sets.
  65043. * @see https://doc.babylonjs.com/babylon101/materials
  65044. */
  65045. export class TexturePacker {
  65046. /** Packer Layout Constant 0 */
  65047. static readonly LAYOUT_STRIP: number;
  65048. /** Packer Layout Constant 1 */
  65049. static readonly LAYOUT_POWER2: number;
  65050. /** Packer Layout Constant 2 */
  65051. static readonly LAYOUT_COLNUM: number;
  65052. /** Packer Layout Constant 0 */
  65053. static readonly SUBUV_WRAP: number;
  65054. /** Packer Layout Constant 1 */
  65055. static readonly SUBUV_EXTEND: number;
  65056. /** Packer Layout Constant 2 */
  65057. static readonly SUBUV_COLOR: number;
  65058. /** The Name of the Texture Package */
  65059. name: string;
  65060. /** The scene scope of the TexturePacker */
  65061. scene: Scene;
  65062. /** The Meshes to target */
  65063. meshes: AbstractMesh[];
  65064. /** Arguments passed with the Constructor */
  65065. options: ITexturePackerOptions;
  65066. /** The promise that is started upon initialization */
  65067. promise: Nullable<Promise<TexturePacker | string>>;
  65068. /** The Container object for the channel sets that are generated */
  65069. sets: object;
  65070. /** The Container array for the frames that are generated */
  65071. frames: TexturePackerFrame[];
  65072. /** The expected number of textures the system is parsing. */
  65073. private _expecting;
  65074. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65075. private _paddingValue;
  65076. /**
  65077. * Initializes a texture package series from an array of meshes or a single mesh.
  65078. * @param name The name of the package
  65079. * @param meshes The target meshes to compose the package from
  65080. * @param options The arguments that texture packer should follow while building.
  65081. * @param scene The scene which the textures are scoped to.
  65082. * @returns TexturePacker
  65083. */
  65084. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65085. /**
  65086. * Starts the package process
  65087. * @param resolve The promises resolution function
  65088. * @returns TexturePacker
  65089. */
  65090. private _createFrames;
  65091. /**
  65092. * Calculates the Size of the Channel Sets
  65093. * @returns Vector2
  65094. */
  65095. private _calculateSize;
  65096. /**
  65097. * Calculates the UV data for the frames.
  65098. * @param baseSize the base frameSize
  65099. * @param padding the base frame padding
  65100. * @param dtSize size of the Dynamic Texture for that channel
  65101. * @param dtUnits is 1/dtSize
  65102. * @param update flag to update the input meshes
  65103. */
  65104. private _calculateMeshUVFrames;
  65105. /**
  65106. * Calculates the frames Offset.
  65107. * @param index of the frame
  65108. * @returns Vector2
  65109. */
  65110. private _getFrameOffset;
  65111. /**
  65112. * Updates a Mesh to the frame data
  65113. * @param mesh that is the target
  65114. * @param frameID or the frame index
  65115. */
  65116. private _updateMeshUV;
  65117. /**
  65118. * Updates a Meshes materials to use the texture packer channels
  65119. * @param m is the mesh to target
  65120. * @param force all channels on the packer to be set.
  65121. */
  65122. private _updateTextureReferences;
  65123. /**
  65124. * Public method to set a Mesh to a frame
  65125. * @param m that is the target
  65126. * @param frameID or the frame index
  65127. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65128. */
  65129. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65130. /**
  65131. * Starts the async promise to compile the texture packer.
  65132. * @returns Promise<void>
  65133. */
  65134. processAsync(): Promise<void>;
  65135. /**
  65136. * Disposes all textures associated with this packer
  65137. */
  65138. dispose(): void;
  65139. /**
  65140. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65141. * @param imageType is the image type to use.
  65142. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65143. */
  65144. download(imageType?: string, quality?: number): void;
  65145. /**
  65146. * Public method to load a texturePacker JSON file.
  65147. * @param data of the JSON file in string format.
  65148. */
  65149. updateFromJSON(data: string): void;
  65150. }
  65151. }
  65152. declare module "babylonjs/Materials/Textures/Packer/index" {
  65153. export * from "babylonjs/Materials/Textures/Packer/packer";
  65154. export * from "babylonjs/Materials/Textures/Packer/frame";
  65155. }
  65156. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65157. import { Scene } from "babylonjs/scene";
  65158. import { Texture } from "babylonjs/Materials/Textures/texture";
  65159. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65160. /**
  65161. * 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.
  65162. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65163. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65164. */
  65165. export class CustomProceduralTexture extends ProceduralTexture {
  65166. private _animate;
  65167. private _time;
  65168. private _config;
  65169. private _texturePath;
  65170. /**
  65171. * Instantiates a new Custom Procedural Texture.
  65172. * 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.
  65173. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65174. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65175. * @param name Define the name of the texture
  65176. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65177. * @param size Define the size of the texture to create
  65178. * @param scene Define the scene the texture belongs to
  65179. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65180. * @param generateMipMaps Define if the texture should creates mip maps or not
  65181. */
  65182. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65183. private _loadJson;
  65184. /**
  65185. * Is the texture ready to be used ? (rendered at least once)
  65186. * @returns true if ready, otherwise, false.
  65187. */
  65188. isReady(): boolean;
  65189. /**
  65190. * Render the texture to its associated render target.
  65191. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65192. */
  65193. render(useCameraPostProcess?: boolean): void;
  65194. /**
  65195. * Update the list of dependant textures samplers in the shader.
  65196. */
  65197. updateTextures(): void;
  65198. /**
  65199. * Update the uniform values of the procedural texture in the shader.
  65200. */
  65201. updateShaderUniforms(): void;
  65202. /**
  65203. * Define if the texture animates or not.
  65204. */
  65205. get animate(): boolean;
  65206. set animate(value: boolean);
  65207. }
  65208. }
  65209. declare module "babylonjs/Shaders/noise.fragment" {
  65210. /** @hidden */
  65211. export var noisePixelShader: {
  65212. name: string;
  65213. shader: string;
  65214. };
  65215. }
  65216. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65217. import { Nullable } from "babylonjs/types";
  65218. import { Scene } from "babylonjs/scene";
  65219. import { Texture } from "babylonjs/Materials/Textures/texture";
  65220. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65221. import "babylonjs/Shaders/noise.fragment";
  65222. /**
  65223. * Class used to generate noise procedural textures
  65224. */
  65225. export class NoiseProceduralTexture extends ProceduralTexture {
  65226. /** Gets or sets the start time (default is 0) */
  65227. time: number;
  65228. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65229. brightness: number;
  65230. /** Defines the number of octaves to process */
  65231. octaves: number;
  65232. /** Defines the level of persistence (0.8 by default) */
  65233. persistence: number;
  65234. /** Gets or sets animation speed factor (default is 1) */
  65235. animationSpeedFactor: number;
  65236. /**
  65237. * Creates a new NoiseProceduralTexture
  65238. * @param name defines the name fo the texture
  65239. * @param size defines the size of the texture (default is 256)
  65240. * @param scene defines the hosting scene
  65241. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65242. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65243. */
  65244. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65245. private _updateShaderUniforms;
  65246. protected _getDefines(): string;
  65247. /** Generate the current state of the procedural texture */
  65248. render(useCameraPostProcess?: boolean): void;
  65249. /**
  65250. * Serializes this noise procedural texture
  65251. * @returns a serialized noise procedural texture object
  65252. */
  65253. serialize(): any;
  65254. /**
  65255. * Clone the texture.
  65256. * @returns the cloned texture
  65257. */
  65258. clone(): NoiseProceduralTexture;
  65259. /**
  65260. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65261. * @param parsedTexture defines parsed texture data
  65262. * @param scene defines the current scene
  65263. * @param rootUrl defines the root URL containing noise procedural texture information
  65264. * @returns a parsed NoiseProceduralTexture
  65265. */
  65266. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65267. }
  65268. }
  65269. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65270. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65271. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65272. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65273. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65274. }
  65275. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65276. import { Nullable } from "babylonjs/types";
  65277. import { Scene } from "babylonjs/scene";
  65278. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65279. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65280. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65281. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65282. /**
  65283. * Raw cube texture where the raw buffers are passed in
  65284. */
  65285. export class RawCubeTexture extends CubeTexture {
  65286. /**
  65287. * Creates a cube texture where the raw buffers are passed in.
  65288. * @param scene defines the scene the texture is attached to
  65289. * @param data defines the array of data to use to create each face
  65290. * @param size defines the size of the textures
  65291. * @param format defines the format of the data
  65292. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65293. * @param generateMipMaps defines if the engine should generate the mip levels
  65294. * @param invertY defines if data must be stored with Y axis inverted
  65295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65296. * @param compression defines the compression used (null by default)
  65297. */
  65298. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65299. /**
  65300. * Updates the raw cube texture.
  65301. * @param data defines the data to store
  65302. * @param format defines the data format
  65303. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65304. * @param invertY defines if data must be stored with Y axis inverted
  65305. * @param compression defines the compression used (null by default)
  65306. * @param level defines which level of the texture to update
  65307. */
  65308. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65309. /**
  65310. * Updates a raw cube texture with RGBD encoded data.
  65311. * @param data defines the array of data [mipmap][face] to use to create each face
  65312. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65313. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65314. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65315. * @returns a promsie that resolves when the operation is complete
  65316. */
  65317. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65318. /**
  65319. * Clones the raw cube texture.
  65320. * @return a new cube texture
  65321. */
  65322. clone(): CubeTexture;
  65323. /** @hidden */
  65324. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65325. }
  65326. }
  65327. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65328. import { Scene } from "babylonjs/scene";
  65329. import { Texture } from "babylonjs/Materials/Textures/texture";
  65330. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65331. /**
  65332. * Class used to store 2D array textures containing user data
  65333. */
  65334. export class RawTexture2DArray extends Texture {
  65335. /** Gets or sets the texture format to use */
  65336. format: number;
  65337. /**
  65338. * Create a new RawTexture2DArray
  65339. * @param data defines the data of the texture
  65340. * @param width defines the width of the texture
  65341. * @param height defines the height of the texture
  65342. * @param depth defines the number of layers of the texture
  65343. * @param format defines the texture format to use
  65344. * @param scene defines the hosting scene
  65345. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65346. * @param invertY defines if texture must be stored with Y axis inverted
  65347. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65348. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65349. */
  65350. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65351. /** Gets or sets the texture format to use */
  65352. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65353. /**
  65354. * Update the texture with new data
  65355. * @param data defines the data to store in the texture
  65356. */
  65357. update(data: ArrayBufferView): void;
  65358. }
  65359. }
  65360. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65361. import { Scene } from "babylonjs/scene";
  65362. import { Texture } from "babylonjs/Materials/Textures/texture";
  65363. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65364. /**
  65365. * Class used to store 3D textures containing user data
  65366. */
  65367. export class RawTexture3D extends Texture {
  65368. /** Gets or sets the texture format to use */
  65369. format: number;
  65370. /**
  65371. * Create a new RawTexture3D
  65372. * @param data defines the data of the texture
  65373. * @param width defines the width of the texture
  65374. * @param height defines the height of the texture
  65375. * @param depth defines the depth of the texture
  65376. * @param format defines the texture format to use
  65377. * @param scene defines the hosting scene
  65378. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65379. * @param invertY defines if texture must be stored with Y axis inverted
  65380. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65381. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65382. */
  65383. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65384. /** Gets or sets the texture format to use */
  65385. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65386. /**
  65387. * Update the texture with new data
  65388. * @param data defines the data to store in the texture
  65389. */
  65390. update(data: ArrayBufferView): void;
  65391. }
  65392. }
  65393. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65394. import { Scene } from "babylonjs/scene";
  65395. import { Plane } from "babylonjs/Maths/math.plane";
  65396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65397. /**
  65398. * Creates a refraction texture used by refraction channel of the standard material.
  65399. * It is like a mirror but to see through a material.
  65400. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65401. */
  65402. export class RefractionTexture extends RenderTargetTexture {
  65403. /**
  65404. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65405. * 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.
  65406. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65407. */
  65408. refractionPlane: Plane;
  65409. /**
  65410. * Define how deep under the surface we should see.
  65411. */
  65412. depth: number;
  65413. /**
  65414. * Creates a refraction texture used by refraction channel of the standard material.
  65415. * It is like a mirror but to see through a material.
  65416. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65417. * @param name Define the texture name
  65418. * @param size Define the size of the underlying texture
  65419. * @param scene Define the scene the refraction belongs to
  65420. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65421. */
  65422. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65423. /**
  65424. * Clone the refraction texture.
  65425. * @returns the cloned texture
  65426. */
  65427. clone(): RefractionTexture;
  65428. /**
  65429. * Serialize the texture to a JSON representation you could use in Parse later on
  65430. * @returns the serialized JSON representation
  65431. */
  65432. serialize(): any;
  65433. }
  65434. }
  65435. declare module "babylonjs/Materials/Textures/index" {
  65436. export * from "babylonjs/Materials/Textures/baseTexture";
  65437. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65438. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65439. export * from "babylonjs/Materials/Textures/cubeTexture";
  65440. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65441. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65442. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65443. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65444. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65445. export * from "babylonjs/Materials/Textures/internalTexture";
  65446. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65447. export * from "babylonjs/Materials/Textures/Loaders/index";
  65448. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65449. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65450. export * from "babylonjs/Materials/Textures/Packer/index";
  65451. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65452. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65453. export * from "babylonjs/Materials/Textures/rawTexture";
  65454. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65455. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65456. export * from "babylonjs/Materials/Textures/refractionTexture";
  65457. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65458. export * from "babylonjs/Materials/Textures/texture";
  65459. export * from "babylonjs/Materials/Textures/videoTexture";
  65460. }
  65461. declare module "babylonjs/Materials/Node/Enums/index" {
  65462. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65463. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65464. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65465. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65466. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65467. }
  65468. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65472. import { Mesh } from "babylonjs/Meshes/mesh";
  65473. import { Effect } from "babylonjs/Materials/effect";
  65474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65475. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65476. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65477. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65478. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65479. /**
  65480. * Block used to add support for vertex skinning (bones)
  65481. */
  65482. export class BonesBlock extends NodeMaterialBlock {
  65483. /**
  65484. * Creates a new BonesBlock
  65485. * @param name defines the block name
  65486. */
  65487. constructor(name: string);
  65488. /**
  65489. * Initialize the block and prepare the context for build
  65490. * @param state defines the state that will be used for the build
  65491. */
  65492. initialize(state: NodeMaterialBuildState): void;
  65493. /**
  65494. * Gets the current class name
  65495. * @returns the class name
  65496. */
  65497. getClassName(): string;
  65498. /**
  65499. * Gets the matrix indices input component
  65500. */
  65501. get matricesIndices(): NodeMaterialConnectionPoint;
  65502. /**
  65503. * Gets the matrix weights input component
  65504. */
  65505. get matricesWeights(): NodeMaterialConnectionPoint;
  65506. /**
  65507. * Gets the extra matrix indices input component
  65508. */
  65509. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65510. /**
  65511. * Gets the extra matrix weights input component
  65512. */
  65513. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65514. /**
  65515. * Gets the world input component
  65516. */
  65517. get world(): NodeMaterialConnectionPoint;
  65518. /**
  65519. * Gets the output component
  65520. */
  65521. get output(): NodeMaterialConnectionPoint;
  65522. autoConfigure(material: NodeMaterial): void;
  65523. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65524. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65526. protected _buildBlock(state: NodeMaterialBuildState): this;
  65527. }
  65528. }
  65529. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65532. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65534. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65535. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65536. /**
  65537. * Block used to add support for instances
  65538. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65539. */
  65540. export class InstancesBlock extends NodeMaterialBlock {
  65541. /**
  65542. * Creates a new InstancesBlock
  65543. * @param name defines the block name
  65544. */
  65545. constructor(name: string);
  65546. /**
  65547. * Gets the current class name
  65548. * @returns the class name
  65549. */
  65550. getClassName(): string;
  65551. /**
  65552. * Gets the first world row input component
  65553. */
  65554. get world0(): NodeMaterialConnectionPoint;
  65555. /**
  65556. * Gets the second world row input component
  65557. */
  65558. get world1(): NodeMaterialConnectionPoint;
  65559. /**
  65560. * Gets the third world row input component
  65561. */
  65562. get world2(): NodeMaterialConnectionPoint;
  65563. /**
  65564. * Gets the forth world row input component
  65565. */
  65566. get world3(): NodeMaterialConnectionPoint;
  65567. /**
  65568. * Gets the world input component
  65569. */
  65570. get world(): NodeMaterialConnectionPoint;
  65571. /**
  65572. * Gets the output component
  65573. */
  65574. get output(): NodeMaterialConnectionPoint;
  65575. /**
  65576. * Gets the isntanceID component
  65577. */
  65578. get instanceID(): NodeMaterialConnectionPoint;
  65579. autoConfigure(material: NodeMaterial): void;
  65580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65581. protected _buildBlock(state: NodeMaterialBuildState): this;
  65582. }
  65583. }
  65584. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65589. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65590. import { Effect } from "babylonjs/Materials/effect";
  65591. import { Mesh } from "babylonjs/Meshes/mesh";
  65592. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65593. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65594. /**
  65595. * Block used to add morph targets support to vertex shader
  65596. */
  65597. export class MorphTargetsBlock extends NodeMaterialBlock {
  65598. private _repeatableContentAnchor;
  65599. /**
  65600. * Create a new MorphTargetsBlock
  65601. * @param name defines the block name
  65602. */
  65603. constructor(name: string);
  65604. /**
  65605. * Gets the current class name
  65606. * @returns the class name
  65607. */
  65608. getClassName(): string;
  65609. /**
  65610. * Gets the position input component
  65611. */
  65612. get position(): NodeMaterialConnectionPoint;
  65613. /**
  65614. * Gets the normal input component
  65615. */
  65616. get normal(): NodeMaterialConnectionPoint;
  65617. /**
  65618. * Gets the tangent input component
  65619. */
  65620. get tangent(): NodeMaterialConnectionPoint;
  65621. /**
  65622. * Gets the tangent input component
  65623. */
  65624. get uv(): NodeMaterialConnectionPoint;
  65625. /**
  65626. * Gets the position output component
  65627. */
  65628. get positionOutput(): NodeMaterialConnectionPoint;
  65629. /**
  65630. * Gets the normal output component
  65631. */
  65632. get normalOutput(): NodeMaterialConnectionPoint;
  65633. /**
  65634. * Gets the tangent output component
  65635. */
  65636. get tangentOutput(): NodeMaterialConnectionPoint;
  65637. /**
  65638. * Gets the tangent output component
  65639. */
  65640. get uvOutput(): NodeMaterialConnectionPoint;
  65641. initialize(state: NodeMaterialBuildState): void;
  65642. autoConfigure(material: NodeMaterial): void;
  65643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65644. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65645. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65646. protected _buildBlock(state: NodeMaterialBuildState): this;
  65647. }
  65648. }
  65649. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65653. import { Nullable } from "babylonjs/types";
  65654. import { Scene } from "babylonjs/scene";
  65655. import { Effect } from "babylonjs/Materials/effect";
  65656. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65657. import { Mesh } from "babylonjs/Meshes/mesh";
  65658. import { Light } from "babylonjs/Lights/light";
  65659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65660. /**
  65661. * Block used to get data information from a light
  65662. */
  65663. export class LightInformationBlock extends NodeMaterialBlock {
  65664. private _lightDataUniformName;
  65665. private _lightColorUniformName;
  65666. private _lightTypeDefineName;
  65667. /**
  65668. * Gets or sets the light associated with this block
  65669. */
  65670. light: Nullable<Light>;
  65671. /**
  65672. * Creates a new LightInformationBlock
  65673. * @param name defines the block name
  65674. */
  65675. constructor(name: string);
  65676. /**
  65677. * Gets the current class name
  65678. * @returns the class name
  65679. */
  65680. getClassName(): string;
  65681. /**
  65682. * Gets the world position input component
  65683. */
  65684. get worldPosition(): NodeMaterialConnectionPoint;
  65685. /**
  65686. * Gets the direction output component
  65687. */
  65688. get direction(): NodeMaterialConnectionPoint;
  65689. /**
  65690. * Gets the direction output component
  65691. */
  65692. get color(): NodeMaterialConnectionPoint;
  65693. /**
  65694. * Gets the direction output component
  65695. */
  65696. get intensity(): NodeMaterialConnectionPoint;
  65697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65698. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65699. protected _buildBlock(state: NodeMaterialBuildState): this;
  65700. serialize(): any;
  65701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65702. }
  65703. }
  65704. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65705. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65706. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65707. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65708. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65709. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65710. }
  65711. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65716. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65717. import { Effect } from "babylonjs/Materials/effect";
  65718. import { Mesh } from "babylonjs/Meshes/mesh";
  65719. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65720. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65721. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65722. /**
  65723. * Block used to add image processing support to fragment shader
  65724. */
  65725. export class ImageProcessingBlock extends NodeMaterialBlock {
  65726. /**
  65727. * Create a new ImageProcessingBlock
  65728. * @param name defines the block name
  65729. */
  65730. constructor(name: string);
  65731. /**
  65732. * Gets the current class name
  65733. * @returns the class name
  65734. */
  65735. getClassName(): string;
  65736. /**
  65737. * Gets the color input component
  65738. */
  65739. get color(): NodeMaterialConnectionPoint;
  65740. /**
  65741. * Gets the output component
  65742. */
  65743. get output(): NodeMaterialConnectionPoint;
  65744. /**
  65745. * Initialize the block and prepare the context for build
  65746. * @param state defines the state that will be used for the build
  65747. */
  65748. initialize(state: NodeMaterialBuildState): void;
  65749. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65750. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65751. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65752. protected _buildBlock(state: NodeMaterialBuildState): this;
  65753. }
  65754. }
  65755. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65759. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65761. import { Effect } from "babylonjs/Materials/effect";
  65762. import { Mesh } from "babylonjs/Meshes/mesh";
  65763. import { Scene } from "babylonjs/scene";
  65764. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65765. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65766. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65767. /**
  65768. * Block used to pertub normals based on a normal map
  65769. */
  65770. export class PerturbNormalBlock extends NodeMaterialBlock {
  65771. private _tangentSpaceParameterName;
  65772. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65773. invertX: boolean;
  65774. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65775. invertY: boolean;
  65776. /**
  65777. * Create a new PerturbNormalBlock
  65778. * @param name defines the block name
  65779. */
  65780. constructor(name: string);
  65781. /**
  65782. * Gets the current class name
  65783. * @returns the class name
  65784. */
  65785. getClassName(): string;
  65786. /**
  65787. * Gets the world position input component
  65788. */
  65789. get worldPosition(): NodeMaterialConnectionPoint;
  65790. /**
  65791. * Gets the world normal input component
  65792. */
  65793. get worldNormal(): NodeMaterialConnectionPoint;
  65794. /**
  65795. * Gets the world tangent input component
  65796. */
  65797. get worldTangent(): NodeMaterialConnectionPoint;
  65798. /**
  65799. * Gets the uv input component
  65800. */
  65801. get uv(): NodeMaterialConnectionPoint;
  65802. /**
  65803. * Gets the normal map color input component
  65804. */
  65805. get normalMapColor(): NodeMaterialConnectionPoint;
  65806. /**
  65807. * Gets the strength input component
  65808. */
  65809. get strength(): NodeMaterialConnectionPoint;
  65810. /**
  65811. * Gets the output component
  65812. */
  65813. get output(): NodeMaterialConnectionPoint;
  65814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65815. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65816. autoConfigure(material: NodeMaterial): void;
  65817. protected _buildBlock(state: NodeMaterialBuildState): this;
  65818. protected _dumpPropertiesCode(): string;
  65819. serialize(): any;
  65820. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65821. }
  65822. }
  65823. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65827. /**
  65828. * Block used to discard a pixel if a value is smaller than a cutoff
  65829. */
  65830. export class DiscardBlock extends NodeMaterialBlock {
  65831. /**
  65832. * Create a new DiscardBlock
  65833. * @param name defines the block name
  65834. */
  65835. constructor(name: string);
  65836. /**
  65837. * Gets the current class name
  65838. * @returns the class name
  65839. */
  65840. getClassName(): string;
  65841. /**
  65842. * Gets the color input component
  65843. */
  65844. get value(): NodeMaterialConnectionPoint;
  65845. /**
  65846. * Gets the cutoff input component
  65847. */
  65848. get cutoff(): NodeMaterialConnectionPoint;
  65849. protected _buildBlock(state: NodeMaterialBuildState): this;
  65850. }
  65851. }
  65852. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65856. /**
  65857. * Block used to test if the fragment shader is front facing
  65858. */
  65859. export class FrontFacingBlock extends NodeMaterialBlock {
  65860. /**
  65861. * Creates a new FrontFacingBlock
  65862. * @param name defines the block name
  65863. */
  65864. constructor(name: string);
  65865. /**
  65866. * Gets the current class name
  65867. * @returns the class name
  65868. */
  65869. getClassName(): string;
  65870. /**
  65871. * Gets the output component
  65872. */
  65873. get output(): NodeMaterialConnectionPoint;
  65874. protected _buildBlock(state: NodeMaterialBuildState): this;
  65875. }
  65876. }
  65877. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65881. /**
  65882. * Block used to get the derivative value on x and y of a given input
  65883. */
  65884. export class DerivativeBlock extends NodeMaterialBlock {
  65885. /**
  65886. * Create a new DerivativeBlock
  65887. * @param name defines the block name
  65888. */
  65889. constructor(name: string);
  65890. /**
  65891. * Gets the current class name
  65892. * @returns the class name
  65893. */
  65894. getClassName(): string;
  65895. /**
  65896. * Gets the input component
  65897. */
  65898. get input(): NodeMaterialConnectionPoint;
  65899. /**
  65900. * Gets the derivative output on x
  65901. */
  65902. get dx(): NodeMaterialConnectionPoint;
  65903. /**
  65904. * Gets the derivative output on y
  65905. */
  65906. get dy(): NodeMaterialConnectionPoint;
  65907. protected _buildBlock(state: NodeMaterialBuildState): this;
  65908. }
  65909. }
  65910. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65914. /**
  65915. * Block used to make gl_FragCoord available
  65916. */
  65917. export class FragCoordBlock extends NodeMaterialBlock {
  65918. /**
  65919. * Creates a new FragCoordBlock
  65920. * @param name defines the block name
  65921. */
  65922. constructor(name: string);
  65923. /**
  65924. * Gets the current class name
  65925. * @returns the class name
  65926. */
  65927. getClassName(): string;
  65928. /**
  65929. * Gets the xy component
  65930. */
  65931. get xy(): NodeMaterialConnectionPoint;
  65932. /**
  65933. * Gets the xyz component
  65934. */
  65935. get xyz(): NodeMaterialConnectionPoint;
  65936. /**
  65937. * Gets the xyzw component
  65938. */
  65939. get xyzw(): NodeMaterialConnectionPoint;
  65940. /**
  65941. * Gets the x component
  65942. */
  65943. get x(): NodeMaterialConnectionPoint;
  65944. /**
  65945. * Gets the y component
  65946. */
  65947. get y(): NodeMaterialConnectionPoint;
  65948. /**
  65949. * Gets the z component
  65950. */
  65951. get z(): NodeMaterialConnectionPoint;
  65952. /**
  65953. * Gets the w component
  65954. */
  65955. get output(): NodeMaterialConnectionPoint;
  65956. protected writeOutputs(state: NodeMaterialBuildState): string;
  65957. protected _buildBlock(state: NodeMaterialBuildState): this;
  65958. }
  65959. }
  65960. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65961. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65962. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65963. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65964. import { Effect } from "babylonjs/Materials/effect";
  65965. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65966. import { Mesh } from "babylonjs/Meshes/mesh";
  65967. /**
  65968. * Block used to get the screen sizes
  65969. */
  65970. export class ScreenSizeBlock extends NodeMaterialBlock {
  65971. private _varName;
  65972. private _scene;
  65973. /**
  65974. * Creates a new ScreenSizeBlock
  65975. * @param name defines the block name
  65976. */
  65977. constructor(name: string);
  65978. /**
  65979. * Gets the current class name
  65980. * @returns the class name
  65981. */
  65982. getClassName(): string;
  65983. /**
  65984. * Gets the xy component
  65985. */
  65986. get xy(): NodeMaterialConnectionPoint;
  65987. /**
  65988. * Gets the x component
  65989. */
  65990. get x(): NodeMaterialConnectionPoint;
  65991. /**
  65992. * Gets the y component
  65993. */
  65994. get y(): NodeMaterialConnectionPoint;
  65995. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65996. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65997. protected _buildBlock(state: NodeMaterialBuildState): this;
  65998. }
  65999. }
  66000. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66001. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66002. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66003. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66004. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66005. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66006. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66007. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66008. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66009. }
  66010. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66013. import { Mesh } from "babylonjs/Meshes/mesh";
  66014. import { Effect } from "babylonjs/Materials/effect";
  66015. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66017. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66018. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66019. /**
  66020. * Block used to add support for scene fog
  66021. */
  66022. export class FogBlock extends NodeMaterialBlock {
  66023. private _fogDistanceName;
  66024. private _fogParameters;
  66025. /**
  66026. * Create a new FogBlock
  66027. * @param name defines the block name
  66028. */
  66029. constructor(name: string);
  66030. /**
  66031. * Gets the current class name
  66032. * @returns the class name
  66033. */
  66034. getClassName(): string;
  66035. /**
  66036. * Gets the world position input component
  66037. */
  66038. get worldPosition(): NodeMaterialConnectionPoint;
  66039. /**
  66040. * Gets the view input component
  66041. */
  66042. get view(): NodeMaterialConnectionPoint;
  66043. /**
  66044. * Gets the color input component
  66045. */
  66046. get input(): NodeMaterialConnectionPoint;
  66047. /**
  66048. * Gets the fog color input component
  66049. */
  66050. get fogColor(): NodeMaterialConnectionPoint;
  66051. /**
  66052. * Gets the output component
  66053. */
  66054. get output(): NodeMaterialConnectionPoint;
  66055. autoConfigure(material: NodeMaterial): void;
  66056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66057. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66058. protected _buildBlock(state: NodeMaterialBuildState): this;
  66059. }
  66060. }
  66061. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66062. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66063. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66064. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66066. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66067. import { Effect } from "babylonjs/Materials/effect";
  66068. import { Mesh } from "babylonjs/Meshes/mesh";
  66069. import { Light } from "babylonjs/Lights/light";
  66070. import { Nullable } from "babylonjs/types";
  66071. import { Scene } from "babylonjs/scene";
  66072. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66073. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66074. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66075. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66076. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66077. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66078. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66079. /**
  66080. * Block used to add light in the fragment shader
  66081. */
  66082. export class LightBlock extends NodeMaterialBlock {
  66083. private _lightId;
  66084. /**
  66085. * Gets or sets the light associated with this block
  66086. */
  66087. light: Nullable<Light>;
  66088. /**
  66089. * Create a new LightBlock
  66090. * @param name defines the block name
  66091. */
  66092. constructor(name: string);
  66093. /**
  66094. * Gets the current class name
  66095. * @returns the class name
  66096. */
  66097. getClassName(): string;
  66098. /**
  66099. * Gets the world position input component
  66100. */
  66101. get worldPosition(): NodeMaterialConnectionPoint;
  66102. /**
  66103. * Gets the world normal input component
  66104. */
  66105. get worldNormal(): NodeMaterialConnectionPoint;
  66106. /**
  66107. * Gets the camera (or eye) position component
  66108. */
  66109. get cameraPosition(): NodeMaterialConnectionPoint;
  66110. /**
  66111. * Gets the glossiness component
  66112. */
  66113. get glossiness(): NodeMaterialConnectionPoint;
  66114. /**
  66115. * Gets the glossinness power component
  66116. */
  66117. get glossPower(): NodeMaterialConnectionPoint;
  66118. /**
  66119. * Gets the diffuse color component
  66120. */
  66121. get diffuseColor(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the specular color component
  66124. */
  66125. get specularColor(): NodeMaterialConnectionPoint;
  66126. /**
  66127. * Gets the diffuse output component
  66128. */
  66129. get diffuseOutput(): NodeMaterialConnectionPoint;
  66130. /**
  66131. * Gets the specular output component
  66132. */
  66133. get specularOutput(): NodeMaterialConnectionPoint;
  66134. /**
  66135. * Gets the shadow output component
  66136. */
  66137. get shadow(): NodeMaterialConnectionPoint;
  66138. autoConfigure(material: NodeMaterial): void;
  66139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66140. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66141. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66142. private _injectVertexCode;
  66143. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66144. serialize(): any;
  66145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66146. }
  66147. }
  66148. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66151. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66152. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66153. /**
  66154. * Block used to read a reflection texture from a sampler
  66155. */
  66156. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66157. /**
  66158. * Create a new ReflectionTextureBlock
  66159. * @param name defines the block name
  66160. */
  66161. constructor(name: string);
  66162. /**
  66163. * Gets the current class name
  66164. * @returns the class name
  66165. */
  66166. getClassName(): string;
  66167. /**
  66168. * Gets the world position input component
  66169. */
  66170. get position(): NodeMaterialConnectionPoint;
  66171. /**
  66172. * Gets the world position input component
  66173. */
  66174. get worldPosition(): NodeMaterialConnectionPoint;
  66175. /**
  66176. * Gets the world normal input component
  66177. */
  66178. get worldNormal(): NodeMaterialConnectionPoint;
  66179. /**
  66180. * Gets the world input component
  66181. */
  66182. get world(): NodeMaterialConnectionPoint;
  66183. /**
  66184. * Gets the camera (or eye) position component
  66185. */
  66186. get cameraPosition(): NodeMaterialConnectionPoint;
  66187. /**
  66188. * Gets the view input component
  66189. */
  66190. get view(): NodeMaterialConnectionPoint;
  66191. /**
  66192. * Gets the rgb output component
  66193. */
  66194. get rgb(): NodeMaterialConnectionPoint;
  66195. /**
  66196. * Gets the rgba output component
  66197. */
  66198. get rgba(): NodeMaterialConnectionPoint;
  66199. /**
  66200. * Gets the r output component
  66201. */
  66202. get r(): NodeMaterialConnectionPoint;
  66203. /**
  66204. * Gets the g output component
  66205. */
  66206. get g(): NodeMaterialConnectionPoint;
  66207. /**
  66208. * Gets the b output component
  66209. */
  66210. get b(): NodeMaterialConnectionPoint;
  66211. /**
  66212. * Gets the a output component
  66213. */
  66214. get a(): NodeMaterialConnectionPoint;
  66215. autoConfigure(material: NodeMaterial): void;
  66216. protected _buildBlock(state: NodeMaterialBuildState): this;
  66217. }
  66218. }
  66219. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66220. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66221. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66222. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66223. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66224. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66225. }
  66226. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66227. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66228. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66229. }
  66230. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66234. /**
  66235. * Block used to add 2 vectors
  66236. */
  66237. export class AddBlock extends NodeMaterialBlock {
  66238. /**
  66239. * Creates a new AddBlock
  66240. * @param name defines the block name
  66241. */
  66242. constructor(name: string);
  66243. /**
  66244. * Gets the current class name
  66245. * @returns the class name
  66246. */
  66247. getClassName(): string;
  66248. /**
  66249. * Gets the left operand input component
  66250. */
  66251. get left(): NodeMaterialConnectionPoint;
  66252. /**
  66253. * Gets the right operand input component
  66254. */
  66255. get right(): NodeMaterialConnectionPoint;
  66256. /**
  66257. * Gets the output component
  66258. */
  66259. get output(): NodeMaterialConnectionPoint;
  66260. protected _buildBlock(state: NodeMaterialBuildState): this;
  66261. }
  66262. }
  66263. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66267. /**
  66268. * Block used to scale a vector by a float
  66269. */
  66270. export class ScaleBlock extends NodeMaterialBlock {
  66271. /**
  66272. * Creates a new ScaleBlock
  66273. * @param name defines the block name
  66274. */
  66275. constructor(name: string);
  66276. /**
  66277. * Gets the current class name
  66278. * @returns the class name
  66279. */
  66280. getClassName(): string;
  66281. /**
  66282. * Gets the input component
  66283. */
  66284. get input(): NodeMaterialConnectionPoint;
  66285. /**
  66286. * Gets the factor input component
  66287. */
  66288. get factor(): NodeMaterialConnectionPoint;
  66289. /**
  66290. * Gets the output component
  66291. */
  66292. get output(): NodeMaterialConnectionPoint;
  66293. protected _buildBlock(state: NodeMaterialBuildState): this;
  66294. }
  66295. }
  66296. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66300. import { Scene } from "babylonjs/scene";
  66301. /**
  66302. * Block used to clamp a float
  66303. */
  66304. export class ClampBlock extends NodeMaterialBlock {
  66305. /** Gets or sets the minimum range */
  66306. minimum: number;
  66307. /** Gets or sets the maximum range */
  66308. maximum: number;
  66309. /**
  66310. * Creates a new ClampBlock
  66311. * @param name defines the block name
  66312. */
  66313. constructor(name: string);
  66314. /**
  66315. * Gets the current class name
  66316. * @returns the class name
  66317. */
  66318. getClassName(): string;
  66319. /**
  66320. * Gets the value input component
  66321. */
  66322. get value(): NodeMaterialConnectionPoint;
  66323. /**
  66324. * Gets the output component
  66325. */
  66326. get output(): NodeMaterialConnectionPoint;
  66327. protected _buildBlock(state: NodeMaterialBuildState): this;
  66328. protected _dumpPropertiesCode(): string;
  66329. serialize(): any;
  66330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66331. }
  66332. }
  66333. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  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. /**
  66338. * Block used to apply a cross product between 2 vectors
  66339. */
  66340. export class CrossBlock extends NodeMaterialBlock {
  66341. /**
  66342. * Creates a new CrossBlock
  66343. * @param name defines the block name
  66344. */
  66345. constructor(name: string);
  66346. /**
  66347. * Gets the current class name
  66348. * @returns the class name
  66349. */
  66350. getClassName(): string;
  66351. /**
  66352. * Gets the left operand input component
  66353. */
  66354. get left(): NodeMaterialConnectionPoint;
  66355. /**
  66356. * Gets the right operand input component
  66357. */
  66358. get right(): NodeMaterialConnectionPoint;
  66359. /**
  66360. * Gets the output component
  66361. */
  66362. get output(): NodeMaterialConnectionPoint;
  66363. protected _buildBlock(state: NodeMaterialBuildState): this;
  66364. }
  66365. }
  66366. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66370. /**
  66371. * Block used to apply a dot product between 2 vectors
  66372. */
  66373. export class DotBlock extends NodeMaterialBlock {
  66374. /**
  66375. * Creates a new DotBlock
  66376. * @param name defines the block name
  66377. */
  66378. constructor(name: string);
  66379. /**
  66380. * Gets the current class name
  66381. * @returns the class name
  66382. */
  66383. getClassName(): string;
  66384. /**
  66385. * Gets the left operand input component
  66386. */
  66387. get left(): NodeMaterialConnectionPoint;
  66388. /**
  66389. * Gets the right operand input component
  66390. */
  66391. get right(): NodeMaterialConnectionPoint;
  66392. /**
  66393. * Gets the output component
  66394. */
  66395. get output(): NodeMaterialConnectionPoint;
  66396. protected _buildBlock(state: NodeMaterialBuildState): this;
  66397. }
  66398. }
  66399. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66403. /**
  66404. * Block used to normalize a vector
  66405. */
  66406. export class NormalizeBlock extends NodeMaterialBlock {
  66407. /**
  66408. * Creates a new NormalizeBlock
  66409. * @param name defines the block name
  66410. */
  66411. constructor(name: string);
  66412. /**
  66413. * Gets the current class name
  66414. * @returns the class name
  66415. */
  66416. getClassName(): string;
  66417. /**
  66418. * Gets the input component
  66419. */
  66420. get input(): NodeMaterialConnectionPoint;
  66421. /**
  66422. * Gets the output component
  66423. */
  66424. get output(): NodeMaterialConnectionPoint;
  66425. protected _buildBlock(state: NodeMaterialBuildState): this;
  66426. }
  66427. }
  66428. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66432. /**
  66433. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66434. */
  66435. export class ColorMergerBlock extends NodeMaterialBlock {
  66436. /**
  66437. * Create a new ColorMergerBlock
  66438. * @param name defines the block name
  66439. */
  66440. constructor(name: string);
  66441. /**
  66442. * Gets the current class name
  66443. * @returns the class name
  66444. */
  66445. getClassName(): string;
  66446. /**
  66447. * Gets the rgb component (input)
  66448. */
  66449. get rgbIn(): NodeMaterialConnectionPoint;
  66450. /**
  66451. * Gets the r component (input)
  66452. */
  66453. get r(): NodeMaterialConnectionPoint;
  66454. /**
  66455. * Gets the g component (input)
  66456. */
  66457. get g(): NodeMaterialConnectionPoint;
  66458. /**
  66459. * Gets the b component (input)
  66460. */
  66461. get b(): NodeMaterialConnectionPoint;
  66462. /**
  66463. * Gets the a component (input)
  66464. */
  66465. get a(): NodeMaterialConnectionPoint;
  66466. /**
  66467. * Gets the rgba component (output)
  66468. */
  66469. get rgba(): NodeMaterialConnectionPoint;
  66470. /**
  66471. * Gets the rgb component (output)
  66472. */
  66473. get rgbOut(): NodeMaterialConnectionPoint;
  66474. /**
  66475. * Gets the rgb component (output)
  66476. * @deprecated Please use rgbOut instead.
  66477. */
  66478. get rgb(): NodeMaterialConnectionPoint;
  66479. protected _buildBlock(state: NodeMaterialBuildState): this;
  66480. }
  66481. }
  66482. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66486. /**
  66487. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66488. */
  66489. export class VectorSplitterBlock extends NodeMaterialBlock {
  66490. /**
  66491. * Create a new VectorSplitterBlock
  66492. * @param name defines the block name
  66493. */
  66494. constructor(name: string);
  66495. /**
  66496. * Gets the current class name
  66497. * @returns the class name
  66498. */
  66499. getClassName(): string;
  66500. /**
  66501. * Gets the xyzw component (input)
  66502. */
  66503. get xyzw(): NodeMaterialConnectionPoint;
  66504. /**
  66505. * Gets the xyz component (input)
  66506. */
  66507. get xyzIn(): NodeMaterialConnectionPoint;
  66508. /**
  66509. * Gets the xy component (input)
  66510. */
  66511. get xyIn(): NodeMaterialConnectionPoint;
  66512. /**
  66513. * Gets the xyz component (output)
  66514. */
  66515. get xyzOut(): NodeMaterialConnectionPoint;
  66516. /**
  66517. * Gets the xy component (output)
  66518. */
  66519. get xyOut(): NodeMaterialConnectionPoint;
  66520. /**
  66521. * Gets the x component (output)
  66522. */
  66523. get x(): NodeMaterialConnectionPoint;
  66524. /**
  66525. * Gets the y component (output)
  66526. */
  66527. get y(): NodeMaterialConnectionPoint;
  66528. /**
  66529. * Gets the z component (output)
  66530. */
  66531. get z(): NodeMaterialConnectionPoint;
  66532. /**
  66533. * Gets the w component (output)
  66534. */
  66535. get w(): NodeMaterialConnectionPoint;
  66536. protected _inputRename(name: string): string;
  66537. protected _outputRename(name: string): string;
  66538. protected _buildBlock(state: NodeMaterialBuildState): this;
  66539. }
  66540. }
  66541. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66542. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66543. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66544. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66545. /**
  66546. * Block used to lerp between 2 values
  66547. */
  66548. export class LerpBlock extends NodeMaterialBlock {
  66549. /**
  66550. * Creates a new LerpBlock
  66551. * @param name defines the block name
  66552. */
  66553. constructor(name: string);
  66554. /**
  66555. * Gets the current class name
  66556. * @returns the class name
  66557. */
  66558. getClassName(): string;
  66559. /**
  66560. * Gets the left operand input component
  66561. */
  66562. get left(): NodeMaterialConnectionPoint;
  66563. /**
  66564. * Gets the right operand input component
  66565. */
  66566. get right(): NodeMaterialConnectionPoint;
  66567. /**
  66568. * Gets the gradient operand input component
  66569. */
  66570. get gradient(): NodeMaterialConnectionPoint;
  66571. /**
  66572. * Gets the output component
  66573. */
  66574. get output(): NodeMaterialConnectionPoint;
  66575. protected _buildBlock(state: NodeMaterialBuildState): this;
  66576. }
  66577. }
  66578. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66582. /**
  66583. * Block used to divide 2 vectors
  66584. */
  66585. export class DivideBlock extends NodeMaterialBlock {
  66586. /**
  66587. * Creates a new DivideBlock
  66588. * @param name defines the block name
  66589. */
  66590. constructor(name: string);
  66591. /**
  66592. * Gets the current class name
  66593. * @returns the class name
  66594. */
  66595. getClassName(): string;
  66596. /**
  66597. * Gets the left operand input component
  66598. */
  66599. get left(): NodeMaterialConnectionPoint;
  66600. /**
  66601. * Gets the right operand input component
  66602. */
  66603. get right(): NodeMaterialConnectionPoint;
  66604. /**
  66605. * Gets the output component
  66606. */
  66607. get output(): NodeMaterialConnectionPoint;
  66608. protected _buildBlock(state: NodeMaterialBuildState): this;
  66609. }
  66610. }
  66611. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66615. /**
  66616. * Block used to subtract 2 vectors
  66617. */
  66618. export class SubtractBlock extends NodeMaterialBlock {
  66619. /**
  66620. * Creates a new SubtractBlock
  66621. * @param name defines the block name
  66622. */
  66623. constructor(name: string);
  66624. /**
  66625. * Gets the current class name
  66626. * @returns the class name
  66627. */
  66628. getClassName(): string;
  66629. /**
  66630. * Gets the left operand input component
  66631. */
  66632. get left(): NodeMaterialConnectionPoint;
  66633. /**
  66634. * Gets the right operand input component
  66635. */
  66636. get right(): NodeMaterialConnectionPoint;
  66637. /**
  66638. * Gets the output component
  66639. */
  66640. get output(): NodeMaterialConnectionPoint;
  66641. protected _buildBlock(state: NodeMaterialBuildState): this;
  66642. }
  66643. }
  66644. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66648. /**
  66649. * Block used to step a value
  66650. */
  66651. export class StepBlock extends NodeMaterialBlock {
  66652. /**
  66653. * Creates a new StepBlock
  66654. * @param name defines the block name
  66655. */
  66656. constructor(name: string);
  66657. /**
  66658. * Gets the current class name
  66659. * @returns the class name
  66660. */
  66661. getClassName(): string;
  66662. /**
  66663. * Gets the value operand input component
  66664. */
  66665. get value(): NodeMaterialConnectionPoint;
  66666. /**
  66667. * Gets the edge operand input component
  66668. */
  66669. get edge(): NodeMaterialConnectionPoint;
  66670. /**
  66671. * Gets the output component
  66672. */
  66673. get output(): NodeMaterialConnectionPoint;
  66674. protected _buildBlock(state: NodeMaterialBuildState): this;
  66675. }
  66676. }
  66677. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66681. /**
  66682. * Block used to get the opposite (1 - x) of a value
  66683. */
  66684. export class OneMinusBlock extends NodeMaterialBlock {
  66685. /**
  66686. * Creates a new OneMinusBlock
  66687. * @param name defines the block name
  66688. */
  66689. constructor(name: string);
  66690. /**
  66691. * Gets the current class name
  66692. * @returns the class name
  66693. */
  66694. getClassName(): string;
  66695. /**
  66696. * Gets the input component
  66697. */
  66698. get input(): NodeMaterialConnectionPoint;
  66699. /**
  66700. * Gets the output component
  66701. */
  66702. get output(): NodeMaterialConnectionPoint;
  66703. protected _buildBlock(state: NodeMaterialBuildState): this;
  66704. }
  66705. }
  66706. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66710. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66711. /**
  66712. * Block used to get the view direction
  66713. */
  66714. export class ViewDirectionBlock extends NodeMaterialBlock {
  66715. /**
  66716. * Creates a new ViewDirectionBlock
  66717. * @param name defines the block name
  66718. */
  66719. constructor(name: string);
  66720. /**
  66721. * Gets the current class name
  66722. * @returns the class name
  66723. */
  66724. getClassName(): string;
  66725. /**
  66726. * Gets the world position component
  66727. */
  66728. get worldPosition(): NodeMaterialConnectionPoint;
  66729. /**
  66730. * Gets the camera position component
  66731. */
  66732. get cameraPosition(): NodeMaterialConnectionPoint;
  66733. /**
  66734. * Gets the output component
  66735. */
  66736. get output(): NodeMaterialConnectionPoint;
  66737. autoConfigure(material: NodeMaterial): void;
  66738. protected _buildBlock(state: NodeMaterialBuildState): this;
  66739. }
  66740. }
  66741. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66745. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66746. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66747. /**
  66748. * Block used to compute fresnel value
  66749. */
  66750. export class FresnelBlock extends NodeMaterialBlock {
  66751. /**
  66752. * Create a new FresnelBlock
  66753. * @param name defines the block name
  66754. */
  66755. constructor(name: string);
  66756. /**
  66757. * Gets the current class name
  66758. * @returns the class name
  66759. */
  66760. getClassName(): string;
  66761. /**
  66762. * Gets the world normal input component
  66763. */
  66764. get worldNormal(): NodeMaterialConnectionPoint;
  66765. /**
  66766. * Gets the view direction input component
  66767. */
  66768. get viewDirection(): NodeMaterialConnectionPoint;
  66769. /**
  66770. * Gets the bias input component
  66771. */
  66772. get bias(): NodeMaterialConnectionPoint;
  66773. /**
  66774. * Gets the camera (or eye) position component
  66775. */
  66776. get power(): NodeMaterialConnectionPoint;
  66777. /**
  66778. * Gets the fresnel output component
  66779. */
  66780. get fresnel(): NodeMaterialConnectionPoint;
  66781. autoConfigure(material: NodeMaterial): void;
  66782. protected _buildBlock(state: NodeMaterialBuildState): this;
  66783. }
  66784. }
  66785. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66787. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66789. /**
  66790. * Block used to get the max of 2 values
  66791. */
  66792. export class MaxBlock extends NodeMaterialBlock {
  66793. /**
  66794. * Creates a new MaxBlock
  66795. * @param name defines the block name
  66796. */
  66797. constructor(name: string);
  66798. /**
  66799. * Gets the current class name
  66800. * @returns the class name
  66801. */
  66802. getClassName(): string;
  66803. /**
  66804. * Gets the left operand input component
  66805. */
  66806. get left(): NodeMaterialConnectionPoint;
  66807. /**
  66808. * Gets the right operand input component
  66809. */
  66810. get right(): NodeMaterialConnectionPoint;
  66811. /**
  66812. * Gets the output component
  66813. */
  66814. get output(): NodeMaterialConnectionPoint;
  66815. protected _buildBlock(state: NodeMaterialBuildState): this;
  66816. }
  66817. }
  66818. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66821. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66822. /**
  66823. * Block used to get the min of 2 values
  66824. */
  66825. export class MinBlock extends NodeMaterialBlock {
  66826. /**
  66827. * Creates a new MinBlock
  66828. * @param name defines the block name
  66829. */
  66830. constructor(name: string);
  66831. /**
  66832. * Gets the current class name
  66833. * @returns the class name
  66834. */
  66835. getClassName(): string;
  66836. /**
  66837. * Gets the left operand input component
  66838. */
  66839. get left(): NodeMaterialConnectionPoint;
  66840. /**
  66841. * Gets the right operand input component
  66842. */
  66843. get right(): NodeMaterialConnectionPoint;
  66844. /**
  66845. * Gets the output component
  66846. */
  66847. get output(): NodeMaterialConnectionPoint;
  66848. protected _buildBlock(state: NodeMaterialBuildState): this;
  66849. }
  66850. }
  66851. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66855. /**
  66856. * Block used to get the distance between 2 values
  66857. */
  66858. export class DistanceBlock extends NodeMaterialBlock {
  66859. /**
  66860. * Creates a new DistanceBlock
  66861. * @param name defines the block name
  66862. */
  66863. constructor(name: string);
  66864. /**
  66865. * Gets the current class name
  66866. * @returns the class name
  66867. */
  66868. getClassName(): string;
  66869. /**
  66870. * Gets the left operand input component
  66871. */
  66872. get left(): NodeMaterialConnectionPoint;
  66873. /**
  66874. * Gets the right operand input component
  66875. */
  66876. get right(): NodeMaterialConnectionPoint;
  66877. /**
  66878. * Gets the output component
  66879. */
  66880. get output(): NodeMaterialConnectionPoint;
  66881. protected _buildBlock(state: NodeMaterialBuildState): this;
  66882. }
  66883. }
  66884. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66888. /**
  66889. * Block used to get the length of a vector
  66890. */
  66891. export class LengthBlock extends NodeMaterialBlock {
  66892. /**
  66893. * Creates a new LengthBlock
  66894. * @param name defines the block name
  66895. */
  66896. constructor(name: string);
  66897. /**
  66898. * Gets the current class name
  66899. * @returns the class name
  66900. */
  66901. getClassName(): string;
  66902. /**
  66903. * Gets the value input component
  66904. */
  66905. get value(): NodeMaterialConnectionPoint;
  66906. /**
  66907. * Gets the output component
  66908. */
  66909. get output(): NodeMaterialConnectionPoint;
  66910. protected _buildBlock(state: NodeMaterialBuildState): this;
  66911. }
  66912. }
  66913. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66917. /**
  66918. * Block used to get negative version of a value (i.e. x * -1)
  66919. */
  66920. export class NegateBlock extends NodeMaterialBlock {
  66921. /**
  66922. * Creates a new NegateBlock
  66923. * @param name defines the block name
  66924. */
  66925. constructor(name: string);
  66926. /**
  66927. * Gets the current class name
  66928. * @returns the class name
  66929. */
  66930. getClassName(): string;
  66931. /**
  66932. * Gets the value input component
  66933. */
  66934. get value(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the output component
  66937. */
  66938. get output(): NodeMaterialConnectionPoint;
  66939. protected _buildBlock(state: NodeMaterialBuildState): this;
  66940. }
  66941. }
  66942. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66946. /**
  66947. * Block used to get the value of the first parameter raised to the power of the second
  66948. */
  66949. export class PowBlock extends NodeMaterialBlock {
  66950. /**
  66951. * Creates a new PowBlock
  66952. * @param name defines the block name
  66953. */
  66954. constructor(name: string);
  66955. /**
  66956. * Gets the current class name
  66957. * @returns the class name
  66958. */
  66959. getClassName(): string;
  66960. /**
  66961. * Gets the value operand input component
  66962. */
  66963. get value(): NodeMaterialConnectionPoint;
  66964. /**
  66965. * Gets the power operand input component
  66966. */
  66967. get power(): NodeMaterialConnectionPoint;
  66968. /**
  66969. * Gets the output component
  66970. */
  66971. get output(): NodeMaterialConnectionPoint;
  66972. protected _buildBlock(state: NodeMaterialBuildState): this;
  66973. }
  66974. }
  66975. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66979. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66980. /**
  66981. * Block used to get a random number
  66982. */
  66983. export class RandomNumberBlock extends NodeMaterialBlock {
  66984. /**
  66985. * Creates a new RandomNumberBlock
  66986. * @param name defines the block name
  66987. */
  66988. constructor(name: string);
  66989. /**
  66990. * Gets the current class name
  66991. * @returns the class name
  66992. */
  66993. getClassName(): string;
  66994. /**
  66995. * Gets the seed input component
  66996. */
  66997. get seed(): NodeMaterialConnectionPoint;
  66998. /**
  66999. * Gets the output component
  67000. */
  67001. get output(): NodeMaterialConnectionPoint;
  67002. protected _buildBlock(state: NodeMaterialBuildState): this;
  67003. }
  67004. }
  67005. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67009. /**
  67010. * Block used to compute arc tangent of 2 values
  67011. */
  67012. export class ArcTan2Block extends NodeMaterialBlock {
  67013. /**
  67014. * Creates a new ArcTan2Block
  67015. * @param name defines the block name
  67016. */
  67017. constructor(name: string);
  67018. /**
  67019. * Gets the current class name
  67020. * @returns the class name
  67021. */
  67022. getClassName(): string;
  67023. /**
  67024. * Gets the x operand input component
  67025. */
  67026. get x(): NodeMaterialConnectionPoint;
  67027. /**
  67028. * Gets the y operand input component
  67029. */
  67030. get y(): NodeMaterialConnectionPoint;
  67031. /**
  67032. * Gets the output component
  67033. */
  67034. get output(): NodeMaterialConnectionPoint;
  67035. protected _buildBlock(state: NodeMaterialBuildState): this;
  67036. }
  67037. }
  67038. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67042. /**
  67043. * Block used to smooth step a value
  67044. */
  67045. export class SmoothStepBlock extends NodeMaterialBlock {
  67046. /**
  67047. * Creates a new SmoothStepBlock
  67048. * @param name defines the block name
  67049. */
  67050. constructor(name: string);
  67051. /**
  67052. * Gets the current class name
  67053. * @returns the class name
  67054. */
  67055. getClassName(): string;
  67056. /**
  67057. * Gets the value operand input component
  67058. */
  67059. get value(): NodeMaterialConnectionPoint;
  67060. /**
  67061. * Gets the first edge operand input component
  67062. */
  67063. get edge0(): NodeMaterialConnectionPoint;
  67064. /**
  67065. * Gets the second edge operand input component
  67066. */
  67067. get edge1(): NodeMaterialConnectionPoint;
  67068. /**
  67069. * Gets the output component
  67070. */
  67071. get output(): NodeMaterialConnectionPoint;
  67072. protected _buildBlock(state: NodeMaterialBuildState): this;
  67073. }
  67074. }
  67075. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67079. /**
  67080. * Block used to get the reciprocal (1 / x) of a value
  67081. */
  67082. export class ReciprocalBlock extends NodeMaterialBlock {
  67083. /**
  67084. * Creates a new ReciprocalBlock
  67085. * @param name defines the block name
  67086. */
  67087. constructor(name: string);
  67088. /**
  67089. * Gets the current class name
  67090. * @returns the class name
  67091. */
  67092. getClassName(): string;
  67093. /**
  67094. * Gets the input component
  67095. */
  67096. get input(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the output component
  67099. */
  67100. get output(): NodeMaterialConnectionPoint;
  67101. protected _buildBlock(state: NodeMaterialBuildState): this;
  67102. }
  67103. }
  67104. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67108. /**
  67109. * Block used to replace a color by another one
  67110. */
  67111. export class ReplaceColorBlock extends NodeMaterialBlock {
  67112. /**
  67113. * Creates a new ReplaceColorBlock
  67114. * @param name defines the block name
  67115. */
  67116. constructor(name: string);
  67117. /**
  67118. * Gets the current class name
  67119. * @returns the class name
  67120. */
  67121. getClassName(): string;
  67122. /**
  67123. * Gets the value input component
  67124. */
  67125. get value(): NodeMaterialConnectionPoint;
  67126. /**
  67127. * Gets the reference input component
  67128. */
  67129. get reference(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the distance input component
  67132. */
  67133. get distance(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the replacement input component
  67136. */
  67137. get replacement(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the output component
  67140. */
  67141. get output(): NodeMaterialConnectionPoint;
  67142. protected _buildBlock(state: NodeMaterialBuildState): this;
  67143. }
  67144. }
  67145. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67149. /**
  67150. * Block used to posterize a value
  67151. * @see https://en.wikipedia.org/wiki/Posterization
  67152. */
  67153. export class PosterizeBlock extends NodeMaterialBlock {
  67154. /**
  67155. * Creates a new PosterizeBlock
  67156. * @param name defines the block name
  67157. */
  67158. constructor(name: string);
  67159. /**
  67160. * Gets the current class name
  67161. * @returns the class name
  67162. */
  67163. getClassName(): string;
  67164. /**
  67165. * Gets the value input component
  67166. */
  67167. get value(): NodeMaterialConnectionPoint;
  67168. /**
  67169. * Gets the steps input component
  67170. */
  67171. get steps(): NodeMaterialConnectionPoint;
  67172. /**
  67173. * Gets the output component
  67174. */
  67175. get output(): NodeMaterialConnectionPoint;
  67176. protected _buildBlock(state: NodeMaterialBuildState): this;
  67177. }
  67178. }
  67179. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67180. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67181. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67182. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67183. import { Scene } from "babylonjs/scene";
  67184. /**
  67185. * Operations supported by the Wave block
  67186. */
  67187. export enum WaveBlockKind {
  67188. /** SawTooth */
  67189. SawTooth = 0,
  67190. /** Square */
  67191. Square = 1,
  67192. /** Triangle */
  67193. Triangle = 2
  67194. }
  67195. /**
  67196. * Block used to apply wave operation to floats
  67197. */
  67198. export class WaveBlock extends NodeMaterialBlock {
  67199. /**
  67200. * Gets or sets the kibnd of wave to be applied by the block
  67201. */
  67202. kind: WaveBlockKind;
  67203. /**
  67204. * Creates a new WaveBlock
  67205. * @param name defines the block name
  67206. */
  67207. constructor(name: string);
  67208. /**
  67209. * Gets the current class name
  67210. * @returns the class name
  67211. */
  67212. getClassName(): string;
  67213. /**
  67214. * Gets the input component
  67215. */
  67216. get input(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the output component
  67219. */
  67220. get output(): NodeMaterialConnectionPoint;
  67221. protected _buildBlock(state: NodeMaterialBuildState): this;
  67222. serialize(): any;
  67223. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67224. }
  67225. }
  67226. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67227. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67228. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67229. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67230. import { Color3 } from "babylonjs/Maths/math.color";
  67231. import { Scene } from "babylonjs/scene";
  67232. import { Observable } from "babylonjs/Misc/observable";
  67233. /**
  67234. * Class used to store a color step for the GradientBlock
  67235. */
  67236. export class GradientBlockColorStep {
  67237. private _step;
  67238. /**
  67239. * Gets value indicating which step this color is associated with (between 0 and 1)
  67240. */
  67241. get step(): number;
  67242. /**
  67243. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67244. */
  67245. set step(val: number);
  67246. private _color;
  67247. /**
  67248. * Gets the color associated with this step
  67249. */
  67250. get color(): Color3;
  67251. /**
  67252. * Sets the color associated with this step
  67253. */
  67254. set color(val: Color3);
  67255. /**
  67256. * Creates a new GradientBlockColorStep
  67257. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67258. * @param color defines the color associated with this step
  67259. */
  67260. constructor(step: number, color: Color3);
  67261. }
  67262. /**
  67263. * Block used to return a color from a gradient based on an input value between 0 and 1
  67264. */
  67265. export class GradientBlock extends NodeMaterialBlock {
  67266. /**
  67267. * Gets or sets the list of color steps
  67268. */
  67269. colorSteps: GradientBlockColorStep[];
  67270. /** Gets an observable raised when the value is changed */
  67271. onValueChangedObservable: Observable<GradientBlock>;
  67272. /** calls observable when the value is changed*/
  67273. colorStepsUpdated(): void;
  67274. /**
  67275. * Creates a new GradientBlock
  67276. * @param name defines the block name
  67277. */
  67278. constructor(name: string);
  67279. /**
  67280. * Gets the current class name
  67281. * @returns the class name
  67282. */
  67283. getClassName(): string;
  67284. /**
  67285. * Gets the gradient input component
  67286. */
  67287. get gradient(): NodeMaterialConnectionPoint;
  67288. /**
  67289. * Gets the output component
  67290. */
  67291. get output(): NodeMaterialConnectionPoint;
  67292. private _writeColorConstant;
  67293. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67294. serialize(): any;
  67295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67296. protected _dumpPropertiesCode(): string;
  67297. }
  67298. }
  67299. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67300. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67301. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67302. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67303. /**
  67304. * Block used to normalize lerp between 2 values
  67305. */
  67306. export class NLerpBlock extends NodeMaterialBlock {
  67307. /**
  67308. * Creates a new NLerpBlock
  67309. * @param name defines the block name
  67310. */
  67311. constructor(name: string);
  67312. /**
  67313. * Gets the current class name
  67314. * @returns the class name
  67315. */
  67316. getClassName(): string;
  67317. /**
  67318. * Gets the left operand input component
  67319. */
  67320. get left(): NodeMaterialConnectionPoint;
  67321. /**
  67322. * Gets the right operand input component
  67323. */
  67324. get right(): NodeMaterialConnectionPoint;
  67325. /**
  67326. * Gets the gradient operand input component
  67327. */
  67328. get gradient(): NodeMaterialConnectionPoint;
  67329. /**
  67330. * Gets the output component
  67331. */
  67332. get output(): NodeMaterialConnectionPoint;
  67333. protected _buildBlock(state: NodeMaterialBuildState): this;
  67334. }
  67335. }
  67336. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67340. import { Scene } from "babylonjs/scene";
  67341. /**
  67342. * block used to Generate a Worley Noise 3D Noise Pattern
  67343. */
  67344. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67345. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67346. manhattanDistance: boolean;
  67347. /**
  67348. * Creates a new WorleyNoise3DBlock
  67349. * @param name defines the block name
  67350. */
  67351. constructor(name: string);
  67352. /**
  67353. * Gets the current class name
  67354. * @returns the class name
  67355. */
  67356. getClassName(): string;
  67357. /**
  67358. * Gets the seed input component
  67359. */
  67360. get seed(): NodeMaterialConnectionPoint;
  67361. /**
  67362. * Gets the jitter input component
  67363. */
  67364. get jitter(): NodeMaterialConnectionPoint;
  67365. /**
  67366. * Gets the output component
  67367. */
  67368. get output(): NodeMaterialConnectionPoint;
  67369. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67370. /**
  67371. * Exposes the properties to the UI?
  67372. */
  67373. protected _dumpPropertiesCode(): string;
  67374. /**
  67375. * Exposes the properties to the Seralize?
  67376. */
  67377. serialize(): any;
  67378. /**
  67379. * Exposes the properties to the deseralize?
  67380. */
  67381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67382. }
  67383. }
  67384. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67388. /**
  67389. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67390. */
  67391. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67392. /**
  67393. * Creates a new SimplexPerlin3DBlock
  67394. * @param name defines the block name
  67395. */
  67396. constructor(name: string);
  67397. /**
  67398. * Gets the current class name
  67399. * @returns the class name
  67400. */
  67401. getClassName(): string;
  67402. /**
  67403. * Gets the seed operand input component
  67404. */
  67405. get seed(): NodeMaterialConnectionPoint;
  67406. /**
  67407. * Gets the output component
  67408. */
  67409. get output(): NodeMaterialConnectionPoint;
  67410. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67411. }
  67412. }
  67413. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67417. /**
  67418. * Block used to blend normals
  67419. */
  67420. export class NormalBlendBlock extends NodeMaterialBlock {
  67421. /**
  67422. * Creates a new NormalBlendBlock
  67423. * @param name defines the block name
  67424. */
  67425. constructor(name: string);
  67426. /**
  67427. * Gets the current class name
  67428. * @returns the class name
  67429. */
  67430. getClassName(): string;
  67431. /**
  67432. * Gets the first input component
  67433. */
  67434. get normalMap0(): NodeMaterialConnectionPoint;
  67435. /**
  67436. * Gets the second input component
  67437. */
  67438. get normalMap1(): NodeMaterialConnectionPoint;
  67439. /**
  67440. * Gets the output component
  67441. */
  67442. get output(): NodeMaterialConnectionPoint;
  67443. protected _buildBlock(state: NodeMaterialBuildState): this;
  67444. }
  67445. }
  67446. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67450. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67451. /**
  67452. * Block used to rotate a 2d vector by a given angle
  67453. */
  67454. export class Rotate2dBlock extends NodeMaterialBlock {
  67455. /**
  67456. * Creates a new Rotate2dBlock
  67457. * @param name defines the block name
  67458. */
  67459. constructor(name: string);
  67460. /**
  67461. * Gets the current class name
  67462. * @returns the class name
  67463. */
  67464. getClassName(): string;
  67465. /**
  67466. * Gets the input vector
  67467. */
  67468. get input(): NodeMaterialConnectionPoint;
  67469. /**
  67470. * Gets the input angle
  67471. */
  67472. get angle(): NodeMaterialConnectionPoint;
  67473. /**
  67474. * Gets the output component
  67475. */
  67476. get output(): NodeMaterialConnectionPoint;
  67477. autoConfigure(material: NodeMaterial): void;
  67478. protected _buildBlock(state: NodeMaterialBuildState): this;
  67479. }
  67480. }
  67481. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67485. /**
  67486. * Block used to get the reflected vector from a direction and a normal
  67487. */
  67488. export class ReflectBlock extends NodeMaterialBlock {
  67489. /**
  67490. * Creates a new ReflectBlock
  67491. * @param name defines the block name
  67492. */
  67493. constructor(name: string);
  67494. /**
  67495. * Gets the current class name
  67496. * @returns the class name
  67497. */
  67498. getClassName(): string;
  67499. /**
  67500. * Gets the incident component
  67501. */
  67502. get incident(): NodeMaterialConnectionPoint;
  67503. /**
  67504. * Gets the normal component
  67505. */
  67506. get normal(): NodeMaterialConnectionPoint;
  67507. /**
  67508. * Gets the output component
  67509. */
  67510. get output(): NodeMaterialConnectionPoint;
  67511. protected _buildBlock(state: NodeMaterialBuildState): this;
  67512. }
  67513. }
  67514. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67518. /**
  67519. * Block used to get the refracted vector from a direction and a normal
  67520. */
  67521. export class RefractBlock extends NodeMaterialBlock {
  67522. /**
  67523. * Creates a new RefractBlock
  67524. * @param name defines the block name
  67525. */
  67526. constructor(name: string);
  67527. /**
  67528. * Gets the current class name
  67529. * @returns the class name
  67530. */
  67531. getClassName(): string;
  67532. /**
  67533. * Gets the incident component
  67534. */
  67535. get incident(): NodeMaterialConnectionPoint;
  67536. /**
  67537. * Gets the normal component
  67538. */
  67539. get normal(): NodeMaterialConnectionPoint;
  67540. /**
  67541. * Gets the index of refraction component
  67542. */
  67543. get ior(): NodeMaterialConnectionPoint;
  67544. /**
  67545. * Gets the output component
  67546. */
  67547. get output(): NodeMaterialConnectionPoint;
  67548. protected _buildBlock(state: NodeMaterialBuildState): this;
  67549. }
  67550. }
  67551. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67555. /**
  67556. * Block used to desaturate a color
  67557. */
  67558. export class DesaturateBlock extends NodeMaterialBlock {
  67559. /**
  67560. * Creates a new DesaturateBlock
  67561. * @param name defines the block name
  67562. */
  67563. constructor(name: string);
  67564. /**
  67565. * Gets the current class name
  67566. * @returns the class name
  67567. */
  67568. getClassName(): string;
  67569. /**
  67570. * Gets the color operand input component
  67571. */
  67572. get color(): NodeMaterialConnectionPoint;
  67573. /**
  67574. * Gets the level operand input component
  67575. */
  67576. get level(): NodeMaterialConnectionPoint;
  67577. /**
  67578. * Gets the output component
  67579. */
  67580. get output(): NodeMaterialConnectionPoint;
  67581. protected _buildBlock(state: NodeMaterialBuildState): this;
  67582. }
  67583. }
  67584. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67588. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67589. import { Nullable } from "babylonjs/types";
  67590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67591. import { Scene } from "babylonjs/scene";
  67592. /**
  67593. * Block used to implement the ambient occlusion module of the PBR material
  67594. */
  67595. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67596. /**
  67597. * Create a new AmbientOcclusionBlock
  67598. * @param name defines the block name
  67599. */
  67600. constructor(name: string);
  67601. /**
  67602. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67603. */
  67604. useAmbientInGrayScale: boolean;
  67605. /**
  67606. * Initialize the block and prepare the context for build
  67607. * @param state defines the state that will be used for the build
  67608. */
  67609. initialize(state: NodeMaterialBuildState): void;
  67610. /**
  67611. * Gets the current class name
  67612. * @returns the class name
  67613. */
  67614. getClassName(): string;
  67615. /**
  67616. * Gets the texture input component
  67617. */
  67618. get texture(): NodeMaterialConnectionPoint;
  67619. /**
  67620. * Gets the texture intensity component
  67621. */
  67622. get intensity(): NodeMaterialConnectionPoint;
  67623. /**
  67624. * Gets the direct light intensity input component
  67625. */
  67626. get directLightIntensity(): NodeMaterialConnectionPoint;
  67627. /**
  67628. * Gets the ambient occlusion object output component
  67629. */
  67630. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67631. /**
  67632. * Gets the main code of the block (fragment side)
  67633. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67634. * @returns the shader code
  67635. */
  67636. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67638. protected _buildBlock(state: NodeMaterialBuildState): this;
  67639. protected _dumpPropertiesCode(): string;
  67640. serialize(): any;
  67641. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67642. }
  67643. }
  67644. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67647. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67648. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67650. import { Nullable } from "babylonjs/types";
  67651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67652. import { Mesh } from "babylonjs/Meshes/mesh";
  67653. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67654. import { Effect } from "babylonjs/Materials/effect";
  67655. import { Scene } from "babylonjs/scene";
  67656. /**
  67657. * Block used to implement the reflection module of the PBR material
  67658. */
  67659. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67660. /** @hidden */
  67661. _defineLODReflectionAlpha: string;
  67662. /** @hidden */
  67663. _defineLinearSpecularReflection: string;
  67664. private _vEnvironmentIrradianceName;
  67665. /** @hidden */
  67666. _vReflectionMicrosurfaceInfosName: string;
  67667. /** @hidden */
  67668. _vReflectionInfosName: string;
  67669. /** @hidden */
  67670. _vReflectionFilteringInfoName: string;
  67671. private _scene;
  67672. /**
  67673. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67674. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67675. * It's less burden on the user side in the editor part.
  67676. */
  67677. /** @hidden */
  67678. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67679. /** @hidden */
  67680. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67681. /** @hidden */
  67682. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67683. /**
  67684. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67685. * diffuse part of the IBL.
  67686. */
  67687. useSphericalHarmonics: boolean;
  67688. /**
  67689. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67690. */
  67691. forceIrradianceInFragment: boolean;
  67692. /**
  67693. * Create a new ReflectionBlock
  67694. * @param name defines the block name
  67695. */
  67696. constructor(name: string);
  67697. /**
  67698. * Gets the current class name
  67699. * @returns the class name
  67700. */
  67701. getClassName(): string;
  67702. /**
  67703. * Gets the position input component
  67704. */
  67705. get position(): NodeMaterialConnectionPoint;
  67706. /**
  67707. * Gets the world position input component
  67708. */
  67709. get worldPosition(): NodeMaterialConnectionPoint;
  67710. /**
  67711. * Gets the world normal input component
  67712. */
  67713. get worldNormal(): NodeMaterialConnectionPoint;
  67714. /**
  67715. * Gets the world input component
  67716. */
  67717. get world(): NodeMaterialConnectionPoint;
  67718. /**
  67719. * Gets the camera (or eye) position component
  67720. */
  67721. get cameraPosition(): NodeMaterialConnectionPoint;
  67722. /**
  67723. * Gets the view input component
  67724. */
  67725. get view(): NodeMaterialConnectionPoint;
  67726. /**
  67727. * Gets the color input component
  67728. */
  67729. get color(): NodeMaterialConnectionPoint;
  67730. /**
  67731. * Gets the reflection object output component
  67732. */
  67733. get reflection(): NodeMaterialConnectionPoint;
  67734. /**
  67735. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67736. */
  67737. get hasTexture(): boolean;
  67738. /**
  67739. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67740. */
  67741. get reflectionColor(): string;
  67742. protected _getTexture(): Nullable<BaseTexture>;
  67743. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67744. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67745. /**
  67746. * Gets the code to inject in the vertex shader
  67747. * @param state current state of the node material building
  67748. * @returns the shader code
  67749. */
  67750. handleVertexSide(state: NodeMaterialBuildState): string;
  67751. /**
  67752. * Gets the main code of the block (fragment side)
  67753. * @param state current state of the node material building
  67754. * @param normalVarName name of the existing variable corresponding to the normal
  67755. * @returns the shader code
  67756. */
  67757. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67758. protected _buildBlock(state: NodeMaterialBuildState): this;
  67759. protected _dumpPropertiesCode(): string;
  67760. serialize(): any;
  67761. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67762. }
  67763. }
  67764. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67768. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67770. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67771. import { Scene } from "babylonjs/scene";
  67772. import { Nullable } from "babylonjs/types";
  67773. /**
  67774. * Block used to implement the sheen module of the PBR material
  67775. */
  67776. export class SheenBlock extends NodeMaterialBlock {
  67777. /**
  67778. * Create a new SheenBlock
  67779. * @param name defines the block name
  67780. */
  67781. constructor(name: string);
  67782. /**
  67783. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67784. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67785. * making it easier to setup and tweak the effect
  67786. */
  67787. albedoScaling: boolean;
  67788. /**
  67789. * Defines if the sheen is linked to the sheen color.
  67790. */
  67791. linkSheenWithAlbedo: boolean;
  67792. /**
  67793. * Initialize the block and prepare the context for build
  67794. * @param state defines the state that will be used for the build
  67795. */
  67796. initialize(state: NodeMaterialBuildState): void;
  67797. /**
  67798. * Gets the current class name
  67799. * @returns the class name
  67800. */
  67801. getClassName(): string;
  67802. /**
  67803. * Gets the intensity input component
  67804. */
  67805. get intensity(): NodeMaterialConnectionPoint;
  67806. /**
  67807. * Gets the color input component
  67808. */
  67809. get color(): NodeMaterialConnectionPoint;
  67810. /**
  67811. * Gets the roughness input component
  67812. */
  67813. get roughness(): NodeMaterialConnectionPoint;
  67814. /**
  67815. * Gets the sheen object output component
  67816. */
  67817. get sheen(): NodeMaterialConnectionPoint;
  67818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67819. /**
  67820. * Gets the main code of the block (fragment side)
  67821. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67822. * @returns the shader code
  67823. */
  67824. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67825. protected _buildBlock(state: NodeMaterialBuildState): this;
  67826. protected _dumpPropertiesCode(): string;
  67827. serialize(): any;
  67828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67829. }
  67830. }
  67831. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67832. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67837. import { Scene } from "babylonjs/scene";
  67838. import { Nullable } from "babylonjs/types";
  67839. import { Mesh } from "babylonjs/Meshes/mesh";
  67840. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67841. import { Effect } from "babylonjs/Materials/effect";
  67842. /**
  67843. * Block used to implement the reflectivity module of the PBR material
  67844. */
  67845. export class ReflectivityBlock extends NodeMaterialBlock {
  67846. private _metallicReflectanceColor;
  67847. private _metallicF0Factor;
  67848. /** @hidden */
  67849. _vMetallicReflectanceFactorsName: string;
  67850. /**
  67851. * The property below is set by the main PBR block prior to calling methods of this class.
  67852. */
  67853. /** @hidden */
  67854. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67855. /**
  67856. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67857. */
  67858. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67859. /**
  67860. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67861. */
  67862. useMetallnessFromMetallicTextureBlue: boolean;
  67863. /**
  67864. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67865. */
  67866. useRoughnessFromMetallicTextureAlpha: boolean;
  67867. /**
  67868. * Specifies if the metallic texture contains the roughness information in its green channel.
  67869. */
  67870. useRoughnessFromMetallicTextureGreen: boolean;
  67871. /**
  67872. * Create a new ReflectivityBlock
  67873. * @param name defines the block name
  67874. */
  67875. constructor(name: string);
  67876. /**
  67877. * Initialize the block and prepare the context for build
  67878. * @param state defines the state that will be used for the build
  67879. */
  67880. initialize(state: NodeMaterialBuildState): void;
  67881. /**
  67882. * Gets the current class name
  67883. * @returns the class name
  67884. */
  67885. getClassName(): string;
  67886. /**
  67887. * Gets the metallic input component
  67888. */
  67889. get metallic(): NodeMaterialConnectionPoint;
  67890. /**
  67891. * Gets the roughness input component
  67892. */
  67893. get roughness(): NodeMaterialConnectionPoint;
  67894. /**
  67895. * Gets the texture input component
  67896. */
  67897. get texture(): NodeMaterialConnectionPoint;
  67898. /**
  67899. * Gets the reflectivity object output component
  67900. */
  67901. get reflectivity(): NodeMaterialConnectionPoint;
  67902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67903. /**
  67904. * Gets the main code of the block (fragment side)
  67905. * @param state current state of the node material building
  67906. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67907. * @returns the shader code
  67908. */
  67909. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67911. protected _buildBlock(state: NodeMaterialBuildState): this;
  67912. protected _dumpPropertiesCode(): string;
  67913. serialize(): any;
  67914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67915. }
  67916. }
  67917. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67918. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67923. /**
  67924. * Block used to implement the anisotropy module of the PBR material
  67925. */
  67926. export class AnisotropyBlock extends NodeMaterialBlock {
  67927. /**
  67928. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67929. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67930. * It's less burden on the user side in the editor part.
  67931. */
  67932. /** @hidden */
  67933. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67934. /** @hidden */
  67935. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67936. /**
  67937. * Create a new AnisotropyBlock
  67938. * @param name defines the block name
  67939. */
  67940. constructor(name: string);
  67941. /**
  67942. * Initialize the block and prepare the context for build
  67943. * @param state defines the state that will be used for the build
  67944. */
  67945. initialize(state: NodeMaterialBuildState): void;
  67946. /**
  67947. * Gets the current class name
  67948. * @returns the class name
  67949. */
  67950. getClassName(): string;
  67951. /**
  67952. * Gets the intensity input component
  67953. */
  67954. get intensity(): NodeMaterialConnectionPoint;
  67955. /**
  67956. * Gets the direction input component
  67957. */
  67958. get direction(): NodeMaterialConnectionPoint;
  67959. /**
  67960. * Gets the texture input component
  67961. */
  67962. get texture(): NodeMaterialConnectionPoint;
  67963. /**
  67964. * Gets the uv input component
  67965. */
  67966. get uv(): NodeMaterialConnectionPoint;
  67967. /**
  67968. * Gets the worldTangent input component
  67969. */
  67970. get worldTangent(): NodeMaterialConnectionPoint;
  67971. /**
  67972. * Gets the anisotropy object output component
  67973. */
  67974. get anisotropy(): NodeMaterialConnectionPoint;
  67975. private _generateTBNSpace;
  67976. /**
  67977. * Gets the main code of the block (fragment side)
  67978. * @param state current state of the node material building
  67979. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67980. * @returns the shader code
  67981. */
  67982. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67984. protected _buildBlock(state: NodeMaterialBuildState): this;
  67985. }
  67986. }
  67987. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67991. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67993. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67994. import { Nullable } from "babylonjs/types";
  67995. import { Mesh } from "babylonjs/Meshes/mesh";
  67996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67997. import { Effect } from "babylonjs/Materials/effect";
  67998. /**
  67999. * Block used to implement the clear coat module of the PBR material
  68000. */
  68001. export class ClearCoatBlock extends NodeMaterialBlock {
  68002. private _scene;
  68003. /**
  68004. * Create a new ClearCoatBlock
  68005. * @param name defines the block name
  68006. */
  68007. constructor(name: string);
  68008. /**
  68009. * Initialize the block and prepare the context for build
  68010. * @param state defines the state that will be used for the build
  68011. */
  68012. initialize(state: NodeMaterialBuildState): void;
  68013. /**
  68014. * Gets the current class name
  68015. * @returns the class name
  68016. */
  68017. getClassName(): string;
  68018. /**
  68019. * Gets the intensity input component
  68020. */
  68021. get intensity(): NodeMaterialConnectionPoint;
  68022. /**
  68023. * Gets the roughness input component
  68024. */
  68025. get roughness(): NodeMaterialConnectionPoint;
  68026. /**
  68027. * Gets the ior input component
  68028. */
  68029. get ior(): NodeMaterialConnectionPoint;
  68030. /**
  68031. * Gets the texture input component
  68032. */
  68033. get texture(): NodeMaterialConnectionPoint;
  68034. /**
  68035. * Gets the bump texture input component
  68036. */
  68037. get bumpTexture(): NodeMaterialConnectionPoint;
  68038. /**
  68039. * Gets the uv input component
  68040. */
  68041. get uv(): NodeMaterialConnectionPoint;
  68042. /**
  68043. * Gets the tint color input component
  68044. */
  68045. get tintColor(): NodeMaterialConnectionPoint;
  68046. /**
  68047. * Gets the tint "at distance" input component
  68048. */
  68049. get tintAtDistance(): NodeMaterialConnectionPoint;
  68050. /**
  68051. * Gets the tint thickness input component
  68052. */
  68053. get tintThickness(): NodeMaterialConnectionPoint;
  68054. /**
  68055. * Gets the world tangent input component
  68056. */
  68057. get worldTangent(): NodeMaterialConnectionPoint;
  68058. /**
  68059. * Gets the clear coat object output component
  68060. */
  68061. get clearcoat(): NodeMaterialConnectionPoint;
  68062. autoConfigure(material: NodeMaterial): void;
  68063. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68064. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68065. private _generateTBNSpace;
  68066. /**
  68067. * Gets the main code of the block (fragment side)
  68068. * @param state current state of the node material building
  68069. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68070. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68071. * @param worldPosVarName name of the variable holding the world position
  68072. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68073. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68074. * @param worldNormalVarName name of the variable holding the world normal
  68075. * @returns the shader code
  68076. */
  68077. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68078. protected _buildBlock(state: NodeMaterialBuildState): this;
  68079. }
  68080. }
  68081. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68085. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68087. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68088. import { Nullable } from "babylonjs/types";
  68089. /**
  68090. * Block used to implement the sub surface module of the PBR material
  68091. */
  68092. export class SubSurfaceBlock extends NodeMaterialBlock {
  68093. /**
  68094. * Create a new SubSurfaceBlock
  68095. * @param name defines the block name
  68096. */
  68097. constructor(name: string);
  68098. /**
  68099. * Stores the intensity of the different subsurface effects in the thickness texture.
  68100. * * the green channel is the translucency intensity.
  68101. * * the blue channel is the scattering intensity.
  68102. * * the alpha channel is the refraction intensity.
  68103. */
  68104. useMaskFromThicknessTexture: boolean;
  68105. /**
  68106. * Initialize the block and prepare the context for build
  68107. * @param state defines the state that will be used for the build
  68108. */
  68109. initialize(state: NodeMaterialBuildState): void;
  68110. /**
  68111. * Gets the current class name
  68112. * @returns the class name
  68113. */
  68114. getClassName(): string;
  68115. /**
  68116. * Gets the min thickness input component
  68117. */
  68118. get minThickness(): NodeMaterialConnectionPoint;
  68119. /**
  68120. * Gets the max thickness input component
  68121. */
  68122. get maxThickness(): NodeMaterialConnectionPoint;
  68123. /**
  68124. * Gets the thickness texture component
  68125. */
  68126. get thicknessTexture(): NodeMaterialConnectionPoint;
  68127. /**
  68128. * Gets the tint color input component
  68129. */
  68130. get tintColor(): NodeMaterialConnectionPoint;
  68131. /**
  68132. * Gets the translucency intensity input component
  68133. */
  68134. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68135. /**
  68136. * Gets the translucency diffusion distance input component
  68137. */
  68138. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68139. /**
  68140. * Gets the refraction object parameters
  68141. */
  68142. get refraction(): NodeMaterialConnectionPoint;
  68143. /**
  68144. * Gets the sub surface object output component
  68145. */
  68146. get subsurface(): NodeMaterialConnectionPoint;
  68147. autoConfigure(material: NodeMaterial): void;
  68148. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68149. /**
  68150. * Gets the main code of the block (fragment side)
  68151. * @param state current state of the node material building
  68152. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68153. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68154. * @param worldPosVarName name of the variable holding the world position
  68155. * @returns the shader code
  68156. */
  68157. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68158. protected _buildBlock(state: NodeMaterialBuildState): this;
  68159. }
  68160. }
  68161. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68165. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68166. import { Light } from "babylonjs/Lights/light";
  68167. import { Nullable } from "babylonjs/types";
  68168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68169. import { Effect } from "babylonjs/Materials/effect";
  68170. import { Mesh } from "babylonjs/Meshes/mesh";
  68171. import { Scene } from "babylonjs/scene";
  68172. /**
  68173. * Block used to implement the PBR metallic/roughness model
  68174. */
  68175. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68176. /**
  68177. * Gets or sets the light associated with this block
  68178. */
  68179. light: Nullable<Light>;
  68180. private _lightId;
  68181. private _scene;
  68182. private _environmentBRDFTexture;
  68183. private _environmentBrdfSamplerName;
  68184. private _vNormalWName;
  68185. private _invertNormalName;
  68186. /**
  68187. * Create a new ReflectionBlock
  68188. * @param name defines the block name
  68189. */
  68190. constructor(name: string);
  68191. /**
  68192. * Intensity of the direct lights e.g. the four lights available in your scene.
  68193. * This impacts both the direct diffuse and specular highlights.
  68194. */
  68195. directIntensity: number;
  68196. /**
  68197. * Intensity of the environment e.g. how much the environment will light the object
  68198. * either through harmonics for rough material or through the refelction for shiny ones.
  68199. */
  68200. environmentIntensity: number;
  68201. /**
  68202. * This is a special control allowing the reduction of the specular highlights coming from the
  68203. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68204. */
  68205. specularIntensity: number;
  68206. /**
  68207. * Defines the falloff type used in this material.
  68208. * It by default is Physical.
  68209. */
  68210. lightFalloff: number;
  68211. /**
  68212. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68213. */
  68214. useAlphaFromAlbedoTexture: boolean;
  68215. /**
  68216. * Specifies that alpha test should be used
  68217. */
  68218. useAlphaTest: boolean;
  68219. /**
  68220. * Defines the alpha limits in alpha test mode.
  68221. */
  68222. alphaTestCutoff: number;
  68223. /**
  68224. * Specifies that alpha blending should be used
  68225. */
  68226. useAlphaBlending: boolean;
  68227. /**
  68228. * Defines if the alpha value should be determined via the rgb values.
  68229. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68230. */
  68231. opacityRGB: boolean;
  68232. /**
  68233. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68234. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68235. */
  68236. useRadianceOverAlpha: boolean;
  68237. /**
  68238. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68239. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68240. */
  68241. useSpecularOverAlpha: boolean;
  68242. /**
  68243. * Enables specular anti aliasing in the PBR shader.
  68244. * It will both interacts on the Geometry for analytical and IBL lighting.
  68245. * It also prefilter the roughness map based on the bump values.
  68246. */
  68247. enableSpecularAntiAliasing: boolean;
  68248. /**
  68249. * Enables realtime filtering on the texture.
  68250. */
  68251. realTimeFiltering: boolean;
  68252. /**
  68253. * Quality switch for realtime filtering
  68254. */
  68255. realTimeFilteringQuality: number;
  68256. /**
  68257. * Defines if the material uses energy conservation.
  68258. */
  68259. useEnergyConservation: boolean;
  68260. /**
  68261. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68262. * too much the area relying on ambient texture to define their ambient occlusion.
  68263. */
  68264. useRadianceOcclusion: boolean;
  68265. /**
  68266. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68267. * makes the reflect vector face the model (under horizon).
  68268. */
  68269. useHorizonOcclusion: boolean;
  68270. /**
  68271. * If set to true, no lighting calculations will be applied.
  68272. */
  68273. unlit: boolean;
  68274. /**
  68275. * Force normal to face away from face.
  68276. */
  68277. forceNormalForward: boolean;
  68278. /**
  68279. * Defines the material debug mode.
  68280. * It helps seeing only some components of the material while troubleshooting.
  68281. */
  68282. debugMode: number;
  68283. /**
  68284. * Specify from where on screen the debug mode should start.
  68285. * The value goes from -1 (full screen) to 1 (not visible)
  68286. * It helps with side by side comparison against the final render
  68287. * This defaults to 0
  68288. */
  68289. debugLimit: number;
  68290. /**
  68291. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68292. * You can use the factor to better multiply the final value.
  68293. */
  68294. debugFactor: number;
  68295. /**
  68296. * Initialize the block and prepare the context for build
  68297. * @param state defines the state that will be used for the build
  68298. */
  68299. initialize(state: NodeMaterialBuildState): void;
  68300. /**
  68301. * Gets the current class name
  68302. * @returns the class name
  68303. */
  68304. getClassName(): string;
  68305. /**
  68306. * Gets the world position input component
  68307. */
  68308. get worldPosition(): NodeMaterialConnectionPoint;
  68309. /**
  68310. * Gets the world normal input component
  68311. */
  68312. get worldNormal(): NodeMaterialConnectionPoint;
  68313. /**
  68314. * Gets the perturbed normal input component
  68315. */
  68316. get perturbedNormal(): NodeMaterialConnectionPoint;
  68317. /**
  68318. * Gets the camera position input component
  68319. */
  68320. get cameraPosition(): NodeMaterialConnectionPoint;
  68321. /**
  68322. * Gets the base color input component
  68323. */
  68324. get baseColor(): NodeMaterialConnectionPoint;
  68325. /**
  68326. * Gets the opacity texture input component
  68327. */
  68328. get opacityTexture(): NodeMaterialConnectionPoint;
  68329. /**
  68330. * Gets the ambient color input component
  68331. */
  68332. get ambientColor(): NodeMaterialConnectionPoint;
  68333. /**
  68334. * Gets the reflectivity object parameters
  68335. */
  68336. get reflectivity(): NodeMaterialConnectionPoint;
  68337. /**
  68338. * Gets the ambient occlusion object parameters
  68339. */
  68340. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68341. /**
  68342. * Gets the reflection object parameters
  68343. */
  68344. get reflection(): NodeMaterialConnectionPoint;
  68345. /**
  68346. * Gets the sheen object parameters
  68347. */
  68348. get sheen(): NodeMaterialConnectionPoint;
  68349. /**
  68350. * Gets the clear coat object parameters
  68351. */
  68352. get clearcoat(): NodeMaterialConnectionPoint;
  68353. /**
  68354. * Gets the sub surface object parameters
  68355. */
  68356. get subsurface(): NodeMaterialConnectionPoint;
  68357. /**
  68358. * Gets the anisotropy object parameters
  68359. */
  68360. get anisotropy(): NodeMaterialConnectionPoint;
  68361. /**
  68362. * Gets the ambient output component
  68363. */
  68364. get ambient(): NodeMaterialConnectionPoint;
  68365. /**
  68366. * Gets the diffuse output component
  68367. */
  68368. get diffuse(): NodeMaterialConnectionPoint;
  68369. /**
  68370. * Gets the specular output component
  68371. */
  68372. get specular(): NodeMaterialConnectionPoint;
  68373. /**
  68374. * Gets the sheen output component
  68375. */
  68376. get sheenDir(): NodeMaterialConnectionPoint;
  68377. /**
  68378. * Gets the clear coat output component
  68379. */
  68380. get clearcoatDir(): NodeMaterialConnectionPoint;
  68381. /**
  68382. * Gets the indirect diffuse output component
  68383. */
  68384. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68385. /**
  68386. * Gets the indirect specular output component
  68387. */
  68388. get specularIndirect(): NodeMaterialConnectionPoint;
  68389. /**
  68390. * Gets the indirect sheen output component
  68391. */
  68392. get sheenIndirect(): NodeMaterialConnectionPoint;
  68393. /**
  68394. * Gets the indirect clear coat output component
  68395. */
  68396. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68397. /**
  68398. * Gets the refraction output component
  68399. */
  68400. get refraction(): NodeMaterialConnectionPoint;
  68401. /**
  68402. * Gets the global lighting output component
  68403. */
  68404. get lighting(): NodeMaterialConnectionPoint;
  68405. /**
  68406. * Gets the shadow output component
  68407. */
  68408. get shadow(): NodeMaterialConnectionPoint;
  68409. /**
  68410. * Gets the alpha output component
  68411. */
  68412. get alpha(): NodeMaterialConnectionPoint;
  68413. autoConfigure(material: NodeMaterial): void;
  68414. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68415. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68416. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68417. private _injectVertexCode;
  68418. /**
  68419. * Gets the code corresponding to the albedo/opacity module
  68420. * @returns the shader code
  68421. */
  68422. getAlbedoOpacityCode(): string;
  68423. protected _buildBlock(state: NodeMaterialBuildState): this;
  68424. protected _dumpPropertiesCode(): string;
  68425. serialize(): any;
  68426. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68427. }
  68428. }
  68429. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68430. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68431. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68432. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68433. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68434. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68435. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68436. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68437. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68438. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68439. }
  68440. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68441. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68442. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68443. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68444. }
  68445. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68449. /**
  68450. * Block used to compute value of one parameter modulo another
  68451. */
  68452. export class ModBlock extends NodeMaterialBlock {
  68453. /**
  68454. * Creates a new ModBlock
  68455. * @param name defines the block name
  68456. */
  68457. constructor(name: string);
  68458. /**
  68459. * Gets the current class name
  68460. * @returns the class name
  68461. */
  68462. getClassName(): string;
  68463. /**
  68464. * Gets the left operand input component
  68465. */
  68466. get left(): NodeMaterialConnectionPoint;
  68467. /**
  68468. * Gets the right operand input component
  68469. */
  68470. get right(): NodeMaterialConnectionPoint;
  68471. /**
  68472. * Gets the output component
  68473. */
  68474. get output(): NodeMaterialConnectionPoint;
  68475. protected _buildBlock(state: NodeMaterialBuildState): this;
  68476. }
  68477. }
  68478. declare module "babylonjs/Materials/Node/Blocks/index" {
  68479. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68480. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68481. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68482. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68483. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68484. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68485. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68486. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68487. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68488. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68489. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68490. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68491. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68492. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68493. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68494. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68495. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68496. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68497. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68498. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68499. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68500. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68501. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68502. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68503. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68504. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68505. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68506. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68507. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68508. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68509. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68510. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68511. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68512. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68513. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68514. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68515. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68516. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68517. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68518. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68519. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68520. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68521. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68522. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68523. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68524. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68525. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68526. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68527. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68528. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68529. }
  68530. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68531. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68532. }
  68533. declare module "babylonjs/Materials/Node/index" {
  68534. export * from "babylonjs/Materials/Node/Enums/index";
  68535. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68536. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68537. export * from "babylonjs/Materials/Node/nodeMaterial";
  68538. export * from "babylonjs/Materials/Node/Blocks/index";
  68539. export * from "babylonjs/Materials/Node/Optimizers/index";
  68540. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68541. }
  68542. declare module "babylonjs/Materials/index" {
  68543. export * from "babylonjs/Materials/Background/index";
  68544. export * from "babylonjs/Materials/colorCurves";
  68545. export * from "babylonjs/Materials/iEffectFallbacks";
  68546. export * from "babylonjs/Materials/effectFallbacks";
  68547. export * from "babylonjs/Materials/effect";
  68548. export * from "babylonjs/Materials/fresnelParameters";
  68549. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68550. export * from "babylonjs/Materials/material";
  68551. export * from "babylonjs/Materials/materialDefines";
  68552. export * from "babylonjs/Materials/thinMaterialHelper";
  68553. export * from "babylonjs/Materials/materialHelper";
  68554. export * from "babylonjs/Materials/multiMaterial";
  68555. export * from "babylonjs/Materials/PBR/index";
  68556. export * from "babylonjs/Materials/pushMaterial";
  68557. export * from "babylonjs/Materials/shaderMaterial";
  68558. export * from "babylonjs/Materials/standardMaterial";
  68559. export * from "babylonjs/Materials/Textures/index";
  68560. export * from "babylonjs/Materials/uniformBuffer";
  68561. export * from "babylonjs/Materials/materialFlags";
  68562. export * from "babylonjs/Materials/Node/index";
  68563. export * from "babylonjs/Materials/effectRenderer";
  68564. export * from "babylonjs/Materials/shadowDepthWrapper";
  68565. }
  68566. declare module "babylonjs/Maths/index" {
  68567. export * from "babylonjs/Maths/math.scalar";
  68568. export * from "babylonjs/Maths/math";
  68569. export * from "babylonjs/Maths/sphericalPolynomial";
  68570. }
  68571. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68572. import { IDisposable } from "babylonjs/scene";
  68573. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68574. /**
  68575. * Configuration for Draco compression
  68576. */
  68577. export interface IDracoCompressionConfiguration {
  68578. /**
  68579. * Configuration for the decoder.
  68580. */
  68581. decoder: {
  68582. /**
  68583. * The url to the WebAssembly module.
  68584. */
  68585. wasmUrl?: string;
  68586. /**
  68587. * The url to the WebAssembly binary.
  68588. */
  68589. wasmBinaryUrl?: string;
  68590. /**
  68591. * The url to the fallback JavaScript module.
  68592. */
  68593. fallbackUrl?: string;
  68594. };
  68595. }
  68596. /**
  68597. * Draco compression (https://google.github.io/draco/)
  68598. *
  68599. * This class wraps the Draco module.
  68600. *
  68601. * **Encoder**
  68602. *
  68603. * The encoder is not currently implemented.
  68604. *
  68605. * **Decoder**
  68606. *
  68607. * 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.
  68608. *
  68609. * To update the configuration, use the following code:
  68610. * ```javascript
  68611. * DracoCompression.Configuration = {
  68612. * decoder: {
  68613. * wasmUrl: "<url to the WebAssembly library>",
  68614. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68615. * fallbackUrl: "<url to the fallback JavaScript library>",
  68616. * }
  68617. * };
  68618. * ```
  68619. *
  68620. * 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.
  68621. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68622. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68623. *
  68624. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68625. * ```javascript
  68626. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68627. * ```
  68628. *
  68629. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68630. */
  68631. export class DracoCompression implements IDisposable {
  68632. private _workerPoolPromise?;
  68633. private _decoderModulePromise?;
  68634. /**
  68635. * The configuration. Defaults to the following urls:
  68636. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68637. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68638. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68639. */
  68640. static Configuration: IDracoCompressionConfiguration;
  68641. /**
  68642. * Returns true if the decoder configuration is available.
  68643. */
  68644. static get DecoderAvailable(): boolean;
  68645. /**
  68646. * Default number of workers to create when creating the draco compression object.
  68647. */
  68648. static DefaultNumWorkers: number;
  68649. private static GetDefaultNumWorkers;
  68650. private static _Default;
  68651. /**
  68652. * Default instance for the draco compression object.
  68653. */
  68654. static get Default(): DracoCompression;
  68655. /**
  68656. * Constructor
  68657. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68658. */
  68659. constructor(numWorkers?: number);
  68660. /**
  68661. * Stop all async operations and release resources.
  68662. */
  68663. dispose(): void;
  68664. /**
  68665. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68666. * @returns a promise that resolves when ready
  68667. */
  68668. whenReadyAsync(): Promise<void>;
  68669. /**
  68670. * Decode Draco compressed mesh data to vertex data.
  68671. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68672. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68673. * @returns A promise that resolves with the decoded vertex data
  68674. */
  68675. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68676. [kind: string]: number;
  68677. }): Promise<VertexData>;
  68678. }
  68679. }
  68680. declare module "babylonjs/Meshes/Compression/index" {
  68681. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68682. }
  68683. declare module "babylonjs/Meshes/csg" {
  68684. import { Nullable } from "babylonjs/types";
  68685. import { Scene } from "babylonjs/scene";
  68686. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68687. import { Mesh } from "babylonjs/Meshes/mesh";
  68688. import { Material } from "babylonjs/Materials/material";
  68689. /**
  68690. * Class for building Constructive Solid Geometry
  68691. */
  68692. export class CSG {
  68693. private polygons;
  68694. /**
  68695. * The world matrix
  68696. */
  68697. matrix: Matrix;
  68698. /**
  68699. * Stores the position
  68700. */
  68701. position: Vector3;
  68702. /**
  68703. * Stores the rotation
  68704. */
  68705. rotation: Vector3;
  68706. /**
  68707. * Stores the rotation quaternion
  68708. */
  68709. rotationQuaternion: Nullable<Quaternion>;
  68710. /**
  68711. * Stores the scaling vector
  68712. */
  68713. scaling: Vector3;
  68714. /**
  68715. * Convert the Mesh to CSG
  68716. * @param mesh The Mesh to convert to CSG
  68717. * @returns A new CSG from the Mesh
  68718. */
  68719. static FromMesh(mesh: Mesh): CSG;
  68720. /**
  68721. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68722. * @param polygons Polygons used to construct a CSG solid
  68723. */
  68724. private static FromPolygons;
  68725. /**
  68726. * Clones, or makes a deep copy, of the CSG
  68727. * @returns A new CSG
  68728. */
  68729. clone(): CSG;
  68730. /**
  68731. * Unions this CSG with another CSG
  68732. * @param csg The CSG to union against this CSG
  68733. * @returns The unioned CSG
  68734. */
  68735. union(csg: CSG): CSG;
  68736. /**
  68737. * Unions this CSG with another CSG in place
  68738. * @param csg The CSG to union against this CSG
  68739. */
  68740. unionInPlace(csg: CSG): void;
  68741. /**
  68742. * Subtracts this CSG with another CSG
  68743. * @param csg The CSG to subtract against this CSG
  68744. * @returns A new CSG
  68745. */
  68746. subtract(csg: CSG): CSG;
  68747. /**
  68748. * Subtracts this CSG with another CSG in place
  68749. * @param csg The CSG to subtact against this CSG
  68750. */
  68751. subtractInPlace(csg: CSG): void;
  68752. /**
  68753. * Intersect this CSG with another CSG
  68754. * @param csg The CSG to intersect against this CSG
  68755. * @returns A new CSG
  68756. */
  68757. intersect(csg: CSG): CSG;
  68758. /**
  68759. * Intersects this CSG with another CSG in place
  68760. * @param csg The CSG to intersect against this CSG
  68761. */
  68762. intersectInPlace(csg: CSG): void;
  68763. /**
  68764. * Return a new CSG solid with solid and empty space switched. This solid is
  68765. * not modified.
  68766. * @returns A new CSG solid with solid and empty space switched
  68767. */
  68768. inverse(): CSG;
  68769. /**
  68770. * Inverses the CSG in place
  68771. */
  68772. inverseInPlace(): void;
  68773. /**
  68774. * This is used to keep meshes transformations so they can be restored
  68775. * when we build back a Babylon Mesh
  68776. * NB : All CSG operations are performed in world coordinates
  68777. * @param csg The CSG to copy the transform attributes from
  68778. * @returns This CSG
  68779. */
  68780. copyTransformAttributes(csg: CSG): CSG;
  68781. /**
  68782. * Build Raw mesh from CSG
  68783. * Coordinates here are in world space
  68784. * @param name The name of the mesh geometry
  68785. * @param scene The Scene
  68786. * @param keepSubMeshes Specifies if the submeshes should be kept
  68787. * @returns A new Mesh
  68788. */
  68789. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68790. /**
  68791. * Build Mesh from CSG taking material and transforms into account
  68792. * @param name The name of the Mesh
  68793. * @param material The material of the Mesh
  68794. * @param scene The Scene
  68795. * @param keepSubMeshes Specifies if submeshes should be kept
  68796. * @returns The new Mesh
  68797. */
  68798. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68799. }
  68800. }
  68801. declare module "babylonjs/Meshes/trailMesh" {
  68802. import { Mesh } from "babylonjs/Meshes/mesh";
  68803. import { Scene } from "babylonjs/scene";
  68804. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68805. /**
  68806. * Class used to create a trail following a mesh
  68807. */
  68808. export class TrailMesh extends Mesh {
  68809. private _generator;
  68810. private _autoStart;
  68811. private _running;
  68812. private _diameter;
  68813. private _length;
  68814. private _sectionPolygonPointsCount;
  68815. private _sectionVectors;
  68816. private _sectionNormalVectors;
  68817. private _beforeRenderObserver;
  68818. /**
  68819. * @constructor
  68820. * @param name The value used by scene.getMeshByName() to do a lookup.
  68821. * @param generator The mesh or transform node to generate a trail.
  68822. * @param scene The scene to add this mesh to.
  68823. * @param diameter Diameter of trailing mesh. Default is 1.
  68824. * @param length Length of trailing mesh. Default is 60.
  68825. * @param autoStart Automatically start trailing mesh. Default true.
  68826. */
  68827. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68828. /**
  68829. * "TrailMesh"
  68830. * @returns "TrailMesh"
  68831. */
  68832. getClassName(): string;
  68833. private _createMesh;
  68834. /**
  68835. * Start trailing mesh.
  68836. */
  68837. start(): void;
  68838. /**
  68839. * Stop trailing mesh.
  68840. */
  68841. stop(): void;
  68842. /**
  68843. * Update trailing mesh geometry.
  68844. */
  68845. update(): void;
  68846. /**
  68847. * Returns a new TrailMesh object.
  68848. * @param name is a string, the name given to the new mesh
  68849. * @param newGenerator use new generator object for cloned trail mesh
  68850. * @returns a new mesh
  68851. */
  68852. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68853. /**
  68854. * Serializes this trail mesh
  68855. * @param serializationObject object to write serialization to
  68856. */
  68857. serialize(serializationObject: any): void;
  68858. /**
  68859. * Parses a serialized trail mesh
  68860. * @param parsedMesh the serialized mesh
  68861. * @param scene the scene to create the trail mesh in
  68862. * @returns the created trail mesh
  68863. */
  68864. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68865. }
  68866. }
  68867. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68868. import { Nullable } from "babylonjs/types";
  68869. import { Scene } from "babylonjs/scene";
  68870. import { Vector4 } from "babylonjs/Maths/math.vector";
  68871. import { Color4 } from "babylonjs/Maths/math.color";
  68872. import { Mesh } from "babylonjs/Meshes/mesh";
  68873. /**
  68874. * Class containing static functions to help procedurally build meshes
  68875. */
  68876. export class TiledBoxBuilder {
  68877. /**
  68878. * Creates a box mesh
  68879. * 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)
  68880. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68884. * @param name defines the name of the mesh
  68885. * @param options defines the options used to create the mesh
  68886. * @param scene defines the hosting scene
  68887. * @returns the box mesh
  68888. */
  68889. static CreateTiledBox(name: string, options: {
  68890. pattern?: number;
  68891. width?: number;
  68892. height?: number;
  68893. depth?: number;
  68894. tileSize?: number;
  68895. tileWidth?: number;
  68896. tileHeight?: number;
  68897. alignHorizontal?: number;
  68898. alignVertical?: number;
  68899. faceUV?: Vector4[];
  68900. faceColors?: Color4[];
  68901. sideOrientation?: number;
  68902. updatable?: boolean;
  68903. }, scene?: Nullable<Scene>): Mesh;
  68904. }
  68905. }
  68906. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68907. import { Vector4 } from "babylonjs/Maths/math.vector";
  68908. import { Mesh } from "babylonjs/Meshes/mesh";
  68909. /**
  68910. * Class containing static functions to help procedurally build meshes
  68911. */
  68912. export class TorusKnotBuilder {
  68913. /**
  68914. * Creates a torus knot mesh
  68915. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68916. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68917. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68918. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68922. * @param name defines the name of the mesh
  68923. * @param options defines the options used to create the mesh
  68924. * @param scene defines the hosting scene
  68925. * @returns the torus knot mesh
  68926. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68927. */
  68928. static CreateTorusKnot(name: string, options: {
  68929. radius?: number;
  68930. tube?: number;
  68931. radialSegments?: number;
  68932. tubularSegments?: number;
  68933. p?: number;
  68934. q?: number;
  68935. updatable?: boolean;
  68936. sideOrientation?: number;
  68937. frontUVs?: Vector4;
  68938. backUVs?: Vector4;
  68939. }, scene: any): Mesh;
  68940. }
  68941. }
  68942. declare module "babylonjs/Meshes/polygonMesh" {
  68943. import { Scene } from "babylonjs/scene";
  68944. import { Vector2 } from "babylonjs/Maths/math.vector";
  68945. import { Mesh } from "babylonjs/Meshes/mesh";
  68946. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68947. import { Path2 } from "babylonjs/Maths/math.path";
  68948. /**
  68949. * Polygon
  68950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68951. */
  68952. export class Polygon {
  68953. /**
  68954. * Creates a rectangle
  68955. * @param xmin bottom X coord
  68956. * @param ymin bottom Y coord
  68957. * @param xmax top X coord
  68958. * @param ymax top Y coord
  68959. * @returns points that make the resulting rectation
  68960. */
  68961. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68962. /**
  68963. * Creates a circle
  68964. * @param radius radius of circle
  68965. * @param cx scale in x
  68966. * @param cy scale in y
  68967. * @param numberOfSides number of sides that make up the circle
  68968. * @returns points that make the resulting circle
  68969. */
  68970. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68971. /**
  68972. * Creates a polygon from input string
  68973. * @param input Input polygon data
  68974. * @returns the parsed points
  68975. */
  68976. static Parse(input: string): Vector2[];
  68977. /**
  68978. * Starts building a polygon from x and y coordinates
  68979. * @param x x coordinate
  68980. * @param y y coordinate
  68981. * @returns the started path2
  68982. */
  68983. static StartingAt(x: number, y: number): Path2;
  68984. }
  68985. /**
  68986. * Builds a polygon
  68987. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68988. */
  68989. export class PolygonMeshBuilder {
  68990. private _points;
  68991. private _outlinepoints;
  68992. private _holes;
  68993. private _name;
  68994. private _scene;
  68995. private _epoints;
  68996. private _eholes;
  68997. private _addToepoint;
  68998. /**
  68999. * Babylon reference to the earcut plugin.
  69000. */
  69001. bjsEarcut: any;
  69002. /**
  69003. * Creates a PolygonMeshBuilder
  69004. * @param name name of the builder
  69005. * @param contours Path of the polygon
  69006. * @param scene scene to add to when creating the mesh
  69007. * @param earcutInjection can be used to inject your own earcut reference
  69008. */
  69009. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69010. /**
  69011. * Adds a whole within the polygon
  69012. * @param hole Array of points defining the hole
  69013. * @returns this
  69014. */
  69015. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69016. /**
  69017. * Creates the polygon
  69018. * @param updatable If the mesh should be updatable
  69019. * @param depth The depth of the mesh created
  69020. * @returns the created mesh
  69021. */
  69022. build(updatable?: boolean, depth?: number): Mesh;
  69023. /**
  69024. * Creates the polygon
  69025. * @param depth The depth of the mesh created
  69026. * @returns the created VertexData
  69027. */
  69028. buildVertexData(depth?: number): VertexData;
  69029. /**
  69030. * Adds a side to the polygon
  69031. * @param positions points that make the polygon
  69032. * @param normals normals of the polygon
  69033. * @param uvs uvs of the polygon
  69034. * @param indices indices of the polygon
  69035. * @param bounds bounds of the polygon
  69036. * @param points points of the polygon
  69037. * @param depth depth of the polygon
  69038. * @param flip flip of the polygon
  69039. */
  69040. private addSide;
  69041. }
  69042. }
  69043. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69044. import { Scene } from "babylonjs/scene";
  69045. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69046. import { Color4 } from "babylonjs/Maths/math.color";
  69047. import { Mesh } from "babylonjs/Meshes/mesh";
  69048. import { Nullable } from "babylonjs/types";
  69049. /**
  69050. * Class containing static functions to help procedurally build meshes
  69051. */
  69052. export class PolygonBuilder {
  69053. /**
  69054. * Creates a polygon mesh
  69055. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69056. * * 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
  69057. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69060. * * Remember you can only change the shape positions, not their number when updating a polygon
  69061. * @param name defines the name of the mesh
  69062. * @param options defines the options used to create the mesh
  69063. * @param scene defines the hosting scene
  69064. * @param earcutInjection can be used to inject your own earcut reference
  69065. * @returns the polygon mesh
  69066. */
  69067. static CreatePolygon(name: string, options: {
  69068. shape: Vector3[];
  69069. holes?: Vector3[][];
  69070. depth?: number;
  69071. faceUV?: Vector4[];
  69072. faceColors?: Color4[];
  69073. updatable?: boolean;
  69074. sideOrientation?: number;
  69075. frontUVs?: Vector4;
  69076. backUVs?: Vector4;
  69077. wrap?: boolean;
  69078. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69079. /**
  69080. * Creates an extruded polygon mesh, with depth in the Y direction.
  69081. * * 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)
  69082. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69083. * @param name defines the name of the mesh
  69084. * @param options defines the options used to create the mesh
  69085. * @param scene defines the hosting scene
  69086. * @param earcutInjection can be used to inject your own earcut reference
  69087. * @returns the polygon mesh
  69088. */
  69089. static ExtrudePolygon(name: string, options: {
  69090. shape: Vector3[];
  69091. holes?: Vector3[][];
  69092. depth?: number;
  69093. faceUV?: Vector4[];
  69094. faceColors?: Color4[];
  69095. updatable?: boolean;
  69096. sideOrientation?: number;
  69097. frontUVs?: Vector4;
  69098. backUVs?: Vector4;
  69099. wrap?: boolean;
  69100. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69101. }
  69102. }
  69103. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69104. import { Scene } from "babylonjs/scene";
  69105. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69106. import { Mesh } from "babylonjs/Meshes/mesh";
  69107. import { Nullable } from "babylonjs/types";
  69108. /**
  69109. * Class containing static functions to help procedurally build meshes
  69110. */
  69111. export class LatheBuilder {
  69112. /**
  69113. * Creates lathe mesh.
  69114. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69115. * * 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
  69116. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69117. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69118. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69119. * * 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
  69120. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69121. * * 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
  69122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69124. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69126. * @param name defines the name of the mesh
  69127. * @param options defines the options used to create the mesh
  69128. * @param scene defines the hosting scene
  69129. * @returns the lathe mesh
  69130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69131. */
  69132. static CreateLathe(name: string, options: {
  69133. shape: Vector3[];
  69134. radius?: number;
  69135. tessellation?: number;
  69136. clip?: number;
  69137. arc?: number;
  69138. closed?: boolean;
  69139. updatable?: boolean;
  69140. sideOrientation?: number;
  69141. frontUVs?: Vector4;
  69142. backUVs?: Vector4;
  69143. cap?: number;
  69144. invertUV?: boolean;
  69145. }, scene?: Nullable<Scene>): Mesh;
  69146. }
  69147. }
  69148. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69149. import { Nullable } from "babylonjs/types";
  69150. import { Scene } from "babylonjs/scene";
  69151. import { Vector4 } from "babylonjs/Maths/math.vector";
  69152. import { Mesh } from "babylonjs/Meshes/mesh";
  69153. /**
  69154. * Class containing static functions to help procedurally build meshes
  69155. */
  69156. export class TiledPlaneBuilder {
  69157. /**
  69158. * Creates a tiled plane mesh
  69159. * * The parameter `pattern` will, depending on value, do nothing or
  69160. * * * flip (reflect about central vertical) alternate tiles across and up
  69161. * * * flip every tile on alternate rows
  69162. * * * rotate (180 degs) alternate tiles across and up
  69163. * * * rotate every tile on alternate rows
  69164. * * * flip and rotate alternate tiles across and up
  69165. * * * flip and rotate every tile on alternate rows
  69166. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69167. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69169. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69170. * * 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)
  69171. * * 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)
  69172. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69173. * @param name defines the name of the mesh
  69174. * @param options defines the options used to create the mesh
  69175. * @param scene defines the hosting scene
  69176. * @returns the box mesh
  69177. */
  69178. static CreateTiledPlane(name: string, options: {
  69179. pattern?: number;
  69180. tileSize?: number;
  69181. tileWidth?: number;
  69182. tileHeight?: number;
  69183. size?: number;
  69184. width?: number;
  69185. height?: number;
  69186. alignHorizontal?: number;
  69187. alignVertical?: number;
  69188. sideOrientation?: number;
  69189. frontUVs?: Vector4;
  69190. backUVs?: Vector4;
  69191. updatable?: boolean;
  69192. }, scene?: Nullable<Scene>): Mesh;
  69193. }
  69194. }
  69195. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69196. import { Nullable } from "babylonjs/types";
  69197. import { Scene } from "babylonjs/scene";
  69198. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69199. import { Mesh } from "babylonjs/Meshes/mesh";
  69200. /**
  69201. * Class containing static functions to help procedurally build meshes
  69202. */
  69203. export class TubeBuilder {
  69204. /**
  69205. * Creates a tube mesh.
  69206. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69207. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69208. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69209. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69210. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69211. * * 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)
  69212. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69213. * * 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
  69214. * * 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
  69215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69219. * @param name defines the name of the mesh
  69220. * @param options defines the options used to create the mesh
  69221. * @param scene defines the hosting scene
  69222. * @returns the tube mesh
  69223. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69224. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69225. */
  69226. static CreateTube(name: string, options: {
  69227. path: Vector3[];
  69228. radius?: number;
  69229. tessellation?: number;
  69230. radiusFunction?: {
  69231. (i: number, distance: number): number;
  69232. };
  69233. cap?: number;
  69234. arc?: number;
  69235. updatable?: boolean;
  69236. sideOrientation?: number;
  69237. frontUVs?: Vector4;
  69238. backUVs?: Vector4;
  69239. instance?: Mesh;
  69240. invertUV?: boolean;
  69241. }, scene?: Nullable<Scene>): Mesh;
  69242. }
  69243. }
  69244. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69245. import { Scene } from "babylonjs/scene";
  69246. import { Vector4 } from "babylonjs/Maths/math.vector";
  69247. import { Mesh } from "babylonjs/Meshes/mesh";
  69248. import { Nullable } from "babylonjs/types";
  69249. /**
  69250. * Class containing static functions to help procedurally build meshes
  69251. */
  69252. export class IcoSphereBuilder {
  69253. /**
  69254. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69255. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69256. * * 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`)
  69257. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69258. * * 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
  69259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69262. * @param name defines the name of the mesh
  69263. * @param options defines the options used to create the mesh
  69264. * @param scene defines the hosting scene
  69265. * @returns the icosahedron mesh
  69266. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69267. */
  69268. static CreateIcoSphere(name: string, options: {
  69269. radius?: number;
  69270. radiusX?: number;
  69271. radiusY?: number;
  69272. radiusZ?: number;
  69273. flat?: boolean;
  69274. subdivisions?: number;
  69275. sideOrientation?: number;
  69276. frontUVs?: Vector4;
  69277. backUVs?: Vector4;
  69278. updatable?: boolean;
  69279. }, scene?: Nullable<Scene>): Mesh;
  69280. }
  69281. }
  69282. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69283. import { Vector3 } from "babylonjs/Maths/math.vector";
  69284. import { Mesh } from "babylonjs/Meshes/mesh";
  69285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69286. /**
  69287. * Class containing static functions to help procedurally build meshes
  69288. */
  69289. export class DecalBuilder {
  69290. /**
  69291. * Creates a decal mesh.
  69292. * 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
  69293. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69294. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69295. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69296. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69297. * @param name defines the name of the mesh
  69298. * @param sourceMesh defines the mesh where the decal must be applied
  69299. * @param options defines the options used to create the mesh
  69300. * @param scene defines the hosting scene
  69301. * @returns the decal mesh
  69302. * @see https://doc.babylonjs.com/how_to/decals
  69303. */
  69304. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69305. position?: Vector3;
  69306. normal?: Vector3;
  69307. size?: Vector3;
  69308. angle?: number;
  69309. }): Mesh;
  69310. }
  69311. }
  69312. declare module "babylonjs/Meshes/meshBuilder" {
  69313. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69314. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69315. import { Nullable } from "babylonjs/types";
  69316. import { Scene } from "babylonjs/scene";
  69317. import { Mesh } from "babylonjs/Meshes/mesh";
  69318. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69319. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69321. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69322. import { Plane } from "babylonjs/Maths/math.plane";
  69323. /**
  69324. * Class containing static functions to help procedurally build meshes
  69325. */
  69326. export class MeshBuilder {
  69327. /**
  69328. * Creates a box mesh
  69329. * * The parameter `size` sets the size (float) of each box side (default 1)
  69330. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69331. * * 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)
  69332. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69336. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69337. * @param name defines the name of the mesh
  69338. * @param options defines the options used to create the mesh
  69339. * @param scene defines the hosting scene
  69340. * @returns the box mesh
  69341. */
  69342. static CreateBox(name: string, options: {
  69343. size?: number;
  69344. width?: number;
  69345. height?: number;
  69346. depth?: number;
  69347. faceUV?: Vector4[];
  69348. faceColors?: Color4[];
  69349. sideOrientation?: number;
  69350. frontUVs?: Vector4;
  69351. backUVs?: Vector4;
  69352. wrap?: boolean;
  69353. topBaseAt?: number;
  69354. bottomBaseAt?: number;
  69355. updatable?: boolean;
  69356. }, scene?: Nullable<Scene>): Mesh;
  69357. /**
  69358. * Creates a tiled box mesh
  69359. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69361. * @param name defines the name of the mesh
  69362. * @param options defines the options used to create the mesh
  69363. * @param scene defines the hosting scene
  69364. * @returns the tiled box mesh
  69365. */
  69366. static CreateTiledBox(name: string, options: {
  69367. pattern?: number;
  69368. size?: number;
  69369. width?: number;
  69370. height?: number;
  69371. depth: number;
  69372. tileSize?: number;
  69373. tileWidth?: number;
  69374. tileHeight?: number;
  69375. faceUV?: Vector4[];
  69376. faceColors?: Color4[];
  69377. alignHorizontal?: number;
  69378. alignVertical?: number;
  69379. sideOrientation?: number;
  69380. updatable?: boolean;
  69381. }, scene?: Nullable<Scene>): Mesh;
  69382. /**
  69383. * Creates a sphere mesh
  69384. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69385. * * 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`)
  69386. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69387. * * 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
  69388. * * 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)
  69389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69392. * @param name defines the name of the mesh
  69393. * @param options defines the options used to create the mesh
  69394. * @param scene defines the hosting scene
  69395. * @returns the sphere mesh
  69396. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69397. */
  69398. static CreateSphere(name: string, options: {
  69399. segments?: number;
  69400. diameter?: number;
  69401. diameterX?: number;
  69402. diameterY?: number;
  69403. diameterZ?: number;
  69404. arc?: number;
  69405. slice?: number;
  69406. sideOrientation?: number;
  69407. frontUVs?: Vector4;
  69408. backUVs?: Vector4;
  69409. updatable?: boolean;
  69410. }, scene?: Nullable<Scene>): Mesh;
  69411. /**
  69412. * Creates a plane polygonal mesh. By default, this is a disc
  69413. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69414. * * 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
  69415. * * 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
  69416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69419. * @param name defines the name of the mesh
  69420. * @param options defines the options used to create the mesh
  69421. * @param scene defines the hosting scene
  69422. * @returns the plane polygonal mesh
  69423. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69424. */
  69425. static CreateDisc(name: string, options: {
  69426. radius?: number;
  69427. tessellation?: number;
  69428. arc?: number;
  69429. updatable?: boolean;
  69430. sideOrientation?: number;
  69431. frontUVs?: Vector4;
  69432. backUVs?: Vector4;
  69433. }, scene?: Nullable<Scene>): Mesh;
  69434. /**
  69435. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69436. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69437. * * 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`)
  69438. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69439. * * 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
  69440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69443. * @param name defines the name of the mesh
  69444. * @param options defines the options used to create the mesh
  69445. * @param scene defines the hosting scene
  69446. * @returns the icosahedron mesh
  69447. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69448. */
  69449. static CreateIcoSphere(name: string, options: {
  69450. radius?: number;
  69451. radiusX?: number;
  69452. radiusY?: number;
  69453. radiusZ?: number;
  69454. flat?: boolean;
  69455. subdivisions?: number;
  69456. sideOrientation?: number;
  69457. frontUVs?: Vector4;
  69458. backUVs?: Vector4;
  69459. updatable?: boolean;
  69460. }, scene?: Nullable<Scene>): Mesh;
  69461. /**
  69462. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69463. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69464. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69465. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69466. * * 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
  69467. * * 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
  69468. * * 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
  69469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69471. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69472. * * 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
  69473. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69474. * * 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
  69475. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69477. * @param name defines the name of the mesh
  69478. * @param options defines the options used to create the mesh
  69479. * @param scene defines the hosting scene
  69480. * @returns the ribbon mesh
  69481. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69482. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69483. */
  69484. static CreateRibbon(name: string, options: {
  69485. pathArray: Vector3[][];
  69486. closeArray?: boolean;
  69487. closePath?: boolean;
  69488. offset?: number;
  69489. updatable?: boolean;
  69490. sideOrientation?: number;
  69491. frontUVs?: Vector4;
  69492. backUVs?: Vector4;
  69493. instance?: Mesh;
  69494. invertUV?: boolean;
  69495. uvs?: Vector2[];
  69496. colors?: Color4[];
  69497. }, scene?: Nullable<Scene>): Mesh;
  69498. /**
  69499. * Creates a cylinder or a cone mesh
  69500. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69501. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69502. * * 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.
  69503. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69504. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69505. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69506. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69507. * * 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).
  69508. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69509. * * 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).
  69510. * * 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
  69511. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69512. * * 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
  69513. * * 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.
  69514. * * If `enclose` is false, a ring surface is one element.
  69515. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69516. * * 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
  69517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69520. * @param name defines the name of the mesh
  69521. * @param options defines the options used to create the mesh
  69522. * @param scene defines the hosting scene
  69523. * @returns the cylinder mesh
  69524. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69525. */
  69526. static CreateCylinder(name: string, options: {
  69527. height?: number;
  69528. diameterTop?: number;
  69529. diameterBottom?: number;
  69530. diameter?: number;
  69531. tessellation?: number;
  69532. subdivisions?: number;
  69533. arc?: number;
  69534. faceColors?: Color4[];
  69535. faceUV?: Vector4[];
  69536. updatable?: boolean;
  69537. hasRings?: boolean;
  69538. enclose?: boolean;
  69539. cap?: number;
  69540. sideOrientation?: number;
  69541. frontUVs?: Vector4;
  69542. backUVs?: Vector4;
  69543. }, scene?: Nullable<Scene>): Mesh;
  69544. /**
  69545. * Creates a torus mesh
  69546. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69547. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69548. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69552. * @param name defines the name of the mesh
  69553. * @param options defines the options used to create the mesh
  69554. * @param scene defines the hosting scene
  69555. * @returns the torus mesh
  69556. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69557. */
  69558. static CreateTorus(name: string, options: {
  69559. diameter?: number;
  69560. thickness?: number;
  69561. tessellation?: number;
  69562. updatable?: boolean;
  69563. sideOrientation?: number;
  69564. frontUVs?: Vector4;
  69565. backUVs?: Vector4;
  69566. }, scene?: Nullable<Scene>): Mesh;
  69567. /**
  69568. * Creates a torus knot mesh
  69569. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69570. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69571. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69572. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69576. * @param name defines the name of the mesh
  69577. * @param options defines the options used to create the mesh
  69578. * @param scene defines the hosting scene
  69579. * @returns the torus knot mesh
  69580. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69581. */
  69582. static CreateTorusKnot(name: string, options: {
  69583. radius?: number;
  69584. tube?: number;
  69585. radialSegments?: number;
  69586. tubularSegments?: number;
  69587. p?: number;
  69588. q?: number;
  69589. updatable?: boolean;
  69590. sideOrientation?: number;
  69591. frontUVs?: Vector4;
  69592. backUVs?: Vector4;
  69593. }, scene?: Nullable<Scene>): Mesh;
  69594. /**
  69595. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69596. * * 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
  69597. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69598. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69599. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69600. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69601. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69602. * * 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
  69603. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69606. * @param name defines the name of the new line system
  69607. * @param options defines the options used to create the line system
  69608. * @param scene defines the hosting scene
  69609. * @returns a new line system mesh
  69610. */
  69611. static CreateLineSystem(name: string, options: {
  69612. lines: Vector3[][];
  69613. updatable?: boolean;
  69614. instance?: Nullable<LinesMesh>;
  69615. colors?: Nullable<Color4[][]>;
  69616. useVertexAlpha?: boolean;
  69617. }, scene: Nullable<Scene>): LinesMesh;
  69618. /**
  69619. * Creates a line mesh
  69620. * 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
  69621. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69622. * * The parameter `points` is an array successive Vector3
  69623. * * 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
  69624. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69625. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69626. * * When updating an instance, remember that only point positions can change, not the number of points
  69627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69629. * @param name defines the name of the new line system
  69630. * @param options defines the options used to create the line system
  69631. * @param scene defines the hosting scene
  69632. * @returns a new line mesh
  69633. */
  69634. static CreateLines(name: string, options: {
  69635. points: Vector3[];
  69636. updatable?: boolean;
  69637. instance?: Nullable<LinesMesh>;
  69638. colors?: Color4[];
  69639. useVertexAlpha?: boolean;
  69640. }, scene?: Nullable<Scene>): LinesMesh;
  69641. /**
  69642. * Creates a dashed line mesh
  69643. * * 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
  69644. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69645. * * The parameter `points` is an array successive Vector3
  69646. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69647. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69648. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69649. * * 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
  69650. * * When updating an instance, remember that only point positions can change, not the number of points
  69651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69652. * @param name defines the name of the mesh
  69653. * @param options defines the options used to create the mesh
  69654. * @param scene defines the hosting scene
  69655. * @returns the dashed line mesh
  69656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69657. */
  69658. static CreateDashedLines(name: string, options: {
  69659. points: Vector3[];
  69660. dashSize?: number;
  69661. gapSize?: number;
  69662. dashNb?: number;
  69663. updatable?: boolean;
  69664. instance?: LinesMesh;
  69665. }, scene?: Nullable<Scene>): LinesMesh;
  69666. /**
  69667. * 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.
  69668. * * 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.
  69669. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69670. * * 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.
  69671. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69672. * * 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
  69673. * * 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
  69674. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69679. * @param name defines the name of the mesh
  69680. * @param options defines the options used to create the mesh
  69681. * @param scene defines the hosting scene
  69682. * @returns the extruded shape mesh
  69683. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69685. */
  69686. static ExtrudeShape(name: string, options: {
  69687. shape: Vector3[];
  69688. path: Vector3[];
  69689. scale?: number;
  69690. rotation?: number;
  69691. cap?: number;
  69692. updatable?: boolean;
  69693. sideOrientation?: number;
  69694. frontUVs?: Vector4;
  69695. backUVs?: Vector4;
  69696. instance?: Mesh;
  69697. invertUV?: boolean;
  69698. }, scene?: Nullable<Scene>): Mesh;
  69699. /**
  69700. * Creates an custom extruded shape mesh.
  69701. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69702. * * 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.
  69703. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69704. * * 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
  69705. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69706. * * 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
  69707. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69708. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69709. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69710. * * 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
  69711. * * 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
  69712. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69715. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69717. * @param name defines the name of the mesh
  69718. * @param options defines the options used to create the mesh
  69719. * @param scene defines the hosting scene
  69720. * @returns the custom extruded shape mesh
  69721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69722. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69724. */
  69725. static ExtrudeShapeCustom(name: string, options: {
  69726. shape: Vector3[];
  69727. path: Vector3[];
  69728. scaleFunction?: any;
  69729. rotationFunction?: any;
  69730. ribbonCloseArray?: boolean;
  69731. ribbonClosePath?: boolean;
  69732. cap?: number;
  69733. updatable?: boolean;
  69734. sideOrientation?: number;
  69735. frontUVs?: Vector4;
  69736. backUVs?: Vector4;
  69737. instance?: Mesh;
  69738. invertUV?: boolean;
  69739. }, scene?: Nullable<Scene>): Mesh;
  69740. /**
  69741. * Creates lathe mesh.
  69742. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69743. * * 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
  69744. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69745. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69746. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69747. * * 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
  69748. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69749. * * 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
  69750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69754. * @param name defines the name of the mesh
  69755. * @param options defines the options used to create the mesh
  69756. * @param scene defines the hosting scene
  69757. * @returns the lathe mesh
  69758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69759. */
  69760. static CreateLathe(name: string, options: {
  69761. shape: Vector3[];
  69762. radius?: number;
  69763. tessellation?: number;
  69764. clip?: number;
  69765. arc?: number;
  69766. closed?: boolean;
  69767. updatable?: boolean;
  69768. sideOrientation?: number;
  69769. frontUVs?: Vector4;
  69770. backUVs?: Vector4;
  69771. cap?: number;
  69772. invertUV?: boolean;
  69773. }, scene?: Nullable<Scene>): Mesh;
  69774. /**
  69775. * Creates a tiled plane mesh
  69776. * * You can set a limited pattern arrangement with the tiles
  69777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69780. * @param name defines the name of the mesh
  69781. * @param options defines the options used to create the mesh
  69782. * @param scene defines the hosting scene
  69783. * @returns the plane mesh
  69784. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69785. */
  69786. static CreateTiledPlane(name: string, options: {
  69787. pattern?: number;
  69788. tileSize?: number;
  69789. tileWidth?: number;
  69790. tileHeight?: number;
  69791. size?: number;
  69792. width?: number;
  69793. height?: number;
  69794. alignHorizontal?: number;
  69795. alignVertical?: number;
  69796. sideOrientation?: number;
  69797. frontUVs?: Vector4;
  69798. backUVs?: Vector4;
  69799. updatable?: boolean;
  69800. }, scene?: Nullable<Scene>): Mesh;
  69801. /**
  69802. * Creates a plane mesh
  69803. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69804. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69805. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69809. * @param name defines the name of the mesh
  69810. * @param options defines the options used to create the mesh
  69811. * @param scene defines the hosting scene
  69812. * @returns the plane mesh
  69813. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69814. */
  69815. static CreatePlane(name: string, options: {
  69816. size?: number;
  69817. width?: number;
  69818. height?: number;
  69819. sideOrientation?: number;
  69820. frontUVs?: Vector4;
  69821. backUVs?: Vector4;
  69822. updatable?: boolean;
  69823. sourcePlane?: Plane;
  69824. }, scene?: Nullable<Scene>): Mesh;
  69825. /**
  69826. * Creates a ground mesh
  69827. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69828. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69830. * @param name defines the name of the mesh
  69831. * @param options defines the options used to create the mesh
  69832. * @param scene defines the hosting scene
  69833. * @returns the ground mesh
  69834. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69835. */
  69836. static CreateGround(name: string, options: {
  69837. width?: number;
  69838. height?: number;
  69839. subdivisions?: number;
  69840. subdivisionsX?: number;
  69841. subdivisionsY?: number;
  69842. updatable?: boolean;
  69843. }, scene?: Nullable<Scene>): Mesh;
  69844. /**
  69845. * Creates a tiled ground mesh
  69846. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69847. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69848. * * 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
  69849. * * 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
  69850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69851. * @param name defines the name of the mesh
  69852. * @param options defines the options used to create the mesh
  69853. * @param scene defines the hosting scene
  69854. * @returns the tiled ground mesh
  69855. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69856. */
  69857. static CreateTiledGround(name: string, options: {
  69858. xmin: number;
  69859. zmin: number;
  69860. xmax: number;
  69861. zmax: number;
  69862. subdivisions?: {
  69863. w: number;
  69864. h: number;
  69865. };
  69866. precision?: {
  69867. w: number;
  69868. h: number;
  69869. };
  69870. updatable?: boolean;
  69871. }, scene?: Nullable<Scene>): Mesh;
  69872. /**
  69873. * Creates a ground mesh from a height map
  69874. * * The parameter `url` sets the URL of the height map image resource.
  69875. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69876. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69877. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69878. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69879. * * 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.
  69880. * * 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).
  69881. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69883. * @param name defines the name of the mesh
  69884. * @param url defines the url to the height map
  69885. * @param options defines the options used to create the mesh
  69886. * @param scene defines the hosting scene
  69887. * @returns the ground mesh
  69888. * @see https://doc.babylonjs.com/babylon101/height_map
  69889. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69890. */
  69891. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69892. width?: number;
  69893. height?: number;
  69894. subdivisions?: number;
  69895. minHeight?: number;
  69896. maxHeight?: number;
  69897. colorFilter?: Color3;
  69898. alphaFilter?: number;
  69899. updatable?: boolean;
  69900. onReady?: (mesh: GroundMesh) => void;
  69901. }, scene?: Nullable<Scene>): GroundMesh;
  69902. /**
  69903. * Creates a polygon mesh
  69904. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69905. * * 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
  69906. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69909. * * Remember you can only change the shape positions, not their number when updating a polygon
  69910. * @param name defines the name of the mesh
  69911. * @param options defines the options used to create the mesh
  69912. * @param scene defines the hosting scene
  69913. * @param earcutInjection can be used to inject your own earcut reference
  69914. * @returns the polygon mesh
  69915. */
  69916. static CreatePolygon(name: string, options: {
  69917. shape: Vector3[];
  69918. holes?: Vector3[][];
  69919. depth?: number;
  69920. faceUV?: Vector4[];
  69921. faceColors?: Color4[];
  69922. updatable?: boolean;
  69923. sideOrientation?: number;
  69924. frontUVs?: Vector4;
  69925. backUVs?: Vector4;
  69926. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69927. /**
  69928. * Creates an extruded polygon mesh, with depth in the Y direction.
  69929. * * 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)
  69930. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69931. * @param name defines the name of the mesh
  69932. * @param options defines the options used to create the mesh
  69933. * @param scene defines the hosting scene
  69934. * @param earcutInjection can be used to inject your own earcut reference
  69935. * @returns the polygon mesh
  69936. */
  69937. static ExtrudePolygon(name: string, options: {
  69938. shape: Vector3[];
  69939. holes?: Vector3[][];
  69940. depth?: number;
  69941. faceUV?: Vector4[];
  69942. faceColors?: Color4[];
  69943. updatable?: boolean;
  69944. sideOrientation?: number;
  69945. frontUVs?: Vector4;
  69946. backUVs?: Vector4;
  69947. wrap?: boolean;
  69948. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69949. /**
  69950. * Creates a tube mesh.
  69951. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69952. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69953. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69954. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69955. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69956. * * 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)
  69957. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69958. * * 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
  69959. * * 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
  69960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69962. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69964. * @param name defines the name of the mesh
  69965. * @param options defines the options used to create the mesh
  69966. * @param scene defines the hosting scene
  69967. * @returns the tube mesh
  69968. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69969. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69970. */
  69971. static CreateTube(name: string, options: {
  69972. path: Vector3[];
  69973. radius?: number;
  69974. tessellation?: number;
  69975. radiusFunction?: {
  69976. (i: number, distance: number): number;
  69977. };
  69978. cap?: number;
  69979. arc?: number;
  69980. updatable?: boolean;
  69981. sideOrientation?: number;
  69982. frontUVs?: Vector4;
  69983. backUVs?: Vector4;
  69984. instance?: Mesh;
  69985. invertUV?: boolean;
  69986. }, scene?: Nullable<Scene>): Mesh;
  69987. /**
  69988. * Creates a polyhedron mesh
  69989. * * 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
  69990. * * The parameter `size` (positive float, default 1) sets the polygon size
  69991. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69992. * * 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`
  69993. * * 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
  69994. * * 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)`)
  69995. * * 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
  69996. * * 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
  69997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70000. * @param name defines the name of the mesh
  70001. * @param options defines the options used to create the mesh
  70002. * @param scene defines the hosting scene
  70003. * @returns the polyhedron mesh
  70004. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70005. */
  70006. static CreatePolyhedron(name: string, options: {
  70007. type?: number;
  70008. size?: number;
  70009. sizeX?: number;
  70010. sizeY?: number;
  70011. sizeZ?: number;
  70012. custom?: any;
  70013. faceUV?: Vector4[];
  70014. faceColors?: Color4[];
  70015. flat?: boolean;
  70016. updatable?: boolean;
  70017. sideOrientation?: number;
  70018. frontUVs?: Vector4;
  70019. backUVs?: Vector4;
  70020. }, scene?: Nullable<Scene>): Mesh;
  70021. /**
  70022. * Creates a decal mesh.
  70023. * 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
  70024. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70025. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70026. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70027. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70028. * @param name defines the name of the mesh
  70029. * @param sourceMesh defines the mesh where the decal must be applied
  70030. * @param options defines the options used to create the mesh
  70031. * @param scene defines the hosting scene
  70032. * @returns the decal mesh
  70033. * @see https://doc.babylonjs.com/how_to/decals
  70034. */
  70035. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70036. position?: Vector3;
  70037. normal?: Vector3;
  70038. size?: Vector3;
  70039. angle?: number;
  70040. }): Mesh;
  70041. /**
  70042. * Creates a Capsule Mesh
  70043. * @param name defines the name of the mesh.
  70044. * @param options the constructors options used to shape the mesh.
  70045. * @param scene defines the scene the mesh is scoped to.
  70046. * @returns the capsule mesh
  70047. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70048. */
  70049. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70050. }
  70051. }
  70052. declare module "babylonjs/Meshes/meshSimplification" {
  70053. import { Mesh } from "babylonjs/Meshes/mesh";
  70054. /**
  70055. * A simplifier interface for future simplification implementations
  70056. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70057. */
  70058. export interface ISimplifier {
  70059. /**
  70060. * Simplification of a given mesh according to the given settings.
  70061. * Since this requires computation, it is assumed that the function runs async.
  70062. * @param settings The settings of the simplification, including quality and distance
  70063. * @param successCallback A callback that will be called after the mesh was simplified.
  70064. * @param errorCallback in case of an error, this callback will be called. optional.
  70065. */
  70066. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70067. }
  70068. /**
  70069. * Expected simplification settings.
  70070. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70071. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70072. */
  70073. export interface ISimplificationSettings {
  70074. /**
  70075. * Gets or sets the expected quality
  70076. */
  70077. quality: number;
  70078. /**
  70079. * Gets or sets the distance when this optimized version should be used
  70080. */
  70081. distance: number;
  70082. /**
  70083. * Gets an already optimized mesh
  70084. */
  70085. optimizeMesh?: boolean;
  70086. }
  70087. /**
  70088. * Class used to specify simplification options
  70089. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70090. */
  70091. export class SimplificationSettings implements ISimplificationSettings {
  70092. /** expected quality */
  70093. quality: number;
  70094. /** distance when this optimized version should be used */
  70095. distance: number;
  70096. /** already optimized mesh */
  70097. optimizeMesh?: boolean | undefined;
  70098. /**
  70099. * Creates a SimplificationSettings
  70100. * @param quality expected quality
  70101. * @param distance distance when this optimized version should be used
  70102. * @param optimizeMesh already optimized mesh
  70103. */
  70104. constructor(
  70105. /** expected quality */
  70106. quality: number,
  70107. /** distance when this optimized version should be used */
  70108. distance: number,
  70109. /** already optimized mesh */
  70110. optimizeMesh?: boolean | undefined);
  70111. }
  70112. /**
  70113. * Interface used to define a simplification task
  70114. */
  70115. export interface ISimplificationTask {
  70116. /**
  70117. * Array of settings
  70118. */
  70119. settings: Array<ISimplificationSettings>;
  70120. /**
  70121. * Simplification type
  70122. */
  70123. simplificationType: SimplificationType;
  70124. /**
  70125. * Mesh to simplify
  70126. */
  70127. mesh: Mesh;
  70128. /**
  70129. * Callback called on success
  70130. */
  70131. successCallback?: () => void;
  70132. /**
  70133. * Defines if parallel processing can be used
  70134. */
  70135. parallelProcessing: boolean;
  70136. }
  70137. /**
  70138. * Queue used to order the simplification tasks
  70139. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70140. */
  70141. export class SimplificationQueue {
  70142. private _simplificationArray;
  70143. /**
  70144. * Gets a boolean indicating that the process is still running
  70145. */
  70146. running: boolean;
  70147. /**
  70148. * Creates a new queue
  70149. */
  70150. constructor();
  70151. /**
  70152. * Adds a new simplification task
  70153. * @param task defines a task to add
  70154. */
  70155. addTask(task: ISimplificationTask): void;
  70156. /**
  70157. * Execute next task
  70158. */
  70159. executeNext(): void;
  70160. /**
  70161. * Execute a simplification task
  70162. * @param task defines the task to run
  70163. */
  70164. runSimplification(task: ISimplificationTask): void;
  70165. private getSimplifier;
  70166. }
  70167. /**
  70168. * The implemented types of simplification
  70169. * At the moment only Quadratic Error Decimation is implemented
  70170. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70171. */
  70172. export enum SimplificationType {
  70173. /** Quadratic error decimation */
  70174. QUADRATIC = 0
  70175. }
  70176. /**
  70177. * An implementation of the Quadratic Error simplification algorithm.
  70178. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70179. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70180. * @author RaananW
  70181. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70182. */
  70183. export class QuadraticErrorSimplification implements ISimplifier {
  70184. private _mesh;
  70185. private triangles;
  70186. private vertices;
  70187. private references;
  70188. private _reconstructedMesh;
  70189. /** Gets or sets the number pf sync interations */
  70190. syncIterations: number;
  70191. /** Gets or sets the aggressiveness of the simplifier */
  70192. aggressiveness: number;
  70193. /** Gets or sets the number of allowed iterations for decimation */
  70194. decimationIterations: number;
  70195. /** Gets or sets the espilon to use for bounding box computation */
  70196. boundingBoxEpsilon: number;
  70197. /**
  70198. * Creates a new QuadraticErrorSimplification
  70199. * @param _mesh defines the target mesh
  70200. */
  70201. constructor(_mesh: Mesh);
  70202. /**
  70203. * Simplification of a given mesh according to the given settings.
  70204. * Since this requires computation, it is assumed that the function runs async.
  70205. * @param settings The settings of the simplification, including quality and distance
  70206. * @param successCallback A callback that will be called after the mesh was simplified.
  70207. */
  70208. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70209. private runDecimation;
  70210. private initWithMesh;
  70211. private init;
  70212. private reconstructMesh;
  70213. private initDecimatedMesh;
  70214. private isFlipped;
  70215. private updateTriangles;
  70216. private identifyBorder;
  70217. private updateMesh;
  70218. private vertexError;
  70219. private calculateError;
  70220. }
  70221. }
  70222. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70223. import { Scene } from "babylonjs/scene";
  70224. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70225. import { ISceneComponent } from "babylonjs/sceneComponent";
  70226. module "babylonjs/scene" {
  70227. interface Scene {
  70228. /** @hidden (Backing field) */
  70229. _simplificationQueue: SimplificationQueue;
  70230. /**
  70231. * Gets or sets the simplification queue attached to the scene
  70232. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70233. */
  70234. simplificationQueue: SimplificationQueue;
  70235. }
  70236. }
  70237. module "babylonjs/Meshes/mesh" {
  70238. interface Mesh {
  70239. /**
  70240. * Simplify the mesh according to the given array of settings.
  70241. * Function will return immediately and will simplify async
  70242. * @param settings a collection of simplification settings
  70243. * @param parallelProcessing should all levels calculate parallel or one after the other
  70244. * @param simplificationType the type of simplification to run
  70245. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70246. * @returns the current mesh
  70247. */
  70248. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70249. }
  70250. }
  70251. /**
  70252. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70253. * created in a scene
  70254. */
  70255. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70256. /**
  70257. * The component name helpfull to identify the component in the list of scene components.
  70258. */
  70259. readonly name: string;
  70260. /**
  70261. * The scene the component belongs to.
  70262. */
  70263. scene: Scene;
  70264. /**
  70265. * Creates a new instance of the component for the given scene
  70266. * @param scene Defines the scene to register the component in
  70267. */
  70268. constructor(scene: Scene);
  70269. /**
  70270. * Registers the component in a given scene
  70271. */
  70272. register(): void;
  70273. /**
  70274. * Rebuilds the elements related to this component in case of
  70275. * context lost for instance.
  70276. */
  70277. rebuild(): void;
  70278. /**
  70279. * Disposes the component and the associated ressources
  70280. */
  70281. dispose(): void;
  70282. private _beforeCameraUpdate;
  70283. }
  70284. }
  70285. declare module "babylonjs/Meshes/Builders/index" {
  70286. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70287. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70288. export * from "babylonjs/Meshes/Builders/discBuilder";
  70289. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70290. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70291. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70292. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70293. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70294. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70295. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70296. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70297. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70298. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70299. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70300. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70301. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70302. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70303. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70304. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70305. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70306. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70307. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70308. }
  70309. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70310. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70311. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70312. import { Matrix } from "babylonjs/Maths/math.vector";
  70313. module "babylonjs/Meshes/mesh" {
  70314. interface Mesh {
  70315. /**
  70316. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70317. */
  70318. thinInstanceEnablePicking: boolean;
  70319. /**
  70320. * Creates a new thin instance
  70321. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70322. * @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
  70323. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70324. */
  70325. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70326. /**
  70327. * Adds the transformation (matrix) of the current mesh as a thin instance
  70328. * @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
  70329. * @returns the thin instance index number
  70330. */
  70331. thinInstanceAddSelf(refresh: boolean): number;
  70332. /**
  70333. * Registers a custom attribute to be used with thin instances
  70334. * @param kind name of the attribute
  70335. * @param stride size in floats of the attribute
  70336. */
  70337. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70338. /**
  70339. * Sets the matrix of a thin instance
  70340. * @param index index of the thin instance
  70341. * @param matrix matrix to set
  70342. * @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
  70343. */
  70344. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70345. /**
  70346. * Sets the value of a custom attribute for a thin instance
  70347. * @param kind name of the attribute
  70348. * @param index index of the thin instance
  70349. * @param value value to set
  70350. * @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
  70351. */
  70352. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70353. /**
  70354. * 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.
  70355. */
  70356. thinInstanceCount: number;
  70357. /**
  70358. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70359. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70360. * @param buffer buffer to set
  70361. * @param stride size in floats of each value of the buffer
  70362. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70363. */
  70364. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70365. /**
  70366. * Gets the list of world matrices
  70367. * @return an array containing all the world matrices from the thin instances
  70368. */
  70369. thinInstanceGetWorldMatrices(): Matrix[];
  70370. /**
  70371. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70372. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70373. */
  70374. thinInstanceBufferUpdated(kind: string): void;
  70375. /**
  70376. * Applies a partial update to a buffer directly on the GPU
  70377. * 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
  70378. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70379. * @param data the data to set in the GPU buffer
  70380. * @param offset the offset in the GPU buffer where to update the data
  70381. */
  70382. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70383. /**
  70384. * Refreshes the bounding info, taking into account all the thin instances defined
  70385. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70386. */
  70387. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70388. /** @hidden */
  70389. _thinInstanceInitializeUserStorage(): void;
  70390. /** @hidden */
  70391. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70392. /** @hidden */
  70393. _userThinInstanceBuffersStorage: {
  70394. data: {
  70395. [key: string]: Float32Array;
  70396. };
  70397. sizes: {
  70398. [key: string]: number;
  70399. };
  70400. vertexBuffers: {
  70401. [key: string]: Nullable<VertexBuffer>;
  70402. };
  70403. strides: {
  70404. [key: string]: number;
  70405. };
  70406. };
  70407. }
  70408. }
  70409. }
  70410. declare module "babylonjs/Meshes/index" {
  70411. export * from "babylonjs/Meshes/abstractMesh";
  70412. export * from "babylonjs/Meshes/buffer";
  70413. export * from "babylonjs/Meshes/Compression/index";
  70414. export * from "babylonjs/Meshes/csg";
  70415. export * from "babylonjs/Meshes/geometry";
  70416. export * from "babylonjs/Meshes/groundMesh";
  70417. export * from "babylonjs/Meshes/trailMesh";
  70418. export * from "babylonjs/Meshes/instancedMesh";
  70419. export * from "babylonjs/Meshes/linesMesh";
  70420. export * from "babylonjs/Meshes/mesh";
  70421. export * from "babylonjs/Meshes/mesh.vertexData";
  70422. export * from "babylonjs/Meshes/meshBuilder";
  70423. export * from "babylonjs/Meshes/meshSimplification";
  70424. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70425. export * from "babylonjs/Meshes/polygonMesh";
  70426. export * from "babylonjs/Meshes/subMesh";
  70427. export * from "babylonjs/Meshes/meshLODLevel";
  70428. export * from "babylonjs/Meshes/transformNode";
  70429. export * from "babylonjs/Meshes/Builders/index";
  70430. export * from "babylonjs/Meshes/dataBuffer";
  70431. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70432. import "babylonjs/Meshes/thinInstanceMesh";
  70433. export * from "babylonjs/Meshes/thinInstanceMesh";
  70434. }
  70435. declare module "babylonjs/Morph/index" {
  70436. export * from "babylonjs/Morph/morphTarget";
  70437. export * from "babylonjs/Morph/morphTargetManager";
  70438. }
  70439. declare module "babylonjs/Navigation/INavigationEngine" {
  70440. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70441. import { Vector3 } from "babylonjs/Maths/math";
  70442. import { Mesh } from "babylonjs/Meshes/mesh";
  70443. import { Scene } from "babylonjs/scene";
  70444. /**
  70445. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70446. */
  70447. export interface INavigationEnginePlugin {
  70448. /**
  70449. * plugin name
  70450. */
  70451. name: string;
  70452. /**
  70453. * Creates a navigation mesh
  70454. * @param meshes array of all the geometry used to compute the navigatio mesh
  70455. * @param parameters bunch of parameters used to filter geometry
  70456. */
  70457. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70458. /**
  70459. * Create a navigation mesh debug mesh
  70460. * @param scene is where the mesh will be added
  70461. * @returns debug display mesh
  70462. */
  70463. createDebugNavMesh(scene: Scene): Mesh;
  70464. /**
  70465. * Get a navigation mesh constrained position, closest to the parameter position
  70466. * @param position world position
  70467. * @returns the closest point to position constrained by the navigation mesh
  70468. */
  70469. getClosestPoint(position: Vector3): Vector3;
  70470. /**
  70471. * Get a navigation mesh constrained position, closest to the parameter position
  70472. * @param position world position
  70473. * @param result output the closest point to position constrained by the navigation mesh
  70474. */
  70475. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70476. /**
  70477. * Get a navigation mesh constrained position, within a particular radius
  70478. * @param position world position
  70479. * @param maxRadius the maximum distance to the constrained world position
  70480. * @returns the closest point to position constrained by the navigation mesh
  70481. */
  70482. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70483. /**
  70484. * Get a navigation mesh constrained position, within a particular radius
  70485. * @param position world position
  70486. * @param maxRadius the maximum distance to the constrained world position
  70487. * @param result output the closest point to position constrained by the navigation mesh
  70488. */
  70489. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70490. /**
  70491. * Compute the final position from a segment made of destination-position
  70492. * @param position world position
  70493. * @param destination world position
  70494. * @returns the resulting point along the navmesh
  70495. */
  70496. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70497. /**
  70498. * Compute the final position from a segment made of destination-position
  70499. * @param position world position
  70500. * @param destination world position
  70501. * @param result output the resulting point along the navmesh
  70502. */
  70503. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70504. /**
  70505. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70506. * @param start world position
  70507. * @param end world position
  70508. * @returns array containing world position composing the path
  70509. */
  70510. computePath(start: Vector3, end: Vector3): Vector3[];
  70511. /**
  70512. * If this plugin is supported
  70513. * @returns true if plugin is supported
  70514. */
  70515. isSupported(): boolean;
  70516. /**
  70517. * Create a new Crowd so you can add agents
  70518. * @param maxAgents the maximum agent count in the crowd
  70519. * @param maxAgentRadius the maximum radius an agent can have
  70520. * @param scene to attach the crowd to
  70521. * @returns the crowd you can add agents to
  70522. */
  70523. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70524. /**
  70525. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70526. * The queries will try to find a solution within those bounds
  70527. * default is (1,1,1)
  70528. * @param extent x,y,z value that define the extent around the queries point of reference
  70529. */
  70530. setDefaultQueryExtent(extent: Vector3): void;
  70531. /**
  70532. * Get the Bounding box extent specified by setDefaultQueryExtent
  70533. * @returns the box extent values
  70534. */
  70535. getDefaultQueryExtent(): Vector3;
  70536. /**
  70537. * build the navmesh from a previously saved state using getNavmeshData
  70538. * @param data the Uint8Array returned by getNavmeshData
  70539. */
  70540. buildFromNavmeshData(data: Uint8Array): void;
  70541. /**
  70542. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70543. * @returns data the Uint8Array that can be saved and reused
  70544. */
  70545. getNavmeshData(): Uint8Array;
  70546. /**
  70547. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70548. * @param result output the box extent values
  70549. */
  70550. getDefaultQueryExtentToRef(result: Vector3): void;
  70551. /**
  70552. * Release all resources
  70553. */
  70554. dispose(): void;
  70555. }
  70556. /**
  70557. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70558. */
  70559. export interface ICrowd {
  70560. /**
  70561. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70562. * You can attach anything to that node. The node position is updated in the scene update tick.
  70563. * @param pos world position that will be constrained by the navigation mesh
  70564. * @param parameters agent parameters
  70565. * @param transform hooked to the agent that will be update by the scene
  70566. * @returns agent index
  70567. */
  70568. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70569. /**
  70570. * Returns the agent position in world space
  70571. * @param index agent index returned by addAgent
  70572. * @returns world space position
  70573. */
  70574. getAgentPosition(index: number): Vector3;
  70575. /**
  70576. * Gets the agent position result in world space
  70577. * @param index agent index returned by addAgent
  70578. * @param result output world space position
  70579. */
  70580. getAgentPositionToRef(index: number, result: Vector3): void;
  70581. /**
  70582. * Gets the agent velocity in world space
  70583. * @param index agent index returned by addAgent
  70584. * @returns world space velocity
  70585. */
  70586. getAgentVelocity(index: number): Vector3;
  70587. /**
  70588. * Gets the agent velocity result in world space
  70589. * @param index agent index returned by addAgent
  70590. * @param result output world space velocity
  70591. */
  70592. getAgentVelocityToRef(index: number, result: Vector3): void;
  70593. /**
  70594. * remove a particular agent previously created
  70595. * @param index agent index returned by addAgent
  70596. */
  70597. removeAgent(index: number): void;
  70598. /**
  70599. * get the list of all agents attached to this crowd
  70600. * @returns list of agent indices
  70601. */
  70602. getAgents(): number[];
  70603. /**
  70604. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70605. * @param deltaTime in seconds
  70606. */
  70607. update(deltaTime: number): void;
  70608. /**
  70609. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70610. * @param index agent index returned by addAgent
  70611. * @param destination targeted world position
  70612. */
  70613. agentGoto(index: number, destination: Vector3): void;
  70614. /**
  70615. * Teleport the agent to a new position
  70616. * @param index agent index returned by addAgent
  70617. * @param destination targeted world position
  70618. */
  70619. agentTeleport(index: number, destination: Vector3): void;
  70620. /**
  70621. * Update agent parameters
  70622. * @param index agent index returned by addAgent
  70623. * @param parameters agent parameters
  70624. */
  70625. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70626. /**
  70627. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70628. * The queries will try to find a solution within those bounds
  70629. * default is (1,1,1)
  70630. * @param extent x,y,z value that define the extent around the queries point of reference
  70631. */
  70632. setDefaultQueryExtent(extent: Vector3): void;
  70633. /**
  70634. * Get the Bounding box extent specified by setDefaultQueryExtent
  70635. * @returns the box extent values
  70636. */
  70637. getDefaultQueryExtent(): Vector3;
  70638. /**
  70639. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70640. * @param result output the box extent values
  70641. */
  70642. getDefaultQueryExtentToRef(result: Vector3): void;
  70643. /**
  70644. * Release all resources
  70645. */
  70646. dispose(): void;
  70647. }
  70648. /**
  70649. * Configures an agent
  70650. */
  70651. export interface IAgentParameters {
  70652. /**
  70653. * Agent radius. [Limit: >= 0]
  70654. */
  70655. radius: number;
  70656. /**
  70657. * Agent height. [Limit: > 0]
  70658. */
  70659. height: number;
  70660. /**
  70661. * Maximum allowed acceleration. [Limit: >= 0]
  70662. */
  70663. maxAcceleration: number;
  70664. /**
  70665. * Maximum allowed speed. [Limit: >= 0]
  70666. */
  70667. maxSpeed: number;
  70668. /**
  70669. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70670. */
  70671. collisionQueryRange: number;
  70672. /**
  70673. * The path visibility optimization range. [Limit: > 0]
  70674. */
  70675. pathOptimizationRange: number;
  70676. /**
  70677. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70678. */
  70679. separationWeight: number;
  70680. }
  70681. /**
  70682. * Configures the navigation mesh creation
  70683. */
  70684. export interface INavMeshParameters {
  70685. /**
  70686. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70687. */
  70688. cs: number;
  70689. /**
  70690. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70691. */
  70692. ch: number;
  70693. /**
  70694. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70695. */
  70696. walkableSlopeAngle: number;
  70697. /**
  70698. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70699. * be considered walkable. [Limit: >= 3] [Units: vx]
  70700. */
  70701. walkableHeight: number;
  70702. /**
  70703. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70704. */
  70705. walkableClimb: number;
  70706. /**
  70707. * The distance to erode/shrink the walkable area of the heightfield away from
  70708. * obstructions. [Limit: >=0] [Units: vx]
  70709. */
  70710. walkableRadius: number;
  70711. /**
  70712. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70713. */
  70714. maxEdgeLen: number;
  70715. /**
  70716. * The maximum distance a simplfied contour's border edges should deviate
  70717. * the original raw contour. [Limit: >=0] [Units: vx]
  70718. */
  70719. maxSimplificationError: number;
  70720. /**
  70721. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70722. */
  70723. minRegionArea: number;
  70724. /**
  70725. * Any regions with a span count smaller than this value will, if possible,
  70726. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70727. */
  70728. mergeRegionArea: number;
  70729. /**
  70730. * The maximum number of vertices allowed for polygons generated during the
  70731. * contour to polygon conversion process. [Limit: >= 3]
  70732. */
  70733. maxVertsPerPoly: number;
  70734. /**
  70735. * Sets the sampling distance to use when generating the detail mesh.
  70736. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70737. */
  70738. detailSampleDist: number;
  70739. /**
  70740. * The maximum distance the detail mesh surface should deviate from heightfield
  70741. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70742. */
  70743. detailSampleMaxError: number;
  70744. }
  70745. }
  70746. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70747. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70748. import { Mesh } from "babylonjs/Meshes/mesh";
  70749. import { Scene } from "babylonjs/scene";
  70750. import { Vector3 } from "babylonjs/Maths/math";
  70751. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70752. /**
  70753. * RecastJS navigation plugin
  70754. */
  70755. export class RecastJSPlugin implements INavigationEnginePlugin {
  70756. /**
  70757. * Reference to the Recast library
  70758. */
  70759. bjsRECAST: any;
  70760. /**
  70761. * plugin name
  70762. */
  70763. name: string;
  70764. /**
  70765. * the first navmesh created. We might extend this to support multiple navmeshes
  70766. */
  70767. navMesh: any;
  70768. /**
  70769. * Initializes the recastJS plugin
  70770. * @param recastInjection can be used to inject your own recast reference
  70771. */
  70772. constructor(recastInjection?: any);
  70773. /**
  70774. * Creates a navigation mesh
  70775. * @param meshes array of all the geometry used to compute the navigatio mesh
  70776. * @param parameters bunch of parameters used to filter geometry
  70777. */
  70778. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70779. /**
  70780. * Create a navigation mesh debug mesh
  70781. * @param scene is where the mesh will be added
  70782. * @returns debug display mesh
  70783. */
  70784. createDebugNavMesh(scene: Scene): Mesh;
  70785. /**
  70786. * Get a navigation mesh constrained position, closest to the parameter position
  70787. * @param position world position
  70788. * @returns the closest point to position constrained by the navigation mesh
  70789. */
  70790. getClosestPoint(position: Vector3): Vector3;
  70791. /**
  70792. * Get a navigation mesh constrained position, closest to the parameter position
  70793. * @param position world position
  70794. * @param result output the closest point to position constrained by the navigation mesh
  70795. */
  70796. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70797. /**
  70798. * Get a navigation mesh constrained position, within a particular radius
  70799. * @param position world position
  70800. * @param maxRadius the maximum distance to the constrained world position
  70801. * @returns the closest point to position constrained by the navigation mesh
  70802. */
  70803. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70804. /**
  70805. * Get a navigation mesh constrained position, within a particular radius
  70806. * @param position world position
  70807. * @param maxRadius the maximum distance to the constrained world position
  70808. * @param result output the closest point to position constrained by the navigation mesh
  70809. */
  70810. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70811. /**
  70812. * Compute the final position from a segment made of destination-position
  70813. * @param position world position
  70814. * @param destination world position
  70815. * @returns the resulting point along the navmesh
  70816. */
  70817. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70818. /**
  70819. * Compute the final position from a segment made of destination-position
  70820. * @param position world position
  70821. * @param destination world position
  70822. * @param result output the resulting point along the navmesh
  70823. */
  70824. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70825. /**
  70826. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70827. * @param start world position
  70828. * @param end world position
  70829. * @returns array containing world position composing the path
  70830. */
  70831. computePath(start: Vector3, end: Vector3): Vector3[];
  70832. /**
  70833. * Create a new Crowd so you can add agents
  70834. * @param maxAgents the maximum agent count in the crowd
  70835. * @param maxAgentRadius the maximum radius an agent can have
  70836. * @param scene to attach the crowd to
  70837. * @returns the crowd you can add agents to
  70838. */
  70839. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70840. /**
  70841. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70842. * The queries will try to find a solution within those bounds
  70843. * default is (1,1,1)
  70844. * @param extent x,y,z value that define the extent around the queries point of reference
  70845. */
  70846. setDefaultQueryExtent(extent: Vector3): void;
  70847. /**
  70848. * Get the Bounding box extent specified by setDefaultQueryExtent
  70849. * @returns the box extent values
  70850. */
  70851. getDefaultQueryExtent(): Vector3;
  70852. /**
  70853. * build the navmesh from a previously saved state using getNavmeshData
  70854. * @param data the Uint8Array returned by getNavmeshData
  70855. */
  70856. buildFromNavmeshData(data: Uint8Array): void;
  70857. /**
  70858. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70859. * @returns data the Uint8Array that can be saved and reused
  70860. */
  70861. getNavmeshData(): Uint8Array;
  70862. /**
  70863. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70864. * @param result output the box extent values
  70865. */
  70866. getDefaultQueryExtentToRef(result: Vector3): void;
  70867. /**
  70868. * Disposes
  70869. */
  70870. dispose(): void;
  70871. /**
  70872. * If this plugin is supported
  70873. * @returns true if plugin is supported
  70874. */
  70875. isSupported(): boolean;
  70876. }
  70877. /**
  70878. * Recast detour crowd implementation
  70879. */
  70880. export class RecastJSCrowd implements ICrowd {
  70881. /**
  70882. * Recast/detour plugin
  70883. */
  70884. bjsRECASTPlugin: RecastJSPlugin;
  70885. /**
  70886. * Link to the detour crowd
  70887. */
  70888. recastCrowd: any;
  70889. /**
  70890. * One transform per agent
  70891. */
  70892. transforms: TransformNode[];
  70893. /**
  70894. * All agents created
  70895. */
  70896. agents: number[];
  70897. /**
  70898. * Link to the scene is kept to unregister the crowd from the scene
  70899. */
  70900. private _scene;
  70901. /**
  70902. * Observer for crowd updates
  70903. */
  70904. private _onBeforeAnimationsObserver;
  70905. /**
  70906. * Constructor
  70907. * @param plugin recastJS plugin
  70908. * @param maxAgents the maximum agent count in the crowd
  70909. * @param maxAgentRadius the maximum radius an agent can have
  70910. * @param scene to attach the crowd to
  70911. * @returns the crowd you can add agents to
  70912. */
  70913. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70914. /**
  70915. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70916. * You can attach anything to that node. The node position is updated in the scene update tick.
  70917. * @param pos world position that will be constrained by the navigation mesh
  70918. * @param parameters agent parameters
  70919. * @param transform hooked to the agent that will be update by the scene
  70920. * @returns agent index
  70921. */
  70922. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70923. /**
  70924. * Returns the agent position in world space
  70925. * @param index agent index returned by addAgent
  70926. * @returns world space position
  70927. */
  70928. getAgentPosition(index: number): Vector3;
  70929. /**
  70930. * Returns the agent position result in world space
  70931. * @param index agent index returned by addAgent
  70932. * @param result output world space position
  70933. */
  70934. getAgentPositionToRef(index: number, result: Vector3): void;
  70935. /**
  70936. * Returns the agent velocity in world space
  70937. * @param index agent index returned by addAgent
  70938. * @returns world space velocity
  70939. */
  70940. getAgentVelocity(index: number): Vector3;
  70941. /**
  70942. * Returns the agent velocity result in world space
  70943. * @param index agent index returned by addAgent
  70944. * @param result output world space velocity
  70945. */
  70946. getAgentVelocityToRef(index: number, result: Vector3): void;
  70947. /**
  70948. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70949. * @param index agent index returned by addAgent
  70950. * @param destination targeted world position
  70951. */
  70952. agentGoto(index: number, destination: Vector3): void;
  70953. /**
  70954. * Teleport the agent to a new position
  70955. * @param index agent index returned by addAgent
  70956. * @param destination targeted world position
  70957. */
  70958. agentTeleport(index: number, destination: Vector3): void;
  70959. /**
  70960. * Update agent parameters
  70961. * @param index agent index returned by addAgent
  70962. * @param parameters agent parameters
  70963. */
  70964. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70965. /**
  70966. * remove a particular agent previously created
  70967. * @param index agent index returned by addAgent
  70968. */
  70969. removeAgent(index: number): void;
  70970. /**
  70971. * get the list of all agents attached to this crowd
  70972. * @returns list of agent indices
  70973. */
  70974. getAgents(): number[];
  70975. /**
  70976. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70977. * @param deltaTime in seconds
  70978. */
  70979. update(deltaTime: number): void;
  70980. /**
  70981. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70982. * The queries will try to find a solution within those bounds
  70983. * default is (1,1,1)
  70984. * @param extent x,y,z value that define the extent around the queries point of reference
  70985. */
  70986. setDefaultQueryExtent(extent: Vector3): void;
  70987. /**
  70988. * Get the Bounding box extent specified by setDefaultQueryExtent
  70989. * @returns the box extent values
  70990. */
  70991. getDefaultQueryExtent(): Vector3;
  70992. /**
  70993. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70994. * @param result output the box extent values
  70995. */
  70996. getDefaultQueryExtentToRef(result: Vector3): void;
  70997. /**
  70998. * Release all resources
  70999. */
  71000. dispose(): void;
  71001. }
  71002. }
  71003. declare module "babylonjs/Navigation/Plugins/index" {
  71004. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71005. }
  71006. declare module "babylonjs/Navigation/index" {
  71007. export * from "babylonjs/Navigation/INavigationEngine";
  71008. export * from "babylonjs/Navigation/Plugins/index";
  71009. }
  71010. declare module "babylonjs/Offline/database" {
  71011. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71012. /**
  71013. * Class used to enable access to IndexedDB
  71014. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71015. */
  71016. export class Database implements IOfflineProvider {
  71017. private _callbackManifestChecked;
  71018. private _currentSceneUrl;
  71019. private _db;
  71020. private _enableSceneOffline;
  71021. private _enableTexturesOffline;
  71022. private _manifestVersionFound;
  71023. private _mustUpdateRessources;
  71024. private _hasReachedQuota;
  71025. private _isSupported;
  71026. private _idbFactory;
  71027. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71028. private static IsUASupportingBlobStorage;
  71029. /**
  71030. * Gets a boolean indicating if Database storate is enabled (off by default)
  71031. */
  71032. static IDBStorageEnabled: boolean;
  71033. /**
  71034. * Gets a boolean indicating if scene must be saved in the database
  71035. */
  71036. get enableSceneOffline(): boolean;
  71037. /**
  71038. * Gets a boolean indicating if textures must be saved in the database
  71039. */
  71040. get enableTexturesOffline(): boolean;
  71041. /**
  71042. * Creates a new Database
  71043. * @param urlToScene defines the url to load the scene
  71044. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71045. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71046. */
  71047. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71048. private static _ParseURL;
  71049. private static _ReturnFullUrlLocation;
  71050. private _checkManifestFile;
  71051. /**
  71052. * Open the database and make it available
  71053. * @param successCallback defines the callback to call on success
  71054. * @param errorCallback defines the callback to call on error
  71055. */
  71056. open(successCallback: () => void, errorCallback: () => void): void;
  71057. /**
  71058. * Loads an image from the database
  71059. * @param url defines the url to load from
  71060. * @param image defines the target DOM image
  71061. */
  71062. loadImage(url: string, image: HTMLImageElement): void;
  71063. private _loadImageFromDBAsync;
  71064. private _saveImageIntoDBAsync;
  71065. private _checkVersionFromDB;
  71066. private _loadVersionFromDBAsync;
  71067. private _saveVersionIntoDBAsync;
  71068. /**
  71069. * Loads a file from database
  71070. * @param url defines the URL to load from
  71071. * @param sceneLoaded defines a callback to call on success
  71072. * @param progressCallBack defines a callback to call when progress changed
  71073. * @param errorCallback defines a callback to call on error
  71074. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71075. */
  71076. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71077. private _loadFileAsync;
  71078. private _saveFileAsync;
  71079. /**
  71080. * Validates if xhr data is correct
  71081. * @param xhr defines the request to validate
  71082. * @param dataType defines the expected data type
  71083. * @returns true if data is correct
  71084. */
  71085. private static _ValidateXHRData;
  71086. }
  71087. }
  71088. declare module "babylonjs/Offline/index" {
  71089. export * from "babylonjs/Offline/database";
  71090. export * from "babylonjs/Offline/IOfflineProvider";
  71091. }
  71092. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71093. /** @hidden */
  71094. export var gpuUpdateParticlesPixelShader: {
  71095. name: string;
  71096. shader: string;
  71097. };
  71098. }
  71099. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71100. /** @hidden */
  71101. export var gpuUpdateParticlesVertexShader: {
  71102. name: string;
  71103. shader: string;
  71104. };
  71105. }
  71106. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71107. /** @hidden */
  71108. export var clipPlaneFragmentDeclaration2: {
  71109. name: string;
  71110. shader: string;
  71111. };
  71112. }
  71113. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71114. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71115. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71116. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71117. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71118. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71119. /** @hidden */
  71120. export var gpuRenderParticlesPixelShader: {
  71121. name: string;
  71122. shader: string;
  71123. };
  71124. }
  71125. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71126. /** @hidden */
  71127. export var clipPlaneVertexDeclaration2: {
  71128. name: string;
  71129. shader: string;
  71130. };
  71131. }
  71132. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71133. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71134. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71135. /** @hidden */
  71136. export var gpuRenderParticlesVertexShader: {
  71137. name: string;
  71138. shader: string;
  71139. };
  71140. }
  71141. declare module "babylonjs/Particles/gpuParticleSystem" {
  71142. import { Nullable } from "babylonjs/types";
  71143. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71144. import { Observable } from "babylonjs/Misc/observable";
  71145. import { Matrix } from "babylonjs/Maths/math.vector";
  71146. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71147. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71148. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71149. import { IDisposable } from "babylonjs/scene";
  71150. import { Effect } from "babylonjs/Materials/effect";
  71151. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71152. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71153. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71154. import { Scene } from "babylonjs/scene";
  71155. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71156. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71157. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71158. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71159. /**
  71160. * This represents a GPU particle system in Babylon
  71161. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71162. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71163. */
  71164. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71165. /**
  71166. * The layer mask we are rendering the particles through.
  71167. */
  71168. layerMask: number;
  71169. private _capacity;
  71170. private _activeCount;
  71171. private _currentActiveCount;
  71172. private _accumulatedCount;
  71173. private _renderEffect;
  71174. private _updateEffect;
  71175. private _buffer0;
  71176. private _buffer1;
  71177. private _spriteBuffer;
  71178. private _updateVAO;
  71179. private _renderVAO;
  71180. private _targetIndex;
  71181. private _sourceBuffer;
  71182. private _targetBuffer;
  71183. private _currentRenderId;
  71184. private _started;
  71185. private _stopped;
  71186. private _timeDelta;
  71187. private _randomTexture;
  71188. private _randomTexture2;
  71189. private _attributesStrideSize;
  71190. private _updateEffectOptions;
  71191. private _randomTextureSize;
  71192. private _actualFrame;
  71193. private _customEffect;
  71194. private readonly _rawTextureWidth;
  71195. /**
  71196. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71197. */
  71198. static get IsSupported(): boolean;
  71199. /**
  71200. * An event triggered when the system is disposed.
  71201. */
  71202. onDisposeObservable: Observable<IParticleSystem>;
  71203. /**
  71204. * Gets the maximum number of particles active at the same time.
  71205. * @returns The max number of active particles.
  71206. */
  71207. getCapacity(): number;
  71208. /**
  71209. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71210. * to override the particles.
  71211. */
  71212. forceDepthWrite: boolean;
  71213. /**
  71214. * Gets or set the number of active particles
  71215. */
  71216. get activeParticleCount(): number;
  71217. set activeParticleCount(value: number);
  71218. private _preWarmDone;
  71219. /**
  71220. * Specifies if the particles are updated in emitter local space or world space.
  71221. */
  71222. isLocal: boolean;
  71223. /** Gets or sets a matrix to use to compute projection */
  71224. defaultProjectionMatrix: Matrix;
  71225. /**
  71226. * Is this system ready to be used/rendered
  71227. * @return true if the system is ready
  71228. */
  71229. isReady(): boolean;
  71230. /**
  71231. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71232. * @returns True if it has been started, otherwise false.
  71233. */
  71234. isStarted(): boolean;
  71235. /**
  71236. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71237. * @returns True if it has been stopped, otherwise false.
  71238. */
  71239. isStopped(): boolean;
  71240. /**
  71241. * Gets a boolean indicating that the system is stopping
  71242. * @returns true if the system is currently stopping
  71243. */
  71244. isStopping(): boolean;
  71245. /**
  71246. * Gets the number of particles active at the same time.
  71247. * @returns The number of active particles.
  71248. */
  71249. getActiveCount(): number;
  71250. /**
  71251. * Starts the particle system and begins to emit
  71252. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71253. */
  71254. start(delay?: number): void;
  71255. /**
  71256. * Stops the particle system.
  71257. */
  71258. stop(): void;
  71259. /**
  71260. * Remove all active particles
  71261. */
  71262. reset(): void;
  71263. /**
  71264. * Returns the string "GPUParticleSystem"
  71265. * @returns a string containing the class name
  71266. */
  71267. getClassName(): string;
  71268. /**
  71269. * Gets the custom effect used to render the particles
  71270. * @param blendMode Blend mode for which the effect should be retrieved
  71271. * @returns The effect
  71272. */
  71273. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71274. /**
  71275. * Sets the custom effect used to render the particles
  71276. * @param effect The effect to set
  71277. * @param blendMode Blend mode for which the effect should be set
  71278. */
  71279. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71280. /** @hidden */
  71281. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71282. /**
  71283. * Observable that will be called just before the particles are drawn
  71284. */
  71285. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71286. /**
  71287. * Gets the name of the particle vertex shader
  71288. */
  71289. get vertexShaderName(): string;
  71290. private _colorGradientsTexture;
  71291. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71292. /**
  71293. * Adds a new color gradient
  71294. * @param gradient defines the gradient to use (between 0 and 1)
  71295. * @param color1 defines the color to affect to the specified gradient
  71296. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71297. * @returns the current particle system
  71298. */
  71299. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71300. private _refreshColorGradient;
  71301. /** Force the system to rebuild all gradients that need to be resync */
  71302. forceRefreshGradients(): void;
  71303. /**
  71304. * Remove a specific color gradient
  71305. * @param gradient defines the gradient to remove
  71306. * @returns the current particle system
  71307. */
  71308. removeColorGradient(gradient: number): GPUParticleSystem;
  71309. private _angularSpeedGradientsTexture;
  71310. private _sizeGradientsTexture;
  71311. private _velocityGradientsTexture;
  71312. private _limitVelocityGradientsTexture;
  71313. private _dragGradientsTexture;
  71314. private _addFactorGradient;
  71315. /**
  71316. * Adds a new size gradient
  71317. * @param gradient defines the gradient to use (between 0 and 1)
  71318. * @param factor defines the size factor to affect to the specified gradient
  71319. * @returns the current particle system
  71320. */
  71321. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71322. /**
  71323. * Remove a specific size gradient
  71324. * @param gradient defines the gradient to remove
  71325. * @returns the current particle system
  71326. */
  71327. removeSizeGradient(gradient: number): GPUParticleSystem;
  71328. private _refreshFactorGradient;
  71329. /**
  71330. * Adds a new angular speed gradient
  71331. * @param gradient defines the gradient to use (between 0 and 1)
  71332. * @param factor defines the angular speed to affect to the specified gradient
  71333. * @returns the current particle system
  71334. */
  71335. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71336. /**
  71337. * Remove a specific angular speed gradient
  71338. * @param gradient defines the gradient to remove
  71339. * @returns the current particle system
  71340. */
  71341. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71342. /**
  71343. * Adds a new velocity gradient
  71344. * @param gradient defines the gradient to use (between 0 and 1)
  71345. * @param factor defines the velocity to affect to the specified gradient
  71346. * @returns the current particle system
  71347. */
  71348. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71349. /**
  71350. * Remove a specific velocity gradient
  71351. * @param gradient defines the gradient to remove
  71352. * @returns the current particle system
  71353. */
  71354. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71355. /**
  71356. * Adds a new limit velocity gradient
  71357. * @param gradient defines the gradient to use (between 0 and 1)
  71358. * @param factor defines the limit velocity value to affect to the specified gradient
  71359. * @returns the current particle system
  71360. */
  71361. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71362. /**
  71363. * Remove a specific limit velocity gradient
  71364. * @param gradient defines the gradient to remove
  71365. * @returns the current particle system
  71366. */
  71367. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71368. /**
  71369. * Adds a new drag gradient
  71370. * @param gradient defines the gradient to use (between 0 and 1)
  71371. * @param factor defines the drag value to affect to the specified gradient
  71372. * @returns the current particle system
  71373. */
  71374. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71375. /**
  71376. * Remove a specific drag gradient
  71377. * @param gradient defines the gradient to remove
  71378. * @returns the current particle system
  71379. */
  71380. removeDragGradient(gradient: number): GPUParticleSystem;
  71381. /**
  71382. * Not supported by GPUParticleSystem
  71383. * @param gradient defines the gradient to use (between 0 and 1)
  71384. * @param factor defines the emit rate value to affect to the specified gradient
  71385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71386. * @returns the current particle system
  71387. */
  71388. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71389. /**
  71390. * Not supported by GPUParticleSystem
  71391. * @param gradient defines the gradient to remove
  71392. * @returns the current particle system
  71393. */
  71394. removeEmitRateGradient(gradient: number): IParticleSystem;
  71395. /**
  71396. * Not supported by GPUParticleSystem
  71397. * @param gradient defines the gradient to use (between 0 and 1)
  71398. * @param factor defines the start size value to affect to the specified gradient
  71399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71400. * @returns the current particle system
  71401. */
  71402. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71403. /**
  71404. * Not supported by GPUParticleSystem
  71405. * @param gradient defines the gradient to remove
  71406. * @returns the current particle system
  71407. */
  71408. removeStartSizeGradient(gradient: number): IParticleSystem;
  71409. /**
  71410. * Not supported by GPUParticleSystem
  71411. * @param gradient defines the gradient to use (between 0 and 1)
  71412. * @param min defines the color remap minimal range
  71413. * @param max defines the color remap maximal range
  71414. * @returns the current particle system
  71415. */
  71416. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71417. /**
  71418. * Not supported by GPUParticleSystem
  71419. * @param gradient defines the gradient to remove
  71420. * @returns the current particle system
  71421. */
  71422. removeColorRemapGradient(): IParticleSystem;
  71423. /**
  71424. * Not supported by GPUParticleSystem
  71425. * @param gradient defines the gradient to use (between 0 and 1)
  71426. * @param min defines the alpha remap minimal range
  71427. * @param max defines the alpha remap maximal range
  71428. * @returns the current particle system
  71429. */
  71430. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71431. /**
  71432. * Not supported by GPUParticleSystem
  71433. * @param gradient defines the gradient to remove
  71434. * @returns the current particle system
  71435. */
  71436. removeAlphaRemapGradient(): IParticleSystem;
  71437. /**
  71438. * Not supported by GPUParticleSystem
  71439. * @param gradient defines the gradient to use (between 0 and 1)
  71440. * @param color defines the color to affect to the specified gradient
  71441. * @returns the current particle system
  71442. */
  71443. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71444. /**
  71445. * Not supported by GPUParticleSystem
  71446. * @param gradient defines the gradient to remove
  71447. * @returns the current particle system
  71448. */
  71449. removeRampGradient(): IParticleSystem;
  71450. /**
  71451. * Not supported by GPUParticleSystem
  71452. * @returns the list of ramp gradients
  71453. */
  71454. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71455. /**
  71456. * Not supported by GPUParticleSystem
  71457. * Gets or sets a boolean indicating that ramp gradients must be used
  71458. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71459. */
  71460. get useRampGradients(): boolean;
  71461. set useRampGradients(value: boolean);
  71462. /**
  71463. * Not supported by GPUParticleSystem
  71464. * @param gradient defines the gradient to use (between 0 and 1)
  71465. * @param factor defines the life time factor to affect to the specified gradient
  71466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71467. * @returns the current particle system
  71468. */
  71469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71470. /**
  71471. * Not supported by GPUParticleSystem
  71472. * @param gradient defines the gradient to remove
  71473. * @returns the current particle system
  71474. */
  71475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71476. /**
  71477. * Instantiates a GPU particle system.
  71478. * 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.
  71479. * @param name The name of the particle system
  71480. * @param options The options used to create the system
  71481. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71482. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71483. * @param customEffect a custom effect used to change the way particles are rendered by default
  71484. */
  71485. constructor(name: string, options: Partial<{
  71486. capacity: number;
  71487. randomTextureSize: number;
  71488. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71489. protected _reset(): void;
  71490. private _createUpdateVAO;
  71491. private _createRenderVAO;
  71492. private _initialize;
  71493. /** @hidden */
  71494. _recreateUpdateEffect(): void;
  71495. private _getEffect;
  71496. /**
  71497. * Fill the defines array according to the current settings of the particle system
  71498. * @param defines Array to be updated
  71499. * @param blendMode blend mode to take into account when updating the array
  71500. */
  71501. fillDefines(defines: Array<string>, blendMode?: number): void;
  71502. /**
  71503. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71504. * @param uniforms Uniforms array to fill
  71505. * @param attributes Attributes array to fill
  71506. * @param samplers Samplers array to fill
  71507. */
  71508. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71509. /** @hidden */
  71510. _recreateRenderEffect(): Effect;
  71511. /**
  71512. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71513. * @param preWarm defines if we are in the pre-warmimg phase
  71514. */
  71515. animate(preWarm?: boolean): void;
  71516. private _createFactorGradientTexture;
  71517. private _createSizeGradientTexture;
  71518. private _createAngularSpeedGradientTexture;
  71519. private _createVelocityGradientTexture;
  71520. private _createLimitVelocityGradientTexture;
  71521. private _createDragGradientTexture;
  71522. private _createColorGradientTexture;
  71523. /**
  71524. * Renders the particle system in its current state
  71525. * @param preWarm defines if the system should only update the particles but not render them
  71526. * @returns the current number of particles
  71527. */
  71528. render(preWarm?: boolean): number;
  71529. /**
  71530. * Rebuilds the particle system
  71531. */
  71532. rebuild(): void;
  71533. private _releaseBuffers;
  71534. private _releaseVAOs;
  71535. /**
  71536. * Disposes the particle system and free the associated resources
  71537. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71538. */
  71539. dispose(disposeTexture?: boolean): void;
  71540. /**
  71541. * Clones the particle system.
  71542. * @param name The name of the cloned object
  71543. * @param newEmitter The new emitter to use
  71544. * @returns the cloned particle system
  71545. */
  71546. clone(name: string, newEmitter: any): GPUParticleSystem;
  71547. /**
  71548. * Serializes the particle system to a JSON object
  71549. * @param serializeTexture defines if the texture must be serialized as well
  71550. * @returns the JSON object
  71551. */
  71552. serialize(serializeTexture?: boolean): any;
  71553. /**
  71554. * Parses a JSON object to create a GPU particle system.
  71555. * @param parsedParticleSystem The JSON object to parse
  71556. * @param sceneOrEngine The scene or the engine to create the particle system in
  71557. * @param rootUrl The root url to use to load external dependencies like texture
  71558. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71559. * @returns the parsed GPU particle system
  71560. */
  71561. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71562. }
  71563. }
  71564. declare module "babylonjs/Particles/particleSystemSet" {
  71565. import { Nullable } from "babylonjs/types";
  71566. import { Color3 } from "babylonjs/Maths/math.color";
  71567. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71569. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71570. import { Scene, IDisposable } from "babylonjs/scene";
  71571. /**
  71572. * Represents a set of particle systems working together to create a specific effect
  71573. */
  71574. export class ParticleSystemSet implements IDisposable {
  71575. /**
  71576. * Gets or sets base Assets URL
  71577. */
  71578. static BaseAssetsUrl: string;
  71579. private _emitterCreationOptions;
  71580. private _emitterNode;
  71581. /**
  71582. * Gets the particle system list
  71583. */
  71584. systems: IParticleSystem[];
  71585. /**
  71586. * Gets the emitter node used with this set
  71587. */
  71588. get emitterNode(): Nullable<TransformNode>;
  71589. /**
  71590. * Creates a new emitter mesh as a sphere
  71591. * @param options defines the options used to create the sphere
  71592. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71593. * @param scene defines the hosting scene
  71594. */
  71595. setEmitterAsSphere(options: {
  71596. diameter: number;
  71597. segments: number;
  71598. color: Color3;
  71599. }, renderingGroupId: number, scene: Scene): void;
  71600. /**
  71601. * Starts all particle systems of the set
  71602. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71603. */
  71604. start(emitter?: AbstractMesh): void;
  71605. /**
  71606. * Release all associated resources
  71607. */
  71608. dispose(): void;
  71609. /**
  71610. * Serialize the set into a JSON compatible object
  71611. * @param serializeTexture defines if the texture must be serialized as well
  71612. * @returns a JSON compatible representation of the set
  71613. */
  71614. serialize(serializeTexture?: boolean): any;
  71615. /**
  71616. * Parse a new ParticleSystemSet from a serialized source
  71617. * @param data defines a JSON compatible representation of the set
  71618. * @param scene defines the hosting scene
  71619. * @param gpu defines if we want GPU particles or CPU particles
  71620. * @returns a new ParticleSystemSet
  71621. */
  71622. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71623. }
  71624. }
  71625. declare module "babylonjs/Particles/particleHelper" {
  71626. import { Nullable } from "babylonjs/types";
  71627. import { Scene } from "babylonjs/scene";
  71628. import { Vector3 } from "babylonjs/Maths/math.vector";
  71629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71630. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71631. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71632. /**
  71633. * This class is made for on one-liner static method to help creating particle system set.
  71634. */
  71635. export class ParticleHelper {
  71636. /**
  71637. * Gets or sets base Assets URL
  71638. */
  71639. static BaseAssetsUrl: string;
  71640. /** Define the Url to load snippets */
  71641. static SnippetUrl: string;
  71642. /**
  71643. * Create a default particle system that you can tweak
  71644. * @param emitter defines the emitter to use
  71645. * @param capacity defines the system capacity (default is 500 particles)
  71646. * @param scene defines the hosting scene
  71647. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71648. * @returns the new Particle system
  71649. */
  71650. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71651. /**
  71652. * This is the main static method (one-liner) of this helper to create different particle systems
  71653. * @param type This string represents the type to the particle system to create
  71654. * @param scene The scene where the particle system should live
  71655. * @param gpu If the system will use gpu
  71656. * @returns the ParticleSystemSet created
  71657. */
  71658. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71659. /**
  71660. * Static function used to export a particle system to a ParticleSystemSet variable.
  71661. * Please note that the emitter shape is not exported
  71662. * @param systems defines the particle systems to export
  71663. * @returns the created particle system set
  71664. */
  71665. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71666. /**
  71667. * Creates a particle system from a snippet saved in a remote file
  71668. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71669. * @param url defines the url to load from
  71670. * @param scene defines the hosting scene
  71671. * @param gpu If the system will use gpu
  71672. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71673. * @returns a promise that will resolve to the new particle system
  71674. */
  71675. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71676. /**
  71677. * Creates a particle system from a snippet saved by the particle system editor
  71678. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71679. * @param scene defines the hosting scene
  71680. * @param gpu If the system will use gpu
  71681. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71682. * @returns a promise that will resolve to the new particle system
  71683. */
  71684. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71685. }
  71686. }
  71687. declare module "babylonjs/Particles/particleSystemComponent" {
  71688. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71689. import { Effect } from "babylonjs/Materials/effect";
  71690. import "babylonjs/Shaders/particles.vertex";
  71691. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71692. module "babylonjs/Engines/engine" {
  71693. interface Engine {
  71694. /**
  71695. * Create an effect to use with particle systems.
  71696. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71697. * the particle system for which you want to create a custom effect in the last parameter
  71698. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71699. * @param uniformsNames defines a list of attribute names
  71700. * @param samplers defines an array of string used to represent textures
  71701. * @param defines defines the string containing the defines to use to compile the shaders
  71702. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71703. * @param onCompiled defines a function to call when the effect creation is successful
  71704. * @param onError defines a function to call when the effect creation has failed
  71705. * @param particleSystem the particle system you want to create the effect for
  71706. * @returns the new Effect
  71707. */
  71708. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71709. }
  71710. }
  71711. module "babylonjs/Meshes/mesh" {
  71712. interface Mesh {
  71713. /**
  71714. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71715. * @returns an array of IParticleSystem
  71716. */
  71717. getEmittedParticleSystems(): IParticleSystem[];
  71718. /**
  71719. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71720. * @returns an array of IParticleSystem
  71721. */
  71722. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71723. }
  71724. }
  71725. }
  71726. declare module "babylonjs/Particles/pointsCloudSystem" {
  71727. import { Color4 } from "babylonjs/Maths/math";
  71728. import { Mesh } from "babylonjs/Meshes/mesh";
  71729. import { Scene, IDisposable } from "babylonjs/scene";
  71730. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71731. /** Defines the 4 color options */
  71732. export enum PointColor {
  71733. /** color value */
  71734. Color = 2,
  71735. /** uv value */
  71736. UV = 1,
  71737. /** random value */
  71738. Random = 0,
  71739. /** stated value */
  71740. Stated = 3
  71741. }
  71742. /**
  71743. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71744. * 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.
  71745. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71746. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71747. *
  71748. * Full documentation here : TO BE ENTERED
  71749. */
  71750. export class PointsCloudSystem implements IDisposable {
  71751. /**
  71752. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71753. * Example : var p = SPS.particles[i];
  71754. */
  71755. particles: CloudPoint[];
  71756. /**
  71757. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71758. */
  71759. nbParticles: number;
  71760. /**
  71761. * This a counter for your own usage. It's not set by any SPS functions.
  71762. */
  71763. counter: number;
  71764. /**
  71765. * The PCS name. This name is also given to the underlying mesh.
  71766. */
  71767. name: string;
  71768. /**
  71769. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71770. */
  71771. mesh: Mesh;
  71772. /**
  71773. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71774. * Please read :
  71775. */
  71776. vars: any;
  71777. /**
  71778. * @hidden
  71779. */
  71780. _size: number;
  71781. private _scene;
  71782. private _promises;
  71783. private _positions;
  71784. private _indices;
  71785. private _normals;
  71786. private _colors;
  71787. private _uvs;
  71788. private _indices32;
  71789. private _positions32;
  71790. private _colors32;
  71791. private _uvs32;
  71792. private _updatable;
  71793. private _isVisibilityBoxLocked;
  71794. private _alwaysVisible;
  71795. private _groups;
  71796. private _groupCounter;
  71797. private _computeParticleColor;
  71798. private _computeParticleTexture;
  71799. private _computeParticleRotation;
  71800. private _computeBoundingBox;
  71801. private _isReady;
  71802. /**
  71803. * Creates a PCS (Points Cloud System) object
  71804. * @param name (String) is the PCS name, this will be the underlying mesh name
  71805. * @param pointSize (number) is the size for each point
  71806. * @param scene (Scene) is the scene in which the PCS is added
  71807. * @param options defines the options of the PCS e.g.
  71808. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71809. */
  71810. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71811. updatable?: boolean;
  71812. });
  71813. /**
  71814. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71815. * If no points were added to the PCS, the returned mesh is just a single point.
  71816. * @returns a promise for the created mesh
  71817. */
  71818. buildMeshAsync(): Promise<Mesh>;
  71819. /**
  71820. * @hidden
  71821. */
  71822. private _buildMesh;
  71823. private _addParticle;
  71824. private _randomUnitVector;
  71825. private _getColorIndicesForCoord;
  71826. private _setPointsColorOrUV;
  71827. private _colorFromTexture;
  71828. private _calculateDensity;
  71829. /**
  71830. * Adds points to the PCS in random positions within a unit sphere
  71831. * @param nb (positive integer) the number of particles to be created from this model
  71832. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71833. * @returns the number of groups in the system
  71834. */
  71835. addPoints(nb: number, pointFunction?: any): number;
  71836. /**
  71837. * Adds points to the PCS from the surface of the model shape
  71838. * @param mesh is any Mesh object that will be used as a surface model for the points
  71839. * @param nb (positive integer) the number of particles to be created from this model
  71840. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71841. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71842. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71843. * @returns the number of groups in the system
  71844. */
  71845. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71846. /**
  71847. * Adds points to the PCS inside the model shape
  71848. * @param mesh is any Mesh object that will be used as a surface model for the points
  71849. * @param nb (positive integer) the number of particles to be created from this model
  71850. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71851. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71852. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71853. * @returns the number of groups in the system
  71854. */
  71855. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71856. /**
  71857. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71858. * This method calls `updateParticle()` for each particle of the SPS.
  71859. * For an animated SPS, it is usually called within the render loop.
  71860. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71861. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71862. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71863. * @returns the PCS.
  71864. */
  71865. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71866. /**
  71867. * Disposes the PCS.
  71868. */
  71869. dispose(): void;
  71870. /**
  71871. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71872. * doc :
  71873. * @returns the PCS.
  71874. */
  71875. refreshVisibleSize(): PointsCloudSystem;
  71876. /**
  71877. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71878. * @param size the size (float) of the visibility box
  71879. * note : this doesn't lock the PCS mesh bounding box.
  71880. * doc :
  71881. */
  71882. setVisibilityBox(size: number): void;
  71883. /**
  71884. * Gets whether the PCS is always visible or not
  71885. * doc :
  71886. */
  71887. get isAlwaysVisible(): boolean;
  71888. /**
  71889. * Sets the PCS as always visible or not
  71890. * doc :
  71891. */
  71892. set isAlwaysVisible(val: boolean);
  71893. /**
  71894. * Tells to `setParticles()` to compute the particle rotations or not
  71895. * Default value : false. The PCS is faster when it's set to false
  71896. * Note : particle rotations are only applied to parent particles
  71897. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71898. */
  71899. set computeParticleRotation(val: boolean);
  71900. /**
  71901. * Tells to `setParticles()` to compute the particle colors or not.
  71902. * Default value : true. The PCS is faster when it's set to false.
  71903. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71904. */
  71905. set computeParticleColor(val: boolean);
  71906. set computeParticleTexture(val: boolean);
  71907. /**
  71908. * Gets if `setParticles()` computes the particle colors or not.
  71909. * Default value : false. The PCS is faster when it's set to false.
  71910. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71911. */
  71912. get computeParticleColor(): boolean;
  71913. /**
  71914. * Gets if `setParticles()` computes the particle textures or not.
  71915. * Default value : false. The PCS is faster when it's set to false.
  71916. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71917. */
  71918. get computeParticleTexture(): boolean;
  71919. /**
  71920. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71921. */
  71922. set computeBoundingBox(val: boolean);
  71923. /**
  71924. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71925. */
  71926. get computeBoundingBox(): boolean;
  71927. /**
  71928. * This function does nothing. It may be overwritten to set all the particle first values.
  71929. * The PCS doesn't call this function, you may have to call it by your own.
  71930. * doc :
  71931. */
  71932. initParticles(): void;
  71933. /**
  71934. * This function does nothing. It may be overwritten to recycle a particle
  71935. * The PCS doesn't call this function, you can to call it
  71936. * doc :
  71937. * @param particle The particle to recycle
  71938. * @returns the recycled particle
  71939. */
  71940. recycleParticle(particle: CloudPoint): CloudPoint;
  71941. /**
  71942. * Updates a particle : this function should be overwritten by the user.
  71943. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71944. * doc :
  71945. * @example : just set a particle position or velocity and recycle conditions
  71946. * @param particle The particle to update
  71947. * @returns the updated particle
  71948. */
  71949. updateParticle(particle: CloudPoint): CloudPoint;
  71950. /**
  71951. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71952. * This does nothing and may be overwritten by the user.
  71953. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71954. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71955. * @param update the boolean update value actually passed to setParticles()
  71956. */
  71957. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71958. /**
  71959. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71960. * This will be passed three parameters.
  71961. * This does nothing and may be overwritten by the user.
  71962. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71963. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71964. * @param update the boolean update value actually passed to setParticles()
  71965. */
  71966. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71967. }
  71968. }
  71969. declare module "babylonjs/Particles/cloudPoint" {
  71970. import { Nullable } from "babylonjs/types";
  71971. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71972. import { Mesh } from "babylonjs/Meshes/mesh";
  71973. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71974. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71975. /**
  71976. * Represents one particle of a points cloud system.
  71977. */
  71978. export class CloudPoint {
  71979. /**
  71980. * particle global index
  71981. */
  71982. idx: number;
  71983. /**
  71984. * The color of the particle
  71985. */
  71986. color: Nullable<Color4>;
  71987. /**
  71988. * The world space position of the particle.
  71989. */
  71990. position: Vector3;
  71991. /**
  71992. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71993. */
  71994. rotation: Vector3;
  71995. /**
  71996. * The world space rotation quaternion of the particle.
  71997. */
  71998. rotationQuaternion: Nullable<Quaternion>;
  71999. /**
  72000. * The uv of the particle.
  72001. */
  72002. uv: Nullable<Vector2>;
  72003. /**
  72004. * The current speed of the particle.
  72005. */
  72006. velocity: Vector3;
  72007. /**
  72008. * The pivot point in the particle local space.
  72009. */
  72010. pivot: Vector3;
  72011. /**
  72012. * Must the particle be translated from its pivot point in its local space ?
  72013. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72014. * Default : false
  72015. */
  72016. translateFromPivot: boolean;
  72017. /**
  72018. * Index of this particle in the global "positions" array (Internal use)
  72019. * @hidden
  72020. */
  72021. _pos: number;
  72022. /**
  72023. * @hidden Index of this particle in the global "indices" array (Internal use)
  72024. */
  72025. _ind: number;
  72026. /**
  72027. * Group this particle belongs to
  72028. */
  72029. _group: PointsGroup;
  72030. /**
  72031. * Group id of this particle
  72032. */
  72033. groupId: number;
  72034. /**
  72035. * Index of the particle in its group id (Internal use)
  72036. */
  72037. idxInGroup: number;
  72038. /**
  72039. * @hidden Particle BoundingInfo object (Internal use)
  72040. */
  72041. _boundingInfo: BoundingInfo;
  72042. /**
  72043. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72044. */
  72045. _pcs: PointsCloudSystem;
  72046. /**
  72047. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72048. */
  72049. _stillInvisible: boolean;
  72050. /**
  72051. * @hidden Last computed particle rotation matrix
  72052. */
  72053. _rotationMatrix: number[];
  72054. /**
  72055. * Parent particle Id, if any.
  72056. * Default null.
  72057. */
  72058. parentId: Nullable<number>;
  72059. /**
  72060. * @hidden Internal global position in the PCS.
  72061. */
  72062. _globalPosition: Vector3;
  72063. /**
  72064. * Creates a Point Cloud object.
  72065. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72066. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72067. * @param group (PointsGroup) is the group the particle belongs to
  72068. * @param groupId (integer) is the group identifier in the PCS.
  72069. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72070. * @param pcs defines the PCS it is associated to
  72071. */
  72072. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72073. /**
  72074. * get point size
  72075. */
  72076. get size(): Vector3;
  72077. /**
  72078. * Set point size
  72079. */
  72080. set size(scale: Vector3);
  72081. /**
  72082. * Legacy support, changed quaternion to rotationQuaternion
  72083. */
  72084. get quaternion(): Nullable<Quaternion>;
  72085. /**
  72086. * Legacy support, changed quaternion to rotationQuaternion
  72087. */
  72088. set quaternion(q: Nullable<Quaternion>);
  72089. /**
  72090. * Returns a boolean. True if the particle intersects a mesh, else false
  72091. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72092. * @param target is the object (point or mesh) what the intersection is computed against
  72093. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72094. * @returns true if it intersects
  72095. */
  72096. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72097. /**
  72098. * get the rotation matrix of the particle
  72099. * @hidden
  72100. */
  72101. getRotationMatrix(m: Matrix): void;
  72102. }
  72103. /**
  72104. * Represents a group of points in a points cloud system
  72105. * * PCS internal tool, don't use it manually.
  72106. */
  72107. export class PointsGroup {
  72108. /**
  72109. * The group id
  72110. * @hidden
  72111. */
  72112. groupID: number;
  72113. /**
  72114. * image data for group (internal use)
  72115. * @hidden
  72116. */
  72117. _groupImageData: Nullable<ArrayBufferView>;
  72118. /**
  72119. * Image Width (internal use)
  72120. * @hidden
  72121. */
  72122. _groupImgWidth: number;
  72123. /**
  72124. * Image Height (internal use)
  72125. * @hidden
  72126. */
  72127. _groupImgHeight: number;
  72128. /**
  72129. * Custom position function (internal use)
  72130. * @hidden
  72131. */
  72132. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72133. /**
  72134. * density per facet for surface points
  72135. * @hidden
  72136. */
  72137. _groupDensity: number[];
  72138. /**
  72139. * Only when points are colored by texture carries pointer to texture list array
  72140. * @hidden
  72141. */
  72142. _textureNb: number;
  72143. /**
  72144. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72145. * PCS internal tool, don't use it manually.
  72146. * @hidden
  72147. */
  72148. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72149. }
  72150. }
  72151. declare module "babylonjs/Particles/index" {
  72152. export * from "babylonjs/Particles/baseParticleSystem";
  72153. export * from "babylonjs/Particles/EmitterTypes/index";
  72154. export * from "babylonjs/Particles/gpuParticleSystem";
  72155. export * from "babylonjs/Particles/IParticleSystem";
  72156. export * from "babylonjs/Particles/particle";
  72157. export * from "babylonjs/Particles/particleHelper";
  72158. export * from "babylonjs/Particles/particleSystem";
  72159. import "babylonjs/Particles/particleSystemComponent";
  72160. export * from "babylonjs/Particles/particleSystemComponent";
  72161. export * from "babylonjs/Particles/particleSystemSet";
  72162. export * from "babylonjs/Particles/solidParticle";
  72163. export * from "babylonjs/Particles/solidParticleSystem";
  72164. export * from "babylonjs/Particles/cloudPoint";
  72165. export * from "babylonjs/Particles/pointsCloudSystem";
  72166. export * from "babylonjs/Particles/subEmitter";
  72167. }
  72168. declare module "babylonjs/Physics/physicsEngineComponent" {
  72169. import { Nullable } from "babylonjs/types";
  72170. import { Observable, Observer } from "babylonjs/Misc/observable";
  72171. import { Vector3 } from "babylonjs/Maths/math.vector";
  72172. import { Mesh } from "babylonjs/Meshes/mesh";
  72173. import { ISceneComponent } from "babylonjs/sceneComponent";
  72174. import { Scene } from "babylonjs/scene";
  72175. import { Node } from "babylonjs/node";
  72176. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72177. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72178. module "babylonjs/scene" {
  72179. interface Scene {
  72180. /** @hidden (Backing field) */
  72181. _physicsEngine: Nullable<IPhysicsEngine>;
  72182. /** @hidden */
  72183. _physicsTimeAccumulator: number;
  72184. /**
  72185. * Gets the current physics engine
  72186. * @returns a IPhysicsEngine or null if none attached
  72187. */
  72188. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72189. /**
  72190. * Enables physics to the current scene
  72191. * @param gravity defines the scene's gravity for the physics engine
  72192. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72193. * @return a boolean indicating if the physics engine was initialized
  72194. */
  72195. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72196. /**
  72197. * Disables and disposes the physics engine associated with the scene
  72198. */
  72199. disablePhysicsEngine(): void;
  72200. /**
  72201. * Gets a boolean indicating if there is an active physics engine
  72202. * @returns a boolean indicating if there is an active physics engine
  72203. */
  72204. isPhysicsEnabled(): boolean;
  72205. /**
  72206. * Deletes a physics compound impostor
  72207. * @param compound defines the compound to delete
  72208. */
  72209. deleteCompoundImpostor(compound: any): void;
  72210. /**
  72211. * An event triggered when physic simulation is about to be run
  72212. */
  72213. onBeforePhysicsObservable: Observable<Scene>;
  72214. /**
  72215. * An event triggered when physic simulation has been done
  72216. */
  72217. onAfterPhysicsObservable: Observable<Scene>;
  72218. }
  72219. }
  72220. module "babylonjs/Meshes/abstractMesh" {
  72221. interface AbstractMesh {
  72222. /** @hidden */
  72223. _physicsImpostor: Nullable<PhysicsImpostor>;
  72224. /**
  72225. * Gets or sets impostor used for physic simulation
  72226. * @see https://doc.babylonjs.com/features/physics_engine
  72227. */
  72228. physicsImpostor: Nullable<PhysicsImpostor>;
  72229. /**
  72230. * Gets the current physics impostor
  72231. * @see https://doc.babylonjs.com/features/physics_engine
  72232. * @returns a physics impostor or null
  72233. */
  72234. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72235. /** Apply a physic impulse to the mesh
  72236. * @param force defines the force to apply
  72237. * @param contactPoint defines where to apply the force
  72238. * @returns the current mesh
  72239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72240. */
  72241. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72242. /**
  72243. * Creates a physic joint between two meshes
  72244. * @param otherMesh defines the other mesh to use
  72245. * @param pivot1 defines the pivot to use on this mesh
  72246. * @param pivot2 defines the pivot to use on the other mesh
  72247. * @param options defines additional options (can be plugin dependent)
  72248. * @returns the current mesh
  72249. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72250. */
  72251. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72252. /** @hidden */
  72253. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72254. }
  72255. }
  72256. /**
  72257. * Defines the physics engine scene component responsible to manage a physics engine
  72258. */
  72259. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72260. /**
  72261. * The component name helpful to identify the component in the list of scene components.
  72262. */
  72263. readonly name: string;
  72264. /**
  72265. * The scene the component belongs to.
  72266. */
  72267. scene: Scene;
  72268. /**
  72269. * Creates a new instance of the component for the given scene
  72270. * @param scene Defines the scene to register the component in
  72271. */
  72272. constructor(scene: Scene);
  72273. /**
  72274. * Registers the component in a given scene
  72275. */
  72276. register(): void;
  72277. /**
  72278. * Rebuilds the elements related to this component in case of
  72279. * context lost for instance.
  72280. */
  72281. rebuild(): void;
  72282. /**
  72283. * Disposes the component and the associated ressources
  72284. */
  72285. dispose(): void;
  72286. }
  72287. }
  72288. declare module "babylonjs/Physics/physicsHelper" {
  72289. import { Nullable } from "babylonjs/types";
  72290. import { Vector3 } from "babylonjs/Maths/math.vector";
  72291. import { Mesh } from "babylonjs/Meshes/mesh";
  72292. import { Scene } from "babylonjs/scene";
  72293. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72294. /**
  72295. * A helper for physics simulations
  72296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72297. */
  72298. export class PhysicsHelper {
  72299. private _scene;
  72300. private _physicsEngine;
  72301. /**
  72302. * Initializes the Physics helper
  72303. * @param scene Babylon.js scene
  72304. */
  72305. constructor(scene: Scene);
  72306. /**
  72307. * Applies a radial explosion impulse
  72308. * @param origin the origin of the explosion
  72309. * @param radiusOrEventOptions the radius or the options of radial explosion
  72310. * @param strength the explosion strength
  72311. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72312. * @returns A physics radial explosion event, or null
  72313. */
  72314. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72315. /**
  72316. * Applies a radial explosion force
  72317. * @param origin the origin of the explosion
  72318. * @param radiusOrEventOptions the radius or the options of radial explosion
  72319. * @param strength the explosion strength
  72320. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72321. * @returns A physics radial explosion event, or null
  72322. */
  72323. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72324. /**
  72325. * Creates a gravitational field
  72326. * @param origin the origin of the explosion
  72327. * @param radiusOrEventOptions the radius or the options of radial explosion
  72328. * @param strength the explosion strength
  72329. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72330. * @returns A physics gravitational field event, or null
  72331. */
  72332. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72333. /**
  72334. * Creates a physics updraft event
  72335. * @param origin the origin of the updraft
  72336. * @param radiusOrEventOptions the radius or the options of the updraft
  72337. * @param strength the strength of the updraft
  72338. * @param height the height of the updraft
  72339. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72340. * @returns A physics updraft event, or null
  72341. */
  72342. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72343. /**
  72344. * Creates a physics vortex event
  72345. * @param origin the of the vortex
  72346. * @param radiusOrEventOptions the radius or the options of the vortex
  72347. * @param strength the strength of the vortex
  72348. * @param height the height of the vortex
  72349. * @returns a Physics vortex event, or null
  72350. * A physics vortex event or null
  72351. */
  72352. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72353. }
  72354. /**
  72355. * Represents a physics radial explosion event
  72356. */
  72357. class PhysicsRadialExplosionEvent {
  72358. private _scene;
  72359. private _options;
  72360. private _sphere;
  72361. private _dataFetched;
  72362. /**
  72363. * Initializes a radial explosioin event
  72364. * @param _scene BabylonJS scene
  72365. * @param _options The options for the vortex event
  72366. */
  72367. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72368. /**
  72369. * Returns the data related to the radial explosion event (sphere).
  72370. * @returns The radial explosion event data
  72371. */
  72372. getData(): PhysicsRadialExplosionEventData;
  72373. /**
  72374. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72375. * @param impostor A physics imposter
  72376. * @param origin the origin of the explosion
  72377. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72378. */
  72379. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72380. /**
  72381. * Triggers affecterd impostors callbacks
  72382. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72383. */
  72384. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72385. /**
  72386. * Disposes the sphere.
  72387. * @param force Specifies if the sphere should be disposed by force
  72388. */
  72389. dispose(force?: boolean): void;
  72390. /*** Helpers ***/
  72391. private _prepareSphere;
  72392. private _intersectsWithSphere;
  72393. }
  72394. /**
  72395. * Represents a gravitational field event
  72396. */
  72397. class PhysicsGravitationalFieldEvent {
  72398. private _physicsHelper;
  72399. private _scene;
  72400. private _origin;
  72401. private _options;
  72402. private _tickCallback;
  72403. private _sphere;
  72404. private _dataFetched;
  72405. /**
  72406. * Initializes the physics gravitational field event
  72407. * @param _physicsHelper A physics helper
  72408. * @param _scene BabylonJS scene
  72409. * @param _origin The origin position of the gravitational field event
  72410. * @param _options The options for the vortex event
  72411. */
  72412. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72413. /**
  72414. * Returns the data related to the gravitational field event (sphere).
  72415. * @returns A gravitational field event
  72416. */
  72417. getData(): PhysicsGravitationalFieldEventData;
  72418. /**
  72419. * Enables the gravitational field.
  72420. */
  72421. enable(): void;
  72422. /**
  72423. * Disables the gravitational field.
  72424. */
  72425. disable(): void;
  72426. /**
  72427. * Disposes the sphere.
  72428. * @param force The force to dispose from the gravitational field event
  72429. */
  72430. dispose(force?: boolean): void;
  72431. private _tick;
  72432. }
  72433. /**
  72434. * Represents a physics updraft event
  72435. */
  72436. class PhysicsUpdraftEvent {
  72437. private _scene;
  72438. private _origin;
  72439. private _options;
  72440. private _physicsEngine;
  72441. private _originTop;
  72442. private _originDirection;
  72443. private _tickCallback;
  72444. private _cylinder;
  72445. private _cylinderPosition;
  72446. private _dataFetched;
  72447. /**
  72448. * Initializes the physics updraft event
  72449. * @param _scene BabylonJS scene
  72450. * @param _origin The origin position of the updraft
  72451. * @param _options The options for the updraft event
  72452. */
  72453. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72454. /**
  72455. * Returns the data related to the updraft event (cylinder).
  72456. * @returns A physics updraft event
  72457. */
  72458. getData(): PhysicsUpdraftEventData;
  72459. /**
  72460. * Enables the updraft.
  72461. */
  72462. enable(): void;
  72463. /**
  72464. * Disables the updraft.
  72465. */
  72466. disable(): void;
  72467. /**
  72468. * Disposes the cylinder.
  72469. * @param force Specifies if the updraft should be disposed by force
  72470. */
  72471. dispose(force?: boolean): void;
  72472. private getImpostorHitData;
  72473. private _tick;
  72474. /*** Helpers ***/
  72475. private _prepareCylinder;
  72476. private _intersectsWithCylinder;
  72477. }
  72478. /**
  72479. * Represents a physics vortex event
  72480. */
  72481. class PhysicsVortexEvent {
  72482. private _scene;
  72483. private _origin;
  72484. private _options;
  72485. private _physicsEngine;
  72486. private _originTop;
  72487. private _tickCallback;
  72488. private _cylinder;
  72489. private _cylinderPosition;
  72490. private _dataFetched;
  72491. /**
  72492. * Initializes the physics vortex event
  72493. * @param _scene The BabylonJS scene
  72494. * @param _origin The origin position of the vortex
  72495. * @param _options The options for the vortex event
  72496. */
  72497. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72498. /**
  72499. * Returns the data related to the vortex event (cylinder).
  72500. * @returns The physics vortex event data
  72501. */
  72502. getData(): PhysicsVortexEventData;
  72503. /**
  72504. * Enables the vortex.
  72505. */
  72506. enable(): void;
  72507. /**
  72508. * Disables the cortex.
  72509. */
  72510. disable(): void;
  72511. /**
  72512. * Disposes the sphere.
  72513. * @param force
  72514. */
  72515. dispose(force?: boolean): void;
  72516. private getImpostorHitData;
  72517. private _tick;
  72518. /*** Helpers ***/
  72519. private _prepareCylinder;
  72520. private _intersectsWithCylinder;
  72521. }
  72522. /**
  72523. * Options fot the radial explosion event
  72524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72525. */
  72526. export class PhysicsRadialExplosionEventOptions {
  72527. /**
  72528. * The radius of the sphere for the radial explosion.
  72529. */
  72530. radius: number;
  72531. /**
  72532. * The strenth of the explosion.
  72533. */
  72534. strength: number;
  72535. /**
  72536. * The strenght of the force in correspondence to the distance of the affected object
  72537. */
  72538. falloff: PhysicsRadialImpulseFalloff;
  72539. /**
  72540. * Sphere options for the radial explosion.
  72541. */
  72542. sphere: {
  72543. segments: number;
  72544. diameter: number;
  72545. };
  72546. /**
  72547. * Sphere options for the radial explosion.
  72548. */
  72549. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72550. }
  72551. /**
  72552. * Options fot the updraft event
  72553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72554. */
  72555. export class PhysicsUpdraftEventOptions {
  72556. /**
  72557. * The radius of the cylinder for the vortex
  72558. */
  72559. radius: number;
  72560. /**
  72561. * The strenth of the updraft.
  72562. */
  72563. strength: number;
  72564. /**
  72565. * The height of the cylinder for the updraft.
  72566. */
  72567. height: number;
  72568. /**
  72569. * The mode for the the updraft.
  72570. */
  72571. updraftMode: PhysicsUpdraftMode;
  72572. }
  72573. /**
  72574. * Options fot the vortex event
  72575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72576. */
  72577. export class PhysicsVortexEventOptions {
  72578. /**
  72579. * The radius of the cylinder for the vortex
  72580. */
  72581. radius: number;
  72582. /**
  72583. * The strenth of the vortex.
  72584. */
  72585. strength: number;
  72586. /**
  72587. * The height of the cylinder for the vortex.
  72588. */
  72589. height: number;
  72590. /**
  72591. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72592. */
  72593. centripetalForceThreshold: number;
  72594. /**
  72595. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72596. */
  72597. centripetalForceMultiplier: number;
  72598. /**
  72599. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72600. */
  72601. centrifugalForceMultiplier: number;
  72602. /**
  72603. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72604. */
  72605. updraftForceMultiplier: number;
  72606. }
  72607. /**
  72608. * The strenght of the force in correspondence to the distance of the affected object
  72609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72610. */
  72611. export enum PhysicsRadialImpulseFalloff {
  72612. /** Defines that impulse is constant in strength across it's whole radius */
  72613. Constant = 0,
  72614. /** Defines that impulse gets weaker if it's further from the origin */
  72615. Linear = 1
  72616. }
  72617. /**
  72618. * The strength of the force in correspondence to the distance of the affected object
  72619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72620. */
  72621. export enum PhysicsUpdraftMode {
  72622. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72623. Center = 0,
  72624. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72625. Perpendicular = 1
  72626. }
  72627. /**
  72628. * Interface for a physics hit data
  72629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72630. */
  72631. export interface PhysicsHitData {
  72632. /**
  72633. * The force applied at the contact point
  72634. */
  72635. force: Vector3;
  72636. /**
  72637. * The contact point
  72638. */
  72639. contactPoint: Vector3;
  72640. /**
  72641. * The distance from the origin to the contact point
  72642. */
  72643. distanceFromOrigin: number;
  72644. }
  72645. /**
  72646. * Interface for radial explosion event data
  72647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72648. */
  72649. export interface PhysicsRadialExplosionEventData {
  72650. /**
  72651. * A sphere used for the radial explosion event
  72652. */
  72653. sphere: Mesh;
  72654. }
  72655. /**
  72656. * Interface for gravitational field event data
  72657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72658. */
  72659. export interface PhysicsGravitationalFieldEventData {
  72660. /**
  72661. * A sphere mesh used for the gravitational field event
  72662. */
  72663. sphere: Mesh;
  72664. }
  72665. /**
  72666. * Interface for updraft event data
  72667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72668. */
  72669. export interface PhysicsUpdraftEventData {
  72670. /**
  72671. * A cylinder used for the updraft event
  72672. */
  72673. cylinder: Mesh;
  72674. }
  72675. /**
  72676. * Interface for vortex event data
  72677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72678. */
  72679. export interface PhysicsVortexEventData {
  72680. /**
  72681. * A cylinder used for the vortex event
  72682. */
  72683. cylinder: Mesh;
  72684. }
  72685. /**
  72686. * Interface for an affected physics impostor
  72687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72688. */
  72689. export interface PhysicsAffectedImpostorWithData {
  72690. /**
  72691. * The impostor affected by the effect
  72692. */
  72693. impostor: PhysicsImpostor;
  72694. /**
  72695. * The data about the hit/horce from the explosion
  72696. */
  72697. hitData: PhysicsHitData;
  72698. }
  72699. }
  72700. declare module "babylonjs/Physics/Plugins/index" {
  72701. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72702. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72703. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72704. }
  72705. declare module "babylonjs/Physics/index" {
  72706. export * from "babylonjs/Physics/IPhysicsEngine";
  72707. export * from "babylonjs/Physics/physicsEngine";
  72708. export * from "babylonjs/Physics/physicsEngineComponent";
  72709. export * from "babylonjs/Physics/physicsHelper";
  72710. export * from "babylonjs/Physics/physicsImpostor";
  72711. export * from "babylonjs/Physics/physicsJoint";
  72712. export * from "babylonjs/Physics/Plugins/index";
  72713. }
  72714. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72715. /** @hidden */
  72716. export var blackAndWhitePixelShader: {
  72717. name: string;
  72718. shader: string;
  72719. };
  72720. }
  72721. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72722. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72723. import { Camera } from "babylonjs/Cameras/camera";
  72724. import { Engine } from "babylonjs/Engines/engine";
  72725. import "babylonjs/Shaders/blackAndWhite.fragment";
  72726. import { Nullable } from "babylonjs/types";
  72727. import { Scene } from "babylonjs/scene";
  72728. /**
  72729. * Post process used to render in black and white
  72730. */
  72731. export class BlackAndWhitePostProcess extends PostProcess {
  72732. /**
  72733. * Linear about to convert he result to black and white (default: 1)
  72734. */
  72735. degree: number;
  72736. /**
  72737. * Gets a string identifying the name of the class
  72738. * @returns "BlackAndWhitePostProcess" string
  72739. */
  72740. getClassName(): string;
  72741. /**
  72742. * Creates a black and white post process
  72743. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72744. * @param name The name of the effect.
  72745. * @param options The required width/height ratio to downsize to before computing the render pass.
  72746. * @param camera The camera to apply the render pass to.
  72747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72748. * @param engine The engine which the post process will be applied. (default: current engine)
  72749. * @param reusable If the post process can be reused on the same frame. (default: false)
  72750. */
  72751. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72752. /** @hidden */
  72753. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72754. }
  72755. }
  72756. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72757. import { Nullable } from "babylonjs/types";
  72758. import { Camera } from "babylonjs/Cameras/camera";
  72759. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72760. import { Engine } from "babylonjs/Engines/engine";
  72761. /**
  72762. * This represents a set of one or more post processes in Babylon.
  72763. * A post process can be used to apply a shader to a texture after it is rendered.
  72764. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72765. */
  72766. export class PostProcessRenderEffect {
  72767. private _postProcesses;
  72768. private _getPostProcesses;
  72769. private _singleInstance;
  72770. private _cameras;
  72771. private _indicesForCamera;
  72772. /**
  72773. * Name of the effect
  72774. * @hidden
  72775. */
  72776. _name: string;
  72777. /**
  72778. * Instantiates a post process render effect.
  72779. * A post process can be used to apply a shader to a texture after it is rendered.
  72780. * @param engine The engine the effect is tied to
  72781. * @param name The name of the effect
  72782. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72783. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72784. */
  72785. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72786. /**
  72787. * Checks if all the post processes in the effect are supported.
  72788. */
  72789. get isSupported(): boolean;
  72790. /**
  72791. * Updates the current state of the effect
  72792. * @hidden
  72793. */
  72794. _update(): void;
  72795. /**
  72796. * Attaches the effect on cameras
  72797. * @param cameras The camera to attach to.
  72798. * @hidden
  72799. */
  72800. _attachCameras(cameras: Camera): void;
  72801. /**
  72802. * Attaches the effect on cameras
  72803. * @param cameras The camera to attach to.
  72804. * @hidden
  72805. */
  72806. _attachCameras(cameras: Camera[]): void;
  72807. /**
  72808. * Detaches the effect on cameras
  72809. * @param cameras The camera to detatch from.
  72810. * @hidden
  72811. */
  72812. _detachCameras(cameras: Camera): void;
  72813. /**
  72814. * Detatches the effect on cameras
  72815. * @param cameras The camera to detatch from.
  72816. * @hidden
  72817. */
  72818. _detachCameras(cameras: Camera[]): void;
  72819. /**
  72820. * Enables the effect on given cameras
  72821. * @param cameras The camera to enable.
  72822. * @hidden
  72823. */
  72824. _enable(cameras: Camera): void;
  72825. /**
  72826. * Enables the effect on given cameras
  72827. * @param cameras The camera to enable.
  72828. * @hidden
  72829. */
  72830. _enable(cameras: Nullable<Camera[]>): void;
  72831. /**
  72832. * Disables the effect on the given cameras
  72833. * @param cameras The camera to disable.
  72834. * @hidden
  72835. */
  72836. _disable(cameras: Camera): void;
  72837. /**
  72838. * Disables the effect on the given cameras
  72839. * @param cameras The camera to disable.
  72840. * @hidden
  72841. */
  72842. _disable(cameras: Nullable<Camera[]>): void;
  72843. /**
  72844. * Gets a list of the post processes contained in the effect.
  72845. * @param camera The camera to get the post processes on.
  72846. * @returns The list of the post processes in the effect.
  72847. */
  72848. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72849. }
  72850. }
  72851. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72852. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72853. /** @hidden */
  72854. export var extractHighlightsPixelShader: {
  72855. name: string;
  72856. shader: string;
  72857. };
  72858. }
  72859. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72860. import { Nullable } from "babylonjs/types";
  72861. import { Camera } from "babylonjs/Cameras/camera";
  72862. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72863. import { Engine } from "babylonjs/Engines/engine";
  72864. import "babylonjs/Shaders/extractHighlights.fragment";
  72865. /**
  72866. * 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.
  72867. */
  72868. export class ExtractHighlightsPostProcess extends PostProcess {
  72869. /**
  72870. * The luminance threshold, pixels below this value will be set to black.
  72871. */
  72872. threshold: number;
  72873. /** @hidden */
  72874. _exposure: number;
  72875. /**
  72876. * Post process which has the input texture to be used when performing highlight extraction
  72877. * @hidden
  72878. */
  72879. _inputPostProcess: Nullable<PostProcess>;
  72880. /**
  72881. * Gets a string identifying the name of the class
  72882. * @returns "ExtractHighlightsPostProcess" string
  72883. */
  72884. getClassName(): string;
  72885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72886. }
  72887. }
  72888. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72889. /** @hidden */
  72890. export var bloomMergePixelShader: {
  72891. name: string;
  72892. shader: string;
  72893. };
  72894. }
  72895. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72897. import { Nullable } from "babylonjs/types";
  72898. import { Engine } from "babylonjs/Engines/engine";
  72899. import { Camera } from "babylonjs/Cameras/camera";
  72900. import "babylonjs/Shaders/bloomMerge.fragment";
  72901. /**
  72902. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72903. */
  72904. export class BloomMergePostProcess extends PostProcess {
  72905. /** Weight of the bloom to be added to the original input. */
  72906. weight: number;
  72907. /**
  72908. * Gets a string identifying the name of the class
  72909. * @returns "BloomMergePostProcess" string
  72910. */
  72911. getClassName(): string;
  72912. /**
  72913. * Creates a new instance of @see BloomMergePostProcess
  72914. * @param name The name of the effect.
  72915. * @param originalFromInput Post process which's input will be used for the merge.
  72916. * @param blurred Blurred highlights post process which's output will be used.
  72917. * @param weight Weight of the bloom to be added to the original input.
  72918. * @param options The required width/height ratio to downsize to before computing the render pass.
  72919. * @param camera The camera to apply the render pass to.
  72920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72921. * @param engine The engine which the post process will be applied. (default: current engine)
  72922. * @param reusable If the post process can be reused on the same frame. (default: false)
  72923. * @param textureType Type of textures used when performing the post process. (default: 0)
  72924. * @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)
  72925. */
  72926. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72927. /** Weight of the bloom to be added to the original input. */
  72928. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72929. }
  72930. }
  72931. declare module "babylonjs/PostProcesses/bloomEffect" {
  72932. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72934. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72935. import { Camera } from "babylonjs/Cameras/camera";
  72936. import { Scene } from "babylonjs/scene";
  72937. /**
  72938. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72939. */
  72940. export class BloomEffect extends PostProcessRenderEffect {
  72941. private bloomScale;
  72942. /**
  72943. * @hidden Internal
  72944. */
  72945. _effects: Array<PostProcess>;
  72946. /**
  72947. * @hidden Internal
  72948. */
  72949. _downscale: ExtractHighlightsPostProcess;
  72950. private _blurX;
  72951. private _blurY;
  72952. private _merge;
  72953. /**
  72954. * The luminance threshold to find bright areas of the image to bloom.
  72955. */
  72956. get threshold(): number;
  72957. set threshold(value: number);
  72958. /**
  72959. * The strength of the bloom.
  72960. */
  72961. get weight(): number;
  72962. set weight(value: number);
  72963. /**
  72964. * Specifies the size of the bloom blur kernel, relative to the final output size
  72965. */
  72966. get kernel(): number;
  72967. set kernel(value: number);
  72968. /**
  72969. * Creates a new instance of @see BloomEffect
  72970. * @param scene The scene the effect belongs to.
  72971. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72972. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72973. * @param bloomWeight The the strength of bloom.
  72974. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72975. * @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)
  72976. */
  72977. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72978. /**
  72979. * Disposes each of the internal effects for a given camera.
  72980. * @param camera The camera to dispose the effect on.
  72981. */
  72982. disposeEffects(camera: Camera): void;
  72983. /**
  72984. * @hidden Internal
  72985. */
  72986. _updateEffects(): void;
  72987. /**
  72988. * Internal
  72989. * @returns if all the contained post processes are ready.
  72990. * @hidden
  72991. */
  72992. _isReady(): boolean;
  72993. }
  72994. }
  72995. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72996. /** @hidden */
  72997. export var chromaticAberrationPixelShader: {
  72998. name: string;
  72999. shader: string;
  73000. };
  73001. }
  73002. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73003. import { Vector2 } from "babylonjs/Maths/math.vector";
  73004. import { Nullable } from "babylonjs/types";
  73005. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73006. import { Camera } from "babylonjs/Cameras/camera";
  73007. import { Engine } from "babylonjs/Engines/engine";
  73008. import "babylonjs/Shaders/chromaticAberration.fragment";
  73009. import { Scene } from "babylonjs/scene";
  73010. /**
  73011. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73012. */
  73013. export class ChromaticAberrationPostProcess extends PostProcess {
  73014. /**
  73015. * The amount of seperation of rgb channels (default: 30)
  73016. */
  73017. aberrationAmount: number;
  73018. /**
  73019. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73020. */
  73021. radialIntensity: number;
  73022. /**
  73023. * 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))
  73024. */
  73025. direction: Vector2;
  73026. /**
  73027. * 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))
  73028. */
  73029. centerPosition: Vector2;
  73030. /** The width of the screen to apply the effect on */
  73031. screenWidth: number;
  73032. /** The height of the screen to apply the effect on */
  73033. screenHeight: number;
  73034. /**
  73035. * Gets a string identifying the name of the class
  73036. * @returns "ChromaticAberrationPostProcess" string
  73037. */
  73038. getClassName(): string;
  73039. /**
  73040. * Creates a new instance ChromaticAberrationPostProcess
  73041. * @param name The name of the effect.
  73042. * @param screenWidth The width of the screen to apply the effect on.
  73043. * @param screenHeight The height of the screen to apply the effect on.
  73044. * @param options The required width/height ratio to downsize to before computing the render pass.
  73045. * @param camera The camera to apply the render pass to.
  73046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73047. * @param engine The engine which the post process will be applied. (default: current engine)
  73048. * @param reusable If the post process can be reused on the same frame. (default: false)
  73049. * @param textureType Type of textures used when performing the post process. (default: 0)
  73050. * @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)
  73051. */
  73052. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73053. /** @hidden */
  73054. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73055. }
  73056. }
  73057. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73058. /** @hidden */
  73059. export var circleOfConfusionPixelShader: {
  73060. name: string;
  73061. shader: string;
  73062. };
  73063. }
  73064. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73065. import { Nullable } from "babylonjs/types";
  73066. import { Engine } from "babylonjs/Engines/engine";
  73067. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73068. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73069. import { Camera } from "babylonjs/Cameras/camera";
  73070. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73071. /**
  73072. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73073. */
  73074. export class CircleOfConfusionPostProcess extends PostProcess {
  73075. /**
  73076. * 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.
  73077. */
  73078. lensSize: number;
  73079. /**
  73080. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73081. */
  73082. fStop: number;
  73083. /**
  73084. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73085. */
  73086. focusDistance: number;
  73087. /**
  73088. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73089. */
  73090. focalLength: number;
  73091. /**
  73092. * Gets a string identifying the name of the class
  73093. * @returns "CircleOfConfusionPostProcess" string
  73094. */
  73095. getClassName(): string;
  73096. private _depthTexture;
  73097. /**
  73098. * Creates a new instance CircleOfConfusionPostProcess
  73099. * @param name The name of the effect.
  73100. * @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.
  73101. * @param options The required width/height ratio to downsize to before computing the render pass.
  73102. * @param camera The camera to apply the render pass to.
  73103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73104. * @param engine The engine which the post process will be applied. (default: current engine)
  73105. * @param reusable If the post process can be reused on the same frame. (default: false)
  73106. * @param textureType Type of textures used when performing the post process. (default: 0)
  73107. * @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)
  73108. */
  73109. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73110. /**
  73111. * 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.
  73112. */
  73113. set depthTexture(value: RenderTargetTexture);
  73114. }
  73115. }
  73116. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73117. /** @hidden */
  73118. export var colorCorrectionPixelShader: {
  73119. name: string;
  73120. shader: string;
  73121. };
  73122. }
  73123. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73124. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73125. import { Engine } from "babylonjs/Engines/engine";
  73126. import { Camera } from "babylonjs/Cameras/camera";
  73127. import "babylonjs/Shaders/colorCorrection.fragment";
  73128. import { Nullable } from "babylonjs/types";
  73129. import { Scene } from "babylonjs/scene";
  73130. /**
  73131. *
  73132. * This post-process allows the modification of rendered colors by using
  73133. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73134. *
  73135. * The object needs to be provided an url to a texture containing the color
  73136. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73137. * Use an image editing software to tweak the LUT to match your needs.
  73138. *
  73139. * For an example of a color LUT, see here:
  73140. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73141. * For explanations on color grading, see here:
  73142. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73143. *
  73144. */
  73145. export class ColorCorrectionPostProcess extends PostProcess {
  73146. private _colorTableTexture;
  73147. /**
  73148. * Gets the color table url used to create the LUT texture
  73149. */
  73150. colorTableUrl: string;
  73151. /**
  73152. * Gets a string identifying the name of the class
  73153. * @returns "ColorCorrectionPostProcess" string
  73154. */
  73155. getClassName(): string;
  73156. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73157. /** @hidden */
  73158. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73159. }
  73160. }
  73161. declare module "babylonjs/Shaders/convolution.fragment" {
  73162. /** @hidden */
  73163. export var convolutionPixelShader: {
  73164. name: string;
  73165. shader: string;
  73166. };
  73167. }
  73168. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73169. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73170. import { Nullable } from "babylonjs/types";
  73171. import { Camera } from "babylonjs/Cameras/camera";
  73172. import { Engine } from "babylonjs/Engines/engine";
  73173. import "babylonjs/Shaders/convolution.fragment";
  73174. import { Scene } from "babylonjs/scene";
  73175. /**
  73176. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73177. * input texture to perform effects such as edge detection or sharpening
  73178. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73179. */
  73180. export class ConvolutionPostProcess extends PostProcess {
  73181. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73182. kernel: number[];
  73183. /**
  73184. * Gets a string identifying the name of the class
  73185. * @returns "ConvolutionPostProcess" string
  73186. */
  73187. getClassName(): string;
  73188. /**
  73189. * Creates a new instance ConvolutionPostProcess
  73190. * @param name The name of the effect.
  73191. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73192. * @param options The required width/height ratio to downsize to before computing the render pass.
  73193. * @param camera The camera to apply the render pass to.
  73194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73195. * @param engine The engine which the post process will be applied. (default: current engine)
  73196. * @param reusable If the post process can be reused on the same frame. (default: false)
  73197. * @param textureType Type of textures used when performing the post process. (default: 0)
  73198. */
  73199. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73200. /** @hidden */
  73201. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73202. /**
  73203. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73204. */
  73205. static EdgeDetect0Kernel: number[];
  73206. /**
  73207. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73208. */
  73209. static EdgeDetect1Kernel: number[];
  73210. /**
  73211. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73212. */
  73213. static EdgeDetect2Kernel: number[];
  73214. /**
  73215. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73216. */
  73217. static SharpenKernel: number[];
  73218. /**
  73219. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73220. */
  73221. static EmbossKernel: number[];
  73222. /**
  73223. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73224. */
  73225. static GaussianKernel: number[];
  73226. }
  73227. }
  73228. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73229. import { Nullable } from "babylonjs/types";
  73230. import { Vector2 } from "babylonjs/Maths/math.vector";
  73231. import { Camera } from "babylonjs/Cameras/camera";
  73232. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73233. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73234. import { Engine } from "babylonjs/Engines/engine";
  73235. import { Scene } from "babylonjs/scene";
  73236. /**
  73237. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73238. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73239. * based on samples that have a large difference in distance than the center pixel.
  73240. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73241. */
  73242. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73243. /**
  73244. * The direction the blur should be applied
  73245. */
  73246. direction: Vector2;
  73247. /**
  73248. * Gets a string identifying the name of the class
  73249. * @returns "DepthOfFieldBlurPostProcess" string
  73250. */
  73251. getClassName(): string;
  73252. /**
  73253. * Creates a new instance CircleOfConfusionPostProcess
  73254. * @param name The name of the effect.
  73255. * @param scene The scene the effect belongs to.
  73256. * @param direction The direction the blur should be applied.
  73257. * @param kernel The size of the kernel used to blur.
  73258. * @param options The required width/height ratio to downsize to before computing the render pass.
  73259. * @param camera The camera to apply the render pass to.
  73260. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73261. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73263. * @param engine The engine which the post process will be applied. (default: current engine)
  73264. * @param reusable If the post process can be reused on the same frame. (default: false)
  73265. * @param textureType Type of textures used when performing the post process. (default: 0)
  73266. * @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)
  73267. */
  73268. 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);
  73269. }
  73270. }
  73271. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73272. /** @hidden */
  73273. export var depthOfFieldMergePixelShader: {
  73274. name: string;
  73275. shader: string;
  73276. };
  73277. }
  73278. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73279. import { Nullable } from "babylonjs/types";
  73280. import { Camera } from "babylonjs/Cameras/camera";
  73281. import { Effect } from "babylonjs/Materials/effect";
  73282. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73283. import { Engine } from "babylonjs/Engines/engine";
  73284. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73285. /**
  73286. * Options to be set when merging outputs from the default pipeline.
  73287. */
  73288. export class DepthOfFieldMergePostProcessOptions {
  73289. /**
  73290. * The original image to merge on top of
  73291. */
  73292. originalFromInput: PostProcess;
  73293. /**
  73294. * Parameters to perform the merge of the depth of field effect
  73295. */
  73296. depthOfField?: {
  73297. circleOfConfusion: PostProcess;
  73298. blurSteps: Array<PostProcess>;
  73299. };
  73300. /**
  73301. * Parameters to perform the merge of bloom effect
  73302. */
  73303. bloom?: {
  73304. blurred: PostProcess;
  73305. weight: number;
  73306. };
  73307. }
  73308. /**
  73309. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73310. */
  73311. export class DepthOfFieldMergePostProcess extends PostProcess {
  73312. private blurSteps;
  73313. /**
  73314. * Gets a string identifying the name of the class
  73315. * @returns "DepthOfFieldMergePostProcess" string
  73316. */
  73317. getClassName(): string;
  73318. /**
  73319. * Creates a new instance of DepthOfFieldMergePostProcess
  73320. * @param name The name of the effect.
  73321. * @param originalFromInput Post process which's input will be used for the merge.
  73322. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73323. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73324. * @param options The required width/height ratio to downsize to before computing the render pass.
  73325. * @param camera The camera to apply the render pass to.
  73326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73327. * @param engine The engine which the post process will be applied. (default: current engine)
  73328. * @param reusable If the post process can be reused on the same frame. (default: false)
  73329. * @param textureType Type of textures used when performing the post process. (default: 0)
  73330. * @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)
  73331. */
  73332. 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);
  73333. /**
  73334. * Updates the effect with the current post process compile time values and recompiles the shader.
  73335. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73336. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73337. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73338. * @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
  73339. * @param onCompiled Called when the shader has been compiled.
  73340. * @param onError Called if there is an error when compiling a shader.
  73341. */
  73342. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73343. }
  73344. }
  73345. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73346. import { Nullable } from "babylonjs/types";
  73347. import { Camera } from "babylonjs/Cameras/camera";
  73348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73349. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73350. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73351. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73352. import { Scene } from "babylonjs/scene";
  73353. /**
  73354. * Specifies the level of max blur that should be applied when using the depth of field effect
  73355. */
  73356. export enum DepthOfFieldEffectBlurLevel {
  73357. /**
  73358. * Subtle blur
  73359. */
  73360. Low = 0,
  73361. /**
  73362. * Medium blur
  73363. */
  73364. Medium = 1,
  73365. /**
  73366. * Large blur
  73367. */
  73368. High = 2
  73369. }
  73370. /**
  73371. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73372. */
  73373. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73374. private _circleOfConfusion;
  73375. /**
  73376. * @hidden Internal, blurs from high to low
  73377. */
  73378. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73379. private _depthOfFieldBlurY;
  73380. private _dofMerge;
  73381. /**
  73382. * @hidden Internal post processes in depth of field effect
  73383. */
  73384. _effects: Array<PostProcess>;
  73385. /**
  73386. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73387. */
  73388. set focalLength(value: number);
  73389. get focalLength(): number;
  73390. /**
  73391. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73392. */
  73393. set fStop(value: number);
  73394. get fStop(): number;
  73395. /**
  73396. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73397. */
  73398. set focusDistance(value: number);
  73399. get focusDistance(): number;
  73400. /**
  73401. * 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.
  73402. */
  73403. set lensSize(value: number);
  73404. get lensSize(): number;
  73405. /**
  73406. * Creates a new instance DepthOfFieldEffect
  73407. * @param scene The scene the effect belongs to.
  73408. * @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.
  73409. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73410. * @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)
  73411. */
  73412. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73413. /**
  73414. * Get the current class name of the current effet
  73415. * @returns "DepthOfFieldEffect"
  73416. */
  73417. getClassName(): string;
  73418. /**
  73419. * 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.
  73420. */
  73421. set depthTexture(value: RenderTargetTexture);
  73422. /**
  73423. * Disposes each of the internal effects for a given camera.
  73424. * @param camera The camera to dispose the effect on.
  73425. */
  73426. disposeEffects(camera: Camera): void;
  73427. /**
  73428. * @hidden Internal
  73429. */
  73430. _updateEffects(): void;
  73431. /**
  73432. * Internal
  73433. * @returns if all the contained post processes are ready.
  73434. * @hidden
  73435. */
  73436. _isReady(): boolean;
  73437. }
  73438. }
  73439. declare module "babylonjs/Shaders/displayPass.fragment" {
  73440. /** @hidden */
  73441. export var displayPassPixelShader: {
  73442. name: string;
  73443. shader: string;
  73444. };
  73445. }
  73446. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73447. import { Nullable } from "babylonjs/types";
  73448. import { Camera } from "babylonjs/Cameras/camera";
  73449. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73450. import { Engine } from "babylonjs/Engines/engine";
  73451. import "babylonjs/Shaders/displayPass.fragment";
  73452. import { Scene } from "babylonjs/scene";
  73453. /**
  73454. * DisplayPassPostProcess which produces an output the same as it's input
  73455. */
  73456. export class DisplayPassPostProcess extends PostProcess {
  73457. /**
  73458. * Gets a string identifying the name of the class
  73459. * @returns "DisplayPassPostProcess" string
  73460. */
  73461. getClassName(): string;
  73462. /**
  73463. * Creates the DisplayPassPostProcess
  73464. * @param name The name of the effect.
  73465. * @param options The required width/height ratio to downsize to before computing the render pass.
  73466. * @param camera The camera to apply the render pass to.
  73467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73468. * @param engine The engine which the post process will be applied. (default: current engine)
  73469. * @param reusable If the post process can be reused on the same frame. (default: false)
  73470. */
  73471. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73472. /** @hidden */
  73473. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73474. }
  73475. }
  73476. declare module "babylonjs/Shaders/filter.fragment" {
  73477. /** @hidden */
  73478. export var filterPixelShader: {
  73479. name: string;
  73480. shader: string;
  73481. };
  73482. }
  73483. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73484. import { Nullable } from "babylonjs/types";
  73485. import { Matrix } from "babylonjs/Maths/math.vector";
  73486. import { Camera } from "babylonjs/Cameras/camera";
  73487. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73488. import { Engine } from "babylonjs/Engines/engine";
  73489. import "babylonjs/Shaders/filter.fragment";
  73490. import { Scene } from "babylonjs/scene";
  73491. /**
  73492. * Applies a kernel filter to the image
  73493. */
  73494. export class FilterPostProcess extends PostProcess {
  73495. /** The matrix to be applied to the image */
  73496. kernelMatrix: Matrix;
  73497. /**
  73498. * Gets a string identifying the name of the class
  73499. * @returns "FilterPostProcess" string
  73500. */
  73501. getClassName(): string;
  73502. /**
  73503. *
  73504. * @param name The name of the effect.
  73505. * @param kernelMatrix The matrix to be applied to the image
  73506. * @param options The required width/height ratio to downsize to before computing the render pass.
  73507. * @param camera The camera to apply the render pass to.
  73508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73509. * @param engine The engine which the post process will be applied. (default: current engine)
  73510. * @param reusable If the post process can be reused on the same frame. (default: false)
  73511. */
  73512. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73513. /** @hidden */
  73514. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73515. }
  73516. }
  73517. declare module "babylonjs/Shaders/fxaa.fragment" {
  73518. /** @hidden */
  73519. export var fxaaPixelShader: {
  73520. name: string;
  73521. shader: string;
  73522. };
  73523. }
  73524. declare module "babylonjs/Shaders/fxaa.vertex" {
  73525. /** @hidden */
  73526. export var fxaaVertexShader: {
  73527. name: string;
  73528. shader: string;
  73529. };
  73530. }
  73531. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73532. import { Nullable } from "babylonjs/types";
  73533. import { Camera } from "babylonjs/Cameras/camera";
  73534. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73535. import { Engine } from "babylonjs/Engines/engine";
  73536. import "babylonjs/Shaders/fxaa.fragment";
  73537. import "babylonjs/Shaders/fxaa.vertex";
  73538. import { Scene } from "babylonjs/scene";
  73539. /**
  73540. * Fxaa post process
  73541. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73542. */
  73543. export class FxaaPostProcess extends PostProcess {
  73544. /**
  73545. * Gets a string identifying the name of the class
  73546. * @returns "FxaaPostProcess" string
  73547. */
  73548. getClassName(): string;
  73549. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73550. private _getDefines;
  73551. /** @hidden */
  73552. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73553. }
  73554. }
  73555. declare module "babylonjs/Shaders/grain.fragment" {
  73556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73557. /** @hidden */
  73558. export var grainPixelShader: {
  73559. name: string;
  73560. shader: string;
  73561. };
  73562. }
  73563. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73564. import { Nullable } from "babylonjs/types";
  73565. import { Camera } from "babylonjs/Cameras/camera";
  73566. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73567. import { Engine } from "babylonjs/Engines/engine";
  73568. import "babylonjs/Shaders/grain.fragment";
  73569. import { Scene } from "babylonjs/scene";
  73570. /**
  73571. * The GrainPostProcess adds noise to the image at mid luminance levels
  73572. */
  73573. export class GrainPostProcess extends PostProcess {
  73574. /**
  73575. * The intensity of the grain added (default: 30)
  73576. */
  73577. intensity: number;
  73578. /**
  73579. * If the grain should be randomized on every frame
  73580. */
  73581. animated: boolean;
  73582. /**
  73583. * Gets a string identifying the name of the class
  73584. * @returns "GrainPostProcess" string
  73585. */
  73586. getClassName(): string;
  73587. /**
  73588. * Creates a new instance of @see GrainPostProcess
  73589. * @param name The name of the effect.
  73590. * @param options The required width/height ratio to downsize to before computing the render pass.
  73591. * @param camera The camera to apply the render pass to.
  73592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73593. * @param engine The engine which the post process will be applied. (default: current engine)
  73594. * @param reusable If the post process can be reused on the same frame. (default: false)
  73595. * @param textureType Type of textures used when performing the post process. (default: 0)
  73596. * @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)
  73597. */
  73598. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73599. /** @hidden */
  73600. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73601. }
  73602. }
  73603. declare module "babylonjs/Shaders/highlights.fragment" {
  73604. /** @hidden */
  73605. export var highlightsPixelShader: {
  73606. name: string;
  73607. shader: string;
  73608. };
  73609. }
  73610. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73611. import { Nullable } from "babylonjs/types";
  73612. import { Camera } from "babylonjs/Cameras/camera";
  73613. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73614. import { Engine } from "babylonjs/Engines/engine";
  73615. import "babylonjs/Shaders/highlights.fragment";
  73616. /**
  73617. * Extracts highlights from the image
  73618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73619. */
  73620. export class HighlightsPostProcess extends PostProcess {
  73621. /**
  73622. * Gets a string identifying the name of the class
  73623. * @returns "HighlightsPostProcess" string
  73624. */
  73625. getClassName(): string;
  73626. /**
  73627. * Extracts highlights from the image
  73628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73629. * @param name The name of the effect.
  73630. * @param options The required width/height ratio to downsize to before computing the render pass.
  73631. * @param camera The camera to apply the render pass to.
  73632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73633. * @param engine The engine which the post process will be applied. (default: current engine)
  73634. * @param reusable If the post process can be reused on the same frame. (default: false)
  73635. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73636. */
  73637. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73638. }
  73639. }
  73640. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73641. /** @hidden */
  73642. export var mrtFragmentDeclaration: {
  73643. name: string;
  73644. shader: string;
  73645. };
  73646. }
  73647. declare module "babylonjs/Shaders/geometry.fragment" {
  73648. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73649. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73650. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73651. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73652. /** @hidden */
  73653. export var geometryPixelShader: {
  73654. name: string;
  73655. shader: string;
  73656. };
  73657. }
  73658. declare module "babylonjs/Shaders/geometry.vertex" {
  73659. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73660. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73661. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73662. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73663. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73664. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73665. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73666. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73667. /** @hidden */
  73668. export var geometryVertexShader: {
  73669. name: string;
  73670. shader: string;
  73671. };
  73672. }
  73673. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73674. import { Matrix } from "babylonjs/Maths/math.vector";
  73675. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73676. import { Mesh } from "babylonjs/Meshes/mesh";
  73677. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73678. import { Effect } from "babylonjs/Materials/effect";
  73679. import { Scene } from "babylonjs/scene";
  73680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73681. import "babylonjs/Shaders/geometry.fragment";
  73682. import "babylonjs/Shaders/geometry.vertex";
  73683. /** @hidden */
  73684. interface ISavedTransformationMatrix {
  73685. world: Matrix;
  73686. viewProjection: Matrix;
  73687. }
  73688. /**
  73689. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73690. */
  73691. export class GeometryBufferRenderer {
  73692. /**
  73693. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73694. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73695. */
  73696. static readonly POSITION_TEXTURE_TYPE: number;
  73697. /**
  73698. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73699. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73700. */
  73701. static readonly VELOCITY_TEXTURE_TYPE: number;
  73702. /**
  73703. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73704. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73705. */
  73706. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73707. /**
  73708. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73709. * in order to compute objects velocities when enableVelocity is set to "true"
  73710. * @hidden
  73711. */
  73712. _previousTransformationMatrices: {
  73713. [index: number]: ISavedTransformationMatrix;
  73714. };
  73715. /**
  73716. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73717. * in order to compute objects velocities when enableVelocity is set to "true"
  73718. * @hidden
  73719. */
  73720. _previousBonesTransformationMatrices: {
  73721. [index: number]: Float32Array;
  73722. };
  73723. /**
  73724. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73725. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73726. */
  73727. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73728. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73729. renderTransparentMeshes: boolean;
  73730. private _scene;
  73731. private _resizeObserver;
  73732. private _multiRenderTarget;
  73733. private _ratio;
  73734. private _enablePosition;
  73735. private _enableVelocity;
  73736. private _enableReflectivity;
  73737. private _positionIndex;
  73738. private _velocityIndex;
  73739. private _reflectivityIndex;
  73740. protected _effect: Effect;
  73741. protected _cachedDefines: string;
  73742. /**
  73743. * Set the render list (meshes to be rendered) used in the G buffer.
  73744. */
  73745. set renderList(meshes: Mesh[]);
  73746. /**
  73747. * Gets wether or not G buffer are supported by the running hardware.
  73748. * This requires draw buffer supports
  73749. */
  73750. get isSupported(): boolean;
  73751. /**
  73752. * Returns the index of the given texture type in the G-Buffer textures array
  73753. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73754. * @returns the index of the given texture type in the G-Buffer textures array
  73755. */
  73756. getTextureIndex(textureType: number): number;
  73757. /**
  73758. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73759. */
  73760. get enablePosition(): boolean;
  73761. /**
  73762. * Sets whether or not objects positions are enabled for the G buffer.
  73763. */
  73764. set enablePosition(enable: boolean);
  73765. /**
  73766. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73767. */
  73768. get enableVelocity(): boolean;
  73769. /**
  73770. * Sets wether or not objects velocities are enabled for the G buffer.
  73771. */
  73772. set enableVelocity(enable: boolean);
  73773. /**
  73774. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73775. */
  73776. get enableReflectivity(): boolean;
  73777. /**
  73778. * Sets wether or not objects roughness are enabled for the G buffer.
  73779. */
  73780. set enableReflectivity(enable: boolean);
  73781. /**
  73782. * Gets the scene associated with the buffer.
  73783. */
  73784. get scene(): Scene;
  73785. /**
  73786. * Gets the ratio used by the buffer during its creation.
  73787. * How big is the buffer related to the main canvas.
  73788. */
  73789. get ratio(): number;
  73790. /** @hidden */
  73791. static _SceneComponentInitialization: (scene: Scene) => void;
  73792. /**
  73793. * Creates a new G Buffer for the scene
  73794. * @param scene The scene the buffer belongs to
  73795. * @param ratio How big is the buffer related to the main canvas.
  73796. */
  73797. constructor(scene: Scene, ratio?: number);
  73798. /**
  73799. * Checks wether everything is ready to render a submesh to the G buffer.
  73800. * @param subMesh the submesh to check readiness for
  73801. * @param useInstances is the mesh drawn using instance or not
  73802. * @returns true if ready otherwise false
  73803. */
  73804. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73805. /**
  73806. * Gets the current underlying G Buffer.
  73807. * @returns the buffer
  73808. */
  73809. getGBuffer(): MultiRenderTarget;
  73810. /**
  73811. * Gets the number of samples used to render the buffer (anti aliasing).
  73812. */
  73813. get samples(): number;
  73814. /**
  73815. * Sets the number of samples used to render the buffer (anti aliasing).
  73816. */
  73817. set samples(value: number);
  73818. /**
  73819. * Disposes the renderer and frees up associated resources.
  73820. */
  73821. dispose(): void;
  73822. protected _createRenderTargets(): void;
  73823. private _copyBonesTransformationMatrices;
  73824. }
  73825. }
  73826. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73827. import { Nullable } from "babylonjs/types";
  73828. import { Scene } from "babylonjs/scene";
  73829. import { ISceneComponent } from "babylonjs/sceneComponent";
  73830. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73831. module "babylonjs/scene" {
  73832. interface Scene {
  73833. /** @hidden (Backing field) */
  73834. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73835. /**
  73836. * Gets or Sets the current geometry buffer associated to the scene.
  73837. */
  73838. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73839. /**
  73840. * Enables a GeometryBufferRender and associates it with the scene
  73841. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73842. * @returns the GeometryBufferRenderer
  73843. */
  73844. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73845. /**
  73846. * Disables the GeometryBufferRender associated with the scene
  73847. */
  73848. disableGeometryBufferRenderer(): void;
  73849. }
  73850. }
  73851. /**
  73852. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73853. * in several rendering techniques.
  73854. */
  73855. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73856. /**
  73857. * The component name helpful to identify the component in the list of scene components.
  73858. */
  73859. readonly name: string;
  73860. /**
  73861. * The scene the component belongs to.
  73862. */
  73863. scene: Scene;
  73864. /**
  73865. * Creates a new instance of the component for the given scene
  73866. * @param scene Defines the scene to register the component in
  73867. */
  73868. constructor(scene: Scene);
  73869. /**
  73870. * Registers the component in a given scene
  73871. */
  73872. register(): void;
  73873. /**
  73874. * Rebuilds the elements related to this component in case of
  73875. * context lost for instance.
  73876. */
  73877. rebuild(): void;
  73878. /**
  73879. * Disposes the component and the associated ressources
  73880. */
  73881. dispose(): void;
  73882. private _gatherRenderTargets;
  73883. }
  73884. }
  73885. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73886. /** @hidden */
  73887. export var motionBlurPixelShader: {
  73888. name: string;
  73889. shader: string;
  73890. };
  73891. }
  73892. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73893. import { Nullable } from "babylonjs/types";
  73894. import { Camera } from "babylonjs/Cameras/camera";
  73895. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73897. import "babylonjs/Animations/animatable";
  73898. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73899. import "babylonjs/Shaders/motionBlur.fragment";
  73900. import { Engine } from "babylonjs/Engines/engine";
  73901. import { Scene } from "babylonjs/scene";
  73902. /**
  73903. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73904. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73905. * As an example, all you have to do is to create the post-process:
  73906. * var mb = new BABYLON.MotionBlurPostProcess(
  73907. * 'mb', // The name of the effect.
  73908. * scene, // The scene containing the objects to blur according to their velocity.
  73909. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73910. * camera // The camera to apply the render pass to.
  73911. * );
  73912. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73913. */
  73914. export class MotionBlurPostProcess extends PostProcess {
  73915. /**
  73916. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73917. */
  73918. motionStrength: number;
  73919. /**
  73920. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73921. */
  73922. get motionBlurSamples(): number;
  73923. /**
  73924. * Sets the number of iterations to be used for motion blur quality
  73925. */
  73926. set motionBlurSamples(samples: number);
  73927. private _motionBlurSamples;
  73928. private _geometryBufferRenderer;
  73929. /**
  73930. * Gets a string identifying the name of the class
  73931. * @returns "MotionBlurPostProcess" string
  73932. */
  73933. getClassName(): string;
  73934. /**
  73935. * Creates a new instance MotionBlurPostProcess
  73936. * @param name The name of the effect.
  73937. * @param scene The scene containing the objects to blur according to their velocity.
  73938. * @param options The required width/height ratio to downsize to before computing the render pass.
  73939. * @param camera The camera to apply the render pass to.
  73940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73941. * @param engine The engine which the post process will be applied. (default: current engine)
  73942. * @param reusable If the post process can be reused on the same frame. (default: false)
  73943. * @param textureType Type of textures used when performing the post process. (default: 0)
  73944. * @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)
  73945. */
  73946. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73947. /**
  73948. * Excludes the given skinned mesh from computing bones velocities.
  73949. * 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.
  73950. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73951. */
  73952. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73953. /**
  73954. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73955. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73956. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73957. */
  73958. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73959. /**
  73960. * Disposes the post process.
  73961. * @param camera The camera to dispose the post process on.
  73962. */
  73963. dispose(camera?: Camera): void;
  73964. /** @hidden */
  73965. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73966. }
  73967. }
  73968. declare module "babylonjs/Shaders/refraction.fragment" {
  73969. /** @hidden */
  73970. export var refractionPixelShader: {
  73971. name: string;
  73972. shader: string;
  73973. };
  73974. }
  73975. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73976. import { Color3 } from "babylonjs/Maths/math.color";
  73977. import { Camera } from "babylonjs/Cameras/camera";
  73978. import { Texture } from "babylonjs/Materials/Textures/texture";
  73979. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73980. import { Engine } from "babylonjs/Engines/engine";
  73981. import "babylonjs/Shaders/refraction.fragment";
  73982. import { Scene } from "babylonjs/scene";
  73983. /**
  73984. * Post process which applies a refractin texture
  73985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73986. */
  73987. export class RefractionPostProcess extends PostProcess {
  73988. private _refTexture;
  73989. private _ownRefractionTexture;
  73990. /** the base color of the refraction (used to taint the rendering) */
  73991. color: Color3;
  73992. /** simulated refraction depth */
  73993. depth: number;
  73994. /** the coefficient of the base color (0 to remove base color tainting) */
  73995. colorLevel: number;
  73996. /** Gets the url used to load the refraction texture */
  73997. refractionTextureUrl: string;
  73998. /**
  73999. * Gets or sets the refraction texture
  74000. * Please note that you are responsible for disposing the texture if you set it manually
  74001. */
  74002. get refractionTexture(): Texture;
  74003. set refractionTexture(value: Texture);
  74004. /**
  74005. * Gets a string identifying the name of the class
  74006. * @returns "RefractionPostProcess" string
  74007. */
  74008. getClassName(): string;
  74009. /**
  74010. * Initializes the RefractionPostProcess
  74011. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74012. * @param name The name of the effect.
  74013. * @param refractionTextureUrl Url of the refraction texture to use
  74014. * @param color the base color of the refraction (used to taint the rendering)
  74015. * @param depth simulated refraction depth
  74016. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74017. * @param camera The camera to apply the render pass to.
  74018. * @param options The required width/height ratio to downsize to before computing the render pass.
  74019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74020. * @param engine The engine which the post process will be applied. (default: current engine)
  74021. * @param reusable If the post process can be reused on the same frame. (default: false)
  74022. */
  74023. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74024. /**
  74025. * Disposes of the post process
  74026. * @param camera Camera to dispose post process on
  74027. */
  74028. dispose(camera: Camera): void;
  74029. /** @hidden */
  74030. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74031. }
  74032. }
  74033. declare module "babylonjs/Shaders/sharpen.fragment" {
  74034. /** @hidden */
  74035. export var sharpenPixelShader: {
  74036. name: string;
  74037. shader: string;
  74038. };
  74039. }
  74040. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74041. import { Nullable } from "babylonjs/types";
  74042. import { Camera } from "babylonjs/Cameras/camera";
  74043. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74044. import "babylonjs/Shaders/sharpen.fragment";
  74045. import { Engine } from "babylonjs/Engines/engine";
  74046. import { Scene } from "babylonjs/scene";
  74047. /**
  74048. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74049. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74050. */
  74051. export class SharpenPostProcess extends PostProcess {
  74052. /**
  74053. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74054. */
  74055. colorAmount: number;
  74056. /**
  74057. * How much sharpness should be applied (default: 0.3)
  74058. */
  74059. edgeAmount: number;
  74060. /**
  74061. * Gets a string identifying the name of the class
  74062. * @returns "SharpenPostProcess" string
  74063. */
  74064. getClassName(): string;
  74065. /**
  74066. * Creates a new instance ConvolutionPostProcess
  74067. * @param name The name of the effect.
  74068. * @param options The required width/height ratio to downsize to before computing the render pass.
  74069. * @param camera The camera to apply the render pass to.
  74070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74071. * @param engine The engine which the post process will be applied. (default: current engine)
  74072. * @param reusable If the post process can be reused on the same frame. (default: false)
  74073. * @param textureType Type of textures used when performing the post process. (default: 0)
  74074. * @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)
  74075. */
  74076. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74077. /** @hidden */
  74078. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74079. }
  74080. }
  74081. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74082. import { Nullable } from "babylonjs/types";
  74083. import { Camera } from "babylonjs/Cameras/camera";
  74084. import { Engine } from "babylonjs/Engines/engine";
  74085. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74086. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74087. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74088. /**
  74089. * PostProcessRenderPipeline
  74090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74091. */
  74092. export class PostProcessRenderPipeline {
  74093. private engine;
  74094. private _renderEffects;
  74095. private _renderEffectsForIsolatedPass;
  74096. /**
  74097. * List of inspectable custom properties (used by the Inspector)
  74098. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74099. */
  74100. inspectableCustomProperties: IInspectable[];
  74101. /**
  74102. * @hidden
  74103. */
  74104. protected _cameras: Camera[];
  74105. /** @hidden */
  74106. _name: string;
  74107. /**
  74108. * Gets pipeline name
  74109. */
  74110. get name(): string;
  74111. /** Gets the list of attached cameras */
  74112. get cameras(): Camera[];
  74113. /**
  74114. * Initializes a PostProcessRenderPipeline
  74115. * @param engine engine to add the pipeline to
  74116. * @param name name of the pipeline
  74117. */
  74118. constructor(engine: Engine, name: string);
  74119. /**
  74120. * Gets the class name
  74121. * @returns "PostProcessRenderPipeline"
  74122. */
  74123. getClassName(): string;
  74124. /**
  74125. * If all the render effects in the pipeline are supported
  74126. */
  74127. get isSupported(): boolean;
  74128. /**
  74129. * Adds an effect to the pipeline
  74130. * @param renderEffect the effect to add
  74131. */
  74132. addEffect(renderEffect: PostProcessRenderEffect): void;
  74133. /** @hidden */
  74134. _rebuild(): void;
  74135. /** @hidden */
  74136. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74137. /** @hidden */
  74138. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74139. /** @hidden */
  74140. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74141. /** @hidden */
  74142. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74143. /** @hidden */
  74144. _attachCameras(cameras: Camera, unique: boolean): void;
  74145. /** @hidden */
  74146. _attachCameras(cameras: Camera[], unique: boolean): void;
  74147. /** @hidden */
  74148. _detachCameras(cameras: Camera): void;
  74149. /** @hidden */
  74150. _detachCameras(cameras: Nullable<Camera[]>): void;
  74151. /** @hidden */
  74152. _update(): void;
  74153. /** @hidden */
  74154. _reset(): void;
  74155. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74156. /**
  74157. * Sets the required values to the prepass renderer.
  74158. * @param prePassRenderer defines the prepass renderer to setup.
  74159. * @returns true if the pre pass is needed.
  74160. */
  74161. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74162. /**
  74163. * Disposes of the pipeline
  74164. */
  74165. dispose(): void;
  74166. }
  74167. }
  74168. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74169. import { Camera } from "babylonjs/Cameras/camera";
  74170. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74171. /**
  74172. * PostProcessRenderPipelineManager class
  74173. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74174. */
  74175. export class PostProcessRenderPipelineManager {
  74176. private _renderPipelines;
  74177. /**
  74178. * Initializes a PostProcessRenderPipelineManager
  74179. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74180. */
  74181. constructor();
  74182. /**
  74183. * Gets the list of supported render pipelines
  74184. */
  74185. get supportedPipelines(): PostProcessRenderPipeline[];
  74186. /**
  74187. * Adds a pipeline to the manager
  74188. * @param renderPipeline The pipeline to add
  74189. */
  74190. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74191. /**
  74192. * Attaches a camera to the pipeline
  74193. * @param renderPipelineName The name of the pipeline to attach to
  74194. * @param cameras the camera to attach
  74195. * @param unique if the camera can be attached multiple times to the pipeline
  74196. */
  74197. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74198. /**
  74199. * Detaches a camera from the pipeline
  74200. * @param renderPipelineName The name of the pipeline to detach from
  74201. * @param cameras the camera to detach
  74202. */
  74203. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74204. /**
  74205. * Enables an effect by name on a pipeline
  74206. * @param renderPipelineName the name of the pipeline to enable the effect in
  74207. * @param renderEffectName the name of the effect to enable
  74208. * @param cameras the cameras that the effect should be enabled on
  74209. */
  74210. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74211. /**
  74212. * Disables an effect by name on a pipeline
  74213. * @param renderPipelineName the name of the pipeline to disable the effect in
  74214. * @param renderEffectName the name of the effect to disable
  74215. * @param cameras the cameras that the effect should be disabled on
  74216. */
  74217. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74218. /**
  74219. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74220. */
  74221. update(): void;
  74222. /** @hidden */
  74223. _rebuild(): void;
  74224. /**
  74225. * Disposes of the manager and pipelines
  74226. */
  74227. dispose(): void;
  74228. }
  74229. }
  74230. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74231. import { ISceneComponent } from "babylonjs/sceneComponent";
  74232. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74233. import { Scene } from "babylonjs/scene";
  74234. module "babylonjs/scene" {
  74235. interface Scene {
  74236. /** @hidden (Backing field) */
  74237. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74238. /**
  74239. * Gets the postprocess render pipeline manager
  74240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74241. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74242. */
  74243. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74244. }
  74245. }
  74246. /**
  74247. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74248. */
  74249. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74250. /**
  74251. * The component name helpfull to identify the component in the list of scene components.
  74252. */
  74253. readonly name: string;
  74254. /**
  74255. * The scene the component belongs to.
  74256. */
  74257. scene: Scene;
  74258. /**
  74259. * Creates a new instance of the component for the given scene
  74260. * @param scene Defines the scene to register the component in
  74261. */
  74262. constructor(scene: Scene);
  74263. /**
  74264. * Registers the component in a given scene
  74265. */
  74266. register(): void;
  74267. /**
  74268. * Rebuilds the elements related to this component in case of
  74269. * context lost for instance.
  74270. */
  74271. rebuild(): void;
  74272. /**
  74273. * Disposes the component and the associated ressources
  74274. */
  74275. dispose(): void;
  74276. private _gatherRenderTargets;
  74277. }
  74278. }
  74279. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74280. import { Nullable } from "babylonjs/types";
  74281. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74282. import { Camera } from "babylonjs/Cameras/camera";
  74283. import { IDisposable } from "babylonjs/scene";
  74284. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74285. import { Scene } from "babylonjs/scene";
  74286. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74287. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74288. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74289. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74290. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74291. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74292. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74293. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74294. import { Animation } from "babylonjs/Animations/animation";
  74295. /**
  74296. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74297. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74298. */
  74299. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74300. private _scene;
  74301. private _camerasToBeAttached;
  74302. /**
  74303. * ID of the sharpen post process,
  74304. */
  74305. private readonly SharpenPostProcessId;
  74306. /**
  74307. * @ignore
  74308. * ID of the image processing post process;
  74309. */
  74310. readonly ImageProcessingPostProcessId: string;
  74311. /**
  74312. * @ignore
  74313. * ID of the Fast Approximate Anti-Aliasing post process;
  74314. */
  74315. readonly FxaaPostProcessId: string;
  74316. /**
  74317. * ID of the chromatic aberration post process,
  74318. */
  74319. private readonly ChromaticAberrationPostProcessId;
  74320. /**
  74321. * ID of the grain post process
  74322. */
  74323. private readonly GrainPostProcessId;
  74324. /**
  74325. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74326. */
  74327. sharpen: SharpenPostProcess;
  74328. private _sharpenEffect;
  74329. private bloom;
  74330. /**
  74331. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74332. */
  74333. depthOfField: DepthOfFieldEffect;
  74334. /**
  74335. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74336. */
  74337. fxaa: FxaaPostProcess;
  74338. /**
  74339. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74340. */
  74341. imageProcessing: ImageProcessingPostProcess;
  74342. /**
  74343. * Chromatic aberration post process which will shift rgb colors in the image
  74344. */
  74345. chromaticAberration: ChromaticAberrationPostProcess;
  74346. private _chromaticAberrationEffect;
  74347. /**
  74348. * Grain post process which add noise to the image
  74349. */
  74350. grain: GrainPostProcess;
  74351. private _grainEffect;
  74352. /**
  74353. * Glow post process which adds a glow to emissive areas of the image
  74354. */
  74355. private _glowLayer;
  74356. /**
  74357. * Animations which can be used to tweak settings over a period of time
  74358. */
  74359. animations: Animation[];
  74360. private _imageProcessingConfigurationObserver;
  74361. private _sharpenEnabled;
  74362. private _bloomEnabled;
  74363. private _depthOfFieldEnabled;
  74364. private _depthOfFieldBlurLevel;
  74365. private _fxaaEnabled;
  74366. private _imageProcessingEnabled;
  74367. private _defaultPipelineTextureType;
  74368. private _bloomScale;
  74369. private _chromaticAberrationEnabled;
  74370. private _grainEnabled;
  74371. private _buildAllowed;
  74372. /**
  74373. * Gets active scene
  74374. */
  74375. get scene(): Scene;
  74376. /**
  74377. * Enable or disable the sharpen process from the pipeline
  74378. */
  74379. set sharpenEnabled(enabled: boolean);
  74380. get sharpenEnabled(): boolean;
  74381. private _resizeObserver;
  74382. private _hardwareScaleLevel;
  74383. private _bloomKernel;
  74384. /**
  74385. * Specifies the size of the bloom blur kernel, relative to the final output size
  74386. */
  74387. get bloomKernel(): number;
  74388. set bloomKernel(value: number);
  74389. /**
  74390. * Specifies the weight of the bloom in the final rendering
  74391. */
  74392. private _bloomWeight;
  74393. /**
  74394. * Specifies the luma threshold for the area that will be blurred by the bloom
  74395. */
  74396. private _bloomThreshold;
  74397. private _hdr;
  74398. /**
  74399. * The strength of the bloom.
  74400. */
  74401. set bloomWeight(value: number);
  74402. get bloomWeight(): number;
  74403. /**
  74404. * The strength of the bloom.
  74405. */
  74406. set bloomThreshold(value: number);
  74407. get bloomThreshold(): number;
  74408. /**
  74409. * The scale of the bloom, lower value will provide better performance.
  74410. */
  74411. set bloomScale(value: number);
  74412. get bloomScale(): number;
  74413. /**
  74414. * Enable or disable the bloom from the pipeline
  74415. */
  74416. set bloomEnabled(enabled: boolean);
  74417. get bloomEnabled(): boolean;
  74418. private _rebuildBloom;
  74419. /**
  74420. * If the depth of field is enabled.
  74421. */
  74422. get depthOfFieldEnabled(): boolean;
  74423. set depthOfFieldEnabled(enabled: boolean);
  74424. /**
  74425. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74426. */
  74427. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74428. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74429. /**
  74430. * If the anti aliasing is enabled.
  74431. */
  74432. set fxaaEnabled(enabled: boolean);
  74433. get fxaaEnabled(): boolean;
  74434. private _samples;
  74435. /**
  74436. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74437. */
  74438. set samples(sampleCount: number);
  74439. get samples(): number;
  74440. /**
  74441. * If image processing is enabled.
  74442. */
  74443. set imageProcessingEnabled(enabled: boolean);
  74444. get imageProcessingEnabled(): boolean;
  74445. /**
  74446. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74447. */
  74448. set glowLayerEnabled(enabled: boolean);
  74449. get glowLayerEnabled(): boolean;
  74450. /**
  74451. * Gets the glow layer (or null if not defined)
  74452. */
  74453. get glowLayer(): Nullable<GlowLayer>;
  74454. /**
  74455. * Enable or disable the chromaticAberration process from the pipeline
  74456. */
  74457. set chromaticAberrationEnabled(enabled: boolean);
  74458. get chromaticAberrationEnabled(): boolean;
  74459. /**
  74460. * Enable or disable the grain process from the pipeline
  74461. */
  74462. set grainEnabled(enabled: boolean);
  74463. get grainEnabled(): boolean;
  74464. /**
  74465. * @constructor
  74466. * @param name - The rendering pipeline name (default: "")
  74467. * @param hdr - If high dynamic range textures should be used (default: true)
  74468. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74469. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74470. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74471. */
  74472. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74473. /**
  74474. * Get the class name
  74475. * @returns "DefaultRenderingPipeline"
  74476. */
  74477. getClassName(): string;
  74478. /**
  74479. * Force the compilation of the entire pipeline.
  74480. */
  74481. prepare(): void;
  74482. private _hasCleared;
  74483. private _prevPostProcess;
  74484. private _prevPrevPostProcess;
  74485. private _setAutoClearAndTextureSharing;
  74486. private _depthOfFieldSceneObserver;
  74487. private _buildPipeline;
  74488. private _disposePostProcesses;
  74489. /**
  74490. * Adds a camera to the pipeline
  74491. * @param camera the camera to be added
  74492. */
  74493. addCamera(camera: Camera): void;
  74494. /**
  74495. * Removes a camera from the pipeline
  74496. * @param camera the camera to remove
  74497. */
  74498. removeCamera(camera: Camera): void;
  74499. /**
  74500. * Dispose of the pipeline and stop all post processes
  74501. */
  74502. dispose(): void;
  74503. /**
  74504. * Serialize the rendering pipeline (Used when exporting)
  74505. * @returns the serialized object
  74506. */
  74507. serialize(): any;
  74508. /**
  74509. * Parse the serialized pipeline
  74510. * @param source Source pipeline.
  74511. * @param scene The scene to load the pipeline to.
  74512. * @param rootUrl The URL of the serialized pipeline.
  74513. * @returns An instantiated pipeline from the serialized object.
  74514. */
  74515. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74516. }
  74517. }
  74518. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74519. /** @hidden */
  74520. export var lensHighlightsPixelShader: {
  74521. name: string;
  74522. shader: string;
  74523. };
  74524. }
  74525. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74526. /** @hidden */
  74527. export var depthOfFieldPixelShader: {
  74528. name: string;
  74529. shader: string;
  74530. };
  74531. }
  74532. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74533. import { Camera } from "babylonjs/Cameras/camera";
  74534. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74535. import { Scene } from "babylonjs/scene";
  74536. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74537. import "babylonjs/Shaders/chromaticAberration.fragment";
  74538. import "babylonjs/Shaders/lensHighlights.fragment";
  74539. import "babylonjs/Shaders/depthOfField.fragment";
  74540. /**
  74541. * BABYLON.JS Chromatic Aberration GLSL Shader
  74542. * Author: Olivier Guyot
  74543. * Separates very slightly R, G and B colors on the edges of the screen
  74544. * Inspired by Francois Tarlier & Martins Upitis
  74545. */
  74546. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74547. /**
  74548. * @ignore
  74549. * The chromatic aberration PostProcess id in the pipeline
  74550. */
  74551. LensChromaticAberrationEffect: string;
  74552. /**
  74553. * @ignore
  74554. * The highlights enhancing PostProcess id in the pipeline
  74555. */
  74556. HighlightsEnhancingEffect: string;
  74557. /**
  74558. * @ignore
  74559. * The depth-of-field PostProcess id in the pipeline
  74560. */
  74561. LensDepthOfFieldEffect: string;
  74562. private _scene;
  74563. private _depthTexture;
  74564. private _grainTexture;
  74565. private _chromaticAberrationPostProcess;
  74566. private _highlightsPostProcess;
  74567. private _depthOfFieldPostProcess;
  74568. private _edgeBlur;
  74569. private _grainAmount;
  74570. private _chromaticAberration;
  74571. private _distortion;
  74572. private _highlightsGain;
  74573. private _highlightsThreshold;
  74574. private _dofDistance;
  74575. private _dofAperture;
  74576. private _dofDarken;
  74577. private _dofPentagon;
  74578. private _blurNoise;
  74579. /**
  74580. * @constructor
  74581. *
  74582. * Effect parameters are as follow:
  74583. * {
  74584. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74585. * edge_blur: number; // from 0 to x (1 for realism)
  74586. * distortion: number; // from 0 to x (1 for realism)
  74587. * grain_amount: number; // from 0 to 1
  74588. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74589. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74590. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74591. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74592. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74593. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74594. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74595. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74596. * }
  74597. * Note: if an effect parameter is unset, effect is disabled
  74598. *
  74599. * @param name The rendering pipeline name
  74600. * @param parameters - An object containing all parameters (see above)
  74601. * @param scene The scene linked to this pipeline
  74602. * @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)
  74603. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74604. */
  74605. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74606. /**
  74607. * Get the class name
  74608. * @returns "LensRenderingPipeline"
  74609. */
  74610. getClassName(): string;
  74611. /**
  74612. * Gets associated scene
  74613. */
  74614. get scene(): Scene;
  74615. /**
  74616. * Gets or sets the edge blur
  74617. */
  74618. get edgeBlur(): number;
  74619. set edgeBlur(value: number);
  74620. /**
  74621. * Gets or sets the grain amount
  74622. */
  74623. get grainAmount(): number;
  74624. set grainAmount(value: number);
  74625. /**
  74626. * Gets or sets the chromatic aberration amount
  74627. */
  74628. get chromaticAberration(): number;
  74629. set chromaticAberration(value: number);
  74630. /**
  74631. * Gets or sets the depth of field aperture
  74632. */
  74633. get dofAperture(): number;
  74634. set dofAperture(value: number);
  74635. /**
  74636. * Gets or sets the edge distortion
  74637. */
  74638. get edgeDistortion(): number;
  74639. set edgeDistortion(value: number);
  74640. /**
  74641. * Gets or sets the depth of field distortion
  74642. */
  74643. get dofDistortion(): number;
  74644. set dofDistortion(value: number);
  74645. /**
  74646. * Gets or sets the darken out of focus amount
  74647. */
  74648. get darkenOutOfFocus(): number;
  74649. set darkenOutOfFocus(value: number);
  74650. /**
  74651. * Gets or sets a boolean indicating if blur noise is enabled
  74652. */
  74653. get blurNoise(): boolean;
  74654. set blurNoise(value: boolean);
  74655. /**
  74656. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74657. */
  74658. get pentagonBokeh(): boolean;
  74659. set pentagonBokeh(value: boolean);
  74660. /**
  74661. * Gets or sets the highlight grain amount
  74662. */
  74663. get highlightsGain(): number;
  74664. set highlightsGain(value: number);
  74665. /**
  74666. * Gets or sets the highlight threshold
  74667. */
  74668. get highlightsThreshold(): number;
  74669. set highlightsThreshold(value: number);
  74670. /**
  74671. * Sets the amount of blur at the edges
  74672. * @param amount blur amount
  74673. */
  74674. setEdgeBlur(amount: number): void;
  74675. /**
  74676. * Sets edge blur to 0
  74677. */
  74678. disableEdgeBlur(): void;
  74679. /**
  74680. * Sets the amout of grain
  74681. * @param amount Amount of grain
  74682. */
  74683. setGrainAmount(amount: number): void;
  74684. /**
  74685. * Set grain amount to 0
  74686. */
  74687. disableGrain(): void;
  74688. /**
  74689. * Sets the chromatic aberration amount
  74690. * @param amount amount of chromatic aberration
  74691. */
  74692. setChromaticAberration(amount: number): void;
  74693. /**
  74694. * Sets chromatic aberration amount to 0
  74695. */
  74696. disableChromaticAberration(): void;
  74697. /**
  74698. * Sets the EdgeDistortion amount
  74699. * @param amount amount of EdgeDistortion
  74700. */
  74701. setEdgeDistortion(amount: number): void;
  74702. /**
  74703. * Sets edge distortion to 0
  74704. */
  74705. disableEdgeDistortion(): void;
  74706. /**
  74707. * Sets the FocusDistance amount
  74708. * @param amount amount of FocusDistance
  74709. */
  74710. setFocusDistance(amount: number): void;
  74711. /**
  74712. * Disables depth of field
  74713. */
  74714. disableDepthOfField(): void;
  74715. /**
  74716. * Sets the Aperture amount
  74717. * @param amount amount of Aperture
  74718. */
  74719. setAperture(amount: number): void;
  74720. /**
  74721. * Sets the DarkenOutOfFocus amount
  74722. * @param amount amount of DarkenOutOfFocus
  74723. */
  74724. setDarkenOutOfFocus(amount: number): void;
  74725. private _pentagonBokehIsEnabled;
  74726. /**
  74727. * Creates a pentagon bokeh effect
  74728. */
  74729. enablePentagonBokeh(): void;
  74730. /**
  74731. * Disables the pentagon bokeh effect
  74732. */
  74733. disablePentagonBokeh(): void;
  74734. /**
  74735. * Enables noise blur
  74736. */
  74737. enableNoiseBlur(): void;
  74738. /**
  74739. * Disables noise blur
  74740. */
  74741. disableNoiseBlur(): void;
  74742. /**
  74743. * Sets the HighlightsGain amount
  74744. * @param amount amount of HighlightsGain
  74745. */
  74746. setHighlightsGain(amount: number): void;
  74747. /**
  74748. * Sets the HighlightsThreshold amount
  74749. * @param amount amount of HighlightsThreshold
  74750. */
  74751. setHighlightsThreshold(amount: number): void;
  74752. /**
  74753. * Disables highlights
  74754. */
  74755. disableHighlights(): void;
  74756. /**
  74757. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74758. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74759. */
  74760. dispose(disableDepthRender?: boolean): void;
  74761. private _createChromaticAberrationPostProcess;
  74762. private _createHighlightsPostProcess;
  74763. private _createDepthOfFieldPostProcess;
  74764. private _createGrainTexture;
  74765. }
  74766. }
  74767. declare module "babylonjs/Shaders/ssao2.fragment" {
  74768. /** @hidden */
  74769. export var ssao2PixelShader: {
  74770. name: string;
  74771. shader: string;
  74772. };
  74773. }
  74774. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74775. /** @hidden */
  74776. export var ssaoCombinePixelShader: {
  74777. name: string;
  74778. shader: string;
  74779. };
  74780. }
  74781. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74782. import { Camera } from "babylonjs/Cameras/camera";
  74783. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74784. import { Scene } from "babylonjs/scene";
  74785. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74786. import "babylonjs/Shaders/ssao2.fragment";
  74787. import "babylonjs/Shaders/ssaoCombine.fragment";
  74788. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74789. /**
  74790. * Render pipeline to produce ssao effect
  74791. */
  74792. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74793. /**
  74794. * @ignore
  74795. * The PassPostProcess id in the pipeline that contains the original scene color
  74796. */
  74797. SSAOOriginalSceneColorEffect: string;
  74798. /**
  74799. * @ignore
  74800. * The SSAO PostProcess id in the pipeline
  74801. */
  74802. SSAORenderEffect: string;
  74803. /**
  74804. * @ignore
  74805. * The horizontal blur PostProcess id in the pipeline
  74806. */
  74807. SSAOBlurHRenderEffect: string;
  74808. /**
  74809. * @ignore
  74810. * The vertical blur PostProcess id in the pipeline
  74811. */
  74812. SSAOBlurVRenderEffect: string;
  74813. /**
  74814. * @ignore
  74815. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74816. */
  74817. SSAOCombineRenderEffect: string;
  74818. /**
  74819. * The output strength of the SSAO post-process. Default value is 1.0.
  74820. */
  74821. totalStrength: number;
  74822. /**
  74823. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74824. */
  74825. maxZ: number;
  74826. /**
  74827. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74828. */
  74829. minZAspect: number;
  74830. private _samples;
  74831. /**
  74832. * Number of samples used for the SSAO calculations. Default value is 8
  74833. */
  74834. set samples(n: number);
  74835. get samples(): number;
  74836. private _textureSamples;
  74837. /**
  74838. * Number of samples to use for antialiasing
  74839. */
  74840. set textureSamples(n: number);
  74841. get textureSamples(): number;
  74842. /**
  74843. * Force rendering the geometry through geometry buffer
  74844. */
  74845. private _forceGeometryBuffer;
  74846. /**
  74847. * Ratio object used for SSAO ratio and blur ratio
  74848. */
  74849. private _ratio;
  74850. /**
  74851. * Dynamically generated sphere sampler.
  74852. */
  74853. private _sampleSphere;
  74854. /**
  74855. * Blur filter offsets
  74856. */
  74857. private _samplerOffsets;
  74858. private _expensiveBlur;
  74859. /**
  74860. * If bilateral blur should be used
  74861. */
  74862. set expensiveBlur(b: boolean);
  74863. get expensiveBlur(): boolean;
  74864. /**
  74865. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74866. */
  74867. radius: number;
  74868. /**
  74869. * The base color of the SSAO post-process
  74870. * The final result is "base + ssao" between [0, 1]
  74871. */
  74872. base: number;
  74873. /**
  74874. * Support test.
  74875. */
  74876. static get IsSupported(): boolean;
  74877. private _scene;
  74878. private _randomTexture;
  74879. private _originalColorPostProcess;
  74880. private _ssaoPostProcess;
  74881. private _blurHPostProcess;
  74882. private _blurVPostProcess;
  74883. private _ssaoCombinePostProcess;
  74884. private _prePassRenderer;
  74885. /**
  74886. * Gets active scene
  74887. */
  74888. get scene(): Scene;
  74889. /**
  74890. * @constructor
  74891. * @param name The rendering pipeline name
  74892. * @param scene The scene linked to this pipeline
  74893. * @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 }
  74894. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74895. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74896. */
  74897. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74898. /**
  74899. * Get the class name
  74900. * @returns "SSAO2RenderingPipeline"
  74901. */
  74902. getClassName(): string;
  74903. /**
  74904. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74905. */
  74906. dispose(disableGeometryBufferRenderer?: boolean): void;
  74907. private _createBlurPostProcess;
  74908. /** @hidden */
  74909. _rebuild(): void;
  74910. private _bits;
  74911. private _radicalInverse_VdC;
  74912. private _hammersley;
  74913. private _hemisphereSample_uniform;
  74914. private _generateHemisphere;
  74915. private _getDefinesForSSAO;
  74916. private _createSSAOPostProcess;
  74917. private _createSSAOCombinePostProcess;
  74918. private _createRandomTexture;
  74919. /**
  74920. * Serialize the rendering pipeline (Used when exporting)
  74921. * @returns the serialized object
  74922. */
  74923. serialize(): any;
  74924. /**
  74925. * Parse the serialized pipeline
  74926. * @param source Source pipeline.
  74927. * @param scene The scene to load the pipeline to.
  74928. * @param rootUrl The URL of the serialized pipeline.
  74929. * @returns An instantiated pipeline from the serialized object.
  74930. */
  74931. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74932. /**
  74933. * Sets the required values to the prepass renderer.
  74934. * @param prePassRenderer defines the prepass renderer to setup
  74935. * @returns true if the pre pass is needed.
  74936. */
  74937. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74938. }
  74939. }
  74940. declare module "babylonjs/Shaders/ssao.fragment" {
  74941. /** @hidden */
  74942. export var ssaoPixelShader: {
  74943. name: string;
  74944. shader: string;
  74945. };
  74946. }
  74947. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74948. import { Camera } from "babylonjs/Cameras/camera";
  74949. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74950. import { Scene } from "babylonjs/scene";
  74951. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74952. import "babylonjs/Shaders/ssao.fragment";
  74953. import "babylonjs/Shaders/ssaoCombine.fragment";
  74954. /**
  74955. * Render pipeline to produce ssao effect
  74956. */
  74957. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74958. /**
  74959. * @ignore
  74960. * The PassPostProcess id in the pipeline that contains the original scene color
  74961. */
  74962. SSAOOriginalSceneColorEffect: string;
  74963. /**
  74964. * @ignore
  74965. * The SSAO PostProcess id in the pipeline
  74966. */
  74967. SSAORenderEffect: string;
  74968. /**
  74969. * @ignore
  74970. * The horizontal blur PostProcess id in the pipeline
  74971. */
  74972. SSAOBlurHRenderEffect: string;
  74973. /**
  74974. * @ignore
  74975. * The vertical blur PostProcess id in the pipeline
  74976. */
  74977. SSAOBlurVRenderEffect: string;
  74978. /**
  74979. * @ignore
  74980. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74981. */
  74982. SSAOCombineRenderEffect: string;
  74983. /**
  74984. * The output strength of the SSAO post-process. Default value is 1.0.
  74985. */
  74986. totalStrength: number;
  74987. /**
  74988. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74989. */
  74990. radius: number;
  74991. /**
  74992. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74993. * Must not be equal to fallOff and superior to fallOff.
  74994. * Default value is 0.0075
  74995. */
  74996. area: number;
  74997. /**
  74998. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74999. * Must not be equal to area and inferior to area.
  75000. * Default value is 0.000001
  75001. */
  75002. fallOff: number;
  75003. /**
  75004. * The base color of the SSAO post-process
  75005. * The final result is "base + ssao" between [0, 1]
  75006. */
  75007. base: number;
  75008. private _scene;
  75009. private _depthTexture;
  75010. private _randomTexture;
  75011. private _originalColorPostProcess;
  75012. private _ssaoPostProcess;
  75013. private _blurHPostProcess;
  75014. private _blurVPostProcess;
  75015. private _ssaoCombinePostProcess;
  75016. private _firstUpdate;
  75017. /**
  75018. * Gets active scene
  75019. */
  75020. get scene(): Scene;
  75021. /**
  75022. * @constructor
  75023. * @param name - The rendering pipeline name
  75024. * @param scene - The scene linked to this pipeline
  75025. * @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 }
  75026. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75027. */
  75028. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75029. /**
  75030. * Get the class name
  75031. * @returns "SSAORenderingPipeline"
  75032. */
  75033. getClassName(): string;
  75034. /**
  75035. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75036. */
  75037. dispose(disableDepthRender?: boolean): void;
  75038. private _createBlurPostProcess;
  75039. /** @hidden */
  75040. _rebuild(): void;
  75041. private _createSSAOPostProcess;
  75042. private _createSSAOCombinePostProcess;
  75043. private _createRandomTexture;
  75044. }
  75045. }
  75046. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75047. /** @hidden */
  75048. export var screenSpaceReflectionPixelShader: {
  75049. name: string;
  75050. shader: string;
  75051. };
  75052. }
  75053. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75054. import { Nullable } from "babylonjs/types";
  75055. import { Camera } from "babylonjs/Cameras/camera";
  75056. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75057. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75058. import { Engine } from "babylonjs/Engines/engine";
  75059. import { Scene } from "babylonjs/scene";
  75060. /**
  75061. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75062. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75063. */
  75064. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75065. /**
  75066. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75067. */
  75068. threshold: number;
  75069. /**
  75070. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75071. */
  75072. strength: number;
  75073. /**
  75074. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75075. */
  75076. reflectionSpecularFalloffExponent: number;
  75077. /**
  75078. * 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]
  75079. */
  75080. step: number;
  75081. /**
  75082. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75083. */
  75084. roughnessFactor: number;
  75085. private _geometryBufferRenderer;
  75086. private _enableSmoothReflections;
  75087. private _reflectionSamples;
  75088. private _smoothSteps;
  75089. /**
  75090. * Gets a string identifying the name of the class
  75091. * @returns "ScreenSpaceReflectionPostProcess" string
  75092. */
  75093. getClassName(): string;
  75094. /**
  75095. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75096. * @param name The name of the effect.
  75097. * @param scene The scene containing the objects to calculate reflections.
  75098. * @param options The required width/height ratio to downsize to before computing the render pass.
  75099. * @param camera The camera to apply the render pass to.
  75100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75101. * @param engine The engine which the post process will be applied. (default: current engine)
  75102. * @param reusable If the post process can be reused on the same frame. (default: false)
  75103. * @param textureType Type of textures used when performing the post process. (default: 0)
  75104. * @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)
  75105. */
  75106. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75107. /**
  75108. * Gets wether or not smoothing reflections is enabled.
  75109. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75110. */
  75111. get enableSmoothReflections(): boolean;
  75112. /**
  75113. * Sets wether or not smoothing reflections is enabled.
  75114. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75115. */
  75116. set enableSmoothReflections(enabled: boolean);
  75117. /**
  75118. * Gets the number of samples taken while computing reflections. More samples count is high,
  75119. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75120. */
  75121. get reflectionSamples(): number;
  75122. /**
  75123. * Sets the number of samples taken while computing reflections. More samples count is high,
  75124. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75125. */
  75126. set reflectionSamples(samples: number);
  75127. /**
  75128. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75129. * more the post-process will require GPU power and can generate a drop in FPS.
  75130. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75131. */
  75132. get smoothSteps(): number;
  75133. set smoothSteps(steps: number);
  75134. private _updateEffectDefines;
  75135. /** @hidden */
  75136. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75137. }
  75138. }
  75139. declare module "babylonjs/Shaders/standard.fragment" {
  75140. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75141. /** @hidden */
  75142. export var standardPixelShader: {
  75143. name: string;
  75144. shader: string;
  75145. };
  75146. }
  75147. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75148. import { Nullable } from "babylonjs/types";
  75149. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75150. import { Camera } from "babylonjs/Cameras/camera";
  75151. import { Texture } from "babylonjs/Materials/Textures/texture";
  75152. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75153. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75154. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75155. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75156. import { IDisposable } from "babylonjs/scene";
  75157. import { SpotLight } from "babylonjs/Lights/spotLight";
  75158. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75159. import { Scene } from "babylonjs/scene";
  75160. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75161. import { Animation } from "babylonjs/Animations/animation";
  75162. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75163. import "babylonjs/Shaders/standard.fragment";
  75164. /**
  75165. * Standard rendering pipeline
  75166. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75167. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75168. */
  75169. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75170. /**
  75171. * Public members
  75172. */
  75173. /**
  75174. * Post-process which contains the original scene color before the pipeline applies all the effects
  75175. */
  75176. originalPostProcess: Nullable<PostProcess>;
  75177. /**
  75178. * Post-process used to down scale an image x4
  75179. */
  75180. downSampleX4PostProcess: Nullable<PostProcess>;
  75181. /**
  75182. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75183. */
  75184. brightPassPostProcess: Nullable<PostProcess>;
  75185. /**
  75186. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75187. */
  75188. blurHPostProcesses: PostProcess[];
  75189. /**
  75190. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75191. */
  75192. blurVPostProcesses: PostProcess[];
  75193. /**
  75194. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75195. */
  75196. textureAdderPostProcess: Nullable<PostProcess>;
  75197. /**
  75198. * Post-process used to create volumetric lighting effect
  75199. */
  75200. volumetricLightPostProcess: Nullable<PostProcess>;
  75201. /**
  75202. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75203. */
  75204. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75205. /**
  75206. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75207. */
  75208. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75209. /**
  75210. * Post-process used to merge the volumetric light effect and the real scene color
  75211. */
  75212. volumetricLightMergePostProces: Nullable<PostProcess>;
  75213. /**
  75214. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75215. */
  75216. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75217. /**
  75218. * Base post-process used to calculate the average luminance of the final image for HDR
  75219. */
  75220. luminancePostProcess: Nullable<PostProcess>;
  75221. /**
  75222. * Post-processes used to create down sample post-processes in order to get
  75223. * the average luminance of the final image for HDR
  75224. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75225. */
  75226. luminanceDownSamplePostProcesses: PostProcess[];
  75227. /**
  75228. * Post-process used to create a HDR effect (light adaptation)
  75229. */
  75230. hdrPostProcess: Nullable<PostProcess>;
  75231. /**
  75232. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75233. */
  75234. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75235. /**
  75236. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75237. */
  75238. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75239. /**
  75240. * Post-process used to merge the final HDR post-process and the real scene color
  75241. */
  75242. hdrFinalPostProcess: Nullable<PostProcess>;
  75243. /**
  75244. * Post-process used to create a lens flare effect
  75245. */
  75246. lensFlarePostProcess: Nullable<PostProcess>;
  75247. /**
  75248. * Post-process that merges the result of the lens flare post-process and the real scene color
  75249. */
  75250. lensFlareComposePostProcess: Nullable<PostProcess>;
  75251. /**
  75252. * Post-process used to create a motion blur effect
  75253. */
  75254. motionBlurPostProcess: Nullable<PostProcess>;
  75255. /**
  75256. * Post-process used to create a depth of field effect
  75257. */
  75258. depthOfFieldPostProcess: Nullable<PostProcess>;
  75259. /**
  75260. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75261. */
  75262. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75263. /**
  75264. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75265. */
  75266. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75267. /**
  75268. * Represents the brightness threshold in order to configure the illuminated surfaces
  75269. */
  75270. brightThreshold: number;
  75271. /**
  75272. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75273. */
  75274. blurWidth: number;
  75275. /**
  75276. * Sets if the blur for highlighted surfaces must be only horizontal
  75277. */
  75278. horizontalBlur: boolean;
  75279. /**
  75280. * Gets the overall exposure used by the pipeline
  75281. */
  75282. get exposure(): number;
  75283. /**
  75284. * Sets the overall exposure used by the pipeline
  75285. */
  75286. set exposure(value: number);
  75287. /**
  75288. * Texture used typically to simulate "dirty" on camera lens
  75289. */
  75290. lensTexture: Nullable<Texture>;
  75291. /**
  75292. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75293. */
  75294. volumetricLightCoefficient: number;
  75295. /**
  75296. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75297. */
  75298. volumetricLightPower: number;
  75299. /**
  75300. * Used the set the blur intensity to smooth the volumetric lights
  75301. */
  75302. volumetricLightBlurScale: number;
  75303. /**
  75304. * Light (spot or directional) used to generate the volumetric lights rays
  75305. * The source light must have a shadow generate so the pipeline can get its
  75306. * depth map
  75307. */
  75308. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75309. /**
  75310. * For eye adaptation, represents the minimum luminance the eye can see
  75311. */
  75312. hdrMinimumLuminance: number;
  75313. /**
  75314. * For eye adaptation, represents the decrease luminance speed
  75315. */
  75316. hdrDecreaseRate: number;
  75317. /**
  75318. * For eye adaptation, represents the increase luminance speed
  75319. */
  75320. hdrIncreaseRate: number;
  75321. /**
  75322. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75323. */
  75324. get hdrAutoExposure(): boolean;
  75325. /**
  75326. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75327. */
  75328. set hdrAutoExposure(value: boolean);
  75329. /**
  75330. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75331. */
  75332. lensColorTexture: Nullable<Texture>;
  75333. /**
  75334. * The overall strengh for the lens flare effect
  75335. */
  75336. lensFlareStrength: number;
  75337. /**
  75338. * Dispersion coefficient for lens flare ghosts
  75339. */
  75340. lensFlareGhostDispersal: number;
  75341. /**
  75342. * Main lens flare halo width
  75343. */
  75344. lensFlareHaloWidth: number;
  75345. /**
  75346. * Based on the lens distortion effect, defines how much the lens flare result
  75347. * is distorted
  75348. */
  75349. lensFlareDistortionStrength: number;
  75350. /**
  75351. * Configures the blur intensity used for for lens flare (halo)
  75352. */
  75353. lensFlareBlurWidth: number;
  75354. /**
  75355. * Lens star texture must be used to simulate rays on the flares and is available
  75356. * in the documentation
  75357. */
  75358. lensStarTexture: Nullable<Texture>;
  75359. /**
  75360. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75361. * flare effect by taking account of the dirt texture
  75362. */
  75363. lensFlareDirtTexture: Nullable<Texture>;
  75364. /**
  75365. * Represents the focal length for the depth of field effect
  75366. */
  75367. depthOfFieldDistance: number;
  75368. /**
  75369. * Represents the blur intensity for the blurred part of the depth of field effect
  75370. */
  75371. depthOfFieldBlurWidth: number;
  75372. /**
  75373. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75374. */
  75375. get motionStrength(): number;
  75376. /**
  75377. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75378. */
  75379. set motionStrength(strength: number);
  75380. /**
  75381. * Gets wether or not the motion blur post-process is object based or screen based.
  75382. */
  75383. get objectBasedMotionBlur(): boolean;
  75384. /**
  75385. * Sets wether or not the motion blur post-process should be object based or screen based
  75386. */
  75387. set objectBasedMotionBlur(value: boolean);
  75388. /**
  75389. * List of animations for the pipeline (IAnimatable implementation)
  75390. */
  75391. animations: Animation[];
  75392. /**
  75393. * Private members
  75394. */
  75395. private _scene;
  75396. private _currentDepthOfFieldSource;
  75397. private _basePostProcess;
  75398. private _fixedExposure;
  75399. private _currentExposure;
  75400. private _hdrAutoExposure;
  75401. private _hdrCurrentLuminance;
  75402. private _motionStrength;
  75403. private _isObjectBasedMotionBlur;
  75404. private _floatTextureType;
  75405. private _camerasToBeAttached;
  75406. private _ratio;
  75407. private _bloomEnabled;
  75408. private _depthOfFieldEnabled;
  75409. private _vlsEnabled;
  75410. private _lensFlareEnabled;
  75411. private _hdrEnabled;
  75412. private _motionBlurEnabled;
  75413. private _fxaaEnabled;
  75414. private _screenSpaceReflectionsEnabled;
  75415. private _motionBlurSamples;
  75416. private _volumetricLightStepsCount;
  75417. private _samples;
  75418. /**
  75419. * @ignore
  75420. * Specifies if the bloom pipeline is enabled
  75421. */
  75422. get BloomEnabled(): boolean;
  75423. set BloomEnabled(enabled: boolean);
  75424. /**
  75425. * @ignore
  75426. * Specifies if the depth of field pipeline is enabed
  75427. */
  75428. get DepthOfFieldEnabled(): boolean;
  75429. set DepthOfFieldEnabled(enabled: boolean);
  75430. /**
  75431. * @ignore
  75432. * Specifies if the lens flare pipeline is enabed
  75433. */
  75434. get LensFlareEnabled(): boolean;
  75435. set LensFlareEnabled(enabled: boolean);
  75436. /**
  75437. * @ignore
  75438. * Specifies if the HDR pipeline is enabled
  75439. */
  75440. get HDREnabled(): boolean;
  75441. set HDREnabled(enabled: boolean);
  75442. /**
  75443. * @ignore
  75444. * Specifies if the volumetric lights scattering effect is enabled
  75445. */
  75446. get VLSEnabled(): boolean;
  75447. set VLSEnabled(enabled: boolean);
  75448. /**
  75449. * @ignore
  75450. * Specifies if the motion blur effect is enabled
  75451. */
  75452. get MotionBlurEnabled(): boolean;
  75453. set MotionBlurEnabled(enabled: boolean);
  75454. /**
  75455. * Specifies if anti-aliasing is enabled
  75456. */
  75457. get fxaaEnabled(): boolean;
  75458. set fxaaEnabled(enabled: boolean);
  75459. /**
  75460. * Specifies if screen space reflections are enabled.
  75461. */
  75462. get screenSpaceReflectionsEnabled(): boolean;
  75463. set screenSpaceReflectionsEnabled(enabled: boolean);
  75464. /**
  75465. * Specifies the number of steps used to calculate the volumetric lights
  75466. * Typically in interval [50, 200]
  75467. */
  75468. get volumetricLightStepsCount(): number;
  75469. set volumetricLightStepsCount(count: number);
  75470. /**
  75471. * Specifies the number of samples used for the motion blur effect
  75472. * Typically in interval [16, 64]
  75473. */
  75474. get motionBlurSamples(): number;
  75475. set motionBlurSamples(samples: number);
  75476. /**
  75477. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75478. */
  75479. get samples(): number;
  75480. set samples(sampleCount: number);
  75481. /**
  75482. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75483. * @constructor
  75484. * @param name The rendering pipeline name
  75485. * @param scene The scene linked to this pipeline
  75486. * @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)
  75487. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75488. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75489. */
  75490. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75491. private _buildPipeline;
  75492. private _createDownSampleX4PostProcess;
  75493. private _createBrightPassPostProcess;
  75494. private _createBlurPostProcesses;
  75495. private _createTextureAdderPostProcess;
  75496. private _createVolumetricLightPostProcess;
  75497. private _createLuminancePostProcesses;
  75498. private _createHdrPostProcess;
  75499. private _createLensFlarePostProcess;
  75500. private _createDepthOfFieldPostProcess;
  75501. private _createMotionBlurPostProcess;
  75502. private _getDepthTexture;
  75503. private _disposePostProcesses;
  75504. /**
  75505. * Dispose of the pipeline and stop all post processes
  75506. */
  75507. dispose(): void;
  75508. /**
  75509. * Serialize the rendering pipeline (Used when exporting)
  75510. * @returns the serialized object
  75511. */
  75512. serialize(): any;
  75513. /**
  75514. * Parse the serialized pipeline
  75515. * @param source Source pipeline.
  75516. * @param scene The scene to load the pipeline to.
  75517. * @param rootUrl The URL of the serialized pipeline.
  75518. * @returns An instantiated pipeline from the serialized object.
  75519. */
  75520. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75521. /**
  75522. * Luminance steps
  75523. */
  75524. static LuminanceSteps: number;
  75525. }
  75526. }
  75527. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75528. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75529. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75530. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75531. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75532. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75533. }
  75534. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75535. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75536. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75537. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75538. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75539. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75540. }
  75541. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75542. /** @hidden */
  75543. export var stereoscopicInterlacePixelShader: {
  75544. name: string;
  75545. shader: string;
  75546. };
  75547. }
  75548. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75549. import { Camera } from "babylonjs/Cameras/camera";
  75550. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75551. import { Engine } from "babylonjs/Engines/engine";
  75552. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75553. /**
  75554. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75555. */
  75556. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75557. private _stepSize;
  75558. private _passedProcess;
  75559. /**
  75560. * Gets a string identifying the name of the class
  75561. * @returns "StereoscopicInterlacePostProcessI" string
  75562. */
  75563. getClassName(): string;
  75564. /**
  75565. * Initializes a StereoscopicInterlacePostProcessI
  75566. * @param name The name of the effect.
  75567. * @param rigCameras The rig cameras to be appled to the post process
  75568. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75569. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75571. * @param engine The engine which the post process will be applied. (default: current engine)
  75572. * @param reusable If the post process can be reused on the same frame. (default: false)
  75573. */
  75574. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75575. }
  75576. /**
  75577. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75578. */
  75579. export class StereoscopicInterlacePostProcess extends PostProcess {
  75580. private _stepSize;
  75581. private _passedProcess;
  75582. /**
  75583. * Gets a string identifying the name of the class
  75584. * @returns "StereoscopicInterlacePostProcess" string
  75585. */
  75586. getClassName(): string;
  75587. /**
  75588. * Initializes a StereoscopicInterlacePostProcess
  75589. * @param name The name of the effect.
  75590. * @param rigCameras The rig cameras to be appled to the post process
  75591. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75593. * @param engine The engine which the post process will be applied. (default: current engine)
  75594. * @param reusable If the post process can be reused on the same frame. (default: false)
  75595. */
  75596. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75597. }
  75598. }
  75599. declare module "babylonjs/Shaders/tonemap.fragment" {
  75600. /** @hidden */
  75601. export var tonemapPixelShader: {
  75602. name: string;
  75603. shader: string;
  75604. };
  75605. }
  75606. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75607. import { Camera } from "babylonjs/Cameras/camera";
  75608. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75609. import "babylonjs/Shaders/tonemap.fragment";
  75610. import { Engine } from "babylonjs/Engines/engine";
  75611. /** Defines operator used for tonemapping */
  75612. export enum TonemappingOperator {
  75613. /** Hable */
  75614. Hable = 0,
  75615. /** Reinhard */
  75616. Reinhard = 1,
  75617. /** HejiDawson */
  75618. HejiDawson = 2,
  75619. /** Photographic */
  75620. Photographic = 3
  75621. }
  75622. /**
  75623. * Defines a post process to apply tone mapping
  75624. */
  75625. export class TonemapPostProcess extends PostProcess {
  75626. private _operator;
  75627. /** Defines the required exposure adjustement */
  75628. exposureAdjustment: number;
  75629. /**
  75630. * Gets a string identifying the name of the class
  75631. * @returns "TonemapPostProcess" string
  75632. */
  75633. getClassName(): string;
  75634. /**
  75635. * Creates a new TonemapPostProcess
  75636. * @param name defines the name of the postprocess
  75637. * @param _operator defines the operator to use
  75638. * @param exposureAdjustment defines the required exposure adjustement
  75639. * @param camera defines the camera to use (can be null)
  75640. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75641. * @param engine defines the hosting engine (can be ignore if camera is set)
  75642. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75643. */
  75644. constructor(name: string, _operator: TonemappingOperator,
  75645. /** Defines the required exposure adjustement */
  75646. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75647. }
  75648. }
  75649. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75650. /** @hidden */
  75651. export var volumetricLightScatteringPixelShader: {
  75652. name: string;
  75653. shader: string;
  75654. };
  75655. }
  75656. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75657. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75658. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75659. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75660. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75661. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75662. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75663. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75664. /** @hidden */
  75665. export var volumetricLightScatteringPassVertexShader: {
  75666. name: string;
  75667. shader: string;
  75668. };
  75669. }
  75670. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75671. /** @hidden */
  75672. export var volumetricLightScatteringPassPixelShader: {
  75673. name: string;
  75674. shader: string;
  75675. };
  75676. }
  75677. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75678. import { Vector3 } from "babylonjs/Maths/math.vector";
  75679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75680. import { Mesh } from "babylonjs/Meshes/mesh";
  75681. import { Camera } from "babylonjs/Cameras/camera";
  75682. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75683. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75684. import { Scene } from "babylonjs/scene";
  75685. import "babylonjs/Meshes/Builders/planeBuilder";
  75686. import "babylonjs/Shaders/depth.vertex";
  75687. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75688. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75689. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75690. import { Engine } from "babylonjs/Engines/engine";
  75691. /**
  75692. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75693. */
  75694. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75695. private _volumetricLightScatteringPass;
  75696. private _volumetricLightScatteringRTT;
  75697. private _viewPort;
  75698. private _screenCoordinates;
  75699. private _cachedDefines;
  75700. /**
  75701. * If not undefined, the mesh position is computed from the attached node position
  75702. */
  75703. attachedNode: {
  75704. position: Vector3;
  75705. };
  75706. /**
  75707. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75708. */
  75709. customMeshPosition: Vector3;
  75710. /**
  75711. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75712. */
  75713. useCustomMeshPosition: boolean;
  75714. /**
  75715. * If the post-process should inverse the light scattering direction
  75716. */
  75717. invert: boolean;
  75718. /**
  75719. * The internal mesh used by the post-process
  75720. */
  75721. mesh: Mesh;
  75722. /**
  75723. * @hidden
  75724. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75725. */
  75726. get useDiffuseColor(): boolean;
  75727. set useDiffuseColor(useDiffuseColor: boolean);
  75728. /**
  75729. * Array containing the excluded meshes not rendered in the internal pass
  75730. */
  75731. excludedMeshes: AbstractMesh[];
  75732. /**
  75733. * Controls the overall intensity of the post-process
  75734. */
  75735. exposure: number;
  75736. /**
  75737. * Dissipates each sample's contribution in range [0, 1]
  75738. */
  75739. decay: number;
  75740. /**
  75741. * Controls the overall intensity of each sample
  75742. */
  75743. weight: number;
  75744. /**
  75745. * Controls the density of each sample
  75746. */
  75747. density: number;
  75748. /**
  75749. * @constructor
  75750. * @param name The post-process name
  75751. * @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)
  75752. * @param camera The camera that the post-process will be attached to
  75753. * @param mesh The mesh used to create the light scattering
  75754. * @param samples The post-process quality, default 100
  75755. * @param samplingModeThe post-process filtering mode
  75756. * @param engine The babylon engine
  75757. * @param reusable If the post-process is reusable
  75758. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75759. */
  75760. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75761. /**
  75762. * Returns the string "VolumetricLightScatteringPostProcess"
  75763. * @returns "VolumetricLightScatteringPostProcess"
  75764. */
  75765. getClassName(): string;
  75766. private _isReady;
  75767. /**
  75768. * Sets the new light position for light scattering effect
  75769. * @param position The new custom light position
  75770. */
  75771. setCustomMeshPosition(position: Vector3): void;
  75772. /**
  75773. * Returns the light position for light scattering effect
  75774. * @return Vector3 The custom light position
  75775. */
  75776. getCustomMeshPosition(): Vector3;
  75777. /**
  75778. * Disposes the internal assets and detaches the post-process from the camera
  75779. */
  75780. dispose(camera: Camera): void;
  75781. /**
  75782. * Returns the render target texture used by the post-process
  75783. * @return the render target texture used by the post-process
  75784. */
  75785. getPass(): RenderTargetTexture;
  75786. private _meshExcluded;
  75787. private _createPass;
  75788. private _updateMeshScreenCoordinates;
  75789. /**
  75790. * Creates a default mesh for the Volumeric Light Scattering post-process
  75791. * @param name The mesh name
  75792. * @param scene The scene where to create the mesh
  75793. * @return the default mesh
  75794. */
  75795. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75796. }
  75797. }
  75798. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75799. /** @hidden */
  75800. export var screenSpaceCurvaturePixelShader: {
  75801. name: string;
  75802. shader: string;
  75803. };
  75804. }
  75805. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75806. import { Nullable } from "babylonjs/types";
  75807. import { Camera } from "babylonjs/Cameras/camera";
  75808. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75809. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75810. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75811. import { Engine } from "babylonjs/Engines/engine";
  75812. import { Scene } from "babylonjs/scene";
  75813. /**
  75814. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75815. */
  75816. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75817. /**
  75818. * Defines how much ridge the curvature effect displays.
  75819. */
  75820. ridge: number;
  75821. /**
  75822. * Defines how much valley the curvature effect displays.
  75823. */
  75824. valley: number;
  75825. private _geometryBufferRenderer;
  75826. /**
  75827. * Gets a string identifying the name of the class
  75828. * @returns "ScreenSpaceCurvaturePostProcess" string
  75829. */
  75830. getClassName(): string;
  75831. /**
  75832. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75833. * @param name The name of the effect.
  75834. * @param scene The scene containing the objects to blur according to their velocity.
  75835. * @param options The required width/height ratio to downsize to before computing the render pass.
  75836. * @param camera The camera to apply the render pass to.
  75837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75838. * @param engine The engine which the post process will be applied. (default: current engine)
  75839. * @param reusable If the post process can be reused on the same frame. (default: false)
  75840. * @param textureType Type of textures used when performing the post process. (default: 0)
  75841. * @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)
  75842. */
  75843. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75844. /**
  75845. * Support test.
  75846. */
  75847. static get IsSupported(): boolean;
  75848. /** @hidden */
  75849. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75850. }
  75851. }
  75852. declare module "babylonjs/PostProcesses/index" {
  75853. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75854. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75855. export * from "babylonjs/PostProcesses/bloomEffect";
  75856. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75857. export * from "babylonjs/PostProcesses/blurPostProcess";
  75858. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75859. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75860. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75861. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75862. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75863. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75864. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75865. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75866. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75867. export * from "babylonjs/PostProcesses/filterPostProcess";
  75868. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75869. export * from "babylonjs/PostProcesses/grainPostProcess";
  75870. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75871. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75872. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75873. export * from "babylonjs/PostProcesses/passPostProcess";
  75874. export * from "babylonjs/PostProcesses/postProcess";
  75875. export * from "babylonjs/PostProcesses/postProcessManager";
  75876. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75877. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75878. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75879. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75880. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75881. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75882. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75883. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75884. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75885. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75886. }
  75887. declare module "babylonjs/Probes/index" {
  75888. export * from "babylonjs/Probes/reflectionProbe";
  75889. }
  75890. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75891. import { Scene } from "babylonjs/scene";
  75892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75893. import { SmartArray } from "babylonjs/Misc/smartArray";
  75894. import { ISceneComponent } from "babylonjs/sceneComponent";
  75895. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75896. import "babylonjs/Meshes/Builders/boxBuilder";
  75897. import "babylonjs/Shaders/color.fragment";
  75898. import "babylonjs/Shaders/color.vertex";
  75899. import { Color3 } from "babylonjs/Maths/math.color";
  75900. import { Observable } from "babylonjs/Misc/observable";
  75901. module "babylonjs/scene" {
  75902. interface Scene {
  75903. /** @hidden (Backing field) */
  75904. _boundingBoxRenderer: BoundingBoxRenderer;
  75905. /** @hidden (Backing field) */
  75906. _forceShowBoundingBoxes: boolean;
  75907. /**
  75908. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75909. */
  75910. forceShowBoundingBoxes: boolean;
  75911. /**
  75912. * Gets the bounding box renderer associated with the scene
  75913. * @returns a BoundingBoxRenderer
  75914. */
  75915. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75916. }
  75917. }
  75918. module "babylonjs/Meshes/abstractMesh" {
  75919. interface AbstractMesh {
  75920. /** @hidden (Backing field) */
  75921. _showBoundingBox: boolean;
  75922. /**
  75923. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75924. */
  75925. showBoundingBox: boolean;
  75926. }
  75927. }
  75928. /**
  75929. * Component responsible of rendering the bounding box of the meshes in a scene.
  75930. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75931. */
  75932. export class BoundingBoxRenderer implements ISceneComponent {
  75933. /**
  75934. * The component name helpfull to identify the component in the list of scene components.
  75935. */
  75936. readonly name: string;
  75937. /**
  75938. * The scene the component belongs to.
  75939. */
  75940. scene: Scene;
  75941. /**
  75942. * Color of the bounding box lines placed in front of an object
  75943. */
  75944. frontColor: Color3;
  75945. /**
  75946. * Color of the bounding box lines placed behind an object
  75947. */
  75948. backColor: Color3;
  75949. /**
  75950. * Defines if the renderer should show the back lines or not
  75951. */
  75952. showBackLines: boolean;
  75953. /**
  75954. * Observable raised before rendering a bounding box
  75955. */
  75956. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75957. /**
  75958. * Observable raised after rendering a bounding box
  75959. */
  75960. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75961. /**
  75962. * @hidden
  75963. */
  75964. renderList: SmartArray<BoundingBox>;
  75965. private _colorShader;
  75966. private _vertexBuffers;
  75967. private _indexBuffer;
  75968. private _fillIndexBuffer;
  75969. private _fillIndexData;
  75970. /**
  75971. * Instantiates a new bounding box renderer in a scene.
  75972. * @param scene the scene the renderer renders in
  75973. */
  75974. constructor(scene: Scene);
  75975. /**
  75976. * Registers the component in a given scene
  75977. */
  75978. register(): void;
  75979. private _evaluateSubMesh;
  75980. private _activeMesh;
  75981. private _prepareRessources;
  75982. private _createIndexBuffer;
  75983. /**
  75984. * Rebuilds the elements related to this component in case of
  75985. * context lost for instance.
  75986. */
  75987. rebuild(): void;
  75988. /**
  75989. * @hidden
  75990. */
  75991. reset(): void;
  75992. /**
  75993. * Render the bounding boxes of a specific rendering group
  75994. * @param renderingGroupId defines the rendering group to render
  75995. */
  75996. render(renderingGroupId: number): void;
  75997. /**
  75998. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75999. * @param mesh Define the mesh to render the occlusion bounding box for
  76000. */
  76001. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76002. /**
  76003. * Dispose and release the resources attached to this renderer.
  76004. */
  76005. dispose(): void;
  76006. }
  76007. }
  76008. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76009. import { Nullable } from "babylonjs/types";
  76010. import { Scene } from "babylonjs/scene";
  76011. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76012. import { Camera } from "babylonjs/Cameras/camera";
  76013. import { ISceneComponent } from "babylonjs/sceneComponent";
  76014. module "babylonjs/scene" {
  76015. interface Scene {
  76016. /** @hidden (Backing field) */
  76017. _depthRenderer: {
  76018. [id: string]: DepthRenderer;
  76019. };
  76020. /**
  76021. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76022. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76023. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76024. * @returns the created depth renderer
  76025. */
  76026. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  76027. /**
  76028. * Disables a depth renderer for a given camera
  76029. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76030. */
  76031. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76032. }
  76033. }
  76034. /**
  76035. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76036. * in several rendering techniques.
  76037. */
  76038. export class DepthRendererSceneComponent implements ISceneComponent {
  76039. /**
  76040. * The component name helpfull to identify the component in the list of scene components.
  76041. */
  76042. readonly name: string;
  76043. /**
  76044. * The scene the component belongs to.
  76045. */
  76046. scene: Scene;
  76047. /**
  76048. * Creates a new instance of the component for the given scene
  76049. * @param scene Defines the scene to register the component in
  76050. */
  76051. constructor(scene: Scene);
  76052. /**
  76053. * Registers the component in a given scene
  76054. */
  76055. register(): void;
  76056. /**
  76057. * Rebuilds the elements related to this component in case of
  76058. * context lost for instance.
  76059. */
  76060. rebuild(): void;
  76061. /**
  76062. * Disposes the component and the associated ressources
  76063. */
  76064. dispose(): void;
  76065. private _gatherRenderTargets;
  76066. private _gatherActiveCameraRenderTargets;
  76067. }
  76068. }
  76069. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76070. import { Nullable } from "babylonjs/types";
  76071. import { Scene } from "babylonjs/scene";
  76072. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76073. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76074. import { AbstractScene } from "babylonjs/abstractScene";
  76075. module "babylonjs/abstractScene" {
  76076. interface AbstractScene {
  76077. /** @hidden (Backing field) */
  76078. _prePassRenderer: Nullable<PrePassRenderer>;
  76079. /**
  76080. * Gets or Sets the current prepass renderer associated to the scene.
  76081. */
  76082. prePassRenderer: Nullable<PrePassRenderer>;
  76083. /**
  76084. * Enables the prepass and associates it with the scene
  76085. * @returns the PrePassRenderer
  76086. */
  76087. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76088. /**
  76089. * Disables the prepass associated with the scene
  76090. */
  76091. disablePrePassRenderer(): void;
  76092. }
  76093. }
  76094. /**
  76095. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76096. * in several rendering techniques.
  76097. */
  76098. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  76099. /**
  76100. * The component name helpful to identify the component in the list of scene components.
  76101. */
  76102. readonly name: string;
  76103. /**
  76104. * The scene the component belongs to.
  76105. */
  76106. scene: Scene;
  76107. /**
  76108. * Creates a new instance of the component for the given scene
  76109. * @param scene Defines the scene to register the component in
  76110. */
  76111. constructor(scene: Scene);
  76112. /**
  76113. * Registers the component in a given scene
  76114. */
  76115. register(): void;
  76116. private _beforeCameraDraw;
  76117. private _afterCameraDraw;
  76118. private _beforeClearStage;
  76119. /**
  76120. * Serializes the component data to the specified json object
  76121. * @param serializationObject The object to serialize to
  76122. */
  76123. serialize(serializationObject: any): void;
  76124. /**
  76125. * Adds all the elements from the container to the scene
  76126. * @param container the container holding the elements
  76127. */
  76128. addFromContainer(container: AbstractScene): void;
  76129. /**
  76130. * Removes all the elements in the container from the scene
  76131. * @param container contains the elements to remove
  76132. * @param dispose if the removed element should be disposed (default: false)
  76133. */
  76134. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76135. /**
  76136. * Rebuilds the elements related to this component in case of
  76137. * context lost for instance.
  76138. */
  76139. rebuild(): void;
  76140. /**
  76141. * Disposes the component and the associated ressources
  76142. */
  76143. dispose(): void;
  76144. }
  76145. }
  76146. declare module "babylonjs/Shaders/outline.fragment" {
  76147. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76148. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76149. /** @hidden */
  76150. export var outlinePixelShader: {
  76151. name: string;
  76152. shader: string;
  76153. };
  76154. }
  76155. declare module "babylonjs/Shaders/outline.vertex" {
  76156. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76157. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76158. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76159. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76160. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76161. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76162. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76163. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76164. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76165. /** @hidden */
  76166. export var outlineVertexShader: {
  76167. name: string;
  76168. shader: string;
  76169. };
  76170. }
  76171. declare module "babylonjs/Rendering/outlineRenderer" {
  76172. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76173. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76174. import { Scene } from "babylonjs/scene";
  76175. import { ISceneComponent } from "babylonjs/sceneComponent";
  76176. import "babylonjs/Shaders/outline.fragment";
  76177. import "babylonjs/Shaders/outline.vertex";
  76178. module "babylonjs/scene" {
  76179. interface Scene {
  76180. /** @hidden */
  76181. _outlineRenderer: OutlineRenderer;
  76182. /**
  76183. * Gets the outline renderer associated with the scene
  76184. * @returns a OutlineRenderer
  76185. */
  76186. getOutlineRenderer(): OutlineRenderer;
  76187. }
  76188. }
  76189. module "babylonjs/Meshes/abstractMesh" {
  76190. interface AbstractMesh {
  76191. /** @hidden (Backing field) */
  76192. _renderOutline: boolean;
  76193. /**
  76194. * Gets or sets a boolean indicating if the outline must be rendered as well
  76195. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76196. */
  76197. renderOutline: boolean;
  76198. /** @hidden (Backing field) */
  76199. _renderOverlay: boolean;
  76200. /**
  76201. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76202. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76203. */
  76204. renderOverlay: boolean;
  76205. }
  76206. }
  76207. /**
  76208. * This class is responsible to draw bothe outline/overlay of meshes.
  76209. * It should not be used directly but through the available method on mesh.
  76210. */
  76211. export class OutlineRenderer implements ISceneComponent {
  76212. /**
  76213. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76214. */
  76215. private static _StencilReference;
  76216. /**
  76217. * The name of the component. Each component must have a unique name.
  76218. */
  76219. name: string;
  76220. /**
  76221. * The scene the component belongs to.
  76222. */
  76223. scene: Scene;
  76224. /**
  76225. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76226. */
  76227. zOffset: number;
  76228. private _engine;
  76229. private _effect;
  76230. private _cachedDefines;
  76231. private _savedDepthWrite;
  76232. /**
  76233. * Instantiates a new outline renderer. (There could be only one per scene).
  76234. * @param scene Defines the scene it belongs to
  76235. */
  76236. constructor(scene: Scene);
  76237. /**
  76238. * Register the component to one instance of a scene.
  76239. */
  76240. register(): void;
  76241. /**
  76242. * Rebuilds the elements related to this component in case of
  76243. * context lost for instance.
  76244. */
  76245. rebuild(): void;
  76246. /**
  76247. * Disposes the component and the associated ressources.
  76248. */
  76249. dispose(): void;
  76250. /**
  76251. * Renders the outline in the canvas.
  76252. * @param subMesh Defines the sumesh to render
  76253. * @param batch Defines the batch of meshes in case of instances
  76254. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76255. */
  76256. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76257. /**
  76258. * Returns whether or not the outline renderer is ready for a given submesh.
  76259. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76260. * @param subMesh Defines the submesh to check readyness for
  76261. * @param useInstances Defines wheter wee are trying to render instances or not
  76262. * @returns true if ready otherwise false
  76263. */
  76264. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76265. private _beforeRenderingMesh;
  76266. private _afterRenderingMesh;
  76267. }
  76268. }
  76269. declare module "babylonjs/Rendering/index" {
  76270. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76271. export * from "babylonjs/Rendering/depthRenderer";
  76272. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76273. export * from "babylonjs/Rendering/edgesRenderer";
  76274. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76275. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76276. export * from "babylonjs/Rendering/prePassRenderer";
  76277. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76278. export * from "babylonjs/Rendering/outlineRenderer";
  76279. export * from "babylonjs/Rendering/renderingGroup";
  76280. export * from "babylonjs/Rendering/renderingManager";
  76281. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76282. }
  76283. declare module "babylonjs/Sprites/ISprites" {
  76284. /**
  76285. * Defines the basic options interface of a Sprite Frame Source Size.
  76286. */
  76287. export interface ISpriteJSONSpriteSourceSize {
  76288. /**
  76289. * number of the original width of the Frame
  76290. */
  76291. w: number;
  76292. /**
  76293. * number of the original height of the Frame
  76294. */
  76295. h: number;
  76296. }
  76297. /**
  76298. * Defines the basic options interface of a Sprite Frame Data.
  76299. */
  76300. export interface ISpriteJSONSpriteFrameData {
  76301. /**
  76302. * number of the x offset of the Frame
  76303. */
  76304. x: number;
  76305. /**
  76306. * number of the y offset of the Frame
  76307. */
  76308. y: number;
  76309. /**
  76310. * number of the width of the Frame
  76311. */
  76312. w: number;
  76313. /**
  76314. * number of the height of the Frame
  76315. */
  76316. h: number;
  76317. }
  76318. /**
  76319. * Defines the basic options interface of a JSON Sprite.
  76320. */
  76321. export interface ISpriteJSONSprite {
  76322. /**
  76323. * string name of the Frame
  76324. */
  76325. filename: string;
  76326. /**
  76327. * ISpriteJSONSpriteFrame basic object of the frame data
  76328. */
  76329. frame: ISpriteJSONSpriteFrameData;
  76330. /**
  76331. * boolean to flag is the frame was rotated.
  76332. */
  76333. rotated: boolean;
  76334. /**
  76335. * boolean to flag is the frame was trimmed.
  76336. */
  76337. trimmed: boolean;
  76338. /**
  76339. * ISpriteJSONSpriteFrame basic object of the source data
  76340. */
  76341. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76342. /**
  76343. * ISpriteJSONSpriteFrame basic object of the source data
  76344. */
  76345. sourceSize: ISpriteJSONSpriteSourceSize;
  76346. }
  76347. /**
  76348. * Defines the basic options interface of a JSON atlas.
  76349. */
  76350. export interface ISpriteJSONAtlas {
  76351. /**
  76352. * Array of objects that contain the frame data.
  76353. */
  76354. frames: Array<ISpriteJSONSprite>;
  76355. /**
  76356. * object basic object containing the sprite meta data.
  76357. */
  76358. meta?: object;
  76359. }
  76360. }
  76361. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76362. /** @hidden */
  76363. export var spriteMapPixelShader: {
  76364. name: string;
  76365. shader: string;
  76366. };
  76367. }
  76368. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76369. /** @hidden */
  76370. export var spriteMapVertexShader: {
  76371. name: string;
  76372. shader: string;
  76373. };
  76374. }
  76375. declare module "babylonjs/Sprites/spriteMap" {
  76376. import { IDisposable, Scene } from "babylonjs/scene";
  76377. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76378. import { Texture } from "babylonjs/Materials/Textures/texture";
  76379. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76380. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76381. import "babylonjs/Meshes/Builders/planeBuilder";
  76382. import "babylonjs/Shaders/spriteMap.fragment";
  76383. import "babylonjs/Shaders/spriteMap.vertex";
  76384. /**
  76385. * Defines the basic options interface of a SpriteMap
  76386. */
  76387. export interface ISpriteMapOptions {
  76388. /**
  76389. * Vector2 of the number of cells in the grid.
  76390. */
  76391. stageSize?: Vector2;
  76392. /**
  76393. * Vector2 of the size of the output plane in World Units.
  76394. */
  76395. outputSize?: Vector2;
  76396. /**
  76397. * Vector3 of the position of the output plane in World Units.
  76398. */
  76399. outputPosition?: Vector3;
  76400. /**
  76401. * Vector3 of the rotation of the output plane.
  76402. */
  76403. outputRotation?: Vector3;
  76404. /**
  76405. * number of layers that the system will reserve in resources.
  76406. */
  76407. layerCount?: number;
  76408. /**
  76409. * number of max animation frames a single cell will reserve in resources.
  76410. */
  76411. maxAnimationFrames?: number;
  76412. /**
  76413. * number cell index of the base tile when the system compiles.
  76414. */
  76415. baseTile?: number;
  76416. /**
  76417. * boolean flip the sprite after its been repositioned by the framing data.
  76418. */
  76419. flipU?: boolean;
  76420. /**
  76421. * Vector3 scalar of the global RGB values of the SpriteMap.
  76422. */
  76423. colorMultiply?: Vector3;
  76424. }
  76425. /**
  76426. * Defines the IDisposable interface in order to be cleanable from resources.
  76427. */
  76428. export interface ISpriteMap extends IDisposable {
  76429. /**
  76430. * String name of the SpriteMap.
  76431. */
  76432. name: string;
  76433. /**
  76434. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76435. */
  76436. atlasJSON: ISpriteJSONAtlas;
  76437. /**
  76438. * Texture of the SpriteMap.
  76439. */
  76440. spriteSheet: Texture;
  76441. /**
  76442. * The parameters to initialize the SpriteMap with.
  76443. */
  76444. options: ISpriteMapOptions;
  76445. }
  76446. /**
  76447. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76448. */
  76449. export class SpriteMap implements ISpriteMap {
  76450. /** The Name of the spriteMap */
  76451. name: string;
  76452. /** The JSON file with the frame and meta data */
  76453. atlasJSON: ISpriteJSONAtlas;
  76454. /** The systems Sprite Sheet Texture */
  76455. spriteSheet: Texture;
  76456. /** Arguments passed with the Constructor */
  76457. options: ISpriteMapOptions;
  76458. /** Public Sprite Storage array, parsed from atlasJSON */
  76459. sprites: Array<ISpriteJSONSprite>;
  76460. /** Returns the Number of Sprites in the System */
  76461. get spriteCount(): number;
  76462. /** Returns the Position of Output Plane*/
  76463. get position(): Vector3;
  76464. /** Returns the Position of Output Plane*/
  76465. set position(v: Vector3);
  76466. /** Returns the Rotation of Output Plane*/
  76467. get rotation(): Vector3;
  76468. /** Returns the Rotation of Output Plane*/
  76469. set rotation(v: Vector3);
  76470. /** Sets the AnimationMap*/
  76471. get animationMap(): RawTexture;
  76472. /** Sets the AnimationMap*/
  76473. set animationMap(v: RawTexture);
  76474. /** Scene that the SpriteMap was created in */
  76475. private _scene;
  76476. /** Texture Buffer of Float32 that holds tile frame data*/
  76477. private _frameMap;
  76478. /** Texture Buffers of Float32 that holds tileMap data*/
  76479. private _tileMaps;
  76480. /** Texture Buffer of Float32 that holds Animation Data*/
  76481. private _animationMap;
  76482. /** Custom ShaderMaterial Central to the System*/
  76483. private _material;
  76484. /** Custom ShaderMaterial Central to the System*/
  76485. private _output;
  76486. /** Systems Time Ticker*/
  76487. private _time;
  76488. /**
  76489. * Creates a new SpriteMap
  76490. * @param name defines the SpriteMaps Name
  76491. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76492. * @param spriteSheet is the Texture that the Sprites are on.
  76493. * @param options a basic deployment configuration
  76494. * @param scene The Scene that the map is deployed on
  76495. */
  76496. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76497. /**
  76498. * Returns tileID location
  76499. * @returns Vector2 the cell position ID
  76500. */
  76501. getTileID(): Vector2;
  76502. /**
  76503. * Gets the UV location of the mouse over the SpriteMap.
  76504. * @returns Vector2 the UV position of the mouse interaction
  76505. */
  76506. getMousePosition(): Vector2;
  76507. /**
  76508. * Creates the "frame" texture Buffer
  76509. * -------------------------------------
  76510. * Structure of frames
  76511. * "filename": "Falling-Water-2.png",
  76512. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76513. * "rotated": true,
  76514. * "trimmed": true,
  76515. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76516. * "sourceSize": {"w":32,"h":32}
  76517. * @returns RawTexture of the frameMap
  76518. */
  76519. private _createFrameBuffer;
  76520. /**
  76521. * Creates the tileMap texture Buffer
  76522. * @param buffer normally and array of numbers, or a false to generate from scratch
  76523. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76524. * @returns RawTexture of the tileMap
  76525. */
  76526. private _createTileBuffer;
  76527. /**
  76528. * Modifies the data of the tileMaps
  76529. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76530. * @param pos is the iVector2 Coordinates of the Tile
  76531. * @param tile The SpriteIndex of the new Tile
  76532. */
  76533. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76534. /**
  76535. * Creates the animationMap texture Buffer
  76536. * @param buffer normally and array of numbers, or a false to generate from scratch
  76537. * @returns RawTexture of the animationMap
  76538. */
  76539. private _createTileAnimationBuffer;
  76540. /**
  76541. * Modifies the data of the animationMap
  76542. * @param cellID is the Index of the Sprite
  76543. * @param _frame is the target Animation frame
  76544. * @param toCell is the Target Index of the next frame of the animation
  76545. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76546. * @param speed is a global scalar of the time variable on the map.
  76547. */
  76548. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76549. /**
  76550. * Exports the .tilemaps file
  76551. */
  76552. saveTileMaps(): void;
  76553. /**
  76554. * Imports the .tilemaps file
  76555. * @param url of the .tilemaps file
  76556. */
  76557. loadTileMaps(url: string): void;
  76558. /**
  76559. * Release associated resources
  76560. */
  76561. dispose(): void;
  76562. }
  76563. }
  76564. declare module "babylonjs/Sprites/spritePackedManager" {
  76565. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76566. import { Scene } from "babylonjs/scene";
  76567. /**
  76568. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76569. * @see https://doc.babylonjs.com/babylon101/sprites
  76570. */
  76571. export class SpritePackedManager extends SpriteManager {
  76572. /** defines the packed manager's name */
  76573. name: string;
  76574. /**
  76575. * Creates a new sprite manager from a packed sprite sheet
  76576. * @param name defines the manager's name
  76577. * @param imgUrl defines the sprite sheet url
  76578. * @param capacity defines the maximum allowed number of sprites
  76579. * @param scene defines the hosting scene
  76580. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76581. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76582. * @param samplingMode defines the smapling mode to use with spritesheet
  76583. * @param fromPacked set to true; do not alter
  76584. */
  76585. constructor(
  76586. /** defines the packed manager's name */
  76587. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76588. }
  76589. }
  76590. declare module "babylonjs/Sprites/index" {
  76591. export * from "babylonjs/Sprites/sprite";
  76592. export * from "babylonjs/Sprites/ISprites";
  76593. export * from "babylonjs/Sprites/spriteManager";
  76594. export * from "babylonjs/Sprites/spriteMap";
  76595. export * from "babylonjs/Sprites/spritePackedManager";
  76596. export * from "babylonjs/Sprites/spriteSceneComponent";
  76597. }
  76598. declare module "babylonjs/States/index" {
  76599. export * from "babylonjs/States/alphaCullingState";
  76600. export * from "babylonjs/States/depthCullingState";
  76601. export * from "babylonjs/States/stencilState";
  76602. }
  76603. declare module "babylonjs/Misc/assetsManager" {
  76604. import { Scene } from "babylonjs/scene";
  76605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76606. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76607. import { Skeleton } from "babylonjs/Bones/skeleton";
  76608. import { Observable } from "babylonjs/Misc/observable";
  76609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76610. import { Texture } from "babylonjs/Materials/Textures/texture";
  76611. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76612. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76613. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76614. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76615. import { AssetContainer } from "babylonjs/assetContainer";
  76616. /**
  76617. * Defines the list of states available for a task inside a AssetsManager
  76618. */
  76619. export enum AssetTaskState {
  76620. /**
  76621. * Initialization
  76622. */
  76623. INIT = 0,
  76624. /**
  76625. * Running
  76626. */
  76627. RUNNING = 1,
  76628. /**
  76629. * Done
  76630. */
  76631. DONE = 2,
  76632. /**
  76633. * Error
  76634. */
  76635. ERROR = 3
  76636. }
  76637. /**
  76638. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76639. */
  76640. export abstract class AbstractAssetTask {
  76641. /**
  76642. * Task name
  76643. */ name: string;
  76644. /**
  76645. * Callback called when the task is successful
  76646. */
  76647. onSuccess: (task: any) => void;
  76648. /**
  76649. * Callback called when the task is not successful
  76650. */
  76651. onError: (task: any, message?: string, exception?: any) => void;
  76652. /**
  76653. * Creates a new AssetsManager
  76654. * @param name defines the name of the task
  76655. */
  76656. constructor(
  76657. /**
  76658. * Task name
  76659. */ name: string);
  76660. private _isCompleted;
  76661. private _taskState;
  76662. private _errorObject;
  76663. /**
  76664. * Get if the task is completed
  76665. */
  76666. get isCompleted(): boolean;
  76667. /**
  76668. * Gets the current state of the task
  76669. */
  76670. get taskState(): AssetTaskState;
  76671. /**
  76672. * Gets the current error object (if task is in error)
  76673. */
  76674. get errorObject(): {
  76675. message?: string;
  76676. exception?: any;
  76677. };
  76678. /**
  76679. * Internal only
  76680. * @hidden
  76681. */
  76682. _setErrorObject(message?: string, exception?: any): void;
  76683. /**
  76684. * Execute the current task
  76685. * @param scene defines the scene where you want your assets to be loaded
  76686. * @param onSuccess is a callback called when the task is successfully executed
  76687. * @param onError is a callback called if an error occurs
  76688. */
  76689. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76690. /**
  76691. * Execute the current task
  76692. * @param scene defines the scene where you want your assets to be loaded
  76693. * @param onSuccess is a callback called when the task is successfully executed
  76694. * @param onError is a callback called if an error occurs
  76695. */
  76696. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76697. /**
  76698. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76699. * This can be used with failed tasks that have the reason for failure fixed.
  76700. */
  76701. reset(): void;
  76702. private onErrorCallback;
  76703. private onDoneCallback;
  76704. }
  76705. /**
  76706. * Define the interface used by progress events raised during assets loading
  76707. */
  76708. export interface IAssetsProgressEvent {
  76709. /**
  76710. * Defines the number of remaining tasks to process
  76711. */
  76712. remainingCount: number;
  76713. /**
  76714. * Defines the total number of tasks
  76715. */
  76716. totalCount: number;
  76717. /**
  76718. * Defines the task that was just processed
  76719. */
  76720. task: AbstractAssetTask;
  76721. }
  76722. /**
  76723. * Class used to share progress information about assets loading
  76724. */
  76725. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76726. /**
  76727. * Defines the number of remaining tasks to process
  76728. */
  76729. remainingCount: number;
  76730. /**
  76731. * Defines the total number of tasks
  76732. */
  76733. totalCount: number;
  76734. /**
  76735. * Defines the task that was just processed
  76736. */
  76737. task: AbstractAssetTask;
  76738. /**
  76739. * Creates a AssetsProgressEvent
  76740. * @param remainingCount defines the number of remaining tasks to process
  76741. * @param totalCount defines the total number of tasks
  76742. * @param task defines the task that was just processed
  76743. */
  76744. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76745. }
  76746. /**
  76747. * Define a task used by AssetsManager to load assets into a container
  76748. */
  76749. export class ContainerAssetTask extends AbstractAssetTask {
  76750. /**
  76751. * Defines the name of the task
  76752. */
  76753. name: string;
  76754. /**
  76755. * Defines the list of mesh's names you want to load
  76756. */
  76757. meshesNames: any;
  76758. /**
  76759. * Defines the root url to use as a base to load your meshes and associated resources
  76760. */
  76761. rootUrl: string;
  76762. /**
  76763. * Defines the filename or File of the scene to load from
  76764. */
  76765. sceneFilename: string | File;
  76766. /**
  76767. * Get the loaded asset container
  76768. */
  76769. loadedContainer: AssetContainer;
  76770. /**
  76771. * Gets the list of loaded meshes
  76772. */
  76773. loadedMeshes: Array<AbstractMesh>;
  76774. /**
  76775. * Gets the list of loaded particle systems
  76776. */
  76777. loadedParticleSystems: Array<IParticleSystem>;
  76778. /**
  76779. * Gets the list of loaded skeletons
  76780. */
  76781. loadedSkeletons: Array<Skeleton>;
  76782. /**
  76783. * Gets the list of loaded animation groups
  76784. */
  76785. loadedAnimationGroups: Array<AnimationGroup>;
  76786. /**
  76787. * Callback called when the task is successful
  76788. */
  76789. onSuccess: (task: ContainerAssetTask) => void;
  76790. /**
  76791. * Callback called when the task is successful
  76792. */
  76793. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76794. /**
  76795. * Creates a new ContainerAssetTask
  76796. * @param name defines the name of the task
  76797. * @param meshesNames defines the list of mesh's names you want to load
  76798. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76799. * @param sceneFilename defines the filename or File of the scene to load from
  76800. */
  76801. constructor(
  76802. /**
  76803. * Defines the name of the task
  76804. */
  76805. name: string,
  76806. /**
  76807. * Defines the list of mesh's names you want to load
  76808. */
  76809. meshesNames: any,
  76810. /**
  76811. * Defines the root url to use as a base to load your meshes and associated resources
  76812. */
  76813. rootUrl: string,
  76814. /**
  76815. * Defines the filename or File of the scene to load from
  76816. */
  76817. sceneFilename: string | File);
  76818. /**
  76819. * Execute the current task
  76820. * @param scene defines the scene where you want your assets to be loaded
  76821. * @param onSuccess is a callback called when the task is successfully executed
  76822. * @param onError is a callback called if an error occurs
  76823. */
  76824. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76825. }
  76826. /**
  76827. * Define a task used by AssetsManager to load meshes
  76828. */
  76829. export class MeshAssetTask extends AbstractAssetTask {
  76830. /**
  76831. * Defines the name of the task
  76832. */
  76833. name: string;
  76834. /**
  76835. * Defines the list of mesh's names you want to load
  76836. */
  76837. meshesNames: any;
  76838. /**
  76839. * Defines the root url to use as a base to load your meshes and associated resources
  76840. */
  76841. rootUrl: string;
  76842. /**
  76843. * Defines the filename or File of the scene to load from
  76844. */
  76845. sceneFilename: string | File;
  76846. /**
  76847. * Gets the list of loaded meshes
  76848. */
  76849. loadedMeshes: Array<AbstractMesh>;
  76850. /**
  76851. * Gets the list of loaded particle systems
  76852. */
  76853. loadedParticleSystems: Array<IParticleSystem>;
  76854. /**
  76855. * Gets the list of loaded skeletons
  76856. */
  76857. loadedSkeletons: Array<Skeleton>;
  76858. /**
  76859. * Gets the list of loaded animation groups
  76860. */
  76861. loadedAnimationGroups: Array<AnimationGroup>;
  76862. /**
  76863. * Callback called when the task is successful
  76864. */
  76865. onSuccess: (task: MeshAssetTask) => void;
  76866. /**
  76867. * Callback called when the task is successful
  76868. */
  76869. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76870. /**
  76871. * Creates a new MeshAssetTask
  76872. * @param name defines the name of the task
  76873. * @param meshesNames defines the list of mesh's names you want to load
  76874. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76875. * @param sceneFilename defines the filename or File of the scene to load from
  76876. */
  76877. constructor(
  76878. /**
  76879. * Defines the name of the task
  76880. */
  76881. name: string,
  76882. /**
  76883. * Defines the list of mesh's names you want to load
  76884. */
  76885. meshesNames: any,
  76886. /**
  76887. * Defines the root url to use as a base to load your meshes and associated resources
  76888. */
  76889. rootUrl: string,
  76890. /**
  76891. * Defines the filename or File of the scene to load from
  76892. */
  76893. sceneFilename: string | File);
  76894. /**
  76895. * Execute the current task
  76896. * @param scene defines the scene where you want your assets to be loaded
  76897. * @param onSuccess is a callback called when the task is successfully executed
  76898. * @param onError is a callback called if an error occurs
  76899. */
  76900. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76901. }
  76902. /**
  76903. * Define a task used by AssetsManager to load text content
  76904. */
  76905. export class TextFileAssetTask extends AbstractAssetTask {
  76906. /**
  76907. * Defines the name of the task
  76908. */
  76909. name: string;
  76910. /**
  76911. * Defines the location of the file to load
  76912. */
  76913. url: string;
  76914. /**
  76915. * Gets the loaded text string
  76916. */
  76917. text: string;
  76918. /**
  76919. * Callback called when the task is successful
  76920. */
  76921. onSuccess: (task: TextFileAssetTask) => void;
  76922. /**
  76923. * Callback called when the task is successful
  76924. */
  76925. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76926. /**
  76927. * Creates a new TextFileAssetTask object
  76928. * @param name defines the name of the task
  76929. * @param url defines the location of the file to load
  76930. */
  76931. constructor(
  76932. /**
  76933. * Defines the name of the task
  76934. */
  76935. name: string,
  76936. /**
  76937. * Defines the location of the file to load
  76938. */
  76939. url: string);
  76940. /**
  76941. * Execute the current task
  76942. * @param scene defines the scene where you want your assets to be loaded
  76943. * @param onSuccess is a callback called when the task is successfully executed
  76944. * @param onError is a callback called if an error occurs
  76945. */
  76946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76947. }
  76948. /**
  76949. * Define a task used by AssetsManager to load binary data
  76950. */
  76951. export class BinaryFileAssetTask extends AbstractAssetTask {
  76952. /**
  76953. * Defines the name of the task
  76954. */
  76955. name: string;
  76956. /**
  76957. * Defines the location of the file to load
  76958. */
  76959. url: string;
  76960. /**
  76961. * Gets the lodaded data (as an array buffer)
  76962. */
  76963. data: ArrayBuffer;
  76964. /**
  76965. * Callback called when the task is successful
  76966. */
  76967. onSuccess: (task: BinaryFileAssetTask) => void;
  76968. /**
  76969. * Callback called when the task is successful
  76970. */
  76971. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76972. /**
  76973. * Creates a new BinaryFileAssetTask object
  76974. * @param name defines the name of the new task
  76975. * @param url defines the location of the file to load
  76976. */
  76977. constructor(
  76978. /**
  76979. * Defines the name of the task
  76980. */
  76981. name: string,
  76982. /**
  76983. * Defines the location of the file to load
  76984. */
  76985. url: string);
  76986. /**
  76987. * Execute the current task
  76988. * @param scene defines the scene where you want your assets to be loaded
  76989. * @param onSuccess is a callback called when the task is successfully executed
  76990. * @param onError is a callback called if an error occurs
  76991. */
  76992. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76993. }
  76994. /**
  76995. * Define a task used by AssetsManager to load images
  76996. */
  76997. export class ImageAssetTask extends AbstractAssetTask {
  76998. /**
  76999. * Defines the name of the task
  77000. */
  77001. name: string;
  77002. /**
  77003. * Defines the location of the image to load
  77004. */
  77005. url: string;
  77006. /**
  77007. * Gets the loaded images
  77008. */
  77009. image: HTMLImageElement;
  77010. /**
  77011. * Callback called when the task is successful
  77012. */
  77013. onSuccess: (task: ImageAssetTask) => void;
  77014. /**
  77015. * Callback called when the task is successful
  77016. */
  77017. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77018. /**
  77019. * Creates a new ImageAssetTask
  77020. * @param name defines the name of the task
  77021. * @param url defines the location of the image to load
  77022. */
  77023. constructor(
  77024. /**
  77025. * Defines the name of the task
  77026. */
  77027. name: string,
  77028. /**
  77029. * Defines the location of the image to load
  77030. */
  77031. url: string);
  77032. /**
  77033. * Execute the current task
  77034. * @param scene defines the scene where you want your assets to be loaded
  77035. * @param onSuccess is a callback called when the task is successfully executed
  77036. * @param onError is a callback called if an error occurs
  77037. */
  77038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77039. }
  77040. /**
  77041. * Defines the interface used by texture loading tasks
  77042. */
  77043. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77044. /**
  77045. * Gets the loaded texture
  77046. */
  77047. texture: TEX;
  77048. }
  77049. /**
  77050. * Define a task used by AssetsManager to load 2D textures
  77051. */
  77052. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77053. /**
  77054. * Defines the name of the task
  77055. */
  77056. name: string;
  77057. /**
  77058. * Defines the location of the file to load
  77059. */
  77060. url: string;
  77061. /**
  77062. * Defines if mipmap should not be generated (default is false)
  77063. */
  77064. noMipmap?: boolean | undefined;
  77065. /**
  77066. * Defines if texture must be inverted on Y axis (default is true)
  77067. */
  77068. invertY: boolean;
  77069. /**
  77070. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77071. */
  77072. samplingMode: number;
  77073. /**
  77074. * Gets the loaded texture
  77075. */
  77076. texture: Texture;
  77077. /**
  77078. * Callback called when the task is successful
  77079. */
  77080. onSuccess: (task: TextureAssetTask) => void;
  77081. /**
  77082. * Callback called when the task is successful
  77083. */
  77084. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77085. /**
  77086. * Creates a new TextureAssetTask object
  77087. * @param name defines the name of the task
  77088. * @param url defines the location of the file to load
  77089. * @param noMipmap defines if mipmap should not be generated (default is false)
  77090. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77091. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77092. */
  77093. constructor(
  77094. /**
  77095. * Defines the name of the task
  77096. */
  77097. name: string,
  77098. /**
  77099. * Defines the location of the file to load
  77100. */
  77101. url: string,
  77102. /**
  77103. * Defines if mipmap should not be generated (default is false)
  77104. */
  77105. noMipmap?: boolean | undefined,
  77106. /**
  77107. * Defines if texture must be inverted on Y axis (default is true)
  77108. */
  77109. invertY?: boolean,
  77110. /**
  77111. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77112. */
  77113. samplingMode?: number);
  77114. /**
  77115. * Execute the current task
  77116. * @param scene defines the scene where you want your assets to be loaded
  77117. * @param onSuccess is a callback called when the task is successfully executed
  77118. * @param onError is a callback called if an error occurs
  77119. */
  77120. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77121. }
  77122. /**
  77123. * Define a task used by AssetsManager to load cube textures
  77124. */
  77125. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77126. /**
  77127. * Defines the name of the task
  77128. */
  77129. name: string;
  77130. /**
  77131. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77132. */
  77133. url: string;
  77134. /**
  77135. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77136. */
  77137. extensions?: string[] | undefined;
  77138. /**
  77139. * Defines if mipmaps should not be generated (default is false)
  77140. */
  77141. noMipmap?: boolean | undefined;
  77142. /**
  77143. * Defines the explicit list of files (undefined by default)
  77144. */
  77145. files?: string[] | undefined;
  77146. /**
  77147. * Gets the loaded texture
  77148. */
  77149. texture: CubeTexture;
  77150. /**
  77151. * Callback called when the task is successful
  77152. */
  77153. onSuccess: (task: CubeTextureAssetTask) => void;
  77154. /**
  77155. * Callback called when the task is successful
  77156. */
  77157. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77158. /**
  77159. * Creates a new CubeTextureAssetTask
  77160. * @param name defines the name of the task
  77161. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77162. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77163. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77164. * @param files defines the explicit list of files (undefined by default)
  77165. */
  77166. constructor(
  77167. /**
  77168. * Defines the name of the task
  77169. */
  77170. name: string,
  77171. /**
  77172. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77173. */
  77174. url: string,
  77175. /**
  77176. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77177. */
  77178. extensions?: string[] | undefined,
  77179. /**
  77180. * Defines if mipmaps should not be generated (default is false)
  77181. */
  77182. noMipmap?: boolean | undefined,
  77183. /**
  77184. * Defines the explicit list of files (undefined by default)
  77185. */
  77186. files?: string[] | undefined);
  77187. /**
  77188. * Execute the current task
  77189. * @param scene defines the scene where you want your assets to be loaded
  77190. * @param onSuccess is a callback called when the task is successfully executed
  77191. * @param onError is a callback called if an error occurs
  77192. */
  77193. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77194. }
  77195. /**
  77196. * Define a task used by AssetsManager to load HDR cube textures
  77197. */
  77198. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77199. /**
  77200. * Defines the name of the task
  77201. */
  77202. name: string;
  77203. /**
  77204. * Defines the location of the file to load
  77205. */
  77206. url: string;
  77207. /**
  77208. * Defines the desired size (the more it increases the longer the generation will be)
  77209. */
  77210. size: number;
  77211. /**
  77212. * Defines if mipmaps should not be generated (default is false)
  77213. */
  77214. noMipmap: boolean;
  77215. /**
  77216. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77217. */
  77218. generateHarmonics: boolean;
  77219. /**
  77220. * 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)
  77221. */
  77222. gammaSpace: boolean;
  77223. /**
  77224. * Internal Use Only
  77225. */
  77226. reserved: boolean;
  77227. /**
  77228. * Gets the loaded texture
  77229. */
  77230. texture: HDRCubeTexture;
  77231. /**
  77232. * Callback called when the task is successful
  77233. */
  77234. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77235. /**
  77236. * Callback called when the task is successful
  77237. */
  77238. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77239. /**
  77240. * Creates a new HDRCubeTextureAssetTask object
  77241. * @param name defines the name of the task
  77242. * @param url defines the location of the file to load
  77243. * @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.
  77244. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77245. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77246. * @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)
  77247. * @param reserved Internal use only
  77248. */
  77249. constructor(
  77250. /**
  77251. * Defines the name of the task
  77252. */
  77253. name: string,
  77254. /**
  77255. * Defines the location of the file to load
  77256. */
  77257. url: string,
  77258. /**
  77259. * Defines the desired size (the more it increases the longer the generation will be)
  77260. */
  77261. size: number,
  77262. /**
  77263. * Defines if mipmaps should not be generated (default is false)
  77264. */
  77265. noMipmap?: boolean,
  77266. /**
  77267. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77268. */
  77269. generateHarmonics?: boolean,
  77270. /**
  77271. * 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)
  77272. */
  77273. gammaSpace?: boolean,
  77274. /**
  77275. * Internal Use Only
  77276. */
  77277. reserved?: boolean);
  77278. /**
  77279. * Execute the current task
  77280. * @param scene defines the scene where you want your assets to be loaded
  77281. * @param onSuccess is a callback called when the task is successfully executed
  77282. * @param onError is a callback called if an error occurs
  77283. */
  77284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77285. }
  77286. /**
  77287. * Define a task used by AssetsManager to load Equirectangular cube textures
  77288. */
  77289. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77290. /**
  77291. * Defines the name of the task
  77292. */
  77293. name: string;
  77294. /**
  77295. * Defines the location of the file to load
  77296. */
  77297. url: string;
  77298. /**
  77299. * Defines the desired size (the more it increases the longer the generation will be)
  77300. */
  77301. size: number;
  77302. /**
  77303. * Defines if mipmaps should not be generated (default is false)
  77304. */
  77305. noMipmap: boolean;
  77306. /**
  77307. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77308. * but the standard material would require them in Gamma space) (default is true)
  77309. */
  77310. gammaSpace: boolean;
  77311. /**
  77312. * Gets the loaded texture
  77313. */
  77314. texture: EquiRectangularCubeTexture;
  77315. /**
  77316. * Callback called when the task is successful
  77317. */
  77318. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77319. /**
  77320. * Callback called when the task is successful
  77321. */
  77322. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77323. /**
  77324. * Creates a new EquiRectangularCubeTextureAssetTask object
  77325. * @param name defines the name of the task
  77326. * @param url defines the location of the file to load
  77327. * @param size defines the desired size (the more it increases the longer the generation will be)
  77328. * If the size is omitted this implies you are using a preprocessed cubemap.
  77329. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77330. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77331. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77332. * (default is true)
  77333. */
  77334. constructor(
  77335. /**
  77336. * Defines the name of the task
  77337. */
  77338. name: string,
  77339. /**
  77340. * Defines the location of the file to load
  77341. */
  77342. url: string,
  77343. /**
  77344. * Defines the desired size (the more it increases the longer the generation will be)
  77345. */
  77346. size: number,
  77347. /**
  77348. * Defines if mipmaps should not be generated (default is false)
  77349. */
  77350. noMipmap?: boolean,
  77351. /**
  77352. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77353. * but the standard material would require them in Gamma space) (default is true)
  77354. */
  77355. gammaSpace?: boolean);
  77356. /**
  77357. * Execute the current task
  77358. * @param scene defines the scene where you want your assets to be loaded
  77359. * @param onSuccess is a callback called when the task is successfully executed
  77360. * @param onError is a callback called if an error occurs
  77361. */
  77362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77363. }
  77364. /**
  77365. * This class can be used to easily import assets into a scene
  77366. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77367. */
  77368. export class AssetsManager {
  77369. private _scene;
  77370. private _isLoading;
  77371. protected _tasks: AbstractAssetTask[];
  77372. protected _waitingTasksCount: number;
  77373. protected _totalTasksCount: number;
  77374. /**
  77375. * Callback called when all tasks are processed
  77376. */
  77377. onFinish: (tasks: AbstractAssetTask[]) => void;
  77378. /**
  77379. * Callback called when a task is successful
  77380. */
  77381. onTaskSuccess: (task: AbstractAssetTask) => void;
  77382. /**
  77383. * Callback called when a task had an error
  77384. */
  77385. onTaskError: (task: AbstractAssetTask) => void;
  77386. /**
  77387. * Callback called when a task is done (whatever the result is)
  77388. */
  77389. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77390. /**
  77391. * Observable called when all tasks are processed
  77392. */
  77393. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77394. /**
  77395. * Observable called when a task had an error
  77396. */
  77397. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77398. /**
  77399. * Observable called when all tasks were executed
  77400. */
  77401. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77402. /**
  77403. * Observable called when a task is done (whatever the result is)
  77404. */
  77405. onProgressObservable: Observable<IAssetsProgressEvent>;
  77406. /**
  77407. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77408. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77409. */
  77410. useDefaultLoadingScreen: boolean;
  77411. /**
  77412. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77413. * when all assets have been downloaded.
  77414. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77415. */
  77416. autoHideLoadingUI: boolean;
  77417. /**
  77418. * Creates a new AssetsManager
  77419. * @param scene defines the scene to work on
  77420. */
  77421. constructor(scene: Scene);
  77422. /**
  77423. * Add a ContainerAssetTask to the list of active tasks
  77424. * @param taskName defines the name of the new task
  77425. * @param meshesNames defines the name of meshes to load
  77426. * @param rootUrl defines the root url to use to locate files
  77427. * @param sceneFilename defines the filename of the scene file
  77428. * @returns a new ContainerAssetTask object
  77429. */
  77430. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77431. /**
  77432. * Add a MeshAssetTask to the list of active tasks
  77433. * @param taskName defines the name of the new task
  77434. * @param meshesNames defines the name of meshes to load
  77435. * @param rootUrl defines the root url to use to locate files
  77436. * @param sceneFilename defines the filename of the scene file
  77437. * @returns a new MeshAssetTask object
  77438. */
  77439. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77440. /**
  77441. * Add a TextFileAssetTask to the list of active tasks
  77442. * @param taskName defines the name of the new task
  77443. * @param url defines the url of the file to load
  77444. * @returns a new TextFileAssetTask object
  77445. */
  77446. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77447. /**
  77448. * Add a BinaryFileAssetTask to the list of active tasks
  77449. * @param taskName defines the name of the new task
  77450. * @param url defines the url of the file to load
  77451. * @returns a new BinaryFileAssetTask object
  77452. */
  77453. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77454. /**
  77455. * Add a ImageAssetTask to the list of active tasks
  77456. * @param taskName defines the name of the new task
  77457. * @param url defines the url of the file to load
  77458. * @returns a new ImageAssetTask object
  77459. */
  77460. addImageTask(taskName: string, url: string): ImageAssetTask;
  77461. /**
  77462. * Add a TextureAssetTask to the list of active tasks
  77463. * @param taskName defines the name of the new task
  77464. * @param url defines the url of the file to load
  77465. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77466. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77467. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77468. * @returns a new TextureAssetTask object
  77469. */
  77470. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77471. /**
  77472. * Add a CubeTextureAssetTask to the list of active tasks
  77473. * @param taskName defines the name of the new task
  77474. * @param url defines the url of the file to load
  77475. * @param extensions defines the extension to use to load the cube map (can be null)
  77476. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77477. * @param files defines the list of files to load (can be null)
  77478. * @returns a new CubeTextureAssetTask object
  77479. */
  77480. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77481. /**
  77482. *
  77483. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77484. * @param taskName defines the name of the new task
  77485. * @param url defines the url of the file to load
  77486. * @param size defines the size you want for the cubemap (can be null)
  77487. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77488. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77489. * @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)
  77490. * @param reserved Internal use only
  77491. * @returns a new HDRCubeTextureAssetTask object
  77492. */
  77493. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77494. /**
  77495. *
  77496. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77497. * @param taskName defines the name of the new task
  77498. * @param url defines the url of the file to load
  77499. * @param size defines the size you want for the cubemap (can be null)
  77500. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77501. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77502. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77503. * @returns a new EquiRectangularCubeTextureAssetTask object
  77504. */
  77505. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77506. /**
  77507. * Remove a task from the assets manager.
  77508. * @param task the task to remove
  77509. */
  77510. removeTask(task: AbstractAssetTask): void;
  77511. private _decreaseWaitingTasksCount;
  77512. private _runTask;
  77513. /**
  77514. * Reset the AssetsManager and remove all tasks
  77515. * @return the current instance of the AssetsManager
  77516. */
  77517. reset(): AssetsManager;
  77518. /**
  77519. * Start the loading process
  77520. * @return the current instance of the AssetsManager
  77521. */
  77522. load(): AssetsManager;
  77523. /**
  77524. * Start the loading process as an async operation
  77525. * @return a promise returning the list of failed tasks
  77526. */
  77527. loadAsync(): Promise<void>;
  77528. }
  77529. }
  77530. declare module "babylonjs/Misc/deferred" {
  77531. /**
  77532. * Wrapper class for promise with external resolve and reject.
  77533. */
  77534. export class Deferred<T> {
  77535. /**
  77536. * The promise associated with this deferred object.
  77537. */
  77538. readonly promise: Promise<T>;
  77539. private _resolve;
  77540. private _reject;
  77541. /**
  77542. * The resolve method of the promise associated with this deferred object.
  77543. */
  77544. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77545. /**
  77546. * The reject method of the promise associated with this deferred object.
  77547. */
  77548. get reject(): (reason?: any) => void;
  77549. /**
  77550. * Constructor for this deferred object.
  77551. */
  77552. constructor();
  77553. }
  77554. }
  77555. declare module "babylonjs/Misc/meshExploder" {
  77556. import { Mesh } from "babylonjs/Meshes/mesh";
  77557. /**
  77558. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77559. */
  77560. export class MeshExploder {
  77561. private _centerMesh;
  77562. private _meshes;
  77563. private _meshesOrigins;
  77564. private _toCenterVectors;
  77565. private _scaledDirection;
  77566. private _newPosition;
  77567. private _centerPosition;
  77568. /**
  77569. * Explodes meshes from a center mesh.
  77570. * @param meshes The meshes to explode.
  77571. * @param centerMesh The mesh to be center of explosion.
  77572. */
  77573. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77574. private _setCenterMesh;
  77575. /**
  77576. * Get class name
  77577. * @returns "MeshExploder"
  77578. */
  77579. getClassName(): string;
  77580. /**
  77581. * "Exploded meshes"
  77582. * @returns Array of meshes with the centerMesh at index 0.
  77583. */
  77584. getMeshes(): Array<Mesh>;
  77585. /**
  77586. * Explodes meshes giving a specific direction
  77587. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77588. */
  77589. explode(direction?: number): void;
  77590. }
  77591. }
  77592. declare module "babylonjs/Misc/filesInput" {
  77593. import { Engine } from "babylonjs/Engines/engine";
  77594. import { Scene } from "babylonjs/scene";
  77595. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77596. import { Nullable } from "babylonjs/types";
  77597. /**
  77598. * Class used to help managing file picking and drag'n'drop
  77599. */
  77600. export class FilesInput {
  77601. /**
  77602. * List of files ready to be loaded
  77603. */
  77604. static get FilesToLoad(): {
  77605. [key: string]: File;
  77606. };
  77607. /**
  77608. * Callback called when a file is processed
  77609. */
  77610. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77611. private _engine;
  77612. private _currentScene;
  77613. private _sceneLoadedCallback;
  77614. private _progressCallback;
  77615. private _additionalRenderLoopLogicCallback;
  77616. private _textureLoadingCallback;
  77617. private _startingProcessingFilesCallback;
  77618. private _onReloadCallback;
  77619. private _errorCallback;
  77620. private _elementToMonitor;
  77621. private _sceneFileToLoad;
  77622. private _filesToLoad;
  77623. /**
  77624. * Creates a new FilesInput
  77625. * @param engine defines the rendering engine
  77626. * @param scene defines the hosting scene
  77627. * @param sceneLoadedCallback callback called when scene is loaded
  77628. * @param progressCallback callback called to track progress
  77629. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77630. * @param textureLoadingCallback callback called when a texture is loading
  77631. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77632. * @param onReloadCallback callback called when a reload is requested
  77633. * @param errorCallback callback call if an error occurs
  77634. */
  77635. 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>);
  77636. private _dragEnterHandler;
  77637. private _dragOverHandler;
  77638. private _dropHandler;
  77639. /**
  77640. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77641. * @param elementToMonitor defines the DOM element to track
  77642. */
  77643. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77644. /** Gets the current list of files to load */
  77645. get filesToLoad(): File[];
  77646. /**
  77647. * Release all associated resources
  77648. */
  77649. dispose(): void;
  77650. private renderFunction;
  77651. private drag;
  77652. private drop;
  77653. private _traverseFolder;
  77654. private _processFiles;
  77655. /**
  77656. * Load files from a drop event
  77657. * @param event defines the drop event to use as source
  77658. */
  77659. loadFiles(event: any): void;
  77660. private _processReload;
  77661. /**
  77662. * Reload the current scene from the loaded files
  77663. */
  77664. reload(): void;
  77665. }
  77666. }
  77667. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77668. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77669. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77670. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77671. }
  77672. declare module "babylonjs/Misc/sceneOptimizer" {
  77673. import { Scene, IDisposable } from "babylonjs/scene";
  77674. import { Observable } from "babylonjs/Misc/observable";
  77675. /**
  77676. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77677. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77678. */
  77679. export class SceneOptimization {
  77680. /**
  77681. * Defines the priority of this optimization (0 by default which means first in the list)
  77682. */
  77683. priority: number;
  77684. /**
  77685. * Gets a string describing the action executed by the current optimization
  77686. * @returns description string
  77687. */
  77688. getDescription(): string;
  77689. /**
  77690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77691. * @param scene defines the current scene where to apply this optimization
  77692. * @param optimizer defines the current optimizer
  77693. * @returns true if everything that can be done was applied
  77694. */
  77695. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77696. /**
  77697. * Creates the SceneOptimization object
  77698. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77699. * @param desc defines the description associated with the optimization
  77700. */
  77701. constructor(
  77702. /**
  77703. * Defines the priority of this optimization (0 by default which means first in the list)
  77704. */
  77705. priority?: number);
  77706. }
  77707. /**
  77708. * Defines an optimization used to reduce the size of render target textures
  77709. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77710. */
  77711. export class TextureOptimization extends SceneOptimization {
  77712. /**
  77713. * Defines the priority of this optimization (0 by default which means first in the list)
  77714. */
  77715. priority: number;
  77716. /**
  77717. * 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
  77718. */
  77719. maximumSize: number;
  77720. /**
  77721. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77722. */
  77723. step: number;
  77724. /**
  77725. * Gets a string describing the action executed by the current optimization
  77726. * @returns description string
  77727. */
  77728. getDescription(): string;
  77729. /**
  77730. * Creates the TextureOptimization object
  77731. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77732. * @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
  77733. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77734. */
  77735. constructor(
  77736. /**
  77737. * Defines the priority of this optimization (0 by default which means first in the list)
  77738. */
  77739. priority?: number,
  77740. /**
  77741. * 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
  77742. */
  77743. maximumSize?: number,
  77744. /**
  77745. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77746. */
  77747. step?: number);
  77748. /**
  77749. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77750. * @param scene defines the current scene where to apply this optimization
  77751. * @param optimizer defines the current optimizer
  77752. * @returns true if everything that can be done was applied
  77753. */
  77754. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77755. }
  77756. /**
  77757. * Defines an optimization used to increase or decrease the rendering resolution
  77758. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77759. */
  77760. export class HardwareScalingOptimization extends SceneOptimization {
  77761. /**
  77762. * Defines the priority of this optimization (0 by default which means first in the list)
  77763. */
  77764. priority: number;
  77765. /**
  77766. * Defines the maximum scale to use (2 by default)
  77767. */
  77768. maximumScale: number;
  77769. /**
  77770. * Defines the step to use between two passes (0.5 by default)
  77771. */
  77772. step: number;
  77773. private _currentScale;
  77774. private _directionOffset;
  77775. /**
  77776. * Gets a string describing the action executed by the current optimization
  77777. * @return description string
  77778. */
  77779. getDescription(): string;
  77780. /**
  77781. * Creates the HardwareScalingOptimization object
  77782. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77783. * @param maximumScale defines the maximum scale to use (2 by default)
  77784. * @param step defines the step to use between two passes (0.5 by default)
  77785. */
  77786. constructor(
  77787. /**
  77788. * Defines the priority of this optimization (0 by default which means first in the list)
  77789. */
  77790. priority?: number,
  77791. /**
  77792. * Defines the maximum scale to use (2 by default)
  77793. */
  77794. maximumScale?: number,
  77795. /**
  77796. * Defines the step to use between two passes (0.5 by default)
  77797. */
  77798. step?: number);
  77799. /**
  77800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77801. * @param scene defines the current scene where to apply this optimization
  77802. * @param optimizer defines the current optimizer
  77803. * @returns true if everything that can be done was applied
  77804. */
  77805. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77806. }
  77807. /**
  77808. * Defines an optimization used to remove shadows
  77809. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77810. */
  77811. export class ShadowsOptimization extends SceneOptimization {
  77812. /**
  77813. * Gets a string describing the action executed by the current optimization
  77814. * @return description string
  77815. */
  77816. getDescription(): string;
  77817. /**
  77818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77819. * @param scene defines the current scene where to apply this optimization
  77820. * @param optimizer defines the current optimizer
  77821. * @returns true if everything that can be done was applied
  77822. */
  77823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77824. }
  77825. /**
  77826. * Defines an optimization used to turn post-processes off
  77827. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77828. */
  77829. export class PostProcessesOptimization extends SceneOptimization {
  77830. /**
  77831. * Gets a string describing the action executed by the current optimization
  77832. * @return description string
  77833. */
  77834. getDescription(): string;
  77835. /**
  77836. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77837. * @param scene defines the current scene where to apply this optimization
  77838. * @param optimizer defines the current optimizer
  77839. * @returns true if everything that can be done was applied
  77840. */
  77841. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77842. }
  77843. /**
  77844. * Defines an optimization used to turn lens flares off
  77845. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77846. */
  77847. export class LensFlaresOptimization extends SceneOptimization {
  77848. /**
  77849. * Gets a string describing the action executed by the current optimization
  77850. * @return description string
  77851. */
  77852. getDescription(): string;
  77853. /**
  77854. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77855. * @param scene defines the current scene where to apply this optimization
  77856. * @param optimizer defines the current optimizer
  77857. * @returns true if everything that can be done was applied
  77858. */
  77859. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77860. }
  77861. /**
  77862. * Defines an optimization based on user defined callback.
  77863. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77864. */
  77865. export class CustomOptimization extends SceneOptimization {
  77866. /**
  77867. * Callback called to apply the custom optimization.
  77868. */
  77869. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77870. /**
  77871. * Callback called to get custom description
  77872. */
  77873. onGetDescription: () => string;
  77874. /**
  77875. * Gets a string describing the action executed by the current optimization
  77876. * @returns description string
  77877. */
  77878. getDescription(): string;
  77879. /**
  77880. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77881. * @param scene defines the current scene where to apply this optimization
  77882. * @param optimizer defines the current optimizer
  77883. * @returns true if everything that can be done was applied
  77884. */
  77885. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77886. }
  77887. /**
  77888. * Defines an optimization used to turn particles off
  77889. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77890. */
  77891. export class ParticlesOptimization extends SceneOptimization {
  77892. /**
  77893. * Gets a string describing the action executed by the current optimization
  77894. * @return description string
  77895. */
  77896. getDescription(): string;
  77897. /**
  77898. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77899. * @param scene defines the current scene where to apply this optimization
  77900. * @param optimizer defines the current optimizer
  77901. * @returns true if everything that can be done was applied
  77902. */
  77903. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77904. }
  77905. /**
  77906. * Defines an optimization used to turn render targets off
  77907. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77908. */
  77909. export class RenderTargetsOptimization extends SceneOptimization {
  77910. /**
  77911. * Gets a string describing the action executed by the current optimization
  77912. * @return description string
  77913. */
  77914. getDescription(): string;
  77915. /**
  77916. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77917. * @param scene defines the current scene where to apply this optimization
  77918. * @param optimizer defines the current optimizer
  77919. * @returns true if everything that can be done was applied
  77920. */
  77921. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77922. }
  77923. /**
  77924. * Defines an optimization used to merge meshes with compatible materials
  77925. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77926. */
  77927. export class MergeMeshesOptimization extends SceneOptimization {
  77928. private static _UpdateSelectionTree;
  77929. /**
  77930. * Gets or sets a boolean which defines if optimization octree has to be updated
  77931. */
  77932. static get UpdateSelectionTree(): boolean;
  77933. /**
  77934. * Gets or sets a boolean which defines if optimization octree has to be updated
  77935. */
  77936. static set UpdateSelectionTree(value: boolean);
  77937. /**
  77938. * Gets a string describing the action executed by the current optimization
  77939. * @return description string
  77940. */
  77941. getDescription(): string;
  77942. private _canBeMerged;
  77943. /**
  77944. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77945. * @param scene defines the current scene where to apply this optimization
  77946. * @param optimizer defines the current optimizer
  77947. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77948. * @returns true if everything that can be done was applied
  77949. */
  77950. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77951. }
  77952. /**
  77953. * Defines a list of options used by SceneOptimizer
  77954. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77955. */
  77956. export class SceneOptimizerOptions {
  77957. /**
  77958. * Defines the target frame rate to reach (60 by default)
  77959. */
  77960. targetFrameRate: number;
  77961. /**
  77962. * Defines the interval between two checkes (2000ms by default)
  77963. */
  77964. trackerDuration: number;
  77965. /**
  77966. * Gets the list of optimizations to apply
  77967. */
  77968. optimizations: SceneOptimization[];
  77969. /**
  77970. * Creates a new list of options used by SceneOptimizer
  77971. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77972. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77973. */
  77974. constructor(
  77975. /**
  77976. * Defines the target frame rate to reach (60 by default)
  77977. */
  77978. targetFrameRate?: number,
  77979. /**
  77980. * Defines the interval between two checkes (2000ms by default)
  77981. */
  77982. trackerDuration?: number);
  77983. /**
  77984. * Add a new optimization
  77985. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77986. * @returns the current SceneOptimizerOptions
  77987. */
  77988. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77989. /**
  77990. * Add a new custom optimization
  77991. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77992. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77993. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77994. * @returns the current SceneOptimizerOptions
  77995. */
  77996. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77997. /**
  77998. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77999. * @param targetFrameRate defines the target frame rate (60 by default)
  78000. * @returns a SceneOptimizerOptions object
  78001. */
  78002. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78003. /**
  78004. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78005. * @param targetFrameRate defines the target frame rate (60 by default)
  78006. * @returns a SceneOptimizerOptions object
  78007. */
  78008. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78009. /**
  78010. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78011. * @param targetFrameRate defines the target frame rate (60 by default)
  78012. * @returns a SceneOptimizerOptions object
  78013. */
  78014. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78015. }
  78016. /**
  78017. * Class used to run optimizations in order to reach a target frame rate
  78018. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78019. */
  78020. export class SceneOptimizer implements IDisposable {
  78021. private _isRunning;
  78022. private _options;
  78023. private _scene;
  78024. private _currentPriorityLevel;
  78025. private _targetFrameRate;
  78026. private _trackerDuration;
  78027. private _currentFrameRate;
  78028. private _sceneDisposeObserver;
  78029. private _improvementMode;
  78030. /**
  78031. * Defines an observable called when the optimizer reaches the target frame rate
  78032. */
  78033. onSuccessObservable: Observable<SceneOptimizer>;
  78034. /**
  78035. * Defines an observable called when the optimizer enables an optimization
  78036. */
  78037. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78038. /**
  78039. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78040. */
  78041. onFailureObservable: Observable<SceneOptimizer>;
  78042. /**
  78043. * Gets a boolean indicating if the optimizer is in improvement mode
  78044. */
  78045. get isInImprovementMode(): boolean;
  78046. /**
  78047. * Gets the current priority level (0 at start)
  78048. */
  78049. get currentPriorityLevel(): number;
  78050. /**
  78051. * Gets the current frame rate checked by the SceneOptimizer
  78052. */
  78053. get currentFrameRate(): number;
  78054. /**
  78055. * Gets or sets the current target frame rate (60 by default)
  78056. */
  78057. get targetFrameRate(): number;
  78058. /**
  78059. * Gets or sets the current target frame rate (60 by default)
  78060. */
  78061. set targetFrameRate(value: number);
  78062. /**
  78063. * Gets or sets the current interval between two checks (every 2000ms by default)
  78064. */
  78065. get trackerDuration(): number;
  78066. /**
  78067. * Gets or sets the current interval between two checks (every 2000ms by default)
  78068. */
  78069. set trackerDuration(value: number);
  78070. /**
  78071. * Gets the list of active optimizations
  78072. */
  78073. get optimizations(): SceneOptimization[];
  78074. /**
  78075. * Creates a new SceneOptimizer
  78076. * @param scene defines the scene to work on
  78077. * @param options defines the options to use with the SceneOptimizer
  78078. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78079. * @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)
  78080. */
  78081. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78082. /**
  78083. * Stops the current optimizer
  78084. */
  78085. stop(): void;
  78086. /**
  78087. * Reset the optimizer to initial step (current priority level = 0)
  78088. */
  78089. reset(): void;
  78090. /**
  78091. * Start the optimizer. By default it will try to reach a specific framerate
  78092. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78093. */
  78094. start(): void;
  78095. private _checkCurrentState;
  78096. /**
  78097. * Release all resources
  78098. */
  78099. dispose(): void;
  78100. /**
  78101. * Helper function to create a SceneOptimizer with one single line of code
  78102. * @param scene defines the scene to work on
  78103. * @param options defines the options to use with the SceneOptimizer
  78104. * @param onSuccess defines a callback to call on success
  78105. * @param onFailure defines a callback to call on failure
  78106. * @returns the new SceneOptimizer object
  78107. */
  78108. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78109. }
  78110. }
  78111. declare module "babylonjs/Misc/sceneSerializer" {
  78112. import { Scene } from "babylonjs/scene";
  78113. /**
  78114. * Class used to serialize a scene into a string
  78115. */
  78116. export class SceneSerializer {
  78117. /**
  78118. * Clear cache used by a previous serialization
  78119. */
  78120. static ClearCache(): void;
  78121. /**
  78122. * Serialize a scene into a JSON compatible object
  78123. * @param scene defines the scene to serialize
  78124. * @returns a JSON compatible object
  78125. */
  78126. static Serialize(scene: Scene): any;
  78127. /**
  78128. * Serialize a mesh into a JSON compatible object
  78129. * @param toSerialize defines the mesh to serialize
  78130. * @param withParents defines if parents must be serialized as well
  78131. * @param withChildren defines if children must be serialized as well
  78132. * @returns a JSON compatible object
  78133. */
  78134. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78135. }
  78136. }
  78137. declare module "babylonjs/Misc/textureTools" {
  78138. import { Texture } from "babylonjs/Materials/Textures/texture";
  78139. /**
  78140. * Class used to host texture specific utilities
  78141. */
  78142. export class TextureTools {
  78143. /**
  78144. * Uses the GPU to create a copy texture rescaled at a given size
  78145. * @param texture Texture to copy from
  78146. * @param width defines the desired width
  78147. * @param height defines the desired height
  78148. * @param useBilinearMode defines if bilinear mode has to be used
  78149. * @return the generated texture
  78150. */
  78151. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78152. }
  78153. }
  78154. declare module "babylonjs/Misc/videoRecorder" {
  78155. import { Nullable } from "babylonjs/types";
  78156. import { Engine } from "babylonjs/Engines/engine";
  78157. /**
  78158. * This represents the different options available for the video capture.
  78159. */
  78160. export interface VideoRecorderOptions {
  78161. /** Defines the mime type of the video. */
  78162. mimeType: string;
  78163. /** Defines the FPS the video should be recorded at. */
  78164. fps: number;
  78165. /** Defines the chunk size for the recording data. */
  78166. recordChunckSize: number;
  78167. /** The audio tracks to attach to the recording. */
  78168. audioTracks?: MediaStreamTrack[];
  78169. }
  78170. /**
  78171. * This can help with recording videos from BabylonJS.
  78172. * This is based on the available WebRTC functionalities of the browser.
  78173. *
  78174. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78175. */
  78176. export class VideoRecorder {
  78177. private static readonly _defaultOptions;
  78178. /**
  78179. * Returns whether or not the VideoRecorder is available in your browser.
  78180. * @param engine Defines the Babylon Engine.
  78181. * @returns true if supported otherwise false.
  78182. */
  78183. static IsSupported(engine: Engine): boolean;
  78184. private readonly _options;
  78185. private _canvas;
  78186. private _mediaRecorder;
  78187. private _recordedChunks;
  78188. private _fileName;
  78189. private _resolve;
  78190. private _reject;
  78191. /**
  78192. * True when a recording is already in progress.
  78193. */
  78194. get isRecording(): boolean;
  78195. /**
  78196. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78197. * @param engine Defines the BabylonJS Engine you wish to record.
  78198. * @param options Defines options that can be used to customize the capture.
  78199. */
  78200. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78201. /**
  78202. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78203. */
  78204. stopRecording(): void;
  78205. /**
  78206. * Starts recording the canvas for a max duration specified in parameters.
  78207. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78208. * If null no automatic download will start and you can rely on the promise to get the data back.
  78209. * @param maxDuration Defines the maximum recording time in seconds.
  78210. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78211. * @return A promise callback at the end of the recording with the video data in Blob.
  78212. */
  78213. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78214. /**
  78215. * Releases internal resources used during the recording.
  78216. */
  78217. dispose(): void;
  78218. private _handleDataAvailable;
  78219. private _handleError;
  78220. private _handleStop;
  78221. }
  78222. }
  78223. declare module "babylonjs/Misc/screenshotTools" {
  78224. import { Camera } from "babylonjs/Cameras/camera";
  78225. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78226. import { Engine } from "babylonjs/Engines/engine";
  78227. /**
  78228. * Class containing a set of static utilities functions for screenshots
  78229. */
  78230. export class ScreenshotTools {
  78231. /**
  78232. * Captures a screenshot of the current rendering
  78233. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78234. * @param engine defines the rendering engine
  78235. * @param camera defines the source camera
  78236. * @param size This parameter can be set to a single number or to an object with the
  78237. * following (optional) properties: precision, width, height. If a single number is passed,
  78238. * it will be used for both width and height. If an object is passed, the screenshot size
  78239. * will be derived from the parameters. The precision property is a multiplier allowing
  78240. * rendering at a higher or lower resolution
  78241. * @param successCallback defines the callback receives a single parameter which contains the
  78242. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78243. * src parameter of an <img> to display it
  78244. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78245. * Check your browser for supported MIME types
  78246. */
  78247. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78248. /**
  78249. * Captures a screenshot of the current rendering
  78250. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78251. * @param engine defines the rendering engine
  78252. * @param camera defines the source camera
  78253. * @param size This parameter can be set to a single number or to an object with the
  78254. * following (optional) properties: precision, width, height. If a single number is passed,
  78255. * it will be used for both width and height. If an object is passed, the screenshot size
  78256. * will be derived from the parameters. The precision property is a multiplier allowing
  78257. * rendering at a higher or lower resolution
  78258. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78259. * Check your browser for supported MIME types
  78260. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78261. * to the src parameter of an <img> to display it
  78262. */
  78263. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78264. /**
  78265. * Generates an image screenshot from the specified camera.
  78266. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78267. * @param engine The engine to use for rendering
  78268. * @param camera The camera to use for rendering
  78269. * @param size This parameter can be set to a single number or to an object with the
  78270. * following (optional) properties: precision, width, height. If a single number is passed,
  78271. * it will be used for both width and height. If an object is passed, the screenshot size
  78272. * will be derived from the parameters. The precision property is a multiplier allowing
  78273. * rendering at a higher or lower resolution
  78274. * @param successCallback The callback receives a single parameter which contains the
  78275. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78276. * src parameter of an <img> to display it
  78277. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78278. * Check your browser for supported MIME types
  78279. * @param samples Texture samples (default: 1)
  78280. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78281. * @param fileName A name for for the downloaded file.
  78282. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78283. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78284. */
  78285. 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;
  78286. /**
  78287. * Generates an image screenshot from the specified camera.
  78288. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78289. * @param engine The engine to use for rendering
  78290. * @param camera The camera to use for rendering
  78291. * @param size This parameter can be set to a single number or to an object with the
  78292. * following (optional) properties: precision, width, height. If a single number is passed,
  78293. * it will be used for both width and height. If an object is passed, the screenshot size
  78294. * will be derived from the parameters. The precision property is a multiplier allowing
  78295. * rendering at a higher or lower resolution
  78296. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78297. * Check your browser for supported MIME types
  78298. * @param samples Texture samples (default: 1)
  78299. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78300. * @param fileName A name for for the downloaded file.
  78301. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78302. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78303. * to the src parameter of an <img> to display it
  78304. */
  78305. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78306. /**
  78307. * Gets height and width for screenshot size
  78308. * @private
  78309. */
  78310. private static _getScreenshotSize;
  78311. }
  78312. }
  78313. declare module "babylonjs/Misc/dataReader" {
  78314. /**
  78315. * Interface for a data buffer
  78316. */
  78317. export interface IDataBuffer {
  78318. /**
  78319. * Reads bytes from the data buffer.
  78320. * @param byteOffset The byte offset to read
  78321. * @param byteLength The byte length to read
  78322. * @returns A promise that resolves when the bytes are read
  78323. */
  78324. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78325. /**
  78326. * The byte length of the buffer.
  78327. */
  78328. readonly byteLength: number;
  78329. }
  78330. /**
  78331. * Utility class for reading from a data buffer
  78332. */
  78333. export class DataReader {
  78334. /**
  78335. * The data buffer associated with this data reader.
  78336. */
  78337. readonly buffer: IDataBuffer;
  78338. /**
  78339. * The current byte offset from the beginning of the data buffer.
  78340. */
  78341. byteOffset: number;
  78342. private _dataView;
  78343. private _dataByteOffset;
  78344. /**
  78345. * Constructor
  78346. * @param buffer The buffer to read
  78347. */
  78348. constructor(buffer: IDataBuffer);
  78349. /**
  78350. * Loads the given byte length.
  78351. * @param byteLength The byte length to load
  78352. * @returns A promise that resolves when the load is complete
  78353. */
  78354. loadAsync(byteLength: number): Promise<void>;
  78355. /**
  78356. * Read a unsigned 32-bit integer from the currently loaded data range.
  78357. * @returns The 32-bit integer read
  78358. */
  78359. readUint32(): number;
  78360. /**
  78361. * Read a byte array from the currently loaded data range.
  78362. * @param byteLength The byte length to read
  78363. * @returns The byte array read
  78364. */
  78365. readUint8Array(byteLength: number): Uint8Array;
  78366. /**
  78367. * Read a string from the currently loaded data range.
  78368. * @param byteLength The byte length to read
  78369. * @returns The string read
  78370. */
  78371. readString(byteLength: number): string;
  78372. /**
  78373. * Skips the given byte length the currently loaded data range.
  78374. * @param byteLength The byte length to skip
  78375. */
  78376. skipBytes(byteLength: number): void;
  78377. }
  78378. }
  78379. declare module "babylonjs/Misc/dataStorage" {
  78380. /**
  78381. * Class for storing data to local storage if available or in-memory storage otherwise
  78382. */
  78383. export class DataStorage {
  78384. private static _Storage;
  78385. private static _GetStorage;
  78386. /**
  78387. * Reads a string from the data storage
  78388. * @param key The key to read
  78389. * @param defaultValue The value if the key doesn't exist
  78390. * @returns The string value
  78391. */
  78392. static ReadString(key: string, defaultValue: string): string;
  78393. /**
  78394. * Writes a string to the data storage
  78395. * @param key The key to write
  78396. * @param value The value to write
  78397. */
  78398. static WriteString(key: string, value: string): void;
  78399. /**
  78400. * Reads a boolean from the data storage
  78401. * @param key The key to read
  78402. * @param defaultValue The value if the key doesn't exist
  78403. * @returns The boolean value
  78404. */
  78405. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78406. /**
  78407. * Writes a boolean to the data storage
  78408. * @param key The key to write
  78409. * @param value The value to write
  78410. */
  78411. static WriteBoolean(key: string, value: boolean): void;
  78412. /**
  78413. * Reads a number from the data storage
  78414. * @param key The key to read
  78415. * @param defaultValue The value if the key doesn't exist
  78416. * @returns The number value
  78417. */
  78418. static ReadNumber(key: string, defaultValue: number): number;
  78419. /**
  78420. * Writes a number to the data storage
  78421. * @param key The key to write
  78422. * @param value The value to write
  78423. */
  78424. static WriteNumber(key: string, value: number): void;
  78425. }
  78426. }
  78427. declare module "babylonjs/Misc/sceneRecorder" {
  78428. import { Scene } from "babylonjs/scene";
  78429. /**
  78430. * Class used to record delta files between 2 scene states
  78431. */
  78432. export class SceneRecorder {
  78433. private _trackedScene;
  78434. private _savedJSON;
  78435. /**
  78436. * Track a given scene. This means the current scene state will be considered the original state
  78437. * @param scene defines the scene to track
  78438. */
  78439. track(scene: Scene): void;
  78440. /**
  78441. * Get the delta between current state and original state
  78442. * @returns a string containing the delta
  78443. */
  78444. getDelta(): any;
  78445. private _compareArray;
  78446. private _compareObjects;
  78447. private _compareCollections;
  78448. private static GetShadowGeneratorById;
  78449. /**
  78450. * Apply a given delta to a given scene
  78451. * @param deltaJSON defines the JSON containing the delta
  78452. * @param scene defines the scene to apply the delta to
  78453. */
  78454. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78455. private static _ApplyPropertiesToEntity;
  78456. private static _ApplyDeltaForEntity;
  78457. }
  78458. }
  78459. declare module "babylonjs/Misc/index" {
  78460. export * from "babylonjs/Misc/andOrNotEvaluator";
  78461. export * from "babylonjs/Misc/assetsManager";
  78462. export * from "babylonjs/Misc/basis";
  78463. export * from "babylonjs/Misc/dds";
  78464. export * from "babylonjs/Misc/decorators";
  78465. export * from "babylonjs/Misc/deferred";
  78466. export * from "babylonjs/Misc/environmentTextureTools";
  78467. export * from "babylonjs/Misc/meshExploder";
  78468. export * from "babylonjs/Misc/filesInput";
  78469. export * from "babylonjs/Misc/HighDynamicRange/index";
  78470. export * from "babylonjs/Misc/khronosTextureContainer";
  78471. export * from "babylonjs/Misc/observable";
  78472. export * from "babylonjs/Misc/performanceMonitor";
  78473. export * from "babylonjs/Misc/promise";
  78474. export * from "babylonjs/Misc/sceneOptimizer";
  78475. export * from "babylonjs/Misc/sceneSerializer";
  78476. export * from "babylonjs/Misc/smartArray";
  78477. export * from "babylonjs/Misc/stringDictionary";
  78478. export * from "babylonjs/Misc/tags";
  78479. export * from "babylonjs/Misc/textureTools";
  78480. export * from "babylonjs/Misc/tga";
  78481. export * from "babylonjs/Misc/tools";
  78482. export * from "babylonjs/Misc/videoRecorder";
  78483. export * from "babylonjs/Misc/virtualJoystick";
  78484. export * from "babylonjs/Misc/workerPool";
  78485. export * from "babylonjs/Misc/logger";
  78486. export * from "babylonjs/Misc/typeStore";
  78487. export * from "babylonjs/Misc/filesInputStore";
  78488. export * from "babylonjs/Misc/deepCopier";
  78489. export * from "babylonjs/Misc/pivotTools";
  78490. export * from "babylonjs/Misc/precisionDate";
  78491. export * from "babylonjs/Misc/screenshotTools";
  78492. export * from "babylonjs/Misc/typeStore";
  78493. export * from "babylonjs/Misc/webRequest";
  78494. export * from "babylonjs/Misc/iInspectable";
  78495. export * from "babylonjs/Misc/brdfTextureTools";
  78496. export * from "babylonjs/Misc/rgbdTextureTools";
  78497. export * from "babylonjs/Misc/gradients";
  78498. export * from "babylonjs/Misc/perfCounter";
  78499. export * from "babylonjs/Misc/fileRequest";
  78500. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78501. export * from "babylonjs/Misc/retryStrategy";
  78502. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78503. export * from "babylonjs/Misc/canvasGenerator";
  78504. export * from "babylonjs/Misc/fileTools";
  78505. export * from "babylonjs/Misc/stringTools";
  78506. export * from "babylonjs/Misc/dataReader";
  78507. export * from "babylonjs/Misc/minMaxReducer";
  78508. export * from "babylonjs/Misc/depthReducer";
  78509. export * from "babylonjs/Misc/dataStorage";
  78510. export * from "babylonjs/Misc/sceneRecorder";
  78511. export * from "babylonjs/Misc/khronosTextureContainer2";
  78512. }
  78513. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78514. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78515. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78516. import { Observable } from "babylonjs/Misc/observable";
  78517. import { Matrix } from "babylonjs/Maths/math.vector";
  78518. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78519. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78520. /**
  78521. * An interface for all Hit test features
  78522. */
  78523. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78524. /**
  78525. * Triggered when new babylon (transformed) hit test results are available
  78526. */
  78527. onHitTestResultObservable: Observable<T[]>;
  78528. }
  78529. /**
  78530. * Options used for hit testing
  78531. */
  78532. export interface IWebXRLegacyHitTestOptions {
  78533. /**
  78534. * Only test when user interacted with the scene. Default - hit test every frame
  78535. */
  78536. testOnPointerDownOnly?: boolean;
  78537. /**
  78538. * The node to use to transform the local results to world coordinates
  78539. */
  78540. worldParentNode?: TransformNode;
  78541. }
  78542. /**
  78543. * Interface defining the babylon result of raycasting/hit-test
  78544. */
  78545. export interface IWebXRLegacyHitResult {
  78546. /**
  78547. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78548. */
  78549. transformationMatrix: Matrix;
  78550. /**
  78551. * The native hit test result
  78552. */
  78553. xrHitResult: XRHitResult | XRHitTestResult;
  78554. }
  78555. /**
  78556. * The currently-working hit-test module.
  78557. * Hit test (or Ray-casting) is used to interact with the real world.
  78558. * For further information read here - https://github.com/immersive-web/hit-test
  78559. */
  78560. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78561. /**
  78562. * options to use when constructing this feature
  78563. */
  78564. readonly options: IWebXRLegacyHitTestOptions;
  78565. private _direction;
  78566. private _mat;
  78567. private _onSelectEnabled;
  78568. private _origin;
  78569. /**
  78570. * The module's name
  78571. */
  78572. static readonly Name: string;
  78573. /**
  78574. * The (Babylon) version of this module.
  78575. * This is an integer representing the implementation version.
  78576. * This number does not correspond to the WebXR specs version
  78577. */
  78578. static readonly Version: number;
  78579. /**
  78580. * Populated with the last native XR Hit Results
  78581. */
  78582. lastNativeXRHitResults: XRHitResult[];
  78583. /**
  78584. * Triggered when new babylon (transformed) hit test results are available
  78585. */
  78586. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78587. /**
  78588. * Creates a new instance of the (legacy version) hit test feature
  78589. * @param _xrSessionManager an instance of WebXRSessionManager
  78590. * @param options options to use when constructing this feature
  78591. */
  78592. constructor(_xrSessionManager: WebXRSessionManager,
  78593. /**
  78594. * options to use when constructing this feature
  78595. */
  78596. options?: IWebXRLegacyHitTestOptions);
  78597. /**
  78598. * execute a hit test with an XR Ray
  78599. *
  78600. * @param xrSession a native xrSession that will execute this hit test
  78601. * @param xrRay the ray (position and direction) to use for ray-casting
  78602. * @param referenceSpace native XR reference space to use for the hit-test
  78603. * @param filter filter function that will filter the results
  78604. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78605. */
  78606. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78607. /**
  78608. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78609. * @param event the (select) event to use to select with
  78610. * @param referenceSpace the reference space to use for this hit test
  78611. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78612. */
  78613. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78614. /**
  78615. * attach this feature
  78616. * Will usually be called by the features manager
  78617. *
  78618. * @returns true if successful.
  78619. */
  78620. attach(): boolean;
  78621. /**
  78622. * detach this feature.
  78623. * Will usually be called by the features manager
  78624. *
  78625. * @returns true if successful.
  78626. */
  78627. detach(): boolean;
  78628. /**
  78629. * Dispose this feature and all of the resources attached
  78630. */
  78631. dispose(): void;
  78632. protected _onXRFrame(frame: XRFrame): void;
  78633. private _onHitTestResults;
  78634. private _onSelect;
  78635. }
  78636. }
  78637. declare module "babylonjs/XR/features/WebXRHitTest" {
  78638. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78639. import { Observable } from "babylonjs/Misc/observable";
  78640. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78641. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78642. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78643. /**
  78644. * Options used for hit testing (version 2)
  78645. */
  78646. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78647. /**
  78648. * Do not create a permanent hit test. Will usually be used when only
  78649. * transient inputs are needed.
  78650. */
  78651. disablePermanentHitTest?: boolean;
  78652. /**
  78653. * Enable transient (for example touch-based) hit test inspections
  78654. */
  78655. enableTransientHitTest?: boolean;
  78656. /**
  78657. * Offset ray for the permanent hit test
  78658. */
  78659. offsetRay?: Vector3;
  78660. /**
  78661. * Offset ray for the transient hit test
  78662. */
  78663. transientOffsetRay?: Vector3;
  78664. /**
  78665. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78666. */
  78667. useReferenceSpace?: boolean;
  78668. /**
  78669. * Override the default entity type(s) of the hit-test result
  78670. */
  78671. entityTypes?: XRHitTestTrackableType[];
  78672. }
  78673. /**
  78674. * Interface defining the babylon result of hit-test
  78675. */
  78676. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78677. /**
  78678. * The input source that generated this hit test (if transient)
  78679. */
  78680. inputSource?: XRInputSource;
  78681. /**
  78682. * Is this a transient hit test
  78683. */
  78684. isTransient?: boolean;
  78685. /**
  78686. * Position of the hit test result
  78687. */
  78688. position: Vector3;
  78689. /**
  78690. * Rotation of the hit test result
  78691. */
  78692. rotationQuaternion: Quaternion;
  78693. /**
  78694. * The native hit test result
  78695. */
  78696. xrHitResult: XRHitTestResult;
  78697. }
  78698. /**
  78699. * The currently-working hit-test module.
  78700. * Hit test (or Ray-casting) is used to interact with the real world.
  78701. * For further information read here - https://github.com/immersive-web/hit-test
  78702. *
  78703. * Tested on chrome (mobile) 80.
  78704. */
  78705. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78706. /**
  78707. * options to use when constructing this feature
  78708. */
  78709. readonly options: IWebXRHitTestOptions;
  78710. private _tmpMat;
  78711. private _tmpPos;
  78712. private _tmpQuat;
  78713. private _transientXrHitTestSource;
  78714. private _xrHitTestSource;
  78715. private initHitTestSource;
  78716. /**
  78717. * The module's name
  78718. */
  78719. static readonly Name: string;
  78720. /**
  78721. * The (Babylon) version of this module.
  78722. * This is an integer representing the implementation version.
  78723. * This number does not correspond to the WebXR specs version
  78724. */
  78725. static readonly Version: number;
  78726. /**
  78727. * When set to true, each hit test will have its own position/rotation objects
  78728. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78729. * the developers will clone them or copy them as they see fit.
  78730. */
  78731. autoCloneTransformation: boolean;
  78732. /**
  78733. * Triggered when new babylon (transformed) hit test results are available
  78734. * Note - this will be called when results come back from the device. It can be an empty array!!
  78735. */
  78736. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78737. /**
  78738. * Use this to temporarily pause hit test checks.
  78739. */
  78740. paused: boolean;
  78741. /**
  78742. * Creates a new instance of the hit test feature
  78743. * @param _xrSessionManager an instance of WebXRSessionManager
  78744. * @param options options to use when constructing this feature
  78745. */
  78746. constructor(_xrSessionManager: WebXRSessionManager,
  78747. /**
  78748. * options to use when constructing this feature
  78749. */
  78750. options?: IWebXRHitTestOptions);
  78751. /**
  78752. * attach this feature
  78753. * Will usually be called by the features manager
  78754. *
  78755. * @returns true if successful.
  78756. */
  78757. attach(): boolean;
  78758. /**
  78759. * detach this feature.
  78760. * Will usually be called by the features manager
  78761. *
  78762. * @returns true if successful.
  78763. */
  78764. detach(): boolean;
  78765. /**
  78766. * Dispose this feature and all of the resources attached
  78767. */
  78768. dispose(): void;
  78769. protected _onXRFrame(frame: XRFrame): void;
  78770. private _processWebXRHitTestResult;
  78771. }
  78772. }
  78773. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78774. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78775. import { Observable } from "babylonjs/Misc/observable";
  78776. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78777. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78778. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78779. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78780. /**
  78781. * Configuration options of the anchor system
  78782. */
  78783. export interface IWebXRAnchorSystemOptions {
  78784. /**
  78785. * a node that will be used to convert local to world coordinates
  78786. */
  78787. worldParentNode?: TransformNode;
  78788. /**
  78789. * If set to true a reference of the created anchors will be kept until the next session starts
  78790. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78791. */
  78792. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78793. }
  78794. /**
  78795. * A babylon container for an XR Anchor
  78796. */
  78797. export interface IWebXRAnchor {
  78798. /**
  78799. * A babylon-assigned ID for this anchor
  78800. */
  78801. id: number;
  78802. /**
  78803. * Transformation matrix to apply to an object attached to this anchor
  78804. */
  78805. transformationMatrix: Matrix;
  78806. /**
  78807. * The native anchor object
  78808. */
  78809. xrAnchor: XRAnchor;
  78810. /**
  78811. * if defined, this object will be constantly updated by the anchor's position and rotation
  78812. */
  78813. attachedNode?: TransformNode;
  78814. }
  78815. /**
  78816. * An implementation of the anchor system for WebXR.
  78817. * For further information see https://github.com/immersive-web/anchors/
  78818. */
  78819. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78820. private _options;
  78821. private _lastFrameDetected;
  78822. private _trackedAnchors;
  78823. private _referenceSpaceForFrameAnchors;
  78824. private _futureAnchors;
  78825. /**
  78826. * The module's name
  78827. */
  78828. static readonly Name: string;
  78829. /**
  78830. * The (Babylon) version of this module.
  78831. * This is an integer representing the implementation version.
  78832. * This number does not correspond to the WebXR specs version
  78833. */
  78834. static readonly Version: number;
  78835. /**
  78836. * Observers registered here will be executed when a new anchor was added to the session
  78837. */
  78838. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78839. /**
  78840. * Observers registered here will be executed when an anchor was removed from the session
  78841. */
  78842. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78843. /**
  78844. * Observers registered here will be executed when an existing anchor updates
  78845. * This can execute N times every frame
  78846. */
  78847. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78848. /**
  78849. * Set the reference space to use for anchor creation, when not using a hit test.
  78850. * Will default to the session's reference space if not defined
  78851. */
  78852. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78853. /**
  78854. * constructs a new anchor system
  78855. * @param _xrSessionManager an instance of WebXRSessionManager
  78856. * @param _options configuration object for this feature
  78857. */
  78858. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78859. private _tmpVector;
  78860. private _tmpQuaternion;
  78861. private _populateTmpTransformation;
  78862. /**
  78863. * Create a new anchor point using a hit test result at a specific point in the scene
  78864. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78865. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78866. *
  78867. * @param hitTestResult The hit test result to use for this anchor creation
  78868. * @param position an optional position offset for this anchor
  78869. * @param rotationQuaternion an optional rotation offset for this anchor
  78870. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78871. */
  78872. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78873. /**
  78874. * Add a new anchor at a specific position and rotation
  78875. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78876. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78877. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78878. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78879. *
  78880. * @param position the position in which to add an anchor
  78881. * @param rotationQuaternion an optional rotation for the anchor transformation
  78882. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78883. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78884. */
  78885. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78886. /**
  78887. * detach this feature.
  78888. * Will usually be called by the features manager
  78889. *
  78890. * @returns true if successful.
  78891. */
  78892. detach(): boolean;
  78893. /**
  78894. * Dispose this feature and all of the resources attached
  78895. */
  78896. dispose(): void;
  78897. protected _onXRFrame(frame: XRFrame): void;
  78898. /**
  78899. * avoiding using Array.find for global support.
  78900. * @param xrAnchor the plane to find in the array
  78901. */
  78902. private _findIndexInAnchorArray;
  78903. private _updateAnchorWithXRFrame;
  78904. private _createAnchorAtTransformation;
  78905. }
  78906. }
  78907. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78908. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78909. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78910. import { Observable } from "babylonjs/Misc/observable";
  78911. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78912. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78913. /**
  78914. * Options used in the plane detector module
  78915. */
  78916. export interface IWebXRPlaneDetectorOptions {
  78917. /**
  78918. * The node to use to transform the local results to world coordinates
  78919. */
  78920. worldParentNode?: TransformNode;
  78921. /**
  78922. * If set to true a reference of the created planes will be kept until the next session starts
  78923. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78924. */
  78925. doNotRemovePlanesOnSessionEnded?: boolean;
  78926. }
  78927. /**
  78928. * A babylon interface for a WebXR plane.
  78929. * A Plane is actually a polygon, built from N points in space
  78930. *
  78931. * Supported in chrome 79, not supported in canary 81 ATM
  78932. */
  78933. export interface IWebXRPlane {
  78934. /**
  78935. * a babylon-assigned ID for this polygon
  78936. */
  78937. id: number;
  78938. /**
  78939. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78940. */
  78941. polygonDefinition: Array<Vector3>;
  78942. /**
  78943. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78944. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78945. */
  78946. transformationMatrix: Matrix;
  78947. /**
  78948. * the native xr-plane object
  78949. */
  78950. xrPlane: XRPlane;
  78951. }
  78952. /**
  78953. * The plane detector is used to detect planes in the real world when in AR
  78954. * For more information see https://github.com/immersive-web/real-world-geometry/
  78955. */
  78956. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78957. private _options;
  78958. private _detectedPlanes;
  78959. private _enabled;
  78960. private _lastFrameDetected;
  78961. /**
  78962. * The module's name
  78963. */
  78964. static readonly Name: string;
  78965. /**
  78966. * The (Babylon) version of this module.
  78967. * This is an integer representing the implementation version.
  78968. * This number does not correspond to the WebXR specs version
  78969. */
  78970. static readonly Version: number;
  78971. /**
  78972. * Observers registered here will be executed when a new plane was added to the session
  78973. */
  78974. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78975. /**
  78976. * Observers registered here will be executed when a plane is no longer detected in the session
  78977. */
  78978. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78979. /**
  78980. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78981. * This can execute N times every frame
  78982. */
  78983. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78984. /**
  78985. * construct a new Plane Detector
  78986. * @param _xrSessionManager an instance of xr Session manager
  78987. * @param _options configuration to use when constructing this feature
  78988. */
  78989. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78990. /**
  78991. * detach this feature.
  78992. * Will usually be called by the features manager
  78993. *
  78994. * @returns true if successful.
  78995. */
  78996. detach(): boolean;
  78997. /**
  78998. * Dispose this feature and all of the resources attached
  78999. */
  79000. dispose(): void;
  79001. protected _onXRFrame(frame: XRFrame): void;
  79002. private _init;
  79003. private _updatePlaneWithXRPlane;
  79004. /**
  79005. * avoiding using Array.find for global support.
  79006. * @param xrPlane the plane to find in the array
  79007. */
  79008. private findIndexInPlaneArray;
  79009. }
  79010. }
  79011. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79012. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79014. import { Observable } from "babylonjs/Misc/observable";
  79015. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79016. /**
  79017. * Options interface for the background remover plugin
  79018. */
  79019. export interface IWebXRBackgroundRemoverOptions {
  79020. /**
  79021. * Further background meshes to disable when entering AR
  79022. */
  79023. backgroundMeshes?: AbstractMesh[];
  79024. /**
  79025. * flags to configure the removal of the environment helper.
  79026. * If not set, the entire background will be removed. If set, flags should be set as well.
  79027. */
  79028. environmentHelperRemovalFlags?: {
  79029. /**
  79030. * Should the skybox be removed (default false)
  79031. */
  79032. skyBox?: boolean;
  79033. /**
  79034. * Should the ground be removed (default false)
  79035. */
  79036. ground?: boolean;
  79037. };
  79038. /**
  79039. * don't disable the environment helper
  79040. */
  79041. ignoreEnvironmentHelper?: boolean;
  79042. }
  79043. /**
  79044. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79045. */
  79046. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79047. /**
  79048. * read-only options to be used in this module
  79049. */
  79050. readonly options: IWebXRBackgroundRemoverOptions;
  79051. /**
  79052. * The module's name
  79053. */
  79054. static readonly Name: string;
  79055. /**
  79056. * The (Babylon) version of this module.
  79057. * This is an integer representing the implementation version.
  79058. * This number does not correspond to the WebXR specs version
  79059. */
  79060. static readonly Version: number;
  79061. /**
  79062. * registered observers will be triggered when the background state changes
  79063. */
  79064. onBackgroundStateChangedObservable: Observable<boolean>;
  79065. /**
  79066. * constructs a new background remover module
  79067. * @param _xrSessionManager the session manager for this module
  79068. * @param options read-only options to be used in this module
  79069. */
  79070. constructor(_xrSessionManager: WebXRSessionManager,
  79071. /**
  79072. * read-only options to be used in this module
  79073. */
  79074. options?: IWebXRBackgroundRemoverOptions);
  79075. /**
  79076. * attach this feature
  79077. * Will usually be called by the features manager
  79078. *
  79079. * @returns true if successful.
  79080. */
  79081. attach(): boolean;
  79082. /**
  79083. * detach this feature.
  79084. * Will usually be called by the features manager
  79085. *
  79086. * @returns true if successful.
  79087. */
  79088. detach(): boolean;
  79089. /**
  79090. * Dispose this feature and all of the resources attached
  79091. */
  79092. dispose(): void;
  79093. protected _onXRFrame(_xrFrame: XRFrame): void;
  79094. private _setBackgroundState;
  79095. }
  79096. }
  79097. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79098. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79099. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79100. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79101. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79102. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79103. import { Nullable } from "babylonjs/types";
  79104. /**
  79105. * Options for the controller physics feature
  79106. */
  79107. export class IWebXRControllerPhysicsOptions {
  79108. /**
  79109. * Should the headset get its own impostor
  79110. */
  79111. enableHeadsetImpostor?: boolean;
  79112. /**
  79113. * Optional parameters for the headset impostor
  79114. */
  79115. headsetImpostorParams?: {
  79116. /**
  79117. * The type of impostor to create. Default is sphere
  79118. */
  79119. impostorType: number;
  79120. /**
  79121. * the size of the impostor. Defaults to 10cm
  79122. */
  79123. impostorSize?: number | {
  79124. width: number;
  79125. height: number;
  79126. depth: number;
  79127. };
  79128. /**
  79129. * Friction definitions
  79130. */
  79131. friction?: number;
  79132. /**
  79133. * Restitution
  79134. */
  79135. restitution?: number;
  79136. };
  79137. /**
  79138. * The physics properties of the future impostors
  79139. */
  79140. physicsProperties?: {
  79141. /**
  79142. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79143. * Note that this requires a physics engine that supports mesh impostors!
  79144. */
  79145. useControllerMesh?: boolean;
  79146. /**
  79147. * The type of impostor to create. Default is sphere
  79148. */
  79149. impostorType?: number;
  79150. /**
  79151. * the size of the impostor. Defaults to 10cm
  79152. */
  79153. impostorSize?: number | {
  79154. width: number;
  79155. height: number;
  79156. depth: number;
  79157. };
  79158. /**
  79159. * Friction definitions
  79160. */
  79161. friction?: number;
  79162. /**
  79163. * Restitution
  79164. */
  79165. restitution?: number;
  79166. };
  79167. /**
  79168. * the xr input to use with this pointer selection
  79169. */
  79170. xrInput: WebXRInput;
  79171. }
  79172. /**
  79173. * Add physics impostor to your webxr controllers,
  79174. * including naive calculation of their linear and angular velocity
  79175. */
  79176. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79177. private readonly _options;
  79178. private _attachController;
  79179. private _controllers;
  79180. private _debugMode;
  79181. private _delta;
  79182. private _headsetImpostor?;
  79183. private _headsetMesh?;
  79184. private _lastTimestamp;
  79185. private _tmpQuaternion;
  79186. private _tmpVector;
  79187. /**
  79188. * The module's name
  79189. */
  79190. static readonly Name: string;
  79191. /**
  79192. * The (Babylon) version of this module.
  79193. * This is an integer representing the implementation version.
  79194. * This number does not correspond to the webxr specs version
  79195. */
  79196. static readonly Version: number;
  79197. /**
  79198. * Construct a new Controller Physics Feature
  79199. * @param _xrSessionManager the corresponding xr session manager
  79200. * @param _options options to create this feature with
  79201. */
  79202. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79203. /**
  79204. * @hidden
  79205. * enable debugging - will show console outputs and the impostor mesh
  79206. */
  79207. _enablePhysicsDebug(): void;
  79208. /**
  79209. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79210. * @param xrController the controller to add
  79211. */
  79212. addController(xrController: WebXRInputSource): void;
  79213. /**
  79214. * attach this feature
  79215. * Will usually be called by the features manager
  79216. *
  79217. * @returns true if successful.
  79218. */
  79219. attach(): boolean;
  79220. /**
  79221. * detach this feature.
  79222. * Will usually be called by the features manager
  79223. *
  79224. * @returns true if successful.
  79225. */
  79226. detach(): boolean;
  79227. /**
  79228. * Get the headset impostor, if enabled
  79229. * @returns the impostor
  79230. */
  79231. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79232. /**
  79233. * Get the physics impostor of a specific controller.
  79234. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79235. * @param controller the controller or the controller id of which to get the impostor
  79236. * @returns the impostor or null
  79237. */
  79238. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79239. /**
  79240. * Update the physics properties provided in the constructor
  79241. * @param newProperties the new properties object
  79242. */
  79243. setPhysicsProperties(newProperties: {
  79244. impostorType?: number;
  79245. impostorSize?: number | {
  79246. width: number;
  79247. height: number;
  79248. depth: number;
  79249. };
  79250. friction?: number;
  79251. restitution?: number;
  79252. }): void;
  79253. protected _onXRFrame(_xrFrame: any): void;
  79254. private _detachController;
  79255. }
  79256. }
  79257. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79258. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79259. import { Observable } from "babylonjs/Misc/observable";
  79260. import { Vector3 } from "babylonjs/Maths/math.vector";
  79261. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79262. /**
  79263. * A babylon interface for a "WebXR" feature point.
  79264. * Represents the position and confidence value of a given feature point.
  79265. */
  79266. export interface IWebXRFeaturePoint {
  79267. /**
  79268. * Represents the position of the feature point in world space.
  79269. */
  79270. position: Vector3;
  79271. /**
  79272. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79273. */
  79274. confidenceValue: number;
  79275. }
  79276. /**
  79277. * The feature point system is used to detect feature points from real world geometry.
  79278. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79279. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79280. */
  79281. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79282. private _enabled;
  79283. private _featurePointCloud;
  79284. /**
  79285. * The module's name
  79286. */
  79287. static readonly Name: string;
  79288. /**
  79289. * The (Babylon) version of this module.
  79290. * This is an integer representing the implementation version.
  79291. * This number does not correspond to the WebXR specs version
  79292. */
  79293. static readonly Version: number;
  79294. /**
  79295. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79296. * Will notify the observers about which feature points have been added.
  79297. */
  79298. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79299. /**
  79300. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79301. * Will notify the observers about which feature points have been updated.
  79302. */
  79303. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79304. /**
  79305. * The current feature point cloud maintained across frames.
  79306. */
  79307. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79308. /**
  79309. * construct the feature point system
  79310. * @param _xrSessionManager an instance of xr Session manager
  79311. */
  79312. constructor(_xrSessionManager: WebXRSessionManager);
  79313. /**
  79314. * Detach this feature.
  79315. * Will usually be called by the features manager
  79316. *
  79317. * @returns true if successful.
  79318. */
  79319. detach(): boolean;
  79320. /**
  79321. * Dispose this feature and all of the resources attached
  79322. */
  79323. dispose(): void;
  79324. /**
  79325. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79326. */
  79327. protected _onXRFrame(frame: XRFrame): void;
  79328. /**
  79329. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79330. */
  79331. private _init;
  79332. }
  79333. }
  79334. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79335. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79336. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79338. import { Mesh } from "babylonjs/Meshes/mesh";
  79339. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79340. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79341. import { Nullable } from "babylonjs/types";
  79342. import { IDisposable } from "babylonjs/scene";
  79343. import { Observable } from "babylonjs/Misc/observable";
  79344. /**
  79345. * Configuration interface for the hand tracking feature
  79346. */
  79347. export interface IWebXRHandTrackingOptions {
  79348. /**
  79349. * The xrInput that will be used as source for new hands
  79350. */
  79351. xrInput: WebXRInput;
  79352. /**
  79353. * Configuration object for the joint meshes
  79354. */
  79355. jointMeshes?: {
  79356. /**
  79357. * Should the meshes created be invisible (defaults to false)
  79358. */
  79359. invisible?: boolean;
  79360. /**
  79361. * A source mesh to be used to create instances. Defaults to a sphere.
  79362. * This mesh will be the source for all other (25) meshes.
  79363. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79364. */
  79365. sourceMesh?: Mesh;
  79366. /**
  79367. * Should the source mesh stay visible. Defaults to false
  79368. */
  79369. keepOriginalVisible?: boolean;
  79370. /**
  79371. * Scale factor for all instances (defaults to 2)
  79372. */
  79373. scaleFactor?: number;
  79374. /**
  79375. * Should each instance have its own physics impostor
  79376. */
  79377. enablePhysics?: boolean;
  79378. /**
  79379. * If enabled, override default physics properties
  79380. */
  79381. physicsProps?: {
  79382. friction?: number;
  79383. restitution?: number;
  79384. impostorType?: number;
  79385. };
  79386. /**
  79387. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79388. */
  79389. handMesh?: AbstractMesh;
  79390. };
  79391. }
  79392. /**
  79393. * Parts of the hands divided to writs and finger names
  79394. */
  79395. export const enum HandPart {
  79396. /**
  79397. * HandPart - Wrist
  79398. */
  79399. WRIST = "wrist",
  79400. /**
  79401. * HandPart - The THumb
  79402. */
  79403. THUMB = "thumb",
  79404. /**
  79405. * HandPart - Index finger
  79406. */
  79407. INDEX = "index",
  79408. /**
  79409. * HandPart - Middle finger
  79410. */
  79411. MIDDLE = "middle",
  79412. /**
  79413. * HandPart - Ring finger
  79414. */
  79415. RING = "ring",
  79416. /**
  79417. * HandPart - Little finger
  79418. */
  79419. LITTLE = "little"
  79420. }
  79421. /**
  79422. * Representing a single hand (with its corresponding native XRHand object)
  79423. */
  79424. export class WebXRHand implements IDisposable {
  79425. /** the controller to which the hand correlates */
  79426. readonly xrController: WebXRInputSource;
  79427. /** the meshes to be used to track the hand joints */
  79428. readonly trackedMeshes: AbstractMesh[];
  79429. /**
  79430. * Hand-parts definition (key is HandPart)
  79431. */
  79432. handPartsDefinition: {
  79433. [key: string]: number[];
  79434. };
  79435. /**
  79436. * Populate the HandPartsDefinition object.
  79437. * This is called as a side effect since certain browsers don't have XRHand defined.
  79438. */
  79439. private generateHandPartsDefinition;
  79440. /**
  79441. * Construct a new hand object
  79442. * @param xrController the controller to which the hand correlates
  79443. * @param trackedMeshes the meshes to be used to track the hand joints
  79444. */
  79445. constructor(
  79446. /** the controller to which the hand correlates */
  79447. xrController: WebXRInputSource,
  79448. /** the meshes to be used to track the hand joints */
  79449. trackedMeshes: AbstractMesh[]);
  79450. /**
  79451. * Update this hand from the latest xr frame
  79452. * @param xrFrame xrFrame to update from
  79453. * @param referenceSpace The current viewer reference space
  79454. * @param scaleFactor optional scale factor for the meshes
  79455. */
  79456. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79457. /**
  79458. * Get meshes of part of the hand
  79459. * @param part the part of hand to get
  79460. * @returns An array of meshes that correlate to the hand part requested
  79461. */
  79462. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79463. /**
  79464. * Dispose this Hand object
  79465. */
  79466. dispose(): void;
  79467. }
  79468. /**
  79469. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79470. */
  79471. export class WebXRHandTracking extends WebXRAbstractFeature {
  79472. /**
  79473. * options to use when constructing this feature
  79474. */
  79475. readonly options: IWebXRHandTrackingOptions;
  79476. private static _idCounter;
  79477. /**
  79478. * The module's name
  79479. */
  79480. static readonly Name: string;
  79481. /**
  79482. * The (Babylon) version of this module.
  79483. * This is an integer representing the implementation version.
  79484. * This number does not correspond to the WebXR specs version
  79485. */
  79486. static readonly Version: number;
  79487. /**
  79488. * This observable will notify registered observers when a new hand object was added and initialized
  79489. */
  79490. onHandAddedObservable: Observable<WebXRHand>;
  79491. /**
  79492. * This observable will notify its observers right before the hand object is disposed
  79493. */
  79494. onHandRemovedObservable: Observable<WebXRHand>;
  79495. private _hands;
  79496. /**
  79497. * Creates a new instance of the hit test feature
  79498. * @param _xrSessionManager an instance of WebXRSessionManager
  79499. * @param options options to use when constructing this feature
  79500. */
  79501. constructor(_xrSessionManager: WebXRSessionManager,
  79502. /**
  79503. * options to use when constructing this feature
  79504. */
  79505. options: IWebXRHandTrackingOptions);
  79506. /**
  79507. * Check if the needed objects are defined.
  79508. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79509. */
  79510. isCompatible(): boolean;
  79511. /**
  79512. * attach this feature
  79513. * Will usually be called by the features manager
  79514. *
  79515. * @returns true if successful.
  79516. */
  79517. attach(): boolean;
  79518. /**
  79519. * detach this feature.
  79520. * Will usually be called by the features manager
  79521. *
  79522. * @returns true if successful.
  79523. */
  79524. detach(): boolean;
  79525. /**
  79526. * Dispose this feature and all of the resources attached
  79527. */
  79528. dispose(): void;
  79529. /**
  79530. * Get the hand object according to the controller id
  79531. * @param controllerId the controller id to which we want to get the hand
  79532. * @returns null if not found or the WebXRHand object if found
  79533. */
  79534. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79535. /**
  79536. * Get a hand object according to the requested handedness
  79537. * @param handedness the handedness to request
  79538. * @returns null if not found or the WebXRHand object if found
  79539. */
  79540. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79541. protected _onXRFrame(_xrFrame: XRFrame): void;
  79542. private _attachHand;
  79543. private _detachHand;
  79544. }
  79545. }
  79546. declare module "babylonjs/XR/features/index" {
  79547. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79548. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79549. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79550. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79551. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79552. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79553. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79554. export * from "babylonjs/XR/features/WebXRHitTest";
  79555. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79556. export * from "babylonjs/XR/features/WebXRHandTracking";
  79557. }
  79558. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79559. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79561. import { Scene } from "babylonjs/scene";
  79562. /**
  79563. * The motion controller class for all microsoft mixed reality controllers
  79564. */
  79565. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79566. protected readonly _mapping: {
  79567. defaultButton: {
  79568. valueNodeName: string;
  79569. unpressedNodeName: string;
  79570. pressedNodeName: string;
  79571. };
  79572. defaultAxis: {
  79573. valueNodeName: string;
  79574. minNodeName: string;
  79575. maxNodeName: string;
  79576. };
  79577. buttons: {
  79578. "xr-standard-trigger": {
  79579. rootNodeName: string;
  79580. componentProperty: string;
  79581. states: string[];
  79582. };
  79583. "xr-standard-squeeze": {
  79584. rootNodeName: string;
  79585. componentProperty: string;
  79586. states: string[];
  79587. };
  79588. "xr-standard-touchpad": {
  79589. rootNodeName: string;
  79590. labelAnchorNodeName: string;
  79591. touchPointNodeName: string;
  79592. };
  79593. "xr-standard-thumbstick": {
  79594. rootNodeName: string;
  79595. componentProperty: string;
  79596. states: string[];
  79597. };
  79598. };
  79599. axes: {
  79600. "xr-standard-touchpad": {
  79601. "x-axis": {
  79602. rootNodeName: string;
  79603. };
  79604. "y-axis": {
  79605. rootNodeName: string;
  79606. };
  79607. };
  79608. "xr-standard-thumbstick": {
  79609. "x-axis": {
  79610. rootNodeName: string;
  79611. };
  79612. "y-axis": {
  79613. rootNodeName: string;
  79614. };
  79615. };
  79616. };
  79617. };
  79618. /**
  79619. * The base url used to load the left and right controller models
  79620. */
  79621. static MODEL_BASE_URL: string;
  79622. /**
  79623. * The name of the left controller model file
  79624. */
  79625. static MODEL_LEFT_FILENAME: string;
  79626. /**
  79627. * The name of the right controller model file
  79628. */
  79629. static MODEL_RIGHT_FILENAME: string;
  79630. profileId: string;
  79631. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79632. protected _getFilenameAndPath(): {
  79633. filename: string;
  79634. path: string;
  79635. };
  79636. protected _getModelLoadingConstraints(): boolean;
  79637. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79638. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79639. protected _updateModel(): void;
  79640. }
  79641. }
  79642. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79643. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79645. import { Scene } from "babylonjs/scene";
  79646. /**
  79647. * The motion controller class for oculus touch (quest, rift).
  79648. * This class supports legacy mapping as well the standard xr mapping
  79649. */
  79650. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79651. private _forceLegacyControllers;
  79652. private _modelRootNode;
  79653. /**
  79654. * The base url used to load the left and right controller models
  79655. */
  79656. static MODEL_BASE_URL: string;
  79657. /**
  79658. * The name of the left controller model file
  79659. */
  79660. static MODEL_LEFT_FILENAME: string;
  79661. /**
  79662. * The name of the right controller model file
  79663. */
  79664. static MODEL_RIGHT_FILENAME: string;
  79665. /**
  79666. * Base Url for the Quest controller model.
  79667. */
  79668. static QUEST_MODEL_BASE_URL: string;
  79669. profileId: string;
  79670. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79671. protected _getFilenameAndPath(): {
  79672. filename: string;
  79673. path: string;
  79674. };
  79675. protected _getModelLoadingConstraints(): boolean;
  79676. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79677. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79678. protected _updateModel(): void;
  79679. /**
  79680. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79681. * between the touch and touch 2.
  79682. */
  79683. private _isQuest;
  79684. }
  79685. }
  79686. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  79687. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79688. import { Scene } from "babylonjs/scene";
  79689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79690. /**
  79691. * The motion controller class for the standard HTC-Vive controllers
  79692. */
  79693. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79694. private _modelRootNode;
  79695. /**
  79696. * The base url used to load the left and right controller models
  79697. */
  79698. static MODEL_BASE_URL: string;
  79699. /**
  79700. * File name for the controller model.
  79701. */
  79702. static MODEL_FILENAME: string;
  79703. profileId: string;
  79704. /**
  79705. * Create a new Vive motion controller object
  79706. * @param scene the scene to use to create this controller
  79707. * @param gamepadObject the corresponding gamepad object
  79708. * @param handedness the handedness of the controller
  79709. */
  79710. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79711. protected _getFilenameAndPath(): {
  79712. filename: string;
  79713. path: string;
  79714. };
  79715. protected _getModelLoadingConstraints(): boolean;
  79716. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79717. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79718. protected _updateModel(): void;
  79719. }
  79720. }
  79721. declare module "babylonjs/XR/motionController/index" {
  79722. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79723. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  79724. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  79725. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  79726. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  79727. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  79728. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  79729. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  79730. }
  79731. declare module "babylonjs/XR/index" {
  79732. export * from "babylonjs/XR/webXRCamera";
  79733. export * from "babylonjs/XR/webXREnterExitUI";
  79734. export * from "babylonjs/XR/webXRExperienceHelper";
  79735. export * from "babylonjs/XR/webXRInput";
  79736. export * from "babylonjs/XR/webXRInputSource";
  79737. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  79738. export * from "babylonjs/XR/webXRTypes";
  79739. export * from "babylonjs/XR/webXRSessionManager";
  79740. export * from "babylonjs/XR/webXRDefaultExperience";
  79741. export * from "babylonjs/XR/webXRFeaturesManager";
  79742. export * from "babylonjs/XR/features/index";
  79743. export * from "babylonjs/XR/motionController/index";
  79744. }
  79745. declare module "babylonjs/index" {
  79746. export * from "babylonjs/abstractScene";
  79747. export * from "babylonjs/Actions/index";
  79748. export * from "babylonjs/Animations/index";
  79749. export * from "babylonjs/assetContainer";
  79750. export * from "babylonjs/Audio/index";
  79751. export * from "babylonjs/Behaviors/index";
  79752. export * from "babylonjs/Bones/index";
  79753. export * from "babylonjs/Cameras/index";
  79754. export * from "babylonjs/Collisions/index";
  79755. export * from "babylonjs/Culling/index";
  79756. export * from "babylonjs/Debug/index";
  79757. export * from "babylonjs/DeviceInput/index";
  79758. export * from "babylonjs/Engines/index";
  79759. export * from "babylonjs/Events/index";
  79760. export * from "babylonjs/Gamepads/index";
  79761. export * from "babylonjs/Gizmos/index";
  79762. export * from "babylonjs/Helpers/index";
  79763. export * from "babylonjs/Instrumentation/index";
  79764. export * from "babylonjs/Layers/index";
  79765. export * from "babylonjs/LensFlares/index";
  79766. export * from "babylonjs/Lights/index";
  79767. export * from "babylonjs/Loading/index";
  79768. export * from "babylonjs/Materials/index";
  79769. export * from "babylonjs/Maths/index";
  79770. export * from "babylonjs/Meshes/index";
  79771. export * from "babylonjs/Morph/index";
  79772. export * from "babylonjs/Navigation/index";
  79773. export * from "babylonjs/node";
  79774. export * from "babylonjs/Offline/index";
  79775. export * from "babylonjs/Particles/index";
  79776. export * from "babylonjs/Physics/index";
  79777. export * from "babylonjs/PostProcesses/index";
  79778. export * from "babylonjs/Probes/index";
  79779. export * from "babylonjs/Rendering/index";
  79780. export * from "babylonjs/scene";
  79781. export * from "babylonjs/sceneComponent";
  79782. export * from "babylonjs/Sprites/index";
  79783. export * from "babylonjs/States/index";
  79784. export * from "babylonjs/Misc/index";
  79785. export * from "babylonjs/XR/index";
  79786. export * from "babylonjs/types";
  79787. }
  79788. declare module "babylonjs/Animations/pathCursor" {
  79789. import { Vector3 } from "babylonjs/Maths/math.vector";
  79790. import { Path2 } from "babylonjs/Maths/math.path";
  79791. /**
  79792. * A cursor which tracks a point on a path
  79793. */
  79794. export class PathCursor {
  79795. private path;
  79796. /**
  79797. * Stores path cursor callbacks for when an onchange event is triggered
  79798. */
  79799. private _onchange;
  79800. /**
  79801. * The value of the path cursor
  79802. */
  79803. value: number;
  79804. /**
  79805. * The animation array of the path cursor
  79806. */
  79807. animations: Animation[];
  79808. /**
  79809. * Initializes the path cursor
  79810. * @param path The path to track
  79811. */
  79812. constructor(path: Path2);
  79813. /**
  79814. * Gets the cursor point on the path
  79815. * @returns A point on the path cursor at the cursor location
  79816. */
  79817. getPoint(): Vector3;
  79818. /**
  79819. * Moves the cursor ahead by the step amount
  79820. * @param step The amount to move the cursor forward
  79821. * @returns This path cursor
  79822. */
  79823. moveAhead(step?: number): PathCursor;
  79824. /**
  79825. * Moves the cursor behind by the step amount
  79826. * @param step The amount to move the cursor back
  79827. * @returns This path cursor
  79828. */
  79829. moveBack(step?: number): PathCursor;
  79830. /**
  79831. * Moves the cursor by the step amount
  79832. * If the step amount is greater than one, an exception is thrown
  79833. * @param step The amount to move the cursor
  79834. * @returns This path cursor
  79835. */
  79836. move(step: number): PathCursor;
  79837. /**
  79838. * Ensures that the value is limited between zero and one
  79839. * @returns This path cursor
  79840. */
  79841. private ensureLimits;
  79842. /**
  79843. * Runs onchange callbacks on change (used by the animation engine)
  79844. * @returns This path cursor
  79845. */
  79846. private raiseOnChange;
  79847. /**
  79848. * Executes a function on change
  79849. * @param f A path cursor onchange callback
  79850. * @returns This path cursor
  79851. */
  79852. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79853. }
  79854. }
  79855. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79856. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79857. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79858. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79859. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79860. }
  79861. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79862. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79863. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79864. }
  79865. declare module "babylonjs/Engines/Processors/index" {
  79866. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79867. export * from "babylonjs/Engines/Processors/Expressions/index";
  79868. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79869. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79870. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79871. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79872. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79873. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79874. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79875. }
  79876. declare module "babylonjs/Legacy/legacy" {
  79877. import * as Babylon from "babylonjs/index";
  79878. export * from "babylonjs/index";
  79879. }
  79880. declare module "babylonjs/Shaders/blur.fragment" {
  79881. /** @hidden */
  79882. export var blurPixelShader: {
  79883. name: string;
  79884. shader: string;
  79885. };
  79886. }
  79887. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79888. /** @hidden */
  79889. export var pointCloudVertexDeclaration: {
  79890. name: string;
  79891. shader: string;
  79892. };
  79893. }
  79894. declare module "babylonjs" {
  79895. export * from "babylonjs/Legacy/legacy";
  79896. }
  79897. declare module BABYLON {
  79898. /** Alias type for value that can be null */
  79899. export type Nullable<T> = T | null;
  79900. /**
  79901. * Alias type for number that are floats
  79902. * @ignorenaming
  79903. */
  79904. export type float = number;
  79905. /**
  79906. * Alias type for number that are doubles.
  79907. * @ignorenaming
  79908. */
  79909. export type double = number;
  79910. /**
  79911. * Alias type for number that are integer
  79912. * @ignorenaming
  79913. */
  79914. export type int = number;
  79915. /** Alias type for number array or Float32Array */
  79916. export type FloatArray = number[] | Float32Array;
  79917. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79918. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79919. /**
  79920. * Alias for types that can be used by a Buffer or VertexBuffer.
  79921. */
  79922. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79923. /**
  79924. * Alias type for primitive types
  79925. * @ignorenaming
  79926. */
  79927. type Primitive = undefined | null | boolean | string | number | Function;
  79928. /**
  79929. * Type modifier to make all the properties of an object Readonly
  79930. */
  79931. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79932. /**
  79933. * Type modifier to make all the properties of an object Readonly recursively
  79934. */
  79935. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79936. /**
  79937. * Type modifier to make object properties readonly.
  79938. */
  79939. export type DeepImmutableObject<T> = {
  79940. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79941. };
  79942. /** @hidden */
  79943. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79944. }
  79945. }
  79946. declare module BABYLON {
  79947. /**
  79948. * A class serves as a medium between the observable and its observers
  79949. */
  79950. export class EventState {
  79951. /**
  79952. * Create a new EventState
  79953. * @param mask defines the mask associated with this state
  79954. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79955. * @param target defines the original target of the state
  79956. * @param currentTarget defines the current target of the state
  79957. */
  79958. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79959. /**
  79960. * Initialize the current event state
  79961. * @param mask defines the mask associated with this state
  79962. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79963. * @param target defines the original target of the state
  79964. * @param currentTarget defines the current target of the state
  79965. * @returns the current event state
  79966. */
  79967. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79968. /**
  79969. * An Observer can set this property to true to prevent subsequent observers of being notified
  79970. */
  79971. skipNextObservers: boolean;
  79972. /**
  79973. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79974. */
  79975. mask: number;
  79976. /**
  79977. * The object that originally notified the event
  79978. */
  79979. target?: any;
  79980. /**
  79981. * The current object in the bubbling phase
  79982. */
  79983. currentTarget?: any;
  79984. /**
  79985. * This will be populated with the return value of the last function that was executed.
  79986. * If it is the first function in the callback chain it will be the event data.
  79987. */
  79988. lastReturnValue?: any;
  79989. }
  79990. /**
  79991. * Represent an Observer registered to a given Observable object.
  79992. */
  79993. export class Observer<T> {
  79994. /**
  79995. * Defines the callback to call when the observer is notified
  79996. */
  79997. callback: (eventData: T, eventState: EventState) => void;
  79998. /**
  79999. * Defines the mask of the observer (used to filter notifications)
  80000. */
  80001. mask: number;
  80002. /**
  80003. * Defines the current scope used to restore the JS context
  80004. */
  80005. scope: any;
  80006. /** @hidden */
  80007. _willBeUnregistered: boolean;
  80008. /**
  80009. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80010. */
  80011. unregisterOnNextCall: boolean;
  80012. /**
  80013. * Creates a new observer
  80014. * @param callback defines the callback to call when the observer is notified
  80015. * @param mask defines the mask of the observer (used to filter notifications)
  80016. * @param scope defines the current scope used to restore the JS context
  80017. */
  80018. constructor(
  80019. /**
  80020. * Defines the callback to call when the observer is notified
  80021. */
  80022. callback: (eventData: T, eventState: EventState) => void,
  80023. /**
  80024. * Defines the mask of the observer (used to filter notifications)
  80025. */
  80026. mask: number,
  80027. /**
  80028. * Defines the current scope used to restore the JS context
  80029. */
  80030. scope?: any);
  80031. }
  80032. /**
  80033. * Represent a list of observers registered to multiple Observables object.
  80034. */
  80035. export class MultiObserver<T> {
  80036. private _observers;
  80037. private _observables;
  80038. /**
  80039. * Release associated resources
  80040. */
  80041. dispose(): void;
  80042. /**
  80043. * Raise a callback when one of the observable will notify
  80044. * @param observables defines a list of observables to watch
  80045. * @param callback defines the callback to call on notification
  80046. * @param mask defines the mask used to filter notifications
  80047. * @param scope defines the current scope used to restore the JS context
  80048. * @returns the new MultiObserver
  80049. */
  80050. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80051. }
  80052. /**
  80053. * The Observable class is a simple implementation of the Observable pattern.
  80054. *
  80055. * 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.
  80056. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80057. * 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).
  80058. * 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.
  80059. */
  80060. export class Observable<T> {
  80061. private _observers;
  80062. private _eventState;
  80063. private _onObserverAdded;
  80064. /**
  80065. * Gets the list of observers
  80066. */
  80067. get observers(): Array<Observer<T>>;
  80068. /**
  80069. * Creates a new observable
  80070. * @param onObserverAdded defines a callback to call when a new observer is added
  80071. */
  80072. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80073. /**
  80074. * Create a new Observer with the specified callback
  80075. * @param callback the callback that will be executed for that Observer
  80076. * @param mask the mask used to filter observers
  80077. * @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.
  80078. * @param scope optional scope for the callback to be called from
  80079. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80080. * @returns the new observer created for the callback
  80081. */
  80082. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80083. /**
  80084. * Create a new Observer with the specified callback and unregisters after the next notification
  80085. * @param callback the callback that will be executed for that Observer
  80086. * @returns the new observer created for the callback
  80087. */
  80088. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80089. /**
  80090. * Remove an Observer from the Observable object
  80091. * @param observer the instance of the Observer to remove
  80092. * @returns false if it doesn't belong to this Observable
  80093. */
  80094. remove(observer: Nullable<Observer<T>>): boolean;
  80095. /**
  80096. * Remove a callback from the Observable object
  80097. * @param callback the callback to remove
  80098. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80099. * @returns false if it doesn't belong to this Observable
  80100. */
  80101. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80102. private _deferUnregister;
  80103. private _remove;
  80104. /**
  80105. * Moves the observable to the top of the observer list making it get called first when notified
  80106. * @param observer the observer to move
  80107. */
  80108. makeObserverTopPriority(observer: Observer<T>): void;
  80109. /**
  80110. * Moves the observable to the bottom of the observer list making it get called last when notified
  80111. * @param observer the observer to move
  80112. */
  80113. makeObserverBottomPriority(observer: Observer<T>): void;
  80114. /**
  80115. * Notify all Observers by calling their respective callback with the given data
  80116. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80117. * @param eventData defines the data to send to all observers
  80118. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80119. * @param target defines the original target of the state
  80120. * @param currentTarget defines the current target of the state
  80121. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80122. */
  80123. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80124. /**
  80125. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80126. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80127. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80128. * and it is crucial that all callbacks will be executed.
  80129. * The order of the callbacks is kept, callbacks are not executed parallel.
  80130. *
  80131. * @param eventData The data to be sent to each callback
  80132. * @param mask is used to filter observers defaults to -1
  80133. * @param target defines the callback target (see EventState)
  80134. * @param currentTarget defines he current object in the bubbling phase
  80135. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80136. */
  80137. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80138. /**
  80139. * Notify a specific observer
  80140. * @param observer defines the observer to notify
  80141. * @param eventData defines the data to be sent to each callback
  80142. * @param mask is used to filter observers defaults to -1
  80143. */
  80144. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80145. /**
  80146. * Gets a boolean indicating if the observable has at least one observer
  80147. * @returns true is the Observable has at least one Observer registered
  80148. */
  80149. hasObservers(): boolean;
  80150. /**
  80151. * Clear the list of observers
  80152. */
  80153. clear(): void;
  80154. /**
  80155. * Clone the current observable
  80156. * @returns a new observable
  80157. */
  80158. clone(): Observable<T>;
  80159. /**
  80160. * Does this observable handles observer registered with a given mask
  80161. * @param mask defines the mask to be tested
  80162. * @return whether or not one observer registered with the given mask is handeled
  80163. **/
  80164. hasSpecificMask(mask?: number): boolean;
  80165. }
  80166. }
  80167. declare module BABYLON {
  80168. /**
  80169. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80170. * Babylon.js
  80171. */
  80172. export class DomManagement {
  80173. /**
  80174. * Checks if the window object exists
  80175. * @returns true if the window object exists
  80176. */
  80177. static IsWindowObjectExist(): boolean;
  80178. /**
  80179. * Checks if the navigator object exists
  80180. * @returns true if the navigator object exists
  80181. */
  80182. static IsNavigatorAvailable(): boolean;
  80183. /**
  80184. * Check if the document object exists
  80185. * @returns true if the document object exists
  80186. */
  80187. static IsDocumentAvailable(): boolean;
  80188. /**
  80189. * Extracts text content from a DOM element hierarchy
  80190. * @param element defines the root element
  80191. * @returns a string
  80192. */
  80193. static GetDOMTextContent(element: HTMLElement): string;
  80194. }
  80195. }
  80196. declare module BABYLON {
  80197. /**
  80198. * Logger used througouht the application to allow configuration of
  80199. * the log level required for the messages.
  80200. */
  80201. export class Logger {
  80202. /**
  80203. * No log
  80204. */
  80205. static readonly NoneLogLevel: number;
  80206. /**
  80207. * Only message logs
  80208. */
  80209. static readonly MessageLogLevel: number;
  80210. /**
  80211. * Only warning logs
  80212. */
  80213. static readonly WarningLogLevel: number;
  80214. /**
  80215. * Only error logs
  80216. */
  80217. static readonly ErrorLogLevel: number;
  80218. /**
  80219. * All logs
  80220. */
  80221. static readonly AllLogLevel: number;
  80222. private static _LogCache;
  80223. /**
  80224. * Gets a value indicating the number of loading errors
  80225. * @ignorenaming
  80226. */
  80227. static errorsCount: number;
  80228. /**
  80229. * Callback called when a new log is added
  80230. */
  80231. static OnNewCacheEntry: (entry: string) => void;
  80232. private static _AddLogEntry;
  80233. private static _FormatMessage;
  80234. private static _LogDisabled;
  80235. private static _LogEnabled;
  80236. private static _WarnDisabled;
  80237. private static _WarnEnabled;
  80238. private static _ErrorDisabled;
  80239. private static _ErrorEnabled;
  80240. /**
  80241. * Log a message to the console
  80242. */
  80243. static Log: (message: string) => void;
  80244. /**
  80245. * Write a warning message to the console
  80246. */
  80247. static Warn: (message: string) => void;
  80248. /**
  80249. * Write an error message to the console
  80250. */
  80251. static Error: (message: string) => void;
  80252. /**
  80253. * Gets current log cache (list of logs)
  80254. */
  80255. static get LogCache(): string;
  80256. /**
  80257. * Clears the log cache
  80258. */
  80259. static ClearLogCache(): void;
  80260. /**
  80261. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80262. */
  80263. static set LogLevels(level: number);
  80264. }
  80265. }
  80266. declare module BABYLON {
  80267. /** @hidden */
  80268. export class _TypeStore {
  80269. /** @hidden */
  80270. static RegisteredTypes: {
  80271. [key: string]: Object;
  80272. };
  80273. /** @hidden */
  80274. static GetClass(fqdn: string): any;
  80275. }
  80276. }
  80277. declare module BABYLON {
  80278. /**
  80279. * Helper to manipulate strings
  80280. */
  80281. export class StringTools {
  80282. /**
  80283. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80284. * @param str Source string
  80285. * @param suffix Suffix to search for in the source string
  80286. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80287. */
  80288. static EndsWith(str: string, suffix: string): boolean;
  80289. /**
  80290. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80291. * @param str Source string
  80292. * @param suffix Suffix to search for in the source string
  80293. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80294. */
  80295. static StartsWith(str: string, suffix: string): boolean;
  80296. /**
  80297. * Decodes a buffer into a string
  80298. * @param buffer The buffer to decode
  80299. * @returns The decoded string
  80300. */
  80301. static Decode(buffer: Uint8Array | Uint16Array): string;
  80302. /**
  80303. * Encode a buffer to a base64 string
  80304. * @param buffer defines the buffer to encode
  80305. * @returns the encoded string
  80306. */
  80307. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80308. /**
  80309. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80310. * @param num the number to convert and pad
  80311. * @param length the expected length of the string
  80312. * @returns the padded string
  80313. */
  80314. static PadNumber(num: number, length: number): string;
  80315. }
  80316. }
  80317. declare module BABYLON {
  80318. /**
  80319. * Class containing a set of static utilities functions for deep copy.
  80320. */
  80321. export class DeepCopier {
  80322. /**
  80323. * Tries to copy an object by duplicating every property
  80324. * @param source defines the source object
  80325. * @param destination defines the target object
  80326. * @param doNotCopyList defines a list of properties to avoid
  80327. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80328. */
  80329. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80330. }
  80331. }
  80332. declare module BABYLON {
  80333. /**
  80334. * Class containing a set of static utilities functions for precision date
  80335. */
  80336. export class PrecisionDate {
  80337. /**
  80338. * Gets either window.performance.now() if supported or Date.now() else
  80339. */
  80340. static get Now(): number;
  80341. }
  80342. }
  80343. declare module BABYLON {
  80344. /** @hidden */
  80345. export class _DevTools {
  80346. static WarnImport(name: string): string;
  80347. }
  80348. }
  80349. declare module BABYLON {
  80350. /**
  80351. * Interface used to define the mechanism to get data from the network
  80352. */
  80353. export interface IWebRequest {
  80354. /**
  80355. * Returns client's response url
  80356. */
  80357. responseURL: string;
  80358. /**
  80359. * Returns client's status
  80360. */
  80361. status: number;
  80362. /**
  80363. * Returns client's status as a text
  80364. */
  80365. statusText: string;
  80366. }
  80367. }
  80368. declare module BABYLON {
  80369. /**
  80370. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80371. */
  80372. export class WebRequest implements IWebRequest {
  80373. private _xhr;
  80374. /**
  80375. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80376. * i.e. when loading files, where the server/service expects an Authorization header
  80377. */
  80378. static CustomRequestHeaders: {
  80379. [key: string]: string;
  80380. };
  80381. /**
  80382. * Add callback functions in this array to update all the requests before they get sent to the network
  80383. */
  80384. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80385. private _injectCustomRequestHeaders;
  80386. /**
  80387. * Gets or sets a function to be called when loading progress changes
  80388. */
  80389. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80390. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80391. /**
  80392. * Returns client's state
  80393. */
  80394. get readyState(): number;
  80395. /**
  80396. * Returns client's status
  80397. */
  80398. get status(): number;
  80399. /**
  80400. * Returns client's status as a text
  80401. */
  80402. get statusText(): string;
  80403. /**
  80404. * Returns client's response
  80405. */
  80406. get response(): any;
  80407. /**
  80408. * Returns client's response url
  80409. */
  80410. get responseURL(): string;
  80411. /**
  80412. * Returns client's response as text
  80413. */
  80414. get responseText(): string;
  80415. /**
  80416. * Gets or sets the expected response type
  80417. */
  80418. get responseType(): XMLHttpRequestResponseType;
  80419. set responseType(value: XMLHttpRequestResponseType);
  80420. /** @hidden */
  80421. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80422. /** @hidden */
  80423. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80424. /**
  80425. * Cancels any network activity
  80426. */
  80427. abort(): void;
  80428. /**
  80429. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80430. * @param body defines an optional request body
  80431. */
  80432. send(body?: Document | BodyInit | null): void;
  80433. /**
  80434. * Sets the request method, request URL
  80435. * @param method defines the method to use (GET, POST, etc..)
  80436. * @param url defines the url to connect with
  80437. */
  80438. open(method: string, url: string): void;
  80439. /**
  80440. * Sets the value of a request header.
  80441. * @param name The name of the header whose value is to be set
  80442. * @param value The value to set as the body of the header
  80443. */
  80444. setRequestHeader(name: string, value: string): void;
  80445. /**
  80446. * Get the string containing the text of a particular header's value.
  80447. * @param name The name of the header
  80448. * @returns The string containing the text of the given header name
  80449. */
  80450. getResponseHeader(name: string): Nullable<string>;
  80451. }
  80452. }
  80453. declare module BABYLON {
  80454. /**
  80455. * File request interface
  80456. */
  80457. export interface IFileRequest {
  80458. /**
  80459. * Raised when the request is complete (success or error).
  80460. */
  80461. onCompleteObservable: Observable<IFileRequest>;
  80462. /**
  80463. * Aborts the request for a file.
  80464. */
  80465. abort: () => void;
  80466. }
  80467. }
  80468. declare module BABYLON {
  80469. /**
  80470. * Define options used to create a render target texture
  80471. */
  80472. export class RenderTargetCreationOptions {
  80473. /**
  80474. * Specifies is mipmaps must be generated
  80475. */
  80476. generateMipMaps?: boolean;
  80477. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80478. generateDepthBuffer?: boolean;
  80479. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80480. generateStencilBuffer?: boolean;
  80481. /** Defines texture type (int by default) */
  80482. type?: number;
  80483. /** Defines sampling mode (trilinear by default) */
  80484. samplingMode?: number;
  80485. /** Defines format (RGBA by default) */
  80486. format?: number;
  80487. }
  80488. }
  80489. declare module BABYLON {
  80490. /** Defines the cross module used constants to avoid circular dependncies */
  80491. export class Constants {
  80492. /** Defines that alpha blending is disabled */
  80493. static readonly ALPHA_DISABLE: number;
  80494. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80495. static readonly ALPHA_ADD: number;
  80496. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80497. static readonly ALPHA_COMBINE: number;
  80498. /** Defines that alpha blending is DEST - SRC * DEST */
  80499. static readonly ALPHA_SUBTRACT: number;
  80500. /** Defines that alpha blending is SRC * DEST */
  80501. static readonly ALPHA_MULTIPLY: number;
  80502. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80503. static readonly ALPHA_MAXIMIZED: number;
  80504. /** Defines that alpha blending is SRC + DEST */
  80505. static readonly ALPHA_ONEONE: number;
  80506. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80507. static readonly ALPHA_PREMULTIPLIED: number;
  80508. /**
  80509. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80510. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80511. */
  80512. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80513. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80514. static readonly ALPHA_INTERPOLATE: number;
  80515. /**
  80516. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80517. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80518. */
  80519. static readonly ALPHA_SCREENMODE: number;
  80520. /**
  80521. * Defines that alpha blending is SRC + DST
  80522. * Alpha will be set to SRC ALPHA + DST ALPHA
  80523. */
  80524. static readonly ALPHA_ONEONE_ONEONE: number;
  80525. /**
  80526. * Defines that alpha blending is SRC * DST ALPHA + DST
  80527. * Alpha will be set to 0
  80528. */
  80529. static readonly ALPHA_ALPHATOCOLOR: number;
  80530. /**
  80531. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80532. */
  80533. static readonly ALPHA_REVERSEONEMINUS: number;
  80534. /**
  80535. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80536. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80537. */
  80538. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80539. /**
  80540. * Defines that alpha blending is SRC + DST
  80541. * Alpha will be set to SRC ALPHA
  80542. */
  80543. static readonly ALPHA_ONEONE_ONEZERO: number;
  80544. /**
  80545. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80546. * Alpha will be set to DST ALPHA
  80547. */
  80548. static readonly ALPHA_EXCLUSION: number;
  80549. /** Defines that alpha blending equation a SUM */
  80550. static readonly ALPHA_EQUATION_ADD: number;
  80551. /** Defines that alpha blending equation a SUBSTRACTION */
  80552. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80553. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80554. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80555. /** Defines that alpha blending equation a MAX operation */
  80556. static readonly ALPHA_EQUATION_MAX: number;
  80557. /** Defines that alpha blending equation a MIN operation */
  80558. static readonly ALPHA_EQUATION_MIN: number;
  80559. /**
  80560. * Defines that alpha blending equation a DARKEN operation:
  80561. * It takes the min of the src and sums the alpha channels.
  80562. */
  80563. static readonly ALPHA_EQUATION_DARKEN: number;
  80564. /** Defines that the ressource is not delayed*/
  80565. static readonly DELAYLOADSTATE_NONE: number;
  80566. /** Defines that the ressource was successfully delay loaded */
  80567. static readonly DELAYLOADSTATE_LOADED: number;
  80568. /** Defines that the ressource is currently delay loading */
  80569. static readonly DELAYLOADSTATE_LOADING: number;
  80570. /** Defines that the ressource is delayed and has not started loading */
  80571. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80572. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80573. static readonly NEVER: number;
  80574. /** 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 */
  80575. static readonly ALWAYS: number;
  80576. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80577. static readonly LESS: number;
  80578. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80579. static readonly EQUAL: number;
  80580. /** 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 */
  80581. static readonly LEQUAL: number;
  80582. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80583. static readonly GREATER: number;
  80584. /** 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 */
  80585. static readonly GEQUAL: number;
  80586. /** 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 */
  80587. static readonly NOTEQUAL: number;
  80588. /** Passed to stencilOperation to specify that stencil value must be kept */
  80589. static readonly KEEP: number;
  80590. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80591. static readonly REPLACE: number;
  80592. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80593. static readonly INCR: number;
  80594. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80595. static readonly DECR: number;
  80596. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80597. static readonly INVERT: number;
  80598. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80599. static readonly INCR_WRAP: number;
  80600. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80601. static readonly DECR_WRAP: number;
  80602. /** Texture is not repeating outside of 0..1 UVs */
  80603. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80604. /** Texture is repeating outside of 0..1 UVs */
  80605. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80606. /** Texture is repeating and mirrored */
  80607. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80608. /** ALPHA */
  80609. static readonly TEXTUREFORMAT_ALPHA: number;
  80610. /** LUMINANCE */
  80611. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80612. /** LUMINANCE_ALPHA */
  80613. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80614. /** RGB */
  80615. static readonly TEXTUREFORMAT_RGB: number;
  80616. /** RGBA */
  80617. static readonly TEXTUREFORMAT_RGBA: number;
  80618. /** RED */
  80619. static readonly TEXTUREFORMAT_RED: number;
  80620. /** RED (2nd reference) */
  80621. static readonly TEXTUREFORMAT_R: number;
  80622. /** RG */
  80623. static readonly TEXTUREFORMAT_RG: number;
  80624. /** RED_INTEGER */
  80625. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80626. /** RED_INTEGER (2nd reference) */
  80627. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80628. /** RG_INTEGER */
  80629. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80630. /** RGB_INTEGER */
  80631. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80632. /** RGBA_INTEGER */
  80633. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80634. /** UNSIGNED_BYTE */
  80635. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80636. /** UNSIGNED_BYTE (2nd reference) */
  80637. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80638. /** FLOAT */
  80639. static readonly TEXTURETYPE_FLOAT: number;
  80640. /** HALF_FLOAT */
  80641. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80642. /** BYTE */
  80643. static readonly TEXTURETYPE_BYTE: number;
  80644. /** SHORT */
  80645. static readonly TEXTURETYPE_SHORT: number;
  80646. /** UNSIGNED_SHORT */
  80647. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80648. /** INT */
  80649. static readonly TEXTURETYPE_INT: number;
  80650. /** UNSIGNED_INT */
  80651. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80652. /** UNSIGNED_SHORT_4_4_4_4 */
  80653. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80654. /** UNSIGNED_SHORT_5_5_5_1 */
  80655. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80656. /** UNSIGNED_SHORT_5_6_5 */
  80657. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80658. /** UNSIGNED_INT_2_10_10_10_REV */
  80659. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80660. /** UNSIGNED_INT_24_8 */
  80661. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  80662. /** UNSIGNED_INT_10F_11F_11F_REV */
  80663. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  80664. /** UNSIGNED_INT_5_9_9_9_REV */
  80665. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  80666. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  80667. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80668. /** nearest is mag = nearest and min = nearest and no mip */
  80669. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  80670. /** mag = nearest and min = nearest and mip = none */
  80671. static readonly TEXTURE_NEAREST_NEAREST: number;
  80672. /** Bilinear is mag = linear and min = linear and no mip */
  80673. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  80674. /** mag = linear and min = linear and mip = none */
  80675. static readonly TEXTURE_LINEAR_LINEAR: number;
  80676. /** Trilinear is mag = linear and min = linear and mip = linear */
  80677. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  80678. /** Trilinear is mag = linear and min = linear and mip = linear */
  80679. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  80680. /** mag = nearest and min = nearest and mip = nearest */
  80681. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  80682. /** mag = nearest and min = linear and mip = nearest */
  80683. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  80684. /** mag = nearest and min = linear and mip = linear */
  80685. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  80686. /** mag = nearest and min = linear and mip = none */
  80687. static readonly TEXTURE_NEAREST_LINEAR: number;
  80688. /** nearest is mag = nearest and min = nearest and mip = linear */
  80689. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  80690. /** mag = linear and min = nearest and mip = nearest */
  80691. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  80692. /** mag = linear and min = nearest and mip = linear */
  80693. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  80694. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80695. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  80696. /** mag = linear and min = nearest and mip = none */
  80697. static readonly TEXTURE_LINEAR_NEAREST: number;
  80698. /** Explicit coordinates mode */
  80699. static readonly TEXTURE_EXPLICIT_MODE: number;
  80700. /** Spherical coordinates mode */
  80701. static readonly TEXTURE_SPHERICAL_MODE: number;
  80702. /** Planar coordinates mode */
  80703. static readonly TEXTURE_PLANAR_MODE: number;
  80704. /** Cubic coordinates mode */
  80705. static readonly TEXTURE_CUBIC_MODE: number;
  80706. /** Projection coordinates mode */
  80707. static readonly TEXTURE_PROJECTION_MODE: number;
  80708. /** Skybox coordinates mode */
  80709. static readonly TEXTURE_SKYBOX_MODE: number;
  80710. /** Inverse Cubic coordinates mode */
  80711. static readonly TEXTURE_INVCUBIC_MODE: number;
  80712. /** Equirectangular coordinates mode */
  80713. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  80714. /** Equirectangular Fixed coordinates mode */
  80715. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  80716. /** Equirectangular Fixed Mirrored coordinates mode */
  80717. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80718. /** Offline (baking) quality for texture filtering */
  80719. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  80720. /** High quality for texture filtering */
  80721. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  80722. /** Medium quality for texture filtering */
  80723. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  80724. /** Low quality for texture filtering */
  80725. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  80726. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  80727. static readonly SCALEMODE_FLOOR: number;
  80728. /** Defines that texture rescaling will look for the nearest power of 2 size */
  80729. static readonly SCALEMODE_NEAREST: number;
  80730. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  80731. static readonly SCALEMODE_CEILING: number;
  80732. /**
  80733. * The dirty texture flag value
  80734. */
  80735. static readonly MATERIAL_TextureDirtyFlag: number;
  80736. /**
  80737. * The dirty light flag value
  80738. */
  80739. static readonly MATERIAL_LightDirtyFlag: number;
  80740. /**
  80741. * The dirty fresnel flag value
  80742. */
  80743. static readonly MATERIAL_FresnelDirtyFlag: number;
  80744. /**
  80745. * The dirty attribute flag value
  80746. */
  80747. static readonly MATERIAL_AttributesDirtyFlag: number;
  80748. /**
  80749. * The dirty misc flag value
  80750. */
  80751. static readonly MATERIAL_MiscDirtyFlag: number;
  80752. /**
  80753. * The all dirty flag value
  80754. */
  80755. static readonly MATERIAL_AllDirtyFlag: number;
  80756. /**
  80757. * Returns the triangle fill mode
  80758. */
  80759. static readonly MATERIAL_TriangleFillMode: number;
  80760. /**
  80761. * Returns the wireframe mode
  80762. */
  80763. static readonly MATERIAL_WireFrameFillMode: number;
  80764. /**
  80765. * Returns the point fill mode
  80766. */
  80767. static readonly MATERIAL_PointFillMode: number;
  80768. /**
  80769. * Returns the point list draw mode
  80770. */
  80771. static readonly MATERIAL_PointListDrawMode: number;
  80772. /**
  80773. * Returns the line list draw mode
  80774. */
  80775. static readonly MATERIAL_LineListDrawMode: number;
  80776. /**
  80777. * Returns the line loop draw mode
  80778. */
  80779. static readonly MATERIAL_LineLoopDrawMode: number;
  80780. /**
  80781. * Returns the line strip draw mode
  80782. */
  80783. static readonly MATERIAL_LineStripDrawMode: number;
  80784. /**
  80785. * Returns the triangle strip draw mode
  80786. */
  80787. static readonly MATERIAL_TriangleStripDrawMode: number;
  80788. /**
  80789. * Returns the triangle fan draw mode
  80790. */
  80791. static readonly MATERIAL_TriangleFanDrawMode: number;
  80792. /**
  80793. * Stores the clock-wise side orientation
  80794. */
  80795. static readonly MATERIAL_ClockWiseSideOrientation: number;
  80796. /**
  80797. * Stores the counter clock-wise side orientation
  80798. */
  80799. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  80800. /**
  80801. * Nothing
  80802. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80803. */
  80804. static readonly ACTION_NothingTrigger: number;
  80805. /**
  80806. * On pick
  80807. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80808. */
  80809. static readonly ACTION_OnPickTrigger: number;
  80810. /**
  80811. * On left pick
  80812. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80813. */
  80814. static readonly ACTION_OnLeftPickTrigger: number;
  80815. /**
  80816. * On right pick
  80817. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80818. */
  80819. static readonly ACTION_OnRightPickTrigger: number;
  80820. /**
  80821. * On center pick
  80822. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80823. */
  80824. static readonly ACTION_OnCenterPickTrigger: number;
  80825. /**
  80826. * On pick down
  80827. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80828. */
  80829. static readonly ACTION_OnPickDownTrigger: number;
  80830. /**
  80831. * On double pick
  80832. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80833. */
  80834. static readonly ACTION_OnDoublePickTrigger: number;
  80835. /**
  80836. * On pick up
  80837. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80838. */
  80839. static readonly ACTION_OnPickUpTrigger: number;
  80840. /**
  80841. * On pick out.
  80842. * This trigger will only be raised if you also declared a OnPickDown
  80843. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80844. */
  80845. static readonly ACTION_OnPickOutTrigger: number;
  80846. /**
  80847. * On long press
  80848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80849. */
  80850. static readonly ACTION_OnLongPressTrigger: number;
  80851. /**
  80852. * On pointer over
  80853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80854. */
  80855. static readonly ACTION_OnPointerOverTrigger: number;
  80856. /**
  80857. * On pointer out
  80858. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80859. */
  80860. static readonly ACTION_OnPointerOutTrigger: number;
  80861. /**
  80862. * On every frame
  80863. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80864. */
  80865. static readonly ACTION_OnEveryFrameTrigger: number;
  80866. /**
  80867. * On intersection enter
  80868. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80869. */
  80870. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80871. /**
  80872. * On intersection exit
  80873. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80874. */
  80875. static readonly ACTION_OnIntersectionExitTrigger: number;
  80876. /**
  80877. * On key down
  80878. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80879. */
  80880. static readonly ACTION_OnKeyDownTrigger: number;
  80881. /**
  80882. * On key up
  80883. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80884. */
  80885. static readonly ACTION_OnKeyUpTrigger: number;
  80886. /**
  80887. * Billboard mode will only apply to Y axis
  80888. */
  80889. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80890. /**
  80891. * Billboard mode will apply to all axes
  80892. */
  80893. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80894. /**
  80895. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80896. */
  80897. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80898. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80899. * Test order :
  80900. * Is the bounding sphere outside the frustum ?
  80901. * If not, are the bounding box vertices outside the frustum ?
  80902. * It not, then the cullable object is in the frustum.
  80903. */
  80904. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80905. /** Culling strategy : Bounding Sphere Only.
  80906. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80907. * It's also less accurate than the standard because some not visible objects can still be selected.
  80908. * Test : is the bounding sphere outside the frustum ?
  80909. * If not, then the cullable object is in the frustum.
  80910. */
  80911. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80912. /** Culling strategy : Optimistic Inclusion.
  80913. * This in an inclusion test first, then the standard exclusion test.
  80914. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80915. * 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.
  80916. * Anyway, it's as accurate as the standard strategy.
  80917. * Test :
  80918. * Is the cullable object bounding sphere center in the frustum ?
  80919. * If not, apply the default culling strategy.
  80920. */
  80921. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80922. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80923. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80924. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80925. * 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.
  80926. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80927. * Test :
  80928. * Is the cullable object bounding sphere center in the frustum ?
  80929. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80930. */
  80931. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80932. /**
  80933. * No logging while loading
  80934. */
  80935. static readonly SCENELOADER_NO_LOGGING: number;
  80936. /**
  80937. * Minimal logging while loading
  80938. */
  80939. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80940. /**
  80941. * Summary logging while loading
  80942. */
  80943. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80944. /**
  80945. * Detailled logging while loading
  80946. */
  80947. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80948. /**
  80949. * Prepass texture index for color
  80950. */
  80951. static readonly PREPASS_COLOR_INDEX: number;
  80952. /**
  80953. * Prepass texture index for irradiance
  80954. */
  80955. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80956. /**
  80957. * Prepass texture index for depth + normal
  80958. */
  80959. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80960. /**
  80961. * Prepass texture index for albedo
  80962. */
  80963. static readonly PREPASS_ALBEDO_INDEX: number;
  80964. }
  80965. }
  80966. declare module BABYLON {
  80967. /**
  80968. * This represents the required contract to create a new type of texture loader.
  80969. */
  80970. export interface IInternalTextureLoader {
  80971. /**
  80972. * Defines wether the loader supports cascade loading the different faces.
  80973. */
  80974. supportCascades: boolean;
  80975. /**
  80976. * This returns if the loader support the current file information.
  80977. * @param extension defines the file extension of the file being loaded
  80978. * @param mimeType defines the optional mime type of the file being loaded
  80979. * @returns true if the loader can load the specified file
  80980. */
  80981. canLoad(extension: string, mimeType?: string): boolean;
  80982. /**
  80983. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80984. * @param data contains the texture data
  80985. * @param texture defines the BabylonJS internal texture
  80986. * @param createPolynomials will be true if polynomials have been requested
  80987. * @param onLoad defines the callback to trigger once the texture is ready
  80988. * @param onError defines the callback to trigger in case of error
  80989. */
  80990. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80991. /**
  80992. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80993. * @param data contains the texture data
  80994. * @param texture defines the BabylonJS internal texture
  80995. * @param callback defines the method to call once ready to upload
  80996. */
  80997. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80998. }
  80999. }
  81000. declare module BABYLON {
  81001. /**
  81002. * Class used to store and describe the pipeline context associated with an effect
  81003. */
  81004. export interface IPipelineContext {
  81005. /**
  81006. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81007. */
  81008. isAsync: boolean;
  81009. /**
  81010. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81011. */
  81012. isReady: boolean;
  81013. /** @hidden */
  81014. _getVertexShaderCode(): string | null;
  81015. /** @hidden */
  81016. _getFragmentShaderCode(): string | null;
  81017. /** @hidden */
  81018. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81019. }
  81020. }
  81021. declare module BABYLON {
  81022. /**
  81023. * Class used to store gfx data (like WebGLBuffer)
  81024. */
  81025. export class DataBuffer {
  81026. /**
  81027. * Gets or sets the number of objects referencing this buffer
  81028. */
  81029. references: number;
  81030. /** Gets or sets the size of the underlying buffer */
  81031. capacity: number;
  81032. /**
  81033. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81034. */
  81035. is32Bits: boolean;
  81036. /**
  81037. * Gets the underlying buffer
  81038. */
  81039. get underlyingResource(): any;
  81040. }
  81041. }
  81042. declare module BABYLON {
  81043. /** @hidden */
  81044. export interface IShaderProcessor {
  81045. attributeProcessor?: (attribute: string) => string;
  81046. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81047. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81048. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81049. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81050. lineProcessor?: (line: string, isFragment: boolean) => string;
  81051. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81052. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81053. }
  81054. }
  81055. declare module BABYLON {
  81056. /** @hidden */
  81057. export interface ProcessingOptions {
  81058. defines: string[];
  81059. indexParameters: any;
  81060. isFragment: boolean;
  81061. shouldUseHighPrecisionShader: boolean;
  81062. supportsUniformBuffers: boolean;
  81063. shadersRepository: string;
  81064. includesShadersStore: {
  81065. [key: string]: string;
  81066. };
  81067. processor?: IShaderProcessor;
  81068. version: string;
  81069. platformName: string;
  81070. lookForClosingBracketForUniformBuffer?: boolean;
  81071. }
  81072. }
  81073. declare module BABYLON {
  81074. /** @hidden */
  81075. export class ShaderCodeNode {
  81076. line: string;
  81077. children: ShaderCodeNode[];
  81078. additionalDefineKey?: string;
  81079. additionalDefineValue?: string;
  81080. isValid(preprocessors: {
  81081. [key: string]: string;
  81082. }): boolean;
  81083. process(preprocessors: {
  81084. [key: string]: string;
  81085. }, options: ProcessingOptions): string;
  81086. }
  81087. }
  81088. declare module BABYLON {
  81089. /** @hidden */
  81090. export class ShaderCodeCursor {
  81091. private _lines;
  81092. lineIndex: number;
  81093. get currentLine(): string;
  81094. get canRead(): boolean;
  81095. set lines(value: string[]);
  81096. }
  81097. }
  81098. declare module BABYLON {
  81099. /** @hidden */
  81100. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81101. process(preprocessors: {
  81102. [key: string]: string;
  81103. }, options: ProcessingOptions): string;
  81104. }
  81105. }
  81106. declare module BABYLON {
  81107. /** @hidden */
  81108. export class ShaderDefineExpression {
  81109. isTrue(preprocessors: {
  81110. [key: string]: string;
  81111. }): boolean;
  81112. private static _OperatorPriority;
  81113. private static _Stack;
  81114. static postfixToInfix(postfix: string[]): string;
  81115. static infixToPostfix(infix: string): string[];
  81116. }
  81117. }
  81118. declare module BABYLON {
  81119. /** @hidden */
  81120. export class ShaderCodeTestNode extends ShaderCodeNode {
  81121. testExpression: ShaderDefineExpression;
  81122. isValid(preprocessors: {
  81123. [key: string]: string;
  81124. }): boolean;
  81125. }
  81126. }
  81127. declare module BABYLON {
  81128. /** @hidden */
  81129. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81130. define: string;
  81131. not: boolean;
  81132. constructor(define: string, not?: boolean);
  81133. isTrue(preprocessors: {
  81134. [key: string]: string;
  81135. }): boolean;
  81136. }
  81137. }
  81138. declare module BABYLON {
  81139. /** @hidden */
  81140. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81141. leftOperand: ShaderDefineExpression;
  81142. rightOperand: ShaderDefineExpression;
  81143. isTrue(preprocessors: {
  81144. [key: string]: string;
  81145. }): boolean;
  81146. }
  81147. }
  81148. declare module BABYLON {
  81149. /** @hidden */
  81150. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81151. leftOperand: ShaderDefineExpression;
  81152. rightOperand: ShaderDefineExpression;
  81153. isTrue(preprocessors: {
  81154. [key: string]: string;
  81155. }): boolean;
  81156. }
  81157. }
  81158. declare module BABYLON {
  81159. /** @hidden */
  81160. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81161. define: string;
  81162. operand: string;
  81163. testValue: string;
  81164. constructor(define: string, operand: string, testValue: string);
  81165. isTrue(preprocessors: {
  81166. [key: string]: string;
  81167. }): boolean;
  81168. }
  81169. }
  81170. declare module BABYLON {
  81171. /**
  81172. * Class used to enable access to offline support
  81173. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81174. */
  81175. export interface IOfflineProvider {
  81176. /**
  81177. * Gets a boolean indicating if scene must be saved in the database
  81178. */
  81179. enableSceneOffline: boolean;
  81180. /**
  81181. * Gets a boolean indicating if textures must be saved in the database
  81182. */
  81183. enableTexturesOffline: boolean;
  81184. /**
  81185. * Open the offline support and make it available
  81186. * @param successCallback defines the callback to call on success
  81187. * @param errorCallback defines the callback to call on error
  81188. */
  81189. open(successCallback: () => void, errorCallback: () => void): void;
  81190. /**
  81191. * Loads an image from the offline support
  81192. * @param url defines the url to load from
  81193. * @param image defines the target DOM image
  81194. */
  81195. loadImage(url: string, image: HTMLImageElement): void;
  81196. /**
  81197. * Loads a file from offline support
  81198. * @param url defines the URL to load from
  81199. * @param sceneLoaded defines a callback to call on success
  81200. * @param progressCallBack defines a callback to call when progress changed
  81201. * @param errorCallback defines a callback to call on error
  81202. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81203. */
  81204. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81205. }
  81206. }
  81207. declare module BABYLON {
  81208. /**
  81209. * Class used to help managing file picking and drag'n'drop
  81210. * File Storage
  81211. */
  81212. export class FilesInputStore {
  81213. /**
  81214. * List of files ready to be loaded
  81215. */
  81216. static FilesToLoad: {
  81217. [key: string]: File;
  81218. };
  81219. }
  81220. }
  81221. declare module BABYLON {
  81222. /**
  81223. * Class used to define a retry strategy when error happens while loading assets
  81224. */
  81225. export class RetryStrategy {
  81226. /**
  81227. * Function used to defines an exponential back off strategy
  81228. * @param maxRetries defines the maximum number of retries (3 by default)
  81229. * @param baseInterval defines the interval between retries
  81230. * @returns the strategy function to use
  81231. */
  81232. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81233. }
  81234. }
  81235. declare module BABYLON {
  81236. /**
  81237. * @ignore
  81238. * Application error to support additional information when loading a file
  81239. */
  81240. export abstract class BaseError extends Error {
  81241. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81242. }
  81243. }
  81244. declare module BABYLON {
  81245. /** @ignore */
  81246. export class LoadFileError extends BaseError {
  81247. request?: WebRequest;
  81248. file?: File;
  81249. /**
  81250. * Creates a new LoadFileError
  81251. * @param message defines the message of the error
  81252. * @param request defines the optional web request
  81253. * @param file defines the optional file
  81254. */
  81255. constructor(message: string, object?: WebRequest | File);
  81256. }
  81257. /** @ignore */
  81258. export class RequestFileError extends BaseError {
  81259. request: WebRequest;
  81260. /**
  81261. * Creates a new LoadFileError
  81262. * @param message defines the message of the error
  81263. * @param request defines the optional web request
  81264. */
  81265. constructor(message: string, request: WebRequest);
  81266. }
  81267. /** @ignore */
  81268. export class ReadFileError extends BaseError {
  81269. file: File;
  81270. /**
  81271. * Creates a new ReadFileError
  81272. * @param message defines the message of the error
  81273. * @param file defines the optional file
  81274. */
  81275. constructor(message: string, file: File);
  81276. }
  81277. /**
  81278. * @hidden
  81279. */
  81280. export class FileTools {
  81281. /**
  81282. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81283. */
  81284. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81285. /**
  81286. * Gets or sets the base URL to use to load assets
  81287. */
  81288. static BaseUrl: string;
  81289. /**
  81290. * Default behaviour for cors in the application.
  81291. * It can be a string if the expected behavior is identical in the entire app.
  81292. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81293. */
  81294. static CorsBehavior: string | ((url: string | string[]) => string);
  81295. /**
  81296. * Gets or sets a function used to pre-process url before using them to load assets
  81297. */
  81298. static PreprocessUrl: (url: string) => string;
  81299. /**
  81300. * Removes unwanted characters from an url
  81301. * @param url defines the url to clean
  81302. * @returns the cleaned url
  81303. */
  81304. private static _CleanUrl;
  81305. /**
  81306. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81307. * @param url define the url we are trying
  81308. * @param element define the dom element where to configure the cors policy
  81309. */
  81310. static SetCorsBehavior(url: string | string[], element: {
  81311. crossOrigin: string | null;
  81312. }): void;
  81313. /**
  81314. * Loads an image as an HTMLImageElement.
  81315. * @param input url string, ArrayBuffer, or Blob to load
  81316. * @param onLoad callback called when the image successfully loads
  81317. * @param onError callback called when the image fails to load
  81318. * @param offlineProvider offline provider for caching
  81319. * @param mimeType optional mime type
  81320. * @returns the HTMLImageElement of the loaded image
  81321. */
  81322. 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>;
  81323. /**
  81324. * Reads a file from a File object
  81325. * @param file defines the file to load
  81326. * @param onSuccess defines the callback to call when data is loaded
  81327. * @param onProgress defines the callback to call during loading process
  81328. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81329. * @param onError defines the callback to call when an error occurs
  81330. * @returns a file request object
  81331. */
  81332. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81333. /**
  81334. * Loads a file from a url
  81335. * @param url url to load
  81336. * @param onSuccess callback called when the file successfully loads
  81337. * @param onProgress callback called while file is loading (if the server supports this mode)
  81338. * @param offlineProvider defines the offline provider for caching
  81339. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81340. * @param onError callback called when the file fails to load
  81341. * @returns a file request object
  81342. */
  81343. 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;
  81344. /**
  81345. * Loads a file
  81346. * @param url url to load
  81347. * @param onSuccess callback called when the file successfully loads
  81348. * @param onProgress callback called while file is loading (if the server supports this mode)
  81349. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81350. * @param onError callback called when the file fails to load
  81351. * @param onOpened callback called when the web request is opened
  81352. * @returns a file request object
  81353. */
  81354. 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;
  81355. /**
  81356. * Checks if the loaded document was accessed via `file:`-Protocol.
  81357. * @returns boolean
  81358. */
  81359. static IsFileURL(): boolean;
  81360. }
  81361. }
  81362. declare module BABYLON {
  81363. /** @hidden */
  81364. export class ShaderProcessor {
  81365. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81366. private static _ProcessPrecision;
  81367. private static _ExtractOperation;
  81368. private static _BuildSubExpression;
  81369. private static _BuildExpression;
  81370. private static _MoveCursorWithinIf;
  81371. private static _MoveCursor;
  81372. private static _EvaluatePreProcessors;
  81373. private static _PreparePreProcessors;
  81374. private static _ProcessShaderConversion;
  81375. private static _ProcessIncludes;
  81376. /**
  81377. * Loads a file from a url
  81378. * @param url url to load
  81379. * @param onSuccess callback called when the file successfully loads
  81380. * @param onProgress callback called while file is loading (if the server supports this mode)
  81381. * @param offlineProvider defines the offline provider for caching
  81382. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81383. * @param onError callback called when the file fails to load
  81384. * @returns a file request object
  81385. * @hidden
  81386. */
  81387. 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;
  81388. }
  81389. }
  81390. declare module BABYLON {
  81391. /**
  81392. * @hidden
  81393. */
  81394. export interface IColor4Like {
  81395. r: float;
  81396. g: float;
  81397. b: float;
  81398. a: float;
  81399. }
  81400. /**
  81401. * @hidden
  81402. */
  81403. export interface IColor3Like {
  81404. r: float;
  81405. g: float;
  81406. b: float;
  81407. }
  81408. /**
  81409. * @hidden
  81410. */
  81411. export interface IVector4Like {
  81412. x: float;
  81413. y: float;
  81414. z: float;
  81415. w: float;
  81416. }
  81417. /**
  81418. * @hidden
  81419. */
  81420. export interface IVector3Like {
  81421. x: float;
  81422. y: float;
  81423. z: float;
  81424. }
  81425. /**
  81426. * @hidden
  81427. */
  81428. export interface IVector2Like {
  81429. x: float;
  81430. y: float;
  81431. }
  81432. /**
  81433. * @hidden
  81434. */
  81435. export interface IMatrixLike {
  81436. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81437. updateFlag: int;
  81438. }
  81439. /**
  81440. * @hidden
  81441. */
  81442. export interface IViewportLike {
  81443. x: float;
  81444. y: float;
  81445. width: float;
  81446. height: float;
  81447. }
  81448. /**
  81449. * @hidden
  81450. */
  81451. export interface IPlaneLike {
  81452. normal: IVector3Like;
  81453. d: float;
  81454. normalize(): void;
  81455. }
  81456. }
  81457. declare module BABYLON {
  81458. /**
  81459. * Interface used to define common properties for effect fallbacks
  81460. */
  81461. export interface IEffectFallbacks {
  81462. /**
  81463. * Removes the defines that should be removed when falling back.
  81464. * @param currentDefines defines the current define statements for the shader.
  81465. * @param effect defines the current effect we try to compile
  81466. * @returns The resulting defines with defines of the current rank removed.
  81467. */
  81468. reduce(currentDefines: string, effect: Effect): string;
  81469. /**
  81470. * Removes the fallback from the bound mesh.
  81471. */
  81472. unBindMesh(): void;
  81473. /**
  81474. * Checks to see if more fallbacks are still availible.
  81475. */
  81476. hasMoreFallbacks: boolean;
  81477. }
  81478. }
  81479. declare module BABYLON {
  81480. /**
  81481. * Class used to evalaute queries containing `and` and `or` operators
  81482. */
  81483. export class AndOrNotEvaluator {
  81484. /**
  81485. * Evaluate a query
  81486. * @param query defines the query to evaluate
  81487. * @param evaluateCallback defines the callback used to filter result
  81488. * @returns true if the query matches
  81489. */
  81490. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81491. private static _HandleParenthesisContent;
  81492. private static _SimplifyNegation;
  81493. }
  81494. }
  81495. declare module BABYLON {
  81496. /**
  81497. * Class used to store custom tags
  81498. */
  81499. export class Tags {
  81500. /**
  81501. * Adds support for tags on the given object
  81502. * @param obj defines the object to use
  81503. */
  81504. static EnableFor(obj: any): void;
  81505. /**
  81506. * Removes tags support
  81507. * @param obj defines the object to use
  81508. */
  81509. static DisableFor(obj: any): void;
  81510. /**
  81511. * Gets a boolean indicating if the given object has tags
  81512. * @param obj defines the object to use
  81513. * @returns a boolean
  81514. */
  81515. static HasTags(obj: any): boolean;
  81516. /**
  81517. * Gets the tags available on a given object
  81518. * @param obj defines the object to use
  81519. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81520. * @returns the tags
  81521. */
  81522. static GetTags(obj: any, asString?: boolean): any;
  81523. /**
  81524. * Adds tags to an object
  81525. * @param obj defines the object to use
  81526. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81527. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81528. */
  81529. static AddTagsTo(obj: any, tagsString: string): void;
  81530. /**
  81531. * @hidden
  81532. */
  81533. static _AddTagTo(obj: any, tag: string): void;
  81534. /**
  81535. * Removes specific tags from a specific object
  81536. * @param obj defines the object to use
  81537. * @param tagsString defines the tags to remove
  81538. */
  81539. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81540. /**
  81541. * @hidden
  81542. */
  81543. static _RemoveTagFrom(obj: any, tag: string): void;
  81544. /**
  81545. * Defines if tags hosted on an object match a given query
  81546. * @param obj defines the object to use
  81547. * @param tagsQuery defines the tag query
  81548. * @returns a boolean
  81549. */
  81550. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81551. }
  81552. }
  81553. declare module BABYLON {
  81554. /**
  81555. * Scalar computation library
  81556. */
  81557. export class Scalar {
  81558. /**
  81559. * Two pi constants convenient for computation.
  81560. */
  81561. static TwoPi: number;
  81562. /**
  81563. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81564. * @param a number
  81565. * @param b number
  81566. * @param epsilon (default = 1.401298E-45)
  81567. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81568. */
  81569. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81570. /**
  81571. * Returns a string : the upper case translation of the number i to hexadecimal.
  81572. * @param i number
  81573. * @returns the upper case translation of the number i to hexadecimal.
  81574. */
  81575. static ToHex(i: number): string;
  81576. /**
  81577. * Returns -1 if value is negative and +1 is value is positive.
  81578. * @param value the value
  81579. * @returns the value itself if it's equal to zero.
  81580. */
  81581. static Sign(value: number): number;
  81582. /**
  81583. * Returns the value itself if it's between min and max.
  81584. * Returns min if the value is lower than min.
  81585. * Returns max if the value is greater than max.
  81586. * @param value the value to clmap
  81587. * @param min the min value to clamp to (default: 0)
  81588. * @param max the max value to clamp to (default: 1)
  81589. * @returns the clamped value
  81590. */
  81591. static Clamp(value: number, min?: number, max?: number): number;
  81592. /**
  81593. * the log2 of value.
  81594. * @param value the value to compute log2 of
  81595. * @returns the log2 of value.
  81596. */
  81597. static Log2(value: number): number;
  81598. /**
  81599. * Loops the value, so that it is never larger than length and never smaller than 0.
  81600. *
  81601. * This is similar to the modulo operator but it works with floating point numbers.
  81602. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  81603. * With t = 5 and length = 2.5, the result would be 0.0.
  81604. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  81605. * @param value the value
  81606. * @param length the length
  81607. * @returns the looped value
  81608. */
  81609. static Repeat(value: number, length: number): number;
  81610. /**
  81611. * Normalize the value between 0.0 and 1.0 using min and max values
  81612. * @param value value to normalize
  81613. * @param min max to normalize between
  81614. * @param max min to normalize between
  81615. * @returns the normalized value
  81616. */
  81617. static Normalize(value: number, min: number, max: number): number;
  81618. /**
  81619. * Denormalize the value from 0.0 and 1.0 using min and max values
  81620. * @param normalized value to denormalize
  81621. * @param min max to denormalize between
  81622. * @param max min to denormalize between
  81623. * @returns the denormalized value
  81624. */
  81625. static Denormalize(normalized: number, min: number, max: number): number;
  81626. /**
  81627. * Calculates the shortest difference between two given angles given in degrees.
  81628. * @param current current angle in degrees
  81629. * @param target target angle in degrees
  81630. * @returns the delta
  81631. */
  81632. static DeltaAngle(current: number, target: number): number;
  81633. /**
  81634. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81635. * @param tx value
  81636. * @param length length
  81637. * @returns The returned value will move back and forth between 0 and length
  81638. */
  81639. static PingPong(tx: number, length: number): number;
  81640. /**
  81641. * Interpolates between min and max with smoothing at the limits.
  81642. *
  81643. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  81644. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  81645. * @param from from
  81646. * @param to to
  81647. * @param tx value
  81648. * @returns the smooth stepped value
  81649. */
  81650. static SmoothStep(from: number, to: number, tx: number): number;
  81651. /**
  81652. * Moves a value current towards target.
  81653. *
  81654. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  81655. * Negative values of maxDelta pushes the value away from target.
  81656. * @param current current value
  81657. * @param target target value
  81658. * @param maxDelta max distance to move
  81659. * @returns resulting value
  81660. */
  81661. static MoveTowards(current: number, target: number, maxDelta: number): number;
  81662. /**
  81663. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81664. *
  81665. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  81666. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  81667. * @param current current value
  81668. * @param target target value
  81669. * @param maxDelta max distance to move
  81670. * @returns resulting angle
  81671. */
  81672. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  81673. /**
  81674. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  81675. * @param start start value
  81676. * @param end target value
  81677. * @param amount amount to lerp between
  81678. * @returns the lerped value
  81679. */
  81680. static Lerp(start: number, end: number, amount: number): number;
  81681. /**
  81682. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81683. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  81684. * @param start start value
  81685. * @param end target value
  81686. * @param amount amount to lerp between
  81687. * @returns the lerped value
  81688. */
  81689. static LerpAngle(start: number, end: number, amount: number): number;
  81690. /**
  81691. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  81692. * @param a start value
  81693. * @param b target value
  81694. * @param value value between a and b
  81695. * @returns the inverseLerp value
  81696. */
  81697. static InverseLerp(a: number, b: number, value: number): number;
  81698. /**
  81699. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  81700. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  81701. * @param value1 spline value
  81702. * @param tangent1 spline value
  81703. * @param value2 spline value
  81704. * @param tangent2 spline value
  81705. * @param amount input value
  81706. * @returns hermite result
  81707. */
  81708. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  81709. /**
  81710. * Returns a random float number between and min and max values
  81711. * @param min min value of random
  81712. * @param max max value of random
  81713. * @returns random value
  81714. */
  81715. static RandomRange(min: number, max: number): number;
  81716. /**
  81717. * This function returns percentage of a number in a given range.
  81718. *
  81719. * RangeToPercent(40,20,60) will return 0.5 (50%)
  81720. * RangeToPercent(34,0,100) will return 0.34 (34%)
  81721. * @param number to convert to percentage
  81722. * @param min min range
  81723. * @param max max range
  81724. * @returns the percentage
  81725. */
  81726. static RangeToPercent(number: number, min: number, max: number): number;
  81727. /**
  81728. * This function returns number that corresponds to the percentage in a given range.
  81729. *
  81730. * PercentToRange(0.34,0,100) will return 34.
  81731. * @param percent to convert to number
  81732. * @param min min range
  81733. * @param max max range
  81734. * @returns the number
  81735. */
  81736. static PercentToRange(percent: number, min: number, max: number): number;
  81737. /**
  81738. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  81739. * @param angle The angle to normalize in radian.
  81740. * @return The converted angle.
  81741. */
  81742. static NormalizeRadians(angle: number): number;
  81743. }
  81744. }
  81745. declare module BABYLON {
  81746. /**
  81747. * Constant used to convert a value to gamma space
  81748. * @ignorenaming
  81749. */
  81750. export const ToGammaSpace: number;
  81751. /**
  81752. * Constant used to convert a value to linear space
  81753. * @ignorenaming
  81754. */
  81755. export const ToLinearSpace = 2.2;
  81756. /**
  81757. * Constant used to define the minimal number value in Babylon.js
  81758. * @ignorenaming
  81759. */
  81760. let Epsilon: number;
  81761. }
  81762. declare module BABYLON {
  81763. /**
  81764. * Class used to represent a viewport on screen
  81765. */
  81766. export class Viewport {
  81767. /** viewport left coordinate */
  81768. x: number;
  81769. /** viewport top coordinate */
  81770. y: number;
  81771. /**viewport width */
  81772. width: number;
  81773. /** viewport height */
  81774. height: number;
  81775. /**
  81776. * Creates a Viewport object located at (x, y) and sized (width, height)
  81777. * @param x defines viewport left coordinate
  81778. * @param y defines viewport top coordinate
  81779. * @param width defines the viewport width
  81780. * @param height defines the viewport height
  81781. */
  81782. constructor(
  81783. /** viewport left coordinate */
  81784. x: number,
  81785. /** viewport top coordinate */
  81786. y: number,
  81787. /**viewport width */
  81788. width: number,
  81789. /** viewport height */
  81790. height: number);
  81791. /**
  81792. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  81793. * @param renderWidth defines the rendering width
  81794. * @param renderHeight defines the rendering height
  81795. * @returns a new Viewport
  81796. */
  81797. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  81798. /**
  81799. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  81800. * @param renderWidth defines the rendering width
  81801. * @param renderHeight defines the rendering height
  81802. * @param ref defines the target viewport
  81803. * @returns the current viewport
  81804. */
  81805. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  81806. /**
  81807. * Returns a new Viewport copied from the current one
  81808. * @returns a new Viewport
  81809. */
  81810. clone(): Viewport;
  81811. }
  81812. }
  81813. declare module BABYLON {
  81814. /**
  81815. * Class containing a set of static utilities functions for arrays.
  81816. */
  81817. export class ArrayTools {
  81818. /**
  81819. * Returns an array of the given size filled with element built from the given constructor and the paramters
  81820. * @param size the number of element to construct and put in the array
  81821. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  81822. * @returns a new array filled with new objects
  81823. */
  81824. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  81825. }
  81826. }
  81827. declare module BABYLON {
  81828. /**
  81829. * Represents a plane by the equation ax + by + cz + d = 0
  81830. */
  81831. export class Plane {
  81832. private static _TmpMatrix;
  81833. /**
  81834. * Normal of the plane (a,b,c)
  81835. */
  81836. normal: Vector3;
  81837. /**
  81838. * d component of the plane
  81839. */
  81840. d: number;
  81841. /**
  81842. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81843. * @param a a component of the plane
  81844. * @param b b component of the plane
  81845. * @param c c component of the plane
  81846. * @param d d component of the plane
  81847. */
  81848. constructor(a: number, b: number, c: number, d: number);
  81849. /**
  81850. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81851. */
  81852. asArray(): number[];
  81853. /**
  81854. * @returns a new plane copied from the current Plane.
  81855. */
  81856. clone(): Plane;
  81857. /**
  81858. * @returns the string "Plane".
  81859. */
  81860. getClassName(): string;
  81861. /**
  81862. * @returns the Plane hash code.
  81863. */
  81864. getHashCode(): number;
  81865. /**
  81866. * Normalize the current Plane in place.
  81867. * @returns the updated Plane.
  81868. */
  81869. normalize(): Plane;
  81870. /**
  81871. * Applies a transformation the plane and returns the result
  81872. * @param transformation the transformation matrix to be applied to the plane
  81873. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81874. */
  81875. transform(transformation: DeepImmutable<Matrix>): Plane;
  81876. /**
  81877. * Compute the dot product between the point and the plane normal
  81878. * @param point point to calculate the dot product with
  81879. * @returns the dot product (float) of the point coordinates and the plane normal.
  81880. */
  81881. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81882. /**
  81883. * Updates the current Plane from the plane defined by the three given points.
  81884. * @param point1 one of the points used to contruct the plane
  81885. * @param point2 one of the points used to contruct the plane
  81886. * @param point3 one of the points used to contruct the plane
  81887. * @returns the updated Plane.
  81888. */
  81889. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81890. /**
  81891. * Checks if the plane is facing a given direction
  81892. * @param direction the direction to check if the plane is facing
  81893. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81894. * @returns True is the vector "direction" is the same side than the plane normal.
  81895. */
  81896. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81897. /**
  81898. * Calculates the distance to a point
  81899. * @param point point to calculate distance to
  81900. * @returns the signed distance (float) from the given point to the Plane.
  81901. */
  81902. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81903. /**
  81904. * Creates a plane from an array
  81905. * @param array the array to create a plane from
  81906. * @returns a new Plane from the given array.
  81907. */
  81908. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81909. /**
  81910. * Creates a plane from three points
  81911. * @param point1 point used to create the plane
  81912. * @param point2 point used to create the plane
  81913. * @param point3 point used to create the plane
  81914. * @returns a new Plane defined by the three given points.
  81915. */
  81916. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81917. /**
  81918. * Creates a plane from an origin point and a normal
  81919. * @param origin origin of the plane to be constructed
  81920. * @param normal normal of the plane to be constructed
  81921. * @returns a new Plane the normal vector to this plane at the given origin point.
  81922. * Note : the vector "normal" is updated because normalized.
  81923. */
  81924. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81925. /**
  81926. * Calculates the distance from a plane and a point
  81927. * @param origin origin of the plane to be constructed
  81928. * @param normal normal of the plane to be constructed
  81929. * @param point point to calculate distance to
  81930. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81931. */
  81932. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81933. }
  81934. }
  81935. declare module BABYLON {
  81936. /** @hidden */
  81937. export class PerformanceConfigurator {
  81938. /** @hidden */
  81939. static MatrixUse64Bits: boolean;
  81940. /** @hidden */
  81941. static MatrixTrackPrecisionChange: boolean;
  81942. /** @hidden */
  81943. static MatrixCurrentType: any;
  81944. /** @hidden */
  81945. static MatrixTrackedMatrices: Array<any> | null;
  81946. /** @hidden */
  81947. static SetMatrixPrecision(use64bits: boolean): void;
  81948. }
  81949. }
  81950. declare module BABYLON {
  81951. /**
  81952. * Class representing a vector containing 2 coordinates
  81953. */
  81954. export class Vector2 {
  81955. /** defines the first coordinate */
  81956. x: number;
  81957. /** defines the second coordinate */
  81958. y: number;
  81959. /**
  81960. * Creates a new Vector2 from the given x and y coordinates
  81961. * @param x defines the first coordinate
  81962. * @param y defines the second coordinate
  81963. */
  81964. constructor(
  81965. /** defines the first coordinate */
  81966. x?: number,
  81967. /** defines the second coordinate */
  81968. y?: number);
  81969. /**
  81970. * Gets a string with the Vector2 coordinates
  81971. * @returns a string with the Vector2 coordinates
  81972. */
  81973. toString(): string;
  81974. /**
  81975. * Gets class name
  81976. * @returns the string "Vector2"
  81977. */
  81978. getClassName(): string;
  81979. /**
  81980. * Gets current vector hash code
  81981. * @returns the Vector2 hash code as a number
  81982. */
  81983. getHashCode(): number;
  81984. /**
  81985. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81986. * @param array defines the source array
  81987. * @param index defines the offset in source array
  81988. * @returns the current Vector2
  81989. */
  81990. toArray(array: FloatArray, index?: number): Vector2;
  81991. /**
  81992. * Update the current vector from an array
  81993. * @param array defines the destination array
  81994. * @param index defines the offset in the destination array
  81995. * @returns the current Vector3
  81996. */
  81997. fromArray(array: FloatArray, index?: number): Vector2;
  81998. /**
  81999. * Copy the current vector to an array
  82000. * @returns a new array with 2 elements: the Vector2 coordinates.
  82001. */
  82002. asArray(): number[];
  82003. /**
  82004. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82005. * @param source defines the source Vector2
  82006. * @returns the current updated Vector2
  82007. */
  82008. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82009. /**
  82010. * Sets the Vector2 coordinates with the given floats
  82011. * @param x defines the first coordinate
  82012. * @param y defines the second coordinate
  82013. * @returns the current updated Vector2
  82014. */
  82015. copyFromFloats(x: number, y: number): Vector2;
  82016. /**
  82017. * Sets the Vector2 coordinates with the given floats
  82018. * @param x defines the first coordinate
  82019. * @param y defines the second coordinate
  82020. * @returns the current updated Vector2
  82021. */
  82022. set(x: number, y: number): Vector2;
  82023. /**
  82024. * Add another vector with the current one
  82025. * @param otherVector defines the other vector
  82026. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82027. */
  82028. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82029. /**
  82030. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82031. * @param otherVector defines the other vector
  82032. * @param result defines the target vector
  82033. * @returns the unmodified current Vector2
  82034. */
  82035. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82036. /**
  82037. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82038. * @param otherVector defines the other vector
  82039. * @returns the current updated Vector2
  82040. */
  82041. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82042. /**
  82043. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82044. * @param otherVector defines the other vector
  82045. * @returns a new Vector2
  82046. */
  82047. addVector3(otherVector: Vector3): Vector2;
  82048. /**
  82049. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82050. * @param otherVector defines the other vector
  82051. * @returns a new Vector2
  82052. */
  82053. subtract(otherVector: Vector2): Vector2;
  82054. /**
  82055. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82056. * @param otherVector defines the other vector
  82057. * @param result defines the target vector
  82058. * @returns the unmodified current Vector2
  82059. */
  82060. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82061. /**
  82062. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82063. * @param otherVector defines the other vector
  82064. * @returns the current updated Vector2
  82065. */
  82066. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82067. /**
  82068. * Multiplies in place the current Vector2 coordinates by the given ones
  82069. * @param otherVector defines the other vector
  82070. * @returns the current updated Vector2
  82071. */
  82072. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82073. /**
  82074. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82075. * @param otherVector defines the other vector
  82076. * @returns a new Vector2
  82077. */
  82078. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82079. /**
  82080. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82081. * @param otherVector defines the other vector
  82082. * @param result defines the target vector
  82083. * @returns the unmodified current Vector2
  82084. */
  82085. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82086. /**
  82087. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82088. * @param x defines the first coordinate
  82089. * @param y defines the second coordinate
  82090. * @returns a new Vector2
  82091. */
  82092. multiplyByFloats(x: number, y: number): Vector2;
  82093. /**
  82094. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82095. * @param otherVector defines the other vector
  82096. * @returns a new Vector2
  82097. */
  82098. divide(otherVector: Vector2): Vector2;
  82099. /**
  82100. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82101. * @param otherVector defines the other vector
  82102. * @param result defines the target vector
  82103. * @returns the unmodified current Vector2
  82104. */
  82105. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82106. /**
  82107. * Divides the current Vector2 coordinates by the given ones
  82108. * @param otherVector defines the other vector
  82109. * @returns the current updated Vector2
  82110. */
  82111. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82112. /**
  82113. * Gets a new Vector2 with current Vector2 negated coordinates
  82114. * @returns a new Vector2
  82115. */
  82116. negate(): Vector2;
  82117. /**
  82118. * Negate this vector in place
  82119. * @returns this
  82120. */
  82121. negateInPlace(): Vector2;
  82122. /**
  82123. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82124. * @param result defines the Vector3 object where to store the result
  82125. * @returns the current Vector2
  82126. */
  82127. negateToRef(result: Vector2): Vector2;
  82128. /**
  82129. * Multiply the Vector2 coordinates by scale
  82130. * @param scale defines the scaling factor
  82131. * @returns the current updated Vector2
  82132. */
  82133. scaleInPlace(scale: number): Vector2;
  82134. /**
  82135. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82136. * @param scale defines the scaling factor
  82137. * @returns a new Vector2
  82138. */
  82139. scale(scale: number): Vector2;
  82140. /**
  82141. * Scale the current Vector2 values by a factor to a given Vector2
  82142. * @param scale defines the scale factor
  82143. * @param result defines the Vector2 object where to store the result
  82144. * @returns the unmodified current Vector2
  82145. */
  82146. scaleToRef(scale: number, result: Vector2): Vector2;
  82147. /**
  82148. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82149. * @param scale defines the scale factor
  82150. * @param result defines the Vector2 object where to store the result
  82151. * @returns the unmodified current Vector2
  82152. */
  82153. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82154. /**
  82155. * Gets a boolean if two vectors are equals
  82156. * @param otherVector defines the other vector
  82157. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82158. */
  82159. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82160. /**
  82161. * Gets a boolean if two vectors are equals (using an epsilon value)
  82162. * @param otherVector defines the other vector
  82163. * @param epsilon defines the minimal distance to consider equality
  82164. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82165. */
  82166. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82167. /**
  82168. * Gets a new Vector2 from current Vector2 floored values
  82169. * @returns a new Vector2
  82170. */
  82171. floor(): Vector2;
  82172. /**
  82173. * Gets a new Vector2 from current Vector2 floored values
  82174. * @returns a new Vector2
  82175. */
  82176. fract(): Vector2;
  82177. /**
  82178. * Gets the length of the vector
  82179. * @returns the vector length (float)
  82180. */
  82181. length(): number;
  82182. /**
  82183. * Gets the vector squared length
  82184. * @returns the vector squared length (float)
  82185. */
  82186. lengthSquared(): number;
  82187. /**
  82188. * Normalize the vector
  82189. * @returns the current updated Vector2
  82190. */
  82191. normalize(): Vector2;
  82192. /**
  82193. * Gets a new Vector2 copied from the Vector2
  82194. * @returns a new Vector2
  82195. */
  82196. clone(): Vector2;
  82197. /**
  82198. * Gets a new Vector2(0, 0)
  82199. * @returns a new Vector2
  82200. */
  82201. static Zero(): Vector2;
  82202. /**
  82203. * Gets a new Vector2(1, 1)
  82204. * @returns a new Vector2
  82205. */
  82206. static One(): Vector2;
  82207. /**
  82208. * Gets a new Vector2 set from the given index element of the given array
  82209. * @param array defines the data source
  82210. * @param offset defines the offset in the data source
  82211. * @returns a new Vector2
  82212. */
  82213. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82214. /**
  82215. * Sets "result" from the given index element of the given array
  82216. * @param array defines the data source
  82217. * @param offset defines the offset in the data source
  82218. * @param result defines the target vector
  82219. */
  82220. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82221. /**
  82222. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82223. * @param value1 defines 1st point of control
  82224. * @param value2 defines 2nd point of control
  82225. * @param value3 defines 3rd point of control
  82226. * @param value4 defines 4th point of control
  82227. * @param amount defines the interpolation factor
  82228. * @returns a new Vector2
  82229. */
  82230. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82231. /**
  82232. * 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".
  82233. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82234. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82235. * @param value defines the value to clamp
  82236. * @param min defines the lower limit
  82237. * @param max defines the upper limit
  82238. * @returns a new Vector2
  82239. */
  82240. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82241. /**
  82242. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82243. * @param value1 defines the 1st control point
  82244. * @param tangent1 defines the outgoing tangent
  82245. * @param value2 defines the 2nd control point
  82246. * @param tangent2 defines the incoming tangent
  82247. * @param amount defines the interpolation factor
  82248. * @returns a new Vector2
  82249. */
  82250. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82251. /**
  82252. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82253. * @param start defines the start vector
  82254. * @param end defines the end vector
  82255. * @param amount defines the interpolation factor
  82256. * @returns a new Vector2
  82257. */
  82258. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82259. /**
  82260. * Gets the dot product of the vector "left" and the vector "right"
  82261. * @param left defines first vector
  82262. * @param right defines second vector
  82263. * @returns the dot product (float)
  82264. */
  82265. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82266. /**
  82267. * Returns a new Vector2 equal to the normalized given vector
  82268. * @param vector defines the vector to normalize
  82269. * @returns a new Vector2
  82270. */
  82271. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82272. /**
  82273. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82274. * @param left defines 1st vector
  82275. * @param right defines 2nd vector
  82276. * @returns a new Vector2
  82277. */
  82278. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82279. /**
  82280. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82281. * @param left defines 1st vector
  82282. * @param right defines 2nd vector
  82283. * @returns a new Vector2
  82284. */
  82285. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82286. /**
  82287. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82288. * @param vector defines the vector to transform
  82289. * @param transformation defines the matrix to apply
  82290. * @returns a new Vector2
  82291. */
  82292. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82293. /**
  82294. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82295. * @param vector defines the vector to transform
  82296. * @param transformation defines the matrix to apply
  82297. * @param result defines the target vector
  82298. */
  82299. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82300. /**
  82301. * Determines if a given vector is included in a triangle
  82302. * @param p defines the vector to test
  82303. * @param p0 defines 1st triangle point
  82304. * @param p1 defines 2nd triangle point
  82305. * @param p2 defines 3rd triangle point
  82306. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82307. */
  82308. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82309. /**
  82310. * Gets the distance between the vectors "value1" and "value2"
  82311. * @param value1 defines first vector
  82312. * @param value2 defines second vector
  82313. * @returns the distance between vectors
  82314. */
  82315. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82316. /**
  82317. * Returns the squared distance between the vectors "value1" and "value2"
  82318. * @param value1 defines first vector
  82319. * @param value2 defines second vector
  82320. * @returns the squared distance between vectors
  82321. */
  82322. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82323. /**
  82324. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82325. * @param value1 defines first vector
  82326. * @param value2 defines second vector
  82327. * @returns a new Vector2
  82328. */
  82329. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82330. /**
  82331. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82332. * @param p defines the middle point
  82333. * @param segA defines one point of the segment
  82334. * @param segB defines the other point of the segment
  82335. * @returns the shortest distance
  82336. */
  82337. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82338. }
  82339. /**
  82340. * Class used to store (x,y,z) vector representation
  82341. * A Vector3 is the main object used in 3D geometry
  82342. * It can represent etiher the coordinates of a point the space, either a direction
  82343. * Reminder: js uses a left handed forward facing system
  82344. */
  82345. export class Vector3 {
  82346. private static _UpReadOnly;
  82347. private static _ZeroReadOnly;
  82348. /** @hidden */
  82349. _x: number;
  82350. /** @hidden */
  82351. _y: number;
  82352. /** @hidden */
  82353. _z: number;
  82354. /** @hidden */
  82355. _isDirty: boolean;
  82356. /** Gets or sets the x coordinate */
  82357. get x(): number;
  82358. set x(value: number);
  82359. /** Gets or sets the y coordinate */
  82360. get y(): number;
  82361. set y(value: number);
  82362. /** Gets or sets the z coordinate */
  82363. get z(): number;
  82364. set z(value: number);
  82365. /**
  82366. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82367. * @param x defines the first coordinates (on X axis)
  82368. * @param y defines the second coordinates (on Y axis)
  82369. * @param z defines the third coordinates (on Z axis)
  82370. */
  82371. constructor(x?: number, y?: number, z?: number);
  82372. /**
  82373. * Creates a string representation of the Vector3
  82374. * @returns a string with the Vector3 coordinates.
  82375. */
  82376. toString(): string;
  82377. /**
  82378. * Gets the class name
  82379. * @returns the string "Vector3"
  82380. */
  82381. getClassName(): string;
  82382. /**
  82383. * Creates the Vector3 hash code
  82384. * @returns a number which tends to be unique between Vector3 instances
  82385. */
  82386. getHashCode(): number;
  82387. /**
  82388. * Creates an array containing three elements : the coordinates of the Vector3
  82389. * @returns a new array of numbers
  82390. */
  82391. asArray(): number[];
  82392. /**
  82393. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82394. * @param array defines the destination array
  82395. * @param index defines the offset in the destination array
  82396. * @returns the current Vector3
  82397. */
  82398. toArray(array: FloatArray, index?: number): Vector3;
  82399. /**
  82400. * Update the current vector from an array
  82401. * @param array defines the destination array
  82402. * @param index defines the offset in the destination array
  82403. * @returns the current Vector3
  82404. */
  82405. fromArray(array: FloatArray, index?: number): Vector3;
  82406. /**
  82407. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82408. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82409. */
  82410. toQuaternion(): Quaternion;
  82411. /**
  82412. * Adds the given vector to the current Vector3
  82413. * @param otherVector defines the second operand
  82414. * @returns the current updated Vector3
  82415. */
  82416. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82417. /**
  82418. * Adds the given coordinates to the current Vector3
  82419. * @param x defines the x coordinate of the operand
  82420. * @param y defines the y coordinate of the operand
  82421. * @param z defines the z coordinate of the operand
  82422. * @returns the current updated Vector3
  82423. */
  82424. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82425. /**
  82426. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82427. * @param otherVector defines the second operand
  82428. * @returns the resulting Vector3
  82429. */
  82430. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82431. /**
  82432. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82433. * @param otherVector defines the second operand
  82434. * @param result defines the Vector3 object where to store the result
  82435. * @returns the current Vector3
  82436. */
  82437. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82438. /**
  82439. * Subtract the given vector from the current Vector3
  82440. * @param otherVector defines the second operand
  82441. * @returns the current updated Vector3
  82442. */
  82443. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82444. /**
  82445. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82446. * @param otherVector defines the second operand
  82447. * @returns the resulting Vector3
  82448. */
  82449. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82450. /**
  82451. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82452. * @param otherVector defines the second operand
  82453. * @param result defines the Vector3 object where to store the result
  82454. * @returns the current Vector3
  82455. */
  82456. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82457. /**
  82458. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82459. * @param x defines the x coordinate of the operand
  82460. * @param y defines the y coordinate of the operand
  82461. * @param z defines the z coordinate of the operand
  82462. * @returns the resulting Vector3
  82463. */
  82464. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82465. /**
  82466. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82467. * @param x defines the x coordinate of the operand
  82468. * @param y defines the y coordinate of the operand
  82469. * @param z defines the z coordinate of the operand
  82470. * @param result defines the Vector3 object where to store the result
  82471. * @returns the current Vector3
  82472. */
  82473. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82474. /**
  82475. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82476. * @returns a new Vector3
  82477. */
  82478. negate(): Vector3;
  82479. /**
  82480. * Negate this vector in place
  82481. * @returns this
  82482. */
  82483. negateInPlace(): Vector3;
  82484. /**
  82485. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82486. * @param result defines the Vector3 object where to store the result
  82487. * @returns the current Vector3
  82488. */
  82489. negateToRef(result: Vector3): Vector3;
  82490. /**
  82491. * Multiplies the Vector3 coordinates by the float "scale"
  82492. * @param scale defines the multiplier factor
  82493. * @returns the current updated Vector3
  82494. */
  82495. scaleInPlace(scale: number): Vector3;
  82496. /**
  82497. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82498. * @param scale defines the multiplier factor
  82499. * @returns a new Vector3
  82500. */
  82501. scale(scale: number): Vector3;
  82502. /**
  82503. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82504. * @param scale defines the multiplier factor
  82505. * @param result defines the Vector3 object where to store the result
  82506. * @returns the current Vector3
  82507. */
  82508. scaleToRef(scale: number, result: Vector3): Vector3;
  82509. /**
  82510. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82511. * @param scale defines the scale factor
  82512. * @param result defines the Vector3 object where to store the result
  82513. * @returns the unmodified current Vector3
  82514. */
  82515. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82516. /**
  82517. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82518. * @param origin defines the origin of the projection ray
  82519. * @param plane defines the plane to project to
  82520. * @returns the projected vector3
  82521. */
  82522. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82523. /**
  82524. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82525. * @param origin defines the origin of the projection ray
  82526. * @param plane defines the plane to project to
  82527. * @param result defines the Vector3 where to store the result
  82528. */
  82529. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82530. /**
  82531. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82532. * @param otherVector defines the second operand
  82533. * @returns true if both vectors are equals
  82534. */
  82535. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82536. /**
  82537. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82538. * @param otherVector defines the second operand
  82539. * @param epsilon defines the minimal distance to define values as equals
  82540. * @returns true if both vectors are distant less than epsilon
  82541. */
  82542. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82543. /**
  82544. * Returns true if the current Vector3 coordinates equals the given floats
  82545. * @param x defines the x coordinate of the operand
  82546. * @param y defines the y coordinate of the operand
  82547. * @param z defines the z coordinate of the operand
  82548. * @returns true if both vectors are equals
  82549. */
  82550. equalsToFloats(x: number, y: number, z: number): boolean;
  82551. /**
  82552. * Multiplies the current Vector3 coordinates by the given ones
  82553. * @param otherVector defines the second operand
  82554. * @returns the current updated Vector3
  82555. */
  82556. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82557. /**
  82558. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82559. * @param otherVector defines the second operand
  82560. * @returns the new Vector3
  82561. */
  82562. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82563. /**
  82564. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82565. * @param otherVector defines the second operand
  82566. * @param result defines the Vector3 object where to store the result
  82567. * @returns the current Vector3
  82568. */
  82569. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82570. /**
  82571. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82572. * @param x defines the x coordinate of the operand
  82573. * @param y defines the y coordinate of the operand
  82574. * @param z defines the z coordinate of the operand
  82575. * @returns the new Vector3
  82576. */
  82577. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82578. /**
  82579. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82580. * @param otherVector defines the second operand
  82581. * @returns the new Vector3
  82582. */
  82583. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82584. /**
  82585. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82586. * @param otherVector defines the second operand
  82587. * @param result defines the Vector3 object where to store the result
  82588. * @returns the current Vector3
  82589. */
  82590. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82591. /**
  82592. * Divides the current Vector3 coordinates by the given ones.
  82593. * @param otherVector defines the second operand
  82594. * @returns the current updated Vector3
  82595. */
  82596. divideInPlace(otherVector: Vector3): Vector3;
  82597. /**
  82598. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  82599. * @param other defines the second operand
  82600. * @returns the current updated Vector3
  82601. */
  82602. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82603. /**
  82604. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  82605. * @param other defines the second operand
  82606. * @returns the current updated Vector3
  82607. */
  82608. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82609. /**
  82610. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  82611. * @param x defines the x coordinate of the operand
  82612. * @param y defines the y coordinate of the operand
  82613. * @param z defines the z coordinate of the operand
  82614. * @returns the current updated Vector3
  82615. */
  82616. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82617. /**
  82618. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82619. * @param x defines the x coordinate of the operand
  82620. * @param y defines the y coordinate of the operand
  82621. * @param z defines the z coordinate of the operand
  82622. * @returns the current updated Vector3
  82623. */
  82624. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82625. /**
  82626. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82627. * Check if is non uniform within a certain amount of decimal places to account for this
  82628. * @param epsilon the amount the values can differ
  82629. * @returns if the the vector is non uniform to a certain number of decimal places
  82630. */
  82631. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82632. /**
  82633. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82634. */
  82635. get isNonUniform(): boolean;
  82636. /**
  82637. * Gets a new Vector3 from current Vector3 floored values
  82638. * @returns a new Vector3
  82639. */
  82640. floor(): Vector3;
  82641. /**
  82642. * Gets a new Vector3 from current Vector3 floored values
  82643. * @returns a new Vector3
  82644. */
  82645. fract(): Vector3;
  82646. /**
  82647. * Gets the length of the Vector3
  82648. * @returns the length of the Vector3
  82649. */
  82650. length(): number;
  82651. /**
  82652. * Gets the squared length of the Vector3
  82653. * @returns squared length of the Vector3
  82654. */
  82655. lengthSquared(): number;
  82656. /**
  82657. * Normalize the current Vector3.
  82658. * Please note that this is an in place operation.
  82659. * @returns the current updated Vector3
  82660. */
  82661. normalize(): Vector3;
  82662. /**
  82663. * Reorders the x y z properties of the vector in place
  82664. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  82665. * @returns the current updated vector
  82666. */
  82667. reorderInPlace(order: string): this;
  82668. /**
  82669. * Rotates the vector around 0,0,0 by a quaternion
  82670. * @param quaternion the rotation quaternion
  82671. * @param result vector to store the result
  82672. * @returns the resulting vector
  82673. */
  82674. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  82675. /**
  82676. * Rotates a vector around a given point
  82677. * @param quaternion the rotation quaternion
  82678. * @param point the point to rotate around
  82679. * @param result vector to store the result
  82680. * @returns the resulting vector
  82681. */
  82682. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  82683. /**
  82684. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  82685. * The cross product is then orthogonal to both current and "other"
  82686. * @param other defines the right operand
  82687. * @returns the cross product
  82688. */
  82689. cross(other: Vector3): Vector3;
  82690. /**
  82691. * Normalize the current Vector3 with the given input length.
  82692. * Please note that this is an in place operation.
  82693. * @param len the length of the vector
  82694. * @returns the current updated Vector3
  82695. */
  82696. normalizeFromLength(len: number): Vector3;
  82697. /**
  82698. * Normalize the current Vector3 to a new vector
  82699. * @returns the new Vector3
  82700. */
  82701. normalizeToNew(): Vector3;
  82702. /**
  82703. * Normalize the current Vector3 to the reference
  82704. * @param reference define the Vector3 to update
  82705. * @returns the updated Vector3
  82706. */
  82707. normalizeToRef(reference: Vector3): Vector3;
  82708. /**
  82709. * Creates a new Vector3 copied from the current Vector3
  82710. * @returns the new Vector3
  82711. */
  82712. clone(): Vector3;
  82713. /**
  82714. * Copies the given vector coordinates to the current Vector3 ones
  82715. * @param source defines the source Vector3
  82716. * @returns the current updated Vector3
  82717. */
  82718. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  82719. /**
  82720. * Copies the given floats to the current Vector3 coordinates
  82721. * @param x defines the x coordinate of the operand
  82722. * @param y defines the y coordinate of the operand
  82723. * @param z defines the z coordinate of the operand
  82724. * @returns the current updated Vector3
  82725. */
  82726. copyFromFloats(x: number, y: number, z: number): Vector3;
  82727. /**
  82728. * Copies the given floats to the current Vector3 coordinates
  82729. * @param x defines the x coordinate of the operand
  82730. * @param y defines the y coordinate of the operand
  82731. * @param z defines the z coordinate of the operand
  82732. * @returns the current updated Vector3
  82733. */
  82734. set(x: number, y: number, z: number): Vector3;
  82735. /**
  82736. * Copies the given float to the current Vector3 coordinates
  82737. * @param v defines the x, y and z coordinates of the operand
  82738. * @returns the current updated Vector3
  82739. */
  82740. setAll(v: number): Vector3;
  82741. /**
  82742. * Get the clip factor between two vectors
  82743. * @param vector0 defines the first operand
  82744. * @param vector1 defines the second operand
  82745. * @param axis defines the axis to use
  82746. * @param size defines the size along the axis
  82747. * @returns the clip factor
  82748. */
  82749. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  82750. /**
  82751. * Get angle between two vectors
  82752. * @param vector0 angle between vector0 and vector1
  82753. * @param vector1 angle between vector0 and vector1
  82754. * @param normal direction of the normal
  82755. * @return the angle between vector0 and vector1
  82756. */
  82757. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  82758. /**
  82759. * Returns a new Vector3 set from the index "offset" of the given array
  82760. * @param array defines the source array
  82761. * @param offset defines the offset in the source array
  82762. * @returns the new Vector3
  82763. */
  82764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  82765. /**
  82766. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  82767. * @param array defines the source array
  82768. * @param offset defines the offset in the source array
  82769. * @returns the new Vector3
  82770. * @deprecated Please use FromArray instead.
  82771. */
  82772. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  82773. /**
  82774. * Sets the given vector "result" with the element values from the index "offset" of the given array
  82775. * @param array defines the source array
  82776. * @param offset defines the offset in the source array
  82777. * @param result defines the Vector3 where to store the result
  82778. */
  82779. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  82780. /**
  82781. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  82782. * @param array defines the source array
  82783. * @param offset defines the offset in the source array
  82784. * @param result defines the Vector3 where to store the result
  82785. * @deprecated Please use FromArrayToRef instead.
  82786. */
  82787. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  82788. /**
  82789. * Sets the given vector "result" with the given floats.
  82790. * @param x defines the x coordinate of the source
  82791. * @param y defines the y coordinate of the source
  82792. * @param z defines the z coordinate of the source
  82793. * @param result defines the Vector3 where to store the result
  82794. */
  82795. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  82796. /**
  82797. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  82798. * @returns a new empty Vector3
  82799. */
  82800. static Zero(): Vector3;
  82801. /**
  82802. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  82803. * @returns a new unit Vector3
  82804. */
  82805. static One(): Vector3;
  82806. /**
  82807. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  82808. * @returns a new up Vector3
  82809. */
  82810. static Up(): Vector3;
  82811. /**
  82812. * Gets a up Vector3 that must not be updated
  82813. */
  82814. static get UpReadOnly(): DeepImmutable<Vector3>;
  82815. /**
  82816. * Gets a zero Vector3 that must not be updated
  82817. */
  82818. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  82819. /**
  82820. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  82821. * @returns a new down Vector3
  82822. */
  82823. static Down(): Vector3;
  82824. /**
  82825. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  82826. * @param rightHandedSystem is the scene right-handed (negative z)
  82827. * @returns a new forward Vector3
  82828. */
  82829. static Forward(rightHandedSystem?: boolean): Vector3;
  82830. /**
  82831. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  82832. * @param rightHandedSystem is the scene right-handed (negative-z)
  82833. * @returns a new forward Vector3
  82834. */
  82835. static Backward(rightHandedSystem?: boolean): Vector3;
  82836. /**
  82837. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  82838. * @returns a new right Vector3
  82839. */
  82840. static Right(): Vector3;
  82841. /**
  82842. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  82843. * @returns a new left Vector3
  82844. */
  82845. static Left(): Vector3;
  82846. /**
  82847. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82848. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82849. * @param vector defines the Vector3 to transform
  82850. * @param transformation defines the transformation matrix
  82851. * @returns the transformed Vector3
  82852. */
  82853. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82854. /**
  82855. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82856. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82857. * @param vector defines the Vector3 to transform
  82858. * @param transformation defines the transformation matrix
  82859. * @param result defines the Vector3 where to store the result
  82860. */
  82861. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82862. /**
  82863. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82864. * This method computes tranformed coordinates only, not transformed direction vectors
  82865. * @param x define the x coordinate of the source vector
  82866. * @param y define the y coordinate of the source vector
  82867. * @param z define the z coordinate of the source vector
  82868. * @param transformation defines the transformation matrix
  82869. * @param result defines the Vector3 where to store the result
  82870. */
  82871. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82872. /**
  82873. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82874. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82875. * @param vector defines the Vector3 to transform
  82876. * @param transformation defines the transformation matrix
  82877. * @returns the new Vector3
  82878. */
  82879. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82880. /**
  82881. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82882. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82883. * @param vector defines the Vector3 to transform
  82884. * @param transformation defines the transformation matrix
  82885. * @param result defines the Vector3 where to store the result
  82886. */
  82887. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82888. /**
  82889. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82890. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82891. * @param x define the x coordinate of the source vector
  82892. * @param y define the y coordinate of the source vector
  82893. * @param z define the z coordinate of the source vector
  82894. * @param transformation defines the transformation matrix
  82895. * @param result defines the Vector3 where to store the result
  82896. */
  82897. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82898. /**
  82899. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82900. * @param value1 defines the first control point
  82901. * @param value2 defines the second control point
  82902. * @param value3 defines the third control point
  82903. * @param value4 defines the fourth control point
  82904. * @param amount defines the amount on the spline to use
  82905. * @returns the new Vector3
  82906. */
  82907. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82908. /**
  82909. * 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"
  82910. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82911. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82912. * @param value defines the current value
  82913. * @param min defines the lower range value
  82914. * @param max defines the upper range value
  82915. * @returns the new Vector3
  82916. */
  82917. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82918. /**
  82919. * 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"
  82920. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82921. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82922. * @param value defines the current value
  82923. * @param min defines the lower range value
  82924. * @param max defines the upper range value
  82925. * @param result defines the Vector3 where to store the result
  82926. */
  82927. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82928. /**
  82929. * Checks if a given vector is inside a specific range
  82930. * @param v defines the vector to test
  82931. * @param min defines the minimum range
  82932. * @param max defines the maximum range
  82933. */
  82934. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82935. /**
  82936. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82937. * @param value1 defines the first control point
  82938. * @param tangent1 defines the first tangent vector
  82939. * @param value2 defines the second control point
  82940. * @param tangent2 defines the second tangent vector
  82941. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82942. * @returns the new Vector3
  82943. */
  82944. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82945. /**
  82946. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82947. * @param start defines the start value
  82948. * @param end defines the end value
  82949. * @param amount max defines amount between both (between 0 and 1)
  82950. * @returns the new Vector3
  82951. */
  82952. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82953. /**
  82954. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82955. * @param start defines the start value
  82956. * @param end defines the end value
  82957. * @param amount max defines amount between both (between 0 and 1)
  82958. * @param result defines the Vector3 where to store the result
  82959. */
  82960. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82961. /**
  82962. * Returns the dot product (float) between the vectors "left" and "right"
  82963. * @param left defines the left operand
  82964. * @param right defines the right operand
  82965. * @returns the dot product
  82966. */
  82967. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82968. /**
  82969. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82970. * The cross product is then orthogonal to both "left" and "right"
  82971. * @param left defines the left operand
  82972. * @param right defines the right operand
  82973. * @returns the cross product
  82974. */
  82975. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82976. /**
  82977. * Sets the given vector "result" with the cross product of "left" and "right"
  82978. * The cross product is then orthogonal to both "left" and "right"
  82979. * @param left defines the left operand
  82980. * @param right defines the right operand
  82981. * @param result defines the Vector3 where to store the result
  82982. */
  82983. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82984. /**
  82985. * Returns a new Vector3 as the normalization of the given vector
  82986. * @param vector defines the Vector3 to normalize
  82987. * @returns the new Vector3
  82988. */
  82989. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82990. /**
  82991. * Sets the given vector "result" with the normalization of the given first vector
  82992. * @param vector defines the Vector3 to normalize
  82993. * @param result defines the Vector3 where to store the result
  82994. */
  82995. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82996. /**
  82997. * Project a Vector3 onto screen space
  82998. * @param vector defines the Vector3 to project
  82999. * @param world defines the world matrix to use
  83000. * @param transform defines the transform (view x projection) matrix to use
  83001. * @param viewport defines the screen viewport to use
  83002. * @returns the new Vector3
  83003. */
  83004. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83005. /** @hidden */
  83006. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83007. /**
  83008. * Unproject from screen space to object space
  83009. * @param source defines the screen space Vector3 to use
  83010. * @param viewportWidth defines the current width of the viewport
  83011. * @param viewportHeight defines the current height of the viewport
  83012. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83013. * @param transform defines the transform (view x projection) matrix to use
  83014. * @returns the new Vector3
  83015. */
  83016. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83017. /**
  83018. * Unproject from screen space to object space
  83019. * @param source defines the screen space Vector3 to use
  83020. * @param viewportWidth defines the current width of the viewport
  83021. * @param viewportHeight defines the current height of the viewport
  83022. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83023. * @param view defines the view matrix to use
  83024. * @param projection defines the projection matrix to use
  83025. * @returns the new Vector3
  83026. */
  83027. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83028. /**
  83029. * Unproject from screen space to object space
  83030. * @param source defines the screen space Vector3 to use
  83031. * @param viewportWidth defines the current width of the viewport
  83032. * @param viewportHeight defines the current height of the viewport
  83033. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83034. * @param view defines the view matrix to use
  83035. * @param projection defines the projection matrix to use
  83036. * @param result defines the Vector3 where to store the result
  83037. */
  83038. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83039. /**
  83040. * Unproject from screen space to object space
  83041. * @param sourceX defines the screen space x coordinate to use
  83042. * @param sourceY defines the screen space y coordinate to use
  83043. * @param sourceZ defines the screen space z coordinate to use
  83044. * @param viewportWidth defines the current width of the viewport
  83045. * @param viewportHeight defines the current height of the viewport
  83046. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83047. * @param view defines the view matrix to use
  83048. * @param projection defines the projection matrix to use
  83049. * @param result defines the Vector3 where to store the result
  83050. */
  83051. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83052. /**
  83053. * Gets the minimal coordinate values between two Vector3
  83054. * @param left defines the first operand
  83055. * @param right defines the second operand
  83056. * @returns the new Vector3
  83057. */
  83058. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83059. /**
  83060. * Gets the maximal coordinate values between two Vector3
  83061. * @param left defines the first operand
  83062. * @param right defines the second operand
  83063. * @returns the new Vector3
  83064. */
  83065. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83066. /**
  83067. * Returns the distance between the vectors "value1" and "value2"
  83068. * @param value1 defines the first operand
  83069. * @param value2 defines the second operand
  83070. * @returns the distance
  83071. */
  83072. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83073. /**
  83074. * Returns the squared distance between the vectors "value1" and "value2"
  83075. * @param value1 defines the first operand
  83076. * @param value2 defines the second operand
  83077. * @returns the squared distance
  83078. */
  83079. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83080. /**
  83081. * Returns a new Vector3 located at the center between "value1" and "value2"
  83082. * @param value1 defines the first operand
  83083. * @param value2 defines the second operand
  83084. * @returns the new Vector3
  83085. */
  83086. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83087. /**
  83088. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83089. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83090. * to something in order to rotate it from its local system to the given target system
  83091. * Note: axis1, axis2 and axis3 are normalized during this operation
  83092. * @param axis1 defines the first axis
  83093. * @param axis2 defines the second axis
  83094. * @param axis3 defines the third axis
  83095. * @returns a new Vector3
  83096. */
  83097. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83098. /**
  83099. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83100. * @param axis1 defines the first axis
  83101. * @param axis2 defines the second axis
  83102. * @param axis3 defines the third axis
  83103. * @param ref defines the Vector3 where to store the result
  83104. */
  83105. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83106. }
  83107. /**
  83108. * Vector4 class created for EulerAngle class conversion to Quaternion
  83109. */
  83110. export class Vector4 {
  83111. /** x value of the vector */
  83112. x: number;
  83113. /** y value of the vector */
  83114. y: number;
  83115. /** z value of the vector */
  83116. z: number;
  83117. /** w value of the vector */
  83118. w: number;
  83119. /**
  83120. * Creates a Vector4 object from the given floats.
  83121. * @param x x value of the vector
  83122. * @param y y value of the vector
  83123. * @param z z value of the vector
  83124. * @param w w value of the vector
  83125. */
  83126. constructor(
  83127. /** x value of the vector */
  83128. x: number,
  83129. /** y value of the vector */
  83130. y: number,
  83131. /** z value of the vector */
  83132. z: number,
  83133. /** w value of the vector */
  83134. w: number);
  83135. /**
  83136. * Returns the string with the Vector4 coordinates.
  83137. * @returns a string containing all the vector values
  83138. */
  83139. toString(): string;
  83140. /**
  83141. * Returns the string "Vector4".
  83142. * @returns "Vector4"
  83143. */
  83144. getClassName(): string;
  83145. /**
  83146. * Returns the Vector4 hash code.
  83147. * @returns a unique hash code
  83148. */
  83149. getHashCode(): number;
  83150. /**
  83151. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83152. * @returns the resulting array
  83153. */
  83154. asArray(): number[];
  83155. /**
  83156. * Populates the given array from the given index with the Vector4 coordinates.
  83157. * @param array array to populate
  83158. * @param index index of the array to start at (default: 0)
  83159. * @returns the Vector4.
  83160. */
  83161. toArray(array: FloatArray, index?: number): Vector4;
  83162. /**
  83163. * Update the current vector from an array
  83164. * @param array defines the destination array
  83165. * @param index defines the offset in the destination array
  83166. * @returns the current Vector3
  83167. */
  83168. fromArray(array: FloatArray, index?: number): Vector4;
  83169. /**
  83170. * Adds the given vector to the current Vector4.
  83171. * @param otherVector the vector to add
  83172. * @returns the updated Vector4.
  83173. */
  83174. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83175. /**
  83176. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83177. * @param otherVector the vector to add
  83178. * @returns the resulting vector
  83179. */
  83180. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83181. /**
  83182. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83183. * @param otherVector the vector to add
  83184. * @param result the vector to store the result
  83185. * @returns the current Vector4.
  83186. */
  83187. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83188. /**
  83189. * Subtract in place the given vector from the current Vector4.
  83190. * @param otherVector the vector to subtract
  83191. * @returns the updated Vector4.
  83192. */
  83193. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83194. /**
  83195. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83196. * @param otherVector the vector to add
  83197. * @returns the new vector with the result
  83198. */
  83199. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83200. /**
  83201. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83202. * @param otherVector the vector to subtract
  83203. * @param result the vector to store the result
  83204. * @returns the current Vector4.
  83205. */
  83206. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83207. /**
  83208. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83209. */
  83210. /**
  83211. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83212. * @param x value to subtract
  83213. * @param y value to subtract
  83214. * @param z value to subtract
  83215. * @param w value to subtract
  83216. * @returns new vector containing the result
  83217. */
  83218. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83219. /**
  83220. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83221. * @param x value to subtract
  83222. * @param y value to subtract
  83223. * @param z value to subtract
  83224. * @param w value to subtract
  83225. * @param result the vector to store the result in
  83226. * @returns the current Vector4.
  83227. */
  83228. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83229. /**
  83230. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83231. * @returns a new vector with the negated values
  83232. */
  83233. negate(): Vector4;
  83234. /**
  83235. * Negate this vector in place
  83236. * @returns this
  83237. */
  83238. negateInPlace(): Vector4;
  83239. /**
  83240. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83241. * @param result defines the Vector3 object where to store the result
  83242. * @returns the current Vector4
  83243. */
  83244. negateToRef(result: Vector4): Vector4;
  83245. /**
  83246. * Multiplies the current Vector4 coordinates by scale (float).
  83247. * @param scale the number to scale with
  83248. * @returns the updated Vector4.
  83249. */
  83250. scaleInPlace(scale: number): Vector4;
  83251. /**
  83252. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83253. * @param scale the number to scale with
  83254. * @returns a new vector with the result
  83255. */
  83256. scale(scale: number): Vector4;
  83257. /**
  83258. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83259. * @param scale the number to scale with
  83260. * @param result a vector to store the result in
  83261. * @returns the current Vector4.
  83262. */
  83263. scaleToRef(scale: number, result: Vector4): Vector4;
  83264. /**
  83265. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83266. * @param scale defines the scale factor
  83267. * @param result defines the Vector4 object where to store the result
  83268. * @returns the unmodified current Vector4
  83269. */
  83270. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83271. /**
  83272. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83273. * @param otherVector the vector to compare against
  83274. * @returns true if they are equal
  83275. */
  83276. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83277. /**
  83278. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83279. * @param otherVector vector to compare against
  83280. * @param epsilon (Default: very small number)
  83281. * @returns true if they are equal
  83282. */
  83283. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83284. /**
  83285. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83286. * @param x x value to compare against
  83287. * @param y y value to compare against
  83288. * @param z z value to compare against
  83289. * @param w w value to compare against
  83290. * @returns true if equal
  83291. */
  83292. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83293. /**
  83294. * Multiplies in place the current Vector4 by the given one.
  83295. * @param otherVector vector to multiple with
  83296. * @returns the updated Vector4.
  83297. */
  83298. multiplyInPlace(otherVector: Vector4): Vector4;
  83299. /**
  83300. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83301. * @param otherVector vector to multiple with
  83302. * @returns resulting new vector
  83303. */
  83304. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83305. /**
  83306. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83307. * @param otherVector vector to multiple with
  83308. * @param result vector to store the result
  83309. * @returns the current Vector4.
  83310. */
  83311. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83312. /**
  83313. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83314. * @param x x value multiply with
  83315. * @param y y value multiply with
  83316. * @param z z value multiply with
  83317. * @param w w value multiply with
  83318. * @returns resulting new vector
  83319. */
  83320. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83321. /**
  83322. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83323. * @param otherVector vector to devide with
  83324. * @returns resulting new vector
  83325. */
  83326. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83327. /**
  83328. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83329. * @param otherVector vector to devide with
  83330. * @param result vector to store the result
  83331. * @returns the current Vector4.
  83332. */
  83333. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83334. /**
  83335. * Divides the current Vector3 coordinates by the given ones.
  83336. * @param otherVector vector to devide with
  83337. * @returns the updated Vector3.
  83338. */
  83339. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83340. /**
  83341. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83342. * @param other defines the second operand
  83343. * @returns the current updated Vector4
  83344. */
  83345. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83346. /**
  83347. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83348. * @param other defines the second operand
  83349. * @returns the current updated Vector4
  83350. */
  83351. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83352. /**
  83353. * Gets a new Vector4 from current Vector4 floored values
  83354. * @returns a new Vector4
  83355. */
  83356. floor(): Vector4;
  83357. /**
  83358. * Gets a new Vector4 from current Vector3 floored values
  83359. * @returns a new Vector4
  83360. */
  83361. fract(): Vector4;
  83362. /**
  83363. * Returns the Vector4 length (float).
  83364. * @returns the length
  83365. */
  83366. length(): number;
  83367. /**
  83368. * Returns the Vector4 squared length (float).
  83369. * @returns the length squared
  83370. */
  83371. lengthSquared(): number;
  83372. /**
  83373. * Normalizes in place the Vector4.
  83374. * @returns the updated Vector4.
  83375. */
  83376. normalize(): Vector4;
  83377. /**
  83378. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83379. * @returns this converted to a new vector3
  83380. */
  83381. toVector3(): Vector3;
  83382. /**
  83383. * Returns a new Vector4 copied from the current one.
  83384. * @returns the new cloned vector
  83385. */
  83386. clone(): Vector4;
  83387. /**
  83388. * Updates the current Vector4 with the given one coordinates.
  83389. * @param source the source vector to copy from
  83390. * @returns the updated Vector4.
  83391. */
  83392. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83393. /**
  83394. * Updates the current Vector4 coordinates with the given floats.
  83395. * @param x float to copy from
  83396. * @param y float to copy from
  83397. * @param z float to copy from
  83398. * @param w float to copy from
  83399. * @returns the updated Vector4.
  83400. */
  83401. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83402. /**
  83403. * Updates the current Vector4 coordinates with the given floats.
  83404. * @param x float to set from
  83405. * @param y float to set from
  83406. * @param z float to set from
  83407. * @param w float to set from
  83408. * @returns the updated Vector4.
  83409. */
  83410. set(x: number, y: number, z: number, w: number): Vector4;
  83411. /**
  83412. * Copies the given float to the current Vector3 coordinates
  83413. * @param v defines the x, y, z and w coordinates of the operand
  83414. * @returns the current updated Vector3
  83415. */
  83416. setAll(v: number): Vector4;
  83417. /**
  83418. * Returns a new Vector4 set from the starting index of the given array.
  83419. * @param array the array to pull values from
  83420. * @param offset the offset into the array to start at
  83421. * @returns the new vector
  83422. */
  83423. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83424. /**
  83425. * Updates the given vector "result" from the starting index of the given array.
  83426. * @param array the array to pull values from
  83427. * @param offset the offset into the array to start at
  83428. * @param result the vector to store the result in
  83429. */
  83430. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83431. /**
  83432. * Updates the given vector "result" from the starting index of the given Float32Array.
  83433. * @param array the array to pull values from
  83434. * @param offset the offset into the array to start at
  83435. * @param result the vector to store the result in
  83436. */
  83437. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83438. /**
  83439. * Updates the given vector "result" coordinates from the given floats.
  83440. * @param x float to set from
  83441. * @param y float to set from
  83442. * @param z float to set from
  83443. * @param w float to set from
  83444. * @param result the vector to the floats in
  83445. */
  83446. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83447. /**
  83448. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83449. * @returns the new vector
  83450. */
  83451. static Zero(): Vector4;
  83452. /**
  83453. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83454. * @returns the new vector
  83455. */
  83456. static One(): Vector4;
  83457. /**
  83458. * Returns a new normalized Vector4 from the given one.
  83459. * @param vector the vector to normalize
  83460. * @returns the vector
  83461. */
  83462. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83463. /**
  83464. * Updates the given vector "result" from the normalization of the given one.
  83465. * @param vector the vector to normalize
  83466. * @param result the vector to store the result in
  83467. */
  83468. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83469. /**
  83470. * Returns a vector with the minimum values from the left and right vectors
  83471. * @param left left vector to minimize
  83472. * @param right right vector to minimize
  83473. * @returns a new vector with the minimum of the left and right vector values
  83474. */
  83475. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83476. /**
  83477. * Returns a vector with the maximum values from the left and right vectors
  83478. * @param left left vector to maximize
  83479. * @param right right vector to maximize
  83480. * @returns a new vector with the maximum of the left and right vector values
  83481. */
  83482. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83483. /**
  83484. * Returns the distance (float) between the vectors "value1" and "value2".
  83485. * @param value1 value to calulate the distance between
  83486. * @param value2 value to calulate the distance between
  83487. * @return the distance between the two vectors
  83488. */
  83489. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83490. /**
  83491. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83492. * @param value1 value to calulate the distance between
  83493. * @param value2 value to calulate the distance between
  83494. * @return the distance between the two vectors squared
  83495. */
  83496. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83497. /**
  83498. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83499. * @param value1 value to calulate the center between
  83500. * @param value2 value to calulate the center between
  83501. * @return the center between the two vectors
  83502. */
  83503. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83504. /**
  83505. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83506. * This methods computes transformed normalized direction vectors only.
  83507. * @param vector the vector to transform
  83508. * @param transformation the transformation matrix to apply
  83509. * @returns the new vector
  83510. */
  83511. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83512. /**
  83513. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83514. * This methods computes transformed normalized direction vectors only.
  83515. * @param vector the vector to transform
  83516. * @param transformation the transformation matrix to apply
  83517. * @param result the vector to store the result in
  83518. */
  83519. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83520. /**
  83521. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83522. * This methods computes transformed normalized direction vectors only.
  83523. * @param x value to transform
  83524. * @param y value to transform
  83525. * @param z value to transform
  83526. * @param w value to transform
  83527. * @param transformation the transformation matrix to apply
  83528. * @param result the vector to store the results in
  83529. */
  83530. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83531. /**
  83532. * Creates a new Vector4 from a Vector3
  83533. * @param source defines the source data
  83534. * @param w defines the 4th component (default is 0)
  83535. * @returns a new Vector4
  83536. */
  83537. static FromVector3(source: Vector3, w?: number): Vector4;
  83538. }
  83539. /**
  83540. * Class used to store quaternion data
  83541. * @see https://en.wikipedia.org/wiki/Quaternion
  83542. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83543. */
  83544. export class Quaternion {
  83545. /** @hidden */
  83546. _x: number;
  83547. /** @hidden */
  83548. _y: number;
  83549. /** @hidden */
  83550. _z: number;
  83551. /** @hidden */
  83552. _w: number;
  83553. /** @hidden */
  83554. _isDirty: boolean;
  83555. /** Gets or sets the x coordinate */
  83556. get x(): number;
  83557. set x(value: number);
  83558. /** Gets or sets the y coordinate */
  83559. get y(): number;
  83560. set y(value: number);
  83561. /** Gets or sets the z coordinate */
  83562. get z(): number;
  83563. set z(value: number);
  83564. /** Gets or sets the w coordinate */
  83565. get w(): number;
  83566. set w(value: number);
  83567. /**
  83568. * Creates a new Quaternion from the given floats
  83569. * @param x defines the first component (0 by default)
  83570. * @param y defines the second component (0 by default)
  83571. * @param z defines the third component (0 by default)
  83572. * @param w defines the fourth component (1.0 by default)
  83573. */
  83574. constructor(x?: number, y?: number, z?: number, w?: number);
  83575. /**
  83576. * Gets a string representation for the current quaternion
  83577. * @returns a string with the Quaternion coordinates
  83578. */
  83579. toString(): string;
  83580. /**
  83581. * Gets the class name of the quaternion
  83582. * @returns the string "Quaternion"
  83583. */
  83584. getClassName(): string;
  83585. /**
  83586. * Gets a hash code for this quaternion
  83587. * @returns the quaternion hash code
  83588. */
  83589. getHashCode(): number;
  83590. /**
  83591. * Copy the quaternion to an array
  83592. * @returns a new array populated with 4 elements from the quaternion coordinates
  83593. */
  83594. asArray(): number[];
  83595. /**
  83596. * Check if two quaternions are equals
  83597. * @param otherQuaternion defines the second operand
  83598. * @return true if the current quaternion and the given one coordinates are strictly equals
  83599. */
  83600. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  83601. /**
  83602. * Gets a boolean if two quaternions are equals (using an epsilon value)
  83603. * @param otherQuaternion defines the other quaternion
  83604. * @param epsilon defines the minimal distance to consider equality
  83605. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  83606. */
  83607. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  83608. /**
  83609. * Clone the current quaternion
  83610. * @returns a new quaternion copied from the current one
  83611. */
  83612. clone(): Quaternion;
  83613. /**
  83614. * Copy a quaternion to the current one
  83615. * @param other defines the other quaternion
  83616. * @returns the updated current quaternion
  83617. */
  83618. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83619. /**
  83620. * Updates the current quaternion with the given float coordinates
  83621. * @param x defines the x coordinate
  83622. * @param y defines the y coordinate
  83623. * @param z defines the z coordinate
  83624. * @param w defines the w coordinate
  83625. * @returns the updated current quaternion
  83626. */
  83627. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83628. /**
  83629. * Updates the current quaternion from the given float coordinates
  83630. * @param x defines the x coordinate
  83631. * @param y defines the y coordinate
  83632. * @param z defines the z coordinate
  83633. * @param w defines the w coordinate
  83634. * @returns the updated current quaternion
  83635. */
  83636. set(x: number, y: number, z: number, w: number): Quaternion;
  83637. /**
  83638. * Adds two quaternions
  83639. * @param other defines the second operand
  83640. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83641. */
  83642. add(other: DeepImmutable<Quaternion>): Quaternion;
  83643. /**
  83644. * Add a quaternion to the current one
  83645. * @param other defines the quaternion to add
  83646. * @returns the current quaternion
  83647. */
  83648. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  83649. /**
  83650. * Subtract two quaternions
  83651. * @param other defines the second operand
  83652. * @returns a new quaternion as the subtraction result of the given one from the current one
  83653. */
  83654. subtract(other: Quaternion): Quaternion;
  83655. /**
  83656. * Multiplies the current quaternion by a scale factor
  83657. * @param value defines the scale factor
  83658. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  83659. */
  83660. scale(value: number): Quaternion;
  83661. /**
  83662. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  83663. * @param scale defines the scale factor
  83664. * @param result defines the Quaternion object where to store the result
  83665. * @returns the unmodified current quaternion
  83666. */
  83667. scaleToRef(scale: number, result: Quaternion): Quaternion;
  83668. /**
  83669. * Multiplies in place the current quaternion by a scale factor
  83670. * @param value defines the scale factor
  83671. * @returns the current modified quaternion
  83672. */
  83673. scaleInPlace(value: number): Quaternion;
  83674. /**
  83675. * Scale the current quaternion values by a factor and add the result to a given quaternion
  83676. * @param scale defines the scale factor
  83677. * @param result defines the Quaternion object where to store the result
  83678. * @returns the unmodified current quaternion
  83679. */
  83680. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  83681. /**
  83682. * Multiplies two quaternions
  83683. * @param q1 defines the second operand
  83684. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  83685. */
  83686. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  83687. /**
  83688. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  83689. * @param q1 defines the second operand
  83690. * @param result defines the target quaternion
  83691. * @returns the current quaternion
  83692. */
  83693. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  83694. /**
  83695. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  83696. * @param q1 defines the second operand
  83697. * @returns the currentupdated quaternion
  83698. */
  83699. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  83700. /**
  83701. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  83702. * @param ref defines the target quaternion
  83703. * @returns the current quaternion
  83704. */
  83705. conjugateToRef(ref: Quaternion): Quaternion;
  83706. /**
  83707. * Conjugates in place (1-q) the current quaternion
  83708. * @returns the current updated quaternion
  83709. */
  83710. conjugateInPlace(): Quaternion;
  83711. /**
  83712. * Conjugates in place (1-q) the current quaternion
  83713. * @returns a new quaternion
  83714. */
  83715. conjugate(): Quaternion;
  83716. /**
  83717. * Gets length of current quaternion
  83718. * @returns the quaternion length (float)
  83719. */
  83720. length(): number;
  83721. /**
  83722. * Normalize in place the current quaternion
  83723. * @returns the current updated quaternion
  83724. */
  83725. normalize(): Quaternion;
  83726. /**
  83727. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  83728. * @param order is a reserved parameter and is ignore for now
  83729. * @returns a new Vector3 containing the Euler angles
  83730. */
  83731. toEulerAngles(order?: string): Vector3;
  83732. /**
  83733. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  83734. * @param result defines the vector which will be filled with the Euler angles
  83735. * @param order is a reserved parameter and is ignore for now
  83736. * @returns the current unchanged quaternion
  83737. */
  83738. toEulerAnglesToRef(result: Vector3): Quaternion;
  83739. /**
  83740. * Updates the given rotation matrix with the current quaternion values
  83741. * @param result defines the target matrix
  83742. * @returns the current unchanged quaternion
  83743. */
  83744. toRotationMatrix(result: Matrix): Quaternion;
  83745. /**
  83746. * Updates the current quaternion from the given rotation matrix values
  83747. * @param matrix defines the source matrix
  83748. * @returns the current updated quaternion
  83749. */
  83750. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83751. /**
  83752. * Creates a new quaternion from a rotation matrix
  83753. * @param matrix defines the source matrix
  83754. * @returns a new quaternion created from the given rotation matrix values
  83755. */
  83756. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83757. /**
  83758. * Updates the given quaternion with the given rotation matrix values
  83759. * @param matrix defines the source matrix
  83760. * @param result defines the target quaternion
  83761. */
  83762. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  83763. /**
  83764. * Returns the dot product (float) between the quaternions "left" and "right"
  83765. * @param left defines the left operand
  83766. * @param right defines the right operand
  83767. * @returns the dot product
  83768. */
  83769. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  83770. /**
  83771. * Checks if the two quaternions are close to each other
  83772. * @param quat0 defines the first quaternion to check
  83773. * @param quat1 defines the second quaternion to check
  83774. * @returns true if the two quaternions are close to each other
  83775. */
  83776. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  83777. /**
  83778. * Creates an empty quaternion
  83779. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  83780. */
  83781. static Zero(): Quaternion;
  83782. /**
  83783. * Inverse a given quaternion
  83784. * @param q defines the source quaternion
  83785. * @returns a new quaternion as the inverted current quaternion
  83786. */
  83787. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  83788. /**
  83789. * Inverse a given quaternion
  83790. * @param q defines the source quaternion
  83791. * @param result the quaternion the result will be stored in
  83792. * @returns the result quaternion
  83793. */
  83794. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  83795. /**
  83796. * Creates an identity quaternion
  83797. * @returns the identity quaternion
  83798. */
  83799. static Identity(): Quaternion;
  83800. /**
  83801. * Gets a boolean indicating if the given quaternion is identity
  83802. * @param quaternion defines the quaternion to check
  83803. * @returns true if the quaternion is identity
  83804. */
  83805. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  83806. /**
  83807. * Creates a quaternion from a rotation around an axis
  83808. * @param axis defines the axis to use
  83809. * @param angle defines the angle to use
  83810. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  83811. */
  83812. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  83813. /**
  83814. * Creates a rotation around an axis and stores it into the given quaternion
  83815. * @param axis defines the axis to use
  83816. * @param angle defines the angle to use
  83817. * @param result defines the target quaternion
  83818. * @returns the target quaternion
  83819. */
  83820. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  83821. /**
  83822. * Creates a new quaternion from data stored into an array
  83823. * @param array defines the data source
  83824. * @param offset defines the offset in the source array where the data starts
  83825. * @returns a new quaternion
  83826. */
  83827. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  83828. /**
  83829. * Updates the given quaternion "result" from the starting index of the given array.
  83830. * @param array the array to pull values from
  83831. * @param offset the offset into the array to start at
  83832. * @param result the quaternion to store the result in
  83833. */
  83834. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  83835. /**
  83836. * Create a quaternion from Euler rotation angles
  83837. * @param x Pitch
  83838. * @param y Yaw
  83839. * @param z Roll
  83840. * @returns the new Quaternion
  83841. */
  83842. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  83843. /**
  83844. * Updates a quaternion from Euler rotation angles
  83845. * @param x Pitch
  83846. * @param y Yaw
  83847. * @param z Roll
  83848. * @param result the quaternion to store the result
  83849. * @returns the updated quaternion
  83850. */
  83851. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83852. /**
  83853. * Create a quaternion from Euler rotation vector
  83854. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83855. * @returns the new Quaternion
  83856. */
  83857. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83858. /**
  83859. * Updates a quaternion from Euler rotation vector
  83860. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83861. * @param result the quaternion to store the result
  83862. * @returns the updated quaternion
  83863. */
  83864. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83865. /**
  83866. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83867. * @param yaw defines the rotation around Y axis
  83868. * @param pitch defines the rotation around X axis
  83869. * @param roll defines the rotation around Z axis
  83870. * @returns the new quaternion
  83871. */
  83872. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83873. /**
  83874. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83875. * @param yaw defines the rotation around Y axis
  83876. * @param pitch defines the rotation around X axis
  83877. * @param roll defines the rotation around Z axis
  83878. * @param result defines the target quaternion
  83879. */
  83880. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83881. /**
  83882. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83883. * @param alpha defines the rotation around first axis
  83884. * @param beta defines the rotation around second axis
  83885. * @param gamma defines the rotation around third axis
  83886. * @returns the new quaternion
  83887. */
  83888. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83889. /**
  83890. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83891. * @param alpha defines the rotation around first axis
  83892. * @param beta defines the rotation around second axis
  83893. * @param gamma defines the rotation around third axis
  83894. * @param result defines the target quaternion
  83895. */
  83896. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83897. /**
  83898. * 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)
  83899. * @param axis1 defines the first axis
  83900. * @param axis2 defines the second axis
  83901. * @param axis3 defines the third axis
  83902. * @returns the new quaternion
  83903. */
  83904. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83905. /**
  83906. * 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
  83907. * @param axis1 defines the first axis
  83908. * @param axis2 defines the second axis
  83909. * @param axis3 defines the third axis
  83910. * @param ref defines the target quaternion
  83911. */
  83912. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83913. /**
  83914. * Interpolates between two quaternions
  83915. * @param left defines first quaternion
  83916. * @param right defines second quaternion
  83917. * @param amount defines the gradient to use
  83918. * @returns the new interpolated quaternion
  83919. */
  83920. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83921. /**
  83922. * Interpolates between two quaternions and stores it into a target quaternion
  83923. * @param left defines first quaternion
  83924. * @param right defines second quaternion
  83925. * @param amount defines the gradient to use
  83926. * @param result defines the target quaternion
  83927. */
  83928. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83929. /**
  83930. * Interpolate between two quaternions using Hermite interpolation
  83931. * @param value1 defines first quaternion
  83932. * @param tangent1 defines the incoming tangent
  83933. * @param value2 defines second quaternion
  83934. * @param tangent2 defines the outgoing tangent
  83935. * @param amount defines the target quaternion
  83936. * @returns the new interpolated quaternion
  83937. */
  83938. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83939. }
  83940. /**
  83941. * Class used to store matrix data (4x4)
  83942. */
  83943. export class Matrix {
  83944. /**
  83945. * Gets the precision of matrix computations
  83946. */
  83947. static get Use64Bits(): boolean;
  83948. private static _updateFlagSeed;
  83949. private static _identityReadOnly;
  83950. private _isIdentity;
  83951. private _isIdentityDirty;
  83952. private _isIdentity3x2;
  83953. private _isIdentity3x2Dirty;
  83954. /**
  83955. * Gets the update flag of the matrix which is an unique number for the matrix.
  83956. * It will be incremented every time the matrix data change.
  83957. * You can use it to speed the comparison between two versions of the same matrix.
  83958. */
  83959. updateFlag: number;
  83960. private readonly _m;
  83961. /**
  83962. * Gets the internal data of the matrix
  83963. */
  83964. get m(): DeepImmutable<Float32Array | Array<number>>;
  83965. /** @hidden */
  83966. _markAsUpdated(): void;
  83967. /** @hidden */
  83968. private _updateIdentityStatus;
  83969. /**
  83970. * Creates an empty matrix (filled with zeros)
  83971. */
  83972. constructor();
  83973. /**
  83974. * Check if the current matrix is identity
  83975. * @returns true is the matrix is the identity matrix
  83976. */
  83977. isIdentity(): boolean;
  83978. /**
  83979. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83980. * @returns true is the matrix is the identity matrix
  83981. */
  83982. isIdentityAs3x2(): boolean;
  83983. /**
  83984. * Gets the determinant of the matrix
  83985. * @returns the matrix determinant
  83986. */
  83987. determinant(): number;
  83988. /**
  83989. * Returns the matrix as a Float32Array or Array<number>
  83990. * @returns the matrix underlying array
  83991. */
  83992. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83993. /**
  83994. * Returns the matrix as a Float32Array or Array<number>
  83995. * @returns the matrix underlying array.
  83996. */
  83997. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83998. /**
  83999. * Inverts the current matrix in place
  84000. * @returns the current inverted matrix
  84001. */
  84002. invert(): Matrix;
  84003. /**
  84004. * Sets all the matrix elements to zero
  84005. * @returns the current matrix
  84006. */
  84007. reset(): Matrix;
  84008. /**
  84009. * Adds the current matrix with a second one
  84010. * @param other defines the matrix to add
  84011. * @returns a new matrix as the addition of the current matrix and the given one
  84012. */
  84013. add(other: DeepImmutable<Matrix>): Matrix;
  84014. /**
  84015. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84016. * @param other defines the matrix to add
  84017. * @param result defines the target matrix
  84018. * @returns the current matrix
  84019. */
  84020. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84021. /**
  84022. * Adds in place the given matrix to the current matrix
  84023. * @param other defines the second operand
  84024. * @returns the current updated matrix
  84025. */
  84026. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84027. /**
  84028. * Sets the given matrix to the current inverted Matrix
  84029. * @param other defines the target matrix
  84030. * @returns the unmodified current matrix
  84031. */
  84032. invertToRef(other: Matrix): Matrix;
  84033. /**
  84034. * add a value at the specified position in the current Matrix
  84035. * @param index the index of the value within the matrix. between 0 and 15.
  84036. * @param value the value to be added
  84037. * @returns the current updated matrix
  84038. */
  84039. addAtIndex(index: number, value: number): Matrix;
  84040. /**
  84041. * mutiply the specified position in the current Matrix by a value
  84042. * @param index the index of the value within the matrix. between 0 and 15.
  84043. * @param value the value to be added
  84044. * @returns the current updated matrix
  84045. */
  84046. multiplyAtIndex(index: number, value: number): Matrix;
  84047. /**
  84048. * Inserts the translation vector (using 3 floats) in the current matrix
  84049. * @param x defines the 1st component of the translation
  84050. * @param y defines the 2nd component of the translation
  84051. * @param z defines the 3rd component of the translation
  84052. * @returns the current updated matrix
  84053. */
  84054. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84055. /**
  84056. * Adds the translation vector (using 3 floats) in the current matrix
  84057. * @param x defines the 1st component of the translation
  84058. * @param y defines the 2nd component of the translation
  84059. * @param z defines the 3rd component of the translation
  84060. * @returns the current updated matrix
  84061. */
  84062. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84063. /**
  84064. * Inserts the translation vector in the current matrix
  84065. * @param vector3 defines the translation to insert
  84066. * @returns the current updated matrix
  84067. */
  84068. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84069. /**
  84070. * Gets the translation value of the current matrix
  84071. * @returns a new Vector3 as the extracted translation from the matrix
  84072. */
  84073. getTranslation(): Vector3;
  84074. /**
  84075. * Fill a Vector3 with the extracted translation from the matrix
  84076. * @param result defines the Vector3 where to store the translation
  84077. * @returns the current matrix
  84078. */
  84079. getTranslationToRef(result: Vector3): Matrix;
  84080. /**
  84081. * Remove rotation and scaling part from the matrix
  84082. * @returns the updated matrix
  84083. */
  84084. removeRotationAndScaling(): Matrix;
  84085. /**
  84086. * Multiply two matrices
  84087. * @param other defines the second operand
  84088. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84089. */
  84090. multiply(other: DeepImmutable<Matrix>): Matrix;
  84091. /**
  84092. * Copy the current matrix from the given one
  84093. * @param other defines the source matrix
  84094. * @returns the current updated matrix
  84095. */
  84096. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84097. /**
  84098. * Populates the given array from the starting index with the current matrix values
  84099. * @param array defines the target array
  84100. * @param offset defines the offset in the target array where to start storing values
  84101. * @returns the current matrix
  84102. */
  84103. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84104. /**
  84105. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84106. * @param other defines the second operand
  84107. * @param result defines the matrix where to store the multiplication
  84108. * @returns the current matrix
  84109. */
  84110. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84111. /**
  84112. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84113. * @param other defines the second operand
  84114. * @param result defines the array where to store the multiplication
  84115. * @param offset defines the offset in the target array where to start storing values
  84116. * @returns the current matrix
  84117. */
  84118. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84119. /**
  84120. * Check equality between this matrix and a second one
  84121. * @param value defines the second matrix to compare
  84122. * @returns true is the current matrix and the given one values are strictly equal
  84123. */
  84124. equals(value: DeepImmutable<Matrix>): boolean;
  84125. /**
  84126. * Clone the current matrix
  84127. * @returns a new matrix from the current matrix
  84128. */
  84129. clone(): Matrix;
  84130. /**
  84131. * Returns the name of the current matrix class
  84132. * @returns the string "Matrix"
  84133. */
  84134. getClassName(): string;
  84135. /**
  84136. * Gets the hash code of the current matrix
  84137. * @returns the hash code
  84138. */
  84139. getHashCode(): number;
  84140. /**
  84141. * Decomposes the current Matrix into a translation, rotation and scaling components
  84142. * @param scale defines the scale vector3 given as a reference to update
  84143. * @param rotation defines the rotation quaternion given as a reference to update
  84144. * @param translation defines the translation vector3 given as a reference to update
  84145. * @returns true if operation was successful
  84146. */
  84147. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84148. /**
  84149. * Gets specific row of the matrix
  84150. * @param index defines the number of the row to get
  84151. * @returns the index-th row of the current matrix as a new Vector4
  84152. */
  84153. getRow(index: number): Nullable<Vector4>;
  84154. /**
  84155. * Sets the index-th row of the current matrix to the vector4 values
  84156. * @param index defines the number of the row to set
  84157. * @param row defines the target vector4
  84158. * @returns the updated current matrix
  84159. */
  84160. setRow(index: number, row: Vector4): Matrix;
  84161. /**
  84162. * Compute the transpose of the matrix
  84163. * @returns the new transposed matrix
  84164. */
  84165. transpose(): Matrix;
  84166. /**
  84167. * Compute the transpose of the matrix and store it in a given matrix
  84168. * @param result defines the target matrix
  84169. * @returns the current matrix
  84170. */
  84171. transposeToRef(result: Matrix): Matrix;
  84172. /**
  84173. * Sets the index-th row of the current matrix with the given 4 x float values
  84174. * @param index defines the row index
  84175. * @param x defines the x component to set
  84176. * @param y defines the y component to set
  84177. * @param z defines the z component to set
  84178. * @param w defines the w component to set
  84179. * @returns the updated current matrix
  84180. */
  84181. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84182. /**
  84183. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84184. * @param scale defines the scale factor
  84185. * @returns a new matrix
  84186. */
  84187. scale(scale: number): Matrix;
  84188. /**
  84189. * Scale the current matrix values by a factor to a given result matrix
  84190. * @param scale defines the scale factor
  84191. * @param result defines the matrix to store the result
  84192. * @returns the current matrix
  84193. */
  84194. scaleToRef(scale: number, result: Matrix): Matrix;
  84195. /**
  84196. * Scale the current matrix values by a factor and add the result to a given matrix
  84197. * @param scale defines the scale factor
  84198. * @param result defines the Matrix to store the result
  84199. * @returns the current matrix
  84200. */
  84201. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84202. /**
  84203. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84204. * @param ref matrix to store the result
  84205. */
  84206. toNormalMatrix(ref: Matrix): void;
  84207. /**
  84208. * Gets only rotation part of the current matrix
  84209. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84210. */
  84211. getRotationMatrix(): Matrix;
  84212. /**
  84213. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84214. * @param result defines the target matrix to store data to
  84215. * @returns the current matrix
  84216. */
  84217. getRotationMatrixToRef(result: Matrix): Matrix;
  84218. /**
  84219. * Toggles model matrix from being right handed to left handed in place and vice versa
  84220. */
  84221. toggleModelMatrixHandInPlace(): void;
  84222. /**
  84223. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84224. */
  84225. toggleProjectionMatrixHandInPlace(): void;
  84226. /**
  84227. * Creates a matrix from an array
  84228. * @param array defines the source array
  84229. * @param offset defines an offset in the source array
  84230. * @returns a new Matrix set from the starting index of the given array
  84231. */
  84232. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84233. /**
  84234. * Copy the content of an array into a given matrix
  84235. * @param array defines the source array
  84236. * @param offset defines an offset in the source array
  84237. * @param result defines the target matrix
  84238. */
  84239. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84240. /**
  84241. * Stores an array into a matrix after having multiplied each component by a given factor
  84242. * @param array defines the source array
  84243. * @param offset defines the offset in the source array
  84244. * @param scale defines the scaling factor
  84245. * @param result defines the target matrix
  84246. */
  84247. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84248. /**
  84249. * Gets an identity matrix that must not be updated
  84250. */
  84251. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84252. /**
  84253. * Stores a list of values (16) inside a given matrix
  84254. * @param initialM11 defines 1st value of 1st row
  84255. * @param initialM12 defines 2nd value of 1st row
  84256. * @param initialM13 defines 3rd value of 1st row
  84257. * @param initialM14 defines 4th value of 1st row
  84258. * @param initialM21 defines 1st value of 2nd row
  84259. * @param initialM22 defines 2nd value of 2nd row
  84260. * @param initialM23 defines 3rd value of 2nd row
  84261. * @param initialM24 defines 4th value of 2nd row
  84262. * @param initialM31 defines 1st value of 3rd row
  84263. * @param initialM32 defines 2nd value of 3rd row
  84264. * @param initialM33 defines 3rd value of 3rd row
  84265. * @param initialM34 defines 4th value of 3rd row
  84266. * @param initialM41 defines 1st value of 4th row
  84267. * @param initialM42 defines 2nd value of 4th row
  84268. * @param initialM43 defines 3rd value of 4th row
  84269. * @param initialM44 defines 4th value of 4th row
  84270. * @param result defines the target matrix
  84271. */
  84272. 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;
  84273. /**
  84274. * Creates new matrix from a list of values (16)
  84275. * @param initialM11 defines 1st value of 1st row
  84276. * @param initialM12 defines 2nd value of 1st row
  84277. * @param initialM13 defines 3rd value of 1st row
  84278. * @param initialM14 defines 4th value of 1st row
  84279. * @param initialM21 defines 1st value of 2nd row
  84280. * @param initialM22 defines 2nd value of 2nd row
  84281. * @param initialM23 defines 3rd value of 2nd row
  84282. * @param initialM24 defines 4th value of 2nd row
  84283. * @param initialM31 defines 1st value of 3rd row
  84284. * @param initialM32 defines 2nd value of 3rd row
  84285. * @param initialM33 defines 3rd value of 3rd row
  84286. * @param initialM34 defines 4th value of 3rd row
  84287. * @param initialM41 defines 1st value of 4th row
  84288. * @param initialM42 defines 2nd value of 4th row
  84289. * @param initialM43 defines 3rd value of 4th row
  84290. * @param initialM44 defines 4th value of 4th row
  84291. * @returns the new matrix
  84292. */
  84293. 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;
  84294. /**
  84295. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84296. * @param scale defines the scale vector3
  84297. * @param rotation defines the rotation quaternion
  84298. * @param translation defines the translation vector3
  84299. * @returns a new matrix
  84300. */
  84301. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84302. /**
  84303. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84304. * @param scale defines the scale vector3
  84305. * @param rotation defines the rotation quaternion
  84306. * @param translation defines the translation vector3
  84307. * @param result defines the target matrix
  84308. */
  84309. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84310. /**
  84311. * Creates a new identity matrix
  84312. * @returns a new identity matrix
  84313. */
  84314. static Identity(): Matrix;
  84315. /**
  84316. * Creates a new identity matrix and stores the result in a given matrix
  84317. * @param result defines the target matrix
  84318. */
  84319. static IdentityToRef(result: Matrix): void;
  84320. /**
  84321. * Creates a new zero matrix
  84322. * @returns a new zero matrix
  84323. */
  84324. static Zero(): Matrix;
  84325. /**
  84326. * Creates a new rotation matrix for "angle" radians around the X axis
  84327. * @param angle defines the angle (in radians) to use
  84328. * @return the new matrix
  84329. */
  84330. static RotationX(angle: number): Matrix;
  84331. /**
  84332. * Creates a new matrix as the invert of a given matrix
  84333. * @param source defines the source matrix
  84334. * @returns the new matrix
  84335. */
  84336. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84337. /**
  84338. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84339. * @param angle defines the angle (in radians) to use
  84340. * @param result defines the target matrix
  84341. */
  84342. static RotationXToRef(angle: number, result: Matrix): void;
  84343. /**
  84344. * Creates a new rotation matrix for "angle" radians around the Y axis
  84345. * @param angle defines the angle (in radians) to use
  84346. * @return the new matrix
  84347. */
  84348. static RotationY(angle: number): Matrix;
  84349. /**
  84350. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84351. * @param angle defines the angle (in radians) to use
  84352. * @param result defines the target matrix
  84353. */
  84354. static RotationYToRef(angle: number, result: Matrix): void;
  84355. /**
  84356. * Creates a new rotation matrix for "angle" radians around the Z axis
  84357. * @param angle defines the angle (in radians) to use
  84358. * @return the new matrix
  84359. */
  84360. static RotationZ(angle: number): Matrix;
  84361. /**
  84362. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84363. * @param angle defines the angle (in radians) to use
  84364. * @param result defines the target matrix
  84365. */
  84366. static RotationZToRef(angle: number, result: Matrix): void;
  84367. /**
  84368. * Creates a new rotation matrix for "angle" radians around the given axis
  84369. * @param axis defines the axis to use
  84370. * @param angle defines the angle (in radians) to use
  84371. * @return the new matrix
  84372. */
  84373. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84374. /**
  84375. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84376. * @param axis defines the axis to use
  84377. * @param angle defines the angle (in radians) to use
  84378. * @param result defines the target matrix
  84379. */
  84380. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84381. /**
  84382. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84383. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84384. * @param from defines the vector to align
  84385. * @param to defines the vector to align to
  84386. * @param result defines the target matrix
  84387. */
  84388. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84389. /**
  84390. * Creates a rotation matrix
  84391. * @param yaw defines the yaw angle in radians (Y axis)
  84392. * @param pitch defines the pitch angle in radians (X axis)
  84393. * @param roll defines the roll angle in radians (Z axis)
  84394. * @returns the new rotation matrix
  84395. */
  84396. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84397. /**
  84398. * Creates a rotation matrix and stores it in a given matrix
  84399. * @param yaw defines the yaw angle in radians (Y axis)
  84400. * @param pitch defines the pitch angle in radians (X axis)
  84401. * @param roll defines the roll angle in radians (Z axis)
  84402. * @param result defines the target matrix
  84403. */
  84404. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84405. /**
  84406. * Creates a scaling matrix
  84407. * @param x defines the scale factor on X axis
  84408. * @param y defines the scale factor on Y axis
  84409. * @param z defines the scale factor on Z axis
  84410. * @returns the new matrix
  84411. */
  84412. static Scaling(x: number, y: number, z: number): Matrix;
  84413. /**
  84414. * Creates a scaling matrix and stores it in a given matrix
  84415. * @param x defines the scale factor on X axis
  84416. * @param y defines the scale factor on Y axis
  84417. * @param z defines the scale factor on Z axis
  84418. * @param result defines the target matrix
  84419. */
  84420. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84421. /**
  84422. * Creates a translation matrix
  84423. * @param x defines the translation on X axis
  84424. * @param y defines the translation on Y axis
  84425. * @param z defines the translationon Z axis
  84426. * @returns the new matrix
  84427. */
  84428. static Translation(x: number, y: number, z: number): Matrix;
  84429. /**
  84430. * Creates a translation matrix and stores it in a given matrix
  84431. * @param x defines the translation on X axis
  84432. * @param y defines the translation on Y axis
  84433. * @param z defines the translationon Z axis
  84434. * @param result defines the target matrix
  84435. */
  84436. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84437. /**
  84438. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84439. * @param startValue defines the start value
  84440. * @param endValue defines the end value
  84441. * @param gradient defines the gradient factor
  84442. * @returns the new matrix
  84443. */
  84444. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84445. /**
  84446. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84447. * @param startValue defines the start value
  84448. * @param endValue defines the end value
  84449. * @param gradient defines the gradient factor
  84450. * @param result defines the Matrix object where to store data
  84451. */
  84452. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84453. /**
  84454. * Builds a new matrix whose values are computed by:
  84455. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84456. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84457. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84458. * @param startValue defines the first matrix
  84459. * @param endValue defines the second matrix
  84460. * @param gradient defines the gradient between the two matrices
  84461. * @returns the new matrix
  84462. */
  84463. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84464. /**
  84465. * Update a matrix to values which are computed by:
  84466. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84467. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84468. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84469. * @param startValue defines the first matrix
  84470. * @param endValue defines the second matrix
  84471. * @param gradient defines the gradient between the two matrices
  84472. * @param result defines the target matrix
  84473. */
  84474. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84475. /**
  84476. * 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"
  84477. * This function works in left handed mode
  84478. * @param eye defines the final position of the entity
  84479. * @param target defines where the entity should look at
  84480. * @param up defines the up vector for the entity
  84481. * @returns the new matrix
  84482. */
  84483. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84484. /**
  84485. * 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".
  84486. * This function works in left handed mode
  84487. * @param eye defines the final position of the entity
  84488. * @param target defines where the entity should look at
  84489. * @param up defines the up vector for the entity
  84490. * @param result defines the target matrix
  84491. */
  84492. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84493. /**
  84494. * 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"
  84495. * This function works in right handed mode
  84496. * @param eye defines the final position of the entity
  84497. * @param target defines where the entity should look at
  84498. * @param up defines the up vector for the entity
  84499. * @returns the new matrix
  84500. */
  84501. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84502. /**
  84503. * 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".
  84504. * This function works in right handed mode
  84505. * @param eye defines the final position of the entity
  84506. * @param target defines where the entity should look at
  84507. * @param up defines the up vector for the entity
  84508. * @param result defines the target matrix
  84509. */
  84510. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84511. /**
  84512. * Create a left-handed orthographic projection matrix
  84513. * @param width defines the viewport width
  84514. * @param height defines the viewport height
  84515. * @param znear defines the near clip plane
  84516. * @param zfar defines the far clip plane
  84517. * @returns a new matrix as a left-handed orthographic projection matrix
  84518. */
  84519. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84520. /**
  84521. * Store a left-handed orthographic projection to a given matrix
  84522. * @param width defines the viewport width
  84523. * @param height defines the viewport height
  84524. * @param znear defines the near clip plane
  84525. * @param zfar defines the far clip plane
  84526. * @param result defines the target matrix
  84527. */
  84528. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84529. /**
  84530. * Create a left-handed orthographic projection matrix
  84531. * @param left defines the viewport left coordinate
  84532. * @param right defines the viewport right coordinate
  84533. * @param bottom defines the viewport bottom coordinate
  84534. * @param top defines the viewport top coordinate
  84535. * @param znear defines the near clip plane
  84536. * @param zfar defines the far clip plane
  84537. * @returns a new matrix as a left-handed orthographic projection matrix
  84538. */
  84539. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84540. /**
  84541. * Stores a left-handed orthographic projection into a given matrix
  84542. * @param left defines the viewport left coordinate
  84543. * @param right defines the viewport right coordinate
  84544. * @param bottom defines the viewport bottom coordinate
  84545. * @param top defines the viewport top coordinate
  84546. * @param znear defines the near clip plane
  84547. * @param zfar defines the far clip plane
  84548. * @param result defines the target matrix
  84549. */
  84550. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84551. /**
  84552. * Creates a right-handed orthographic projection matrix
  84553. * @param left defines the viewport left coordinate
  84554. * @param right defines the viewport right coordinate
  84555. * @param bottom defines the viewport bottom coordinate
  84556. * @param top defines the viewport top coordinate
  84557. * @param znear defines the near clip plane
  84558. * @param zfar defines the far clip plane
  84559. * @returns a new matrix as a right-handed orthographic projection matrix
  84560. */
  84561. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84562. /**
  84563. * Stores a right-handed orthographic projection into a given matrix
  84564. * @param left defines the viewport left coordinate
  84565. * @param right defines the viewport right coordinate
  84566. * @param bottom defines the viewport bottom coordinate
  84567. * @param top defines the viewport top coordinate
  84568. * @param znear defines the near clip plane
  84569. * @param zfar defines the far clip plane
  84570. * @param result defines the target matrix
  84571. */
  84572. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84573. /**
  84574. * Creates a left-handed perspective projection matrix
  84575. * @param width defines the viewport width
  84576. * @param height defines the viewport height
  84577. * @param znear defines the near clip plane
  84578. * @param zfar defines the far clip plane
  84579. * @returns a new matrix as a left-handed perspective projection matrix
  84580. */
  84581. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84582. /**
  84583. * Creates a left-handed perspective projection matrix
  84584. * @param fov defines the horizontal field of view
  84585. * @param aspect defines the aspect ratio
  84586. * @param znear defines the near clip plane
  84587. * @param zfar defines the far clip plane
  84588. * @returns a new matrix as a left-handed perspective projection matrix
  84589. */
  84590. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84591. /**
  84592. * Stores a left-handed perspective projection into a given matrix
  84593. * @param fov defines the horizontal field of view
  84594. * @param aspect defines the aspect ratio
  84595. * @param znear defines the near clip plane
  84596. * @param zfar defines the far clip plane
  84597. * @param result defines the target matrix
  84598. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84599. */
  84600. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84601. /**
  84602. * Stores a left-handed perspective projection into a given matrix with depth reversed
  84603. * @param fov defines the horizontal field of view
  84604. * @param aspect defines the aspect ratio
  84605. * @param znear defines the near clip plane
  84606. * @param zfar not used as infinity is used as far clip
  84607. * @param result defines the target matrix
  84608. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84609. */
  84610. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84611. /**
  84612. * Creates a right-handed perspective projection matrix
  84613. * @param fov defines the horizontal field of view
  84614. * @param aspect defines the aspect ratio
  84615. * @param znear defines the near clip plane
  84616. * @param zfar defines the far clip plane
  84617. * @returns a new matrix as a right-handed perspective projection matrix
  84618. */
  84619. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84620. /**
  84621. * Stores a right-handed perspective projection into a given matrix
  84622. * @param fov defines the horizontal field of view
  84623. * @param aspect defines the aspect ratio
  84624. * @param znear defines the near clip plane
  84625. * @param zfar defines the far clip plane
  84626. * @param result defines the target matrix
  84627. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84628. */
  84629. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84630. /**
  84631. * Stores a right-handed perspective projection into a given matrix
  84632. * @param fov defines the horizontal field of view
  84633. * @param aspect defines the aspect ratio
  84634. * @param znear defines the near clip plane
  84635. * @param zfar not used as infinity is used as far clip
  84636. * @param result defines the target matrix
  84637. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84638. */
  84639. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84640. /**
  84641. * Stores a perspective projection for WebVR info a given matrix
  84642. * @param fov defines the field of view
  84643. * @param znear defines the near clip plane
  84644. * @param zfar defines the far clip plane
  84645. * @param result defines the target matrix
  84646. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  84647. */
  84648. static PerspectiveFovWebVRToRef(fov: {
  84649. upDegrees: number;
  84650. downDegrees: number;
  84651. leftDegrees: number;
  84652. rightDegrees: number;
  84653. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  84654. /**
  84655. * Computes a complete transformation matrix
  84656. * @param viewport defines the viewport to use
  84657. * @param world defines the world matrix
  84658. * @param view defines the view matrix
  84659. * @param projection defines the projection matrix
  84660. * @param zmin defines the near clip plane
  84661. * @param zmax defines the far clip plane
  84662. * @returns the transformation matrix
  84663. */
  84664. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  84665. /**
  84666. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  84667. * @param matrix defines the matrix to use
  84668. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  84669. */
  84670. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84671. /**
  84672. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  84673. * @param matrix defines the matrix to use
  84674. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  84675. */
  84676. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84677. /**
  84678. * Compute the transpose of a given matrix
  84679. * @param matrix defines the matrix to transpose
  84680. * @returns the new matrix
  84681. */
  84682. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  84683. /**
  84684. * Compute the transpose of a matrix and store it in a target matrix
  84685. * @param matrix defines the matrix to transpose
  84686. * @param result defines the target matrix
  84687. */
  84688. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  84689. /**
  84690. * Computes a reflection matrix from a plane
  84691. * @param plane defines the reflection plane
  84692. * @returns a new matrix
  84693. */
  84694. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  84695. /**
  84696. * Computes a reflection matrix from a plane
  84697. * @param plane defines the reflection plane
  84698. * @param result defines the target matrix
  84699. */
  84700. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  84701. /**
  84702. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  84703. * @param xaxis defines the value of the 1st axis
  84704. * @param yaxis defines the value of the 2nd axis
  84705. * @param zaxis defines the value of the 3rd axis
  84706. * @param result defines the target matrix
  84707. */
  84708. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  84709. /**
  84710. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  84711. * @param quat defines the quaternion to use
  84712. * @param result defines the target matrix
  84713. */
  84714. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  84715. }
  84716. /**
  84717. * @hidden
  84718. */
  84719. export class TmpVectors {
  84720. static Vector2: Vector2[];
  84721. static Vector3: Vector3[];
  84722. static Vector4: Vector4[];
  84723. static Quaternion: Quaternion[];
  84724. static Matrix: Matrix[];
  84725. }
  84726. }
  84727. declare module BABYLON {
  84728. /**
  84729. * Defines potential orientation for back face culling
  84730. */
  84731. export enum Orientation {
  84732. /**
  84733. * Clockwise
  84734. */
  84735. CW = 0,
  84736. /** Counter clockwise */
  84737. CCW = 1
  84738. }
  84739. /** Class used to represent a Bezier curve */
  84740. export class BezierCurve {
  84741. /**
  84742. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  84743. * @param t defines the time
  84744. * @param x1 defines the left coordinate on X axis
  84745. * @param y1 defines the left coordinate on Y axis
  84746. * @param x2 defines the right coordinate on X axis
  84747. * @param y2 defines the right coordinate on Y axis
  84748. * @returns the interpolated value
  84749. */
  84750. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  84751. }
  84752. /**
  84753. * Defines angle representation
  84754. */
  84755. export class Angle {
  84756. private _radians;
  84757. /**
  84758. * Creates an Angle object of "radians" radians (float).
  84759. * @param radians the angle in radians
  84760. */
  84761. constructor(radians: number);
  84762. /**
  84763. * Get value in degrees
  84764. * @returns the Angle value in degrees (float)
  84765. */
  84766. degrees(): number;
  84767. /**
  84768. * Get value in radians
  84769. * @returns the Angle value in radians (float)
  84770. */
  84771. radians(): number;
  84772. /**
  84773. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  84774. * @param a defines first point as the origin
  84775. * @param b defines point
  84776. * @returns a new Angle
  84777. */
  84778. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  84779. /**
  84780. * Gets a new Angle object from the given float in radians
  84781. * @param radians defines the angle value in radians
  84782. * @returns a new Angle
  84783. */
  84784. static FromRadians(radians: number): Angle;
  84785. /**
  84786. * Gets a new Angle object from the given float in degrees
  84787. * @param degrees defines the angle value in degrees
  84788. * @returns a new Angle
  84789. */
  84790. static FromDegrees(degrees: number): Angle;
  84791. }
  84792. /**
  84793. * This represents an arc in a 2d space.
  84794. */
  84795. export class Arc2 {
  84796. /** Defines the start point of the arc */
  84797. startPoint: Vector2;
  84798. /** Defines the mid point of the arc */
  84799. midPoint: Vector2;
  84800. /** Defines the end point of the arc */
  84801. endPoint: Vector2;
  84802. /**
  84803. * Defines the center point of the arc.
  84804. */
  84805. centerPoint: Vector2;
  84806. /**
  84807. * Defines the radius of the arc.
  84808. */
  84809. radius: number;
  84810. /**
  84811. * Defines the angle of the arc (from mid point to end point).
  84812. */
  84813. angle: Angle;
  84814. /**
  84815. * Defines the start angle of the arc (from start point to middle point).
  84816. */
  84817. startAngle: Angle;
  84818. /**
  84819. * Defines the orientation of the arc (clock wise/counter clock wise).
  84820. */
  84821. orientation: Orientation;
  84822. /**
  84823. * Creates an Arc object from the three given points : start, middle and end.
  84824. * @param startPoint Defines the start point of the arc
  84825. * @param midPoint Defines the midlle point of the arc
  84826. * @param endPoint Defines the end point of the arc
  84827. */
  84828. constructor(
  84829. /** Defines the start point of the arc */
  84830. startPoint: Vector2,
  84831. /** Defines the mid point of the arc */
  84832. midPoint: Vector2,
  84833. /** Defines the end point of the arc */
  84834. endPoint: Vector2);
  84835. }
  84836. /**
  84837. * Represents a 2D path made up of multiple 2D points
  84838. */
  84839. export class Path2 {
  84840. private _points;
  84841. private _length;
  84842. /**
  84843. * If the path start and end point are the same
  84844. */
  84845. closed: boolean;
  84846. /**
  84847. * Creates a Path2 object from the starting 2D coordinates x and y.
  84848. * @param x the starting points x value
  84849. * @param y the starting points y value
  84850. */
  84851. constructor(x: number, y: number);
  84852. /**
  84853. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84854. * @param x the added points x value
  84855. * @param y the added points y value
  84856. * @returns the updated Path2.
  84857. */
  84858. addLineTo(x: number, y: number): Path2;
  84859. /**
  84860. * 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.
  84861. * @param midX middle point x value
  84862. * @param midY middle point y value
  84863. * @param endX end point x value
  84864. * @param endY end point y value
  84865. * @param numberOfSegments (default: 36)
  84866. * @returns the updated Path2.
  84867. */
  84868. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84869. /**
  84870. * Closes the Path2.
  84871. * @returns the Path2.
  84872. */
  84873. close(): Path2;
  84874. /**
  84875. * Gets the sum of the distance between each sequential point in the path
  84876. * @returns the Path2 total length (float).
  84877. */
  84878. length(): number;
  84879. /**
  84880. * Gets the points which construct the path
  84881. * @returns the Path2 internal array of points.
  84882. */
  84883. getPoints(): Vector2[];
  84884. /**
  84885. * Retreives the point at the distance aways from the starting point
  84886. * @param normalizedLengthPosition the length along the path to retreive the point from
  84887. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84888. */
  84889. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84890. /**
  84891. * Creates a new path starting from an x and y position
  84892. * @param x starting x value
  84893. * @param y starting y value
  84894. * @returns a new Path2 starting at the coordinates (x, y).
  84895. */
  84896. static StartingAt(x: number, y: number): Path2;
  84897. }
  84898. /**
  84899. * Represents a 3D path made up of multiple 3D points
  84900. */
  84901. export class Path3D {
  84902. /**
  84903. * an array of Vector3, the curve axis of the Path3D
  84904. */
  84905. path: Vector3[];
  84906. private _curve;
  84907. private _distances;
  84908. private _tangents;
  84909. private _normals;
  84910. private _binormals;
  84911. private _raw;
  84912. private _alignTangentsWithPath;
  84913. private readonly _pointAtData;
  84914. /**
  84915. * new Path3D(path, normal, raw)
  84916. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84917. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84918. * @param path an array of Vector3, the curve axis of the Path3D
  84919. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84920. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84921. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84922. */
  84923. constructor(
  84924. /**
  84925. * an array of Vector3, the curve axis of the Path3D
  84926. */
  84927. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84928. /**
  84929. * Returns the Path3D array of successive Vector3 designing its curve.
  84930. * @returns the Path3D array of successive Vector3 designing its curve.
  84931. */
  84932. getCurve(): Vector3[];
  84933. /**
  84934. * Returns the Path3D array of successive Vector3 designing its curve.
  84935. * @returns the Path3D array of successive Vector3 designing its curve.
  84936. */
  84937. getPoints(): Vector3[];
  84938. /**
  84939. * @returns the computed length (float) of the path.
  84940. */
  84941. length(): number;
  84942. /**
  84943. * Returns an array populated with tangent vectors on each Path3D curve point.
  84944. * @returns an array populated with tangent vectors on each Path3D curve point.
  84945. */
  84946. getTangents(): Vector3[];
  84947. /**
  84948. * Returns an array populated with normal vectors on each Path3D curve point.
  84949. * @returns an array populated with normal vectors on each Path3D curve point.
  84950. */
  84951. getNormals(): Vector3[];
  84952. /**
  84953. * Returns an array populated with binormal vectors on each Path3D curve point.
  84954. * @returns an array populated with binormal vectors on each Path3D curve point.
  84955. */
  84956. getBinormals(): Vector3[];
  84957. /**
  84958. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84959. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84960. */
  84961. getDistances(): number[];
  84962. /**
  84963. * Returns an interpolated point along this path
  84964. * @param position the position of the point along this path, from 0.0 to 1.0
  84965. * @returns a new Vector3 as the point
  84966. */
  84967. getPointAt(position: number): Vector3;
  84968. /**
  84969. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84970. * @param position the position of the point along this path, from 0.0 to 1.0
  84971. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84972. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84973. */
  84974. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84975. /**
  84976. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84977. * @param position the position of the point along this path, from 0.0 to 1.0
  84978. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84979. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84980. */
  84981. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84982. /**
  84983. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84984. * @param position the position of the point along this path, from 0.0 to 1.0
  84985. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84986. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84987. */
  84988. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84989. /**
  84990. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84991. * @param position the position of the point along this path, from 0.0 to 1.0
  84992. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84993. */
  84994. getDistanceAt(position: number): number;
  84995. /**
  84996. * Returns the array index of the previous point of an interpolated point along this path
  84997. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84998. * @returns the array index
  84999. */
  85000. getPreviousPointIndexAt(position: number): number;
  85001. /**
  85002. * 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)
  85003. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85004. * @returns the sub position
  85005. */
  85006. getSubPositionAt(position: number): number;
  85007. /**
  85008. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85009. * @param target the vector of which to get the closest position to
  85010. * @returns the position of the closest virtual point on this path to the target vector
  85011. */
  85012. getClosestPositionTo(target: Vector3): number;
  85013. /**
  85014. * Returns a sub path (slice) of this path
  85015. * @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
  85016. * @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
  85017. * @returns a sub path (slice) of this path
  85018. */
  85019. slice(start?: number, end?: number): Path3D;
  85020. /**
  85021. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85022. * @param path path which all values are copied into the curves points
  85023. * @param firstNormal which should be projected onto the curve
  85024. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85025. * @returns the same object updated.
  85026. */
  85027. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85028. private _compute;
  85029. private _getFirstNonNullVector;
  85030. private _getLastNonNullVector;
  85031. private _normalVector;
  85032. /**
  85033. * Updates the point at data for an interpolated point along this curve
  85034. * @param position the position of the point along this curve, from 0.0 to 1.0
  85035. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85036. * @returns the (updated) point at data
  85037. */
  85038. private _updatePointAtData;
  85039. /**
  85040. * Updates the point at data from the specified parameters
  85041. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85042. * @param point the interpolated point
  85043. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85044. */
  85045. private _setPointAtData;
  85046. /**
  85047. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85048. */
  85049. private _updateInterpolationMatrix;
  85050. }
  85051. /**
  85052. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85053. * A Curve3 is designed from a series of successive Vector3.
  85054. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85055. */
  85056. export class Curve3 {
  85057. private _points;
  85058. private _length;
  85059. /**
  85060. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85061. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85062. * @param v1 (Vector3) the control point
  85063. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85064. * @param nbPoints (integer) the wanted number of points in the curve
  85065. * @returns the created Curve3
  85066. */
  85067. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85068. /**
  85069. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85070. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85071. * @param v1 (Vector3) the first control point
  85072. * @param v2 (Vector3) the second control point
  85073. * @param v3 (Vector3) the end point of the Cubic Bezier
  85074. * @param nbPoints (integer) the wanted number of points in the curve
  85075. * @returns the created Curve3
  85076. */
  85077. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85078. /**
  85079. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85080. * @param p1 (Vector3) the origin point of the Hermite Spline
  85081. * @param t1 (Vector3) the tangent vector at the origin point
  85082. * @param p2 (Vector3) the end point of the Hermite Spline
  85083. * @param t2 (Vector3) the tangent vector at the end point
  85084. * @param nbPoints (integer) the wanted number of points in the curve
  85085. * @returns the created Curve3
  85086. */
  85087. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85088. /**
  85089. * Returns a Curve3 object along a CatmullRom Spline curve :
  85090. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85091. * @param nbPoints (integer) the wanted number of points between each curve control points
  85092. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85093. * @returns the created Curve3
  85094. */
  85095. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85096. /**
  85097. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85098. * A Curve3 is designed from a series of successive Vector3.
  85099. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85100. * @param points points which make up the curve
  85101. */
  85102. constructor(points: Vector3[]);
  85103. /**
  85104. * @returns the Curve3 stored array of successive Vector3
  85105. */
  85106. getPoints(): Vector3[];
  85107. /**
  85108. * @returns the computed length (float) of the curve.
  85109. */
  85110. length(): number;
  85111. /**
  85112. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85113. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85114. * curveA and curveB keep unchanged.
  85115. * @param curve the curve to continue from this curve
  85116. * @returns the newly constructed curve
  85117. */
  85118. continue(curve: DeepImmutable<Curve3>): Curve3;
  85119. private _computeLength;
  85120. }
  85121. }
  85122. declare module BABYLON {
  85123. /**
  85124. * This represents the main contract an easing function should follow.
  85125. * Easing functions are used throughout the animation system.
  85126. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85127. */
  85128. export interface IEasingFunction {
  85129. /**
  85130. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85131. * of the easing function.
  85132. * The link below provides some of the most common examples of easing functions.
  85133. * @see https://easings.net/
  85134. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85135. * @returns the corresponding value on the curve defined by the easing function
  85136. */
  85137. ease(gradient: number): number;
  85138. }
  85139. /**
  85140. * Base class used for every default easing function.
  85141. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85142. */
  85143. export class EasingFunction implements IEasingFunction {
  85144. /**
  85145. * Interpolation follows the mathematical formula associated with the easing function.
  85146. */
  85147. static readonly EASINGMODE_EASEIN: number;
  85148. /**
  85149. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85150. */
  85151. static readonly EASINGMODE_EASEOUT: number;
  85152. /**
  85153. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85154. */
  85155. static readonly EASINGMODE_EASEINOUT: number;
  85156. private _easingMode;
  85157. /**
  85158. * Sets the easing mode of the current function.
  85159. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85160. */
  85161. setEasingMode(easingMode: number): void;
  85162. /**
  85163. * Gets the current easing mode.
  85164. * @returns the easing mode
  85165. */
  85166. getEasingMode(): number;
  85167. /**
  85168. * @hidden
  85169. */
  85170. easeInCore(gradient: number): number;
  85171. /**
  85172. * Given an input gradient between 0 and 1, this returns the corresponding value
  85173. * of the easing function.
  85174. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85175. * @returns the corresponding value on the curve defined by the easing function
  85176. */
  85177. ease(gradient: number): number;
  85178. }
  85179. /**
  85180. * Easing function with a circle shape (see link below).
  85181. * @see https://easings.net/#easeInCirc
  85182. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85183. */
  85184. export class CircleEase extends EasingFunction implements IEasingFunction {
  85185. /** @hidden */
  85186. easeInCore(gradient: number): number;
  85187. }
  85188. /**
  85189. * Easing function with a ease back shape (see link below).
  85190. * @see https://easings.net/#easeInBack
  85191. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85192. */
  85193. export class BackEase extends EasingFunction implements IEasingFunction {
  85194. /** Defines the amplitude of the function */
  85195. amplitude: number;
  85196. /**
  85197. * Instantiates a back ease easing
  85198. * @see https://easings.net/#easeInBack
  85199. * @param amplitude Defines the amplitude of the function
  85200. */
  85201. constructor(
  85202. /** Defines the amplitude of the function */
  85203. amplitude?: number);
  85204. /** @hidden */
  85205. easeInCore(gradient: number): number;
  85206. }
  85207. /**
  85208. * Easing function with a bouncing shape (see link below).
  85209. * @see https://easings.net/#easeInBounce
  85210. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85211. */
  85212. export class BounceEase extends EasingFunction implements IEasingFunction {
  85213. /** Defines the number of bounces */
  85214. bounces: number;
  85215. /** Defines the amplitude of the bounce */
  85216. bounciness: number;
  85217. /**
  85218. * Instantiates a bounce easing
  85219. * @see https://easings.net/#easeInBounce
  85220. * @param bounces Defines the number of bounces
  85221. * @param bounciness Defines the amplitude of the bounce
  85222. */
  85223. constructor(
  85224. /** Defines the number of bounces */
  85225. bounces?: number,
  85226. /** Defines the amplitude of the bounce */
  85227. bounciness?: number);
  85228. /** @hidden */
  85229. easeInCore(gradient: number): number;
  85230. }
  85231. /**
  85232. * Easing function with a power of 3 shape (see link below).
  85233. * @see https://easings.net/#easeInCubic
  85234. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85235. */
  85236. export class CubicEase extends EasingFunction implements IEasingFunction {
  85237. /** @hidden */
  85238. easeInCore(gradient: number): number;
  85239. }
  85240. /**
  85241. * Easing function with an elastic shape (see link below).
  85242. * @see https://easings.net/#easeInElastic
  85243. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85244. */
  85245. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85246. /** Defines the number of oscillations*/
  85247. oscillations: number;
  85248. /** Defines the amplitude of the oscillations*/
  85249. springiness: number;
  85250. /**
  85251. * Instantiates an elastic easing function
  85252. * @see https://easings.net/#easeInElastic
  85253. * @param oscillations Defines the number of oscillations
  85254. * @param springiness Defines the amplitude of the oscillations
  85255. */
  85256. constructor(
  85257. /** Defines the number of oscillations*/
  85258. oscillations?: number,
  85259. /** Defines the amplitude of the oscillations*/
  85260. springiness?: number);
  85261. /** @hidden */
  85262. easeInCore(gradient: number): number;
  85263. }
  85264. /**
  85265. * Easing function with an exponential shape (see link below).
  85266. * @see https://easings.net/#easeInExpo
  85267. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85268. */
  85269. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85270. /** Defines the exponent of the function */
  85271. exponent: number;
  85272. /**
  85273. * Instantiates an exponential easing function
  85274. * @see https://easings.net/#easeInExpo
  85275. * @param exponent Defines the exponent of the function
  85276. */
  85277. constructor(
  85278. /** Defines the exponent of the function */
  85279. exponent?: number);
  85280. /** @hidden */
  85281. easeInCore(gradient: number): number;
  85282. }
  85283. /**
  85284. * Easing function with a power shape (see link below).
  85285. * @see https://easings.net/#easeInQuad
  85286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85287. */
  85288. export class PowerEase extends EasingFunction implements IEasingFunction {
  85289. /** Defines the power of the function */
  85290. power: number;
  85291. /**
  85292. * Instantiates an power base easing function
  85293. * @see https://easings.net/#easeInQuad
  85294. * @param power Defines the power of the function
  85295. */
  85296. constructor(
  85297. /** Defines the power of the function */
  85298. power?: number);
  85299. /** @hidden */
  85300. easeInCore(gradient: number): number;
  85301. }
  85302. /**
  85303. * Easing function with a power of 2 shape (see link below).
  85304. * @see https://easings.net/#easeInQuad
  85305. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85306. */
  85307. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85308. /** @hidden */
  85309. easeInCore(gradient: number): number;
  85310. }
  85311. /**
  85312. * Easing function with a power of 4 shape (see link below).
  85313. * @see https://easings.net/#easeInQuart
  85314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85315. */
  85316. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85317. /** @hidden */
  85318. easeInCore(gradient: number): number;
  85319. }
  85320. /**
  85321. * Easing function with a power of 5 shape (see link below).
  85322. * @see https://easings.net/#easeInQuint
  85323. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85324. */
  85325. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85326. /** @hidden */
  85327. easeInCore(gradient: number): number;
  85328. }
  85329. /**
  85330. * Easing function with a sin shape (see link below).
  85331. * @see https://easings.net/#easeInSine
  85332. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85333. */
  85334. export class SineEase extends EasingFunction implements IEasingFunction {
  85335. /** @hidden */
  85336. easeInCore(gradient: number): number;
  85337. }
  85338. /**
  85339. * Easing function with a bezier shape (see link below).
  85340. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85341. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85342. */
  85343. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85344. /** Defines the x component of the start tangent in the bezier curve */
  85345. x1: number;
  85346. /** Defines the y component of the start tangent in the bezier curve */
  85347. y1: number;
  85348. /** Defines the x component of the end tangent in the bezier curve */
  85349. x2: number;
  85350. /** Defines the y component of the end tangent in the bezier curve */
  85351. y2: number;
  85352. /**
  85353. * Instantiates a bezier function
  85354. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85355. * @param x1 Defines the x component of the start tangent in the bezier curve
  85356. * @param y1 Defines the y component of the start tangent in the bezier curve
  85357. * @param x2 Defines the x component of the end tangent in the bezier curve
  85358. * @param y2 Defines the y component of the end tangent in the bezier curve
  85359. */
  85360. constructor(
  85361. /** Defines the x component of the start tangent in the bezier curve */
  85362. x1?: number,
  85363. /** Defines the y component of the start tangent in the bezier curve */
  85364. y1?: number,
  85365. /** Defines the x component of the end tangent in the bezier curve */
  85366. x2?: number,
  85367. /** Defines the y component of the end tangent in the bezier curve */
  85368. y2?: number);
  85369. /** @hidden */
  85370. easeInCore(gradient: number): number;
  85371. }
  85372. }
  85373. declare module BABYLON {
  85374. /**
  85375. * Class used to hold a RBG color
  85376. */
  85377. export class Color3 {
  85378. /**
  85379. * Defines the red component (between 0 and 1, default is 0)
  85380. */
  85381. r: number;
  85382. /**
  85383. * Defines the green component (between 0 and 1, default is 0)
  85384. */
  85385. g: number;
  85386. /**
  85387. * Defines the blue component (between 0 and 1, default is 0)
  85388. */
  85389. b: number;
  85390. /**
  85391. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85392. * @param r defines the red component (between 0 and 1, default is 0)
  85393. * @param g defines the green component (between 0 and 1, default is 0)
  85394. * @param b defines the blue component (between 0 and 1, default is 0)
  85395. */
  85396. constructor(
  85397. /**
  85398. * Defines the red component (between 0 and 1, default is 0)
  85399. */
  85400. r?: number,
  85401. /**
  85402. * Defines the green component (between 0 and 1, default is 0)
  85403. */
  85404. g?: number,
  85405. /**
  85406. * Defines the blue component (between 0 and 1, default is 0)
  85407. */
  85408. b?: number);
  85409. /**
  85410. * Creates a string with the Color3 current values
  85411. * @returns the string representation of the Color3 object
  85412. */
  85413. toString(): string;
  85414. /**
  85415. * Returns the string "Color3"
  85416. * @returns "Color3"
  85417. */
  85418. getClassName(): string;
  85419. /**
  85420. * Compute the Color3 hash code
  85421. * @returns an unique number that can be used to hash Color3 objects
  85422. */
  85423. getHashCode(): number;
  85424. /**
  85425. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85426. * @param array defines the array where to store the r,g,b components
  85427. * @param index defines an optional index in the target array to define where to start storing values
  85428. * @returns the current Color3 object
  85429. */
  85430. toArray(array: FloatArray, index?: number): Color3;
  85431. /**
  85432. * Update the current color with values stored in an array from the starting index of the given array
  85433. * @param array defines the source array
  85434. * @param offset defines an offset in the source array
  85435. * @returns the current Color3 object
  85436. */
  85437. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85438. /**
  85439. * Returns a new Color4 object from the current Color3 and the given alpha
  85440. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85441. * @returns a new Color4 object
  85442. */
  85443. toColor4(alpha?: number): Color4;
  85444. /**
  85445. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85446. * @returns the new array
  85447. */
  85448. asArray(): number[];
  85449. /**
  85450. * Returns the luminance value
  85451. * @returns a float value
  85452. */
  85453. toLuminance(): number;
  85454. /**
  85455. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85456. * @param otherColor defines the second operand
  85457. * @returns the new Color3 object
  85458. */
  85459. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85460. /**
  85461. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85462. * @param otherColor defines the second operand
  85463. * @param result defines the Color3 object where to store the result
  85464. * @returns the current Color3
  85465. */
  85466. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85467. /**
  85468. * Determines equality between Color3 objects
  85469. * @param otherColor defines the second operand
  85470. * @returns true if the rgb values are equal to the given ones
  85471. */
  85472. equals(otherColor: DeepImmutable<Color3>): boolean;
  85473. /**
  85474. * Determines equality between the current Color3 object and a set of r,b,g values
  85475. * @param r defines the red component to check
  85476. * @param g defines the green component to check
  85477. * @param b defines the blue component to check
  85478. * @returns true if the rgb values are equal to the given ones
  85479. */
  85480. equalsFloats(r: number, g: number, b: number): boolean;
  85481. /**
  85482. * Multiplies in place each rgb value by scale
  85483. * @param scale defines the scaling factor
  85484. * @returns the updated Color3
  85485. */
  85486. scale(scale: number): Color3;
  85487. /**
  85488. * Multiplies the rgb values by scale and stores the result into "result"
  85489. * @param scale defines the scaling factor
  85490. * @param result defines the Color3 object where to store the result
  85491. * @returns the unmodified current Color3
  85492. */
  85493. scaleToRef(scale: number, result: Color3): Color3;
  85494. /**
  85495. * Scale the current Color3 values by a factor and add the result to a given Color3
  85496. * @param scale defines the scale factor
  85497. * @param result defines color to store the result into
  85498. * @returns the unmodified current Color3
  85499. */
  85500. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85501. /**
  85502. * Clamps the rgb values by the min and max values and stores the result into "result"
  85503. * @param min defines minimum clamping value (default is 0)
  85504. * @param max defines maximum clamping value (default is 1)
  85505. * @param result defines color to store the result into
  85506. * @returns the original Color3
  85507. */
  85508. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85509. /**
  85510. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85511. * @param otherColor defines the second operand
  85512. * @returns the new Color3
  85513. */
  85514. add(otherColor: DeepImmutable<Color3>): Color3;
  85515. /**
  85516. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85517. * @param otherColor defines the second operand
  85518. * @param result defines Color3 object to store the result into
  85519. * @returns the unmodified current Color3
  85520. */
  85521. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85522. /**
  85523. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85524. * @param otherColor defines the second operand
  85525. * @returns the new Color3
  85526. */
  85527. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85528. /**
  85529. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85530. * @param otherColor defines the second operand
  85531. * @param result defines Color3 object to store the result into
  85532. * @returns the unmodified current Color3
  85533. */
  85534. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85535. /**
  85536. * Copy the current object
  85537. * @returns a new Color3 copied the current one
  85538. */
  85539. clone(): Color3;
  85540. /**
  85541. * Copies the rgb values from the source in the current Color3
  85542. * @param source defines the source Color3 object
  85543. * @returns the updated Color3 object
  85544. */
  85545. copyFrom(source: DeepImmutable<Color3>): Color3;
  85546. /**
  85547. * Updates the Color3 rgb values from the given floats
  85548. * @param r defines the red component to read from
  85549. * @param g defines the green component to read from
  85550. * @param b defines the blue component to read from
  85551. * @returns the current Color3 object
  85552. */
  85553. copyFromFloats(r: number, g: number, b: number): Color3;
  85554. /**
  85555. * Updates the Color3 rgb values from the given floats
  85556. * @param r defines the red component to read from
  85557. * @param g defines the green component to read from
  85558. * @param b defines the blue component to read from
  85559. * @returns the current Color3 object
  85560. */
  85561. set(r: number, g: number, b: number): Color3;
  85562. /**
  85563. * Compute the Color3 hexadecimal code as a string
  85564. * @returns a string containing the hexadecimal representation of the Color3 object
  85565. */
  85566. toHexString(): string;
  85567. /**
  85568. * Computes a new Color3 converted from the current one to linear space
  85569. * @returns a new Color3 object
  85570. */
  85571. toLinearSpace(): Color3;
  85572. /**
  85573. * Converts current color in rgb space to HSV values
  85574. * @returns a new color3 representing the HSV values
  85575. */
  85576. toHSV(): Color3;
  85577. /**
  85578. * Converts current color in rgb space to HSV values
  85579. * @param result defines the Color3 where to store the HSV values
  85580. */
  85581. toHSVToRef(result: Color3): void;
  85582. /**
  85583. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85584. * @param convertedColor defines the Color3 object where to store the linear space version
  85585. * @returns the unmodified Color3
  85586. */
  85587. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85588. /**
  85589. * Computes a new Color3 converted from the current one to gamma space
  85590. * @returns a new Color3 object
  85591. */
  85592. toGammaSpace(): Color3;
  85593. /**
  85594. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85595. * @param convertedColor defines the Color3 object where to store the gamma space version
  85596. * @returns the unmodified Color3
  85597. */
  85598. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85599. private static _BlackReadOnly;
  85600. /**
  85601. * Convert Hue, saturation and value to a Color3 (RGB)
  85602. * @param hue defines the hue
  85603. * @param saturation defines the saturation
  85604. * @param value defines the value
  85605. * @param result defines the Color3 where to store the RGB values
  85606. */
  85607. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  85608. /**
  85609. * Creates a new Color3 from the string containing valid hexadecimal values
  85610. * @param hex defines a string containing valid hexadecimal values
  85611. * @returns a new Color3 object
  85612. */
  85613. static FromHexString(hex: string): Color3;
  85614. /**
  85615. * Creates a new Color3 from the starting index of the given array
  85616. * @param array defines the source array
  85617. * @param offset defines an offset in the source array
  85618. * @returns a new Color3 object
  85619. */
  85620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85621. /**
  85622. * Creates a new Color3 from the starting index element of the given array
  85623. * @param array defines the source array to read from
  85624. * @param offset defines the offset in the source array
  85625. * @param result defines the target Color3 object
  85626. */
  85627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85628. /**
  85629. * Creates a new Color3 from integer values (< 256)
  85630. * @param r defines the red component to read from (value between 0 and 255)
  85631. * @param g defines the green component to read from (value between 0 and 255)
  85632. * @param b defines the blue component to read from (value between 0 and 255)
  85633. * @returns a new Color3 object
  85634. */
  85635. static FromInts(r: number, g: number, b: number): Color3;
  85636. /**
  85637. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85638. * @param start defines the start Color3 value
  85639. * @param end defines the end Color3 value
  85640. * @param amount defines the gradient value between start and end
  85641. * @returns a new Color3 object
  85642. */
  85643. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  85644. /**
  85645. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85646. * @param left defines the start value
  85647. * @param right defines the end value
  85648. * @param amount defines the gradient factor
  85649. * @param result defines the Color3 object where to store the result
  85650. */
  85651. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  85652. /**
  85653. * Returns a Color3 value containing a red color
  85654. * @returns a new Color3 object
  85655. */
  85656. static Red(): Color3;
  85657. /**
  85658. * Returns a Color3 value containing a green color
  85659. * @returns a new Color3 object
  85660. */
  85661. static Green(): Color3;
  85662. /**
  85663. * Returns a Color3 value containing a blue color
  85664. * @returns a new Color3 object
  85665. */
  85666. static Blue(): Color3;
  85667. /**
  85668. * Returns a Color3 value containing a black color
  85669. * @returns a new Color3 object
  85670. */
  85671. static Black(): Color3;
  85672. /**
  85673. * Gets a Color3 value containing a black color that must not be updated
  85674. */
  85675. static get BlackReadOnly(): DeepImmutable<Color3>;
  85676. /**
  85677. * Returns a Color3 value containing a white color
  85678. * @returns a new Color3 object
  85679. */
  85680. static White(): Color3;
  85681. /**
  85682. * Returns a Color3 value containing a purple color
  85683. * @returns a new Color3 object
  85684. */
  85685. static Purple(): Color3;
  85686. /**
  85687. * Returns a Color3 value containing a magenta color
  85688. * @returns a new Color3 object
  85689. */
  85690. static Magenta(): Color3;
  85691. /**
  85692. * Returns a Color3 value containing a yellow color
  85693. * @returns a new Color3 object
  85694. */
  85695. static Yellow(): Color3;
  85696. /**
  85697. * Returns a Color3 value containing a gray color
  85698. * @returns a new Color3 object
  85699. */
  85700. static Gray(): Color3;
  85701. /**
  85702. * Returns a Color3 value containing a teal color
  85703. * @returns a new Color3 object
  85704. */
  85705. static Teal(): Color3;
  85706. /**
  85707. * Returns a Color3 value containing a random color
  85708. * @returns a new Color3 object
  85709. */
  85710. static Random(): Color3;
  85711. }
  85712. /**
  85713. * Class used to hold a RBGA color
  85714. */
  85715. export class Color4 {
  85716. /**
  85717. * Defines the red component (between 0 and 1, default is 0)
  85718. */
  85719. r: number;
  85720. /**
  85721. * Defines the green component (between 0 and 1, default is 0)
  85722. */
  85723. g: number;
  85724. /**
  85725. * Defines the blue component (between 0 and 1, default is 0)
  85726. */
  85727. b: number;
  85728. /**
  85729. * Defines the alpha component (between 0 and 1, default is 1)
  85730. */
  85731. a: number;
  85732. /**
  85733. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  85734. * @param r defines the red component (between 0 and 1, default is 0)
  85735. * @param g defines the green component (between 0 and 1, default is 0)
  85736. * @param b defines the blue component (between 0 and 1, default is 0)
  85737. * @param a defines the alpha component (between 0 and 1, default is 1)
  85738. */
  85739. constructor(
  85740. /**
  85741. * Defines the red component (between 0 and 1, default is 0)
  85742. */
  85743. r?: number,
  85744. /**
  85745. * Defines the green component (between 0 and 1, default is 0)
  85746. */
  85747. g?: number,
  85748. /**
  85749. * Defines the blue component (between 0 and 1, default is 0)
  85750. */
  85751. b?: number,
  85752. /**
  85753. * Defines the alpha component (between 0 and 1, default is 1)
  85754. */
  85755. a?: number);
  85756. /**
  85757. * Adds in place the given Color4 values to the current Color4 object
  85758. * @param right defines the second operand
  85759. * @returns the current updated Color4 object
  85760. */
  85761. addInPlace(right: DeepImmutable<Color4>): Color4;
  85762. /**
  85763. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  85764. * @returns the new array
  85765. */
  85766. asArray(): number[];
  85767. /**
  85768. * Stores from the starting index in the given array the Color4 successive values
  85769. * @param array defines the array where to store the r,g,b components
  85770. * @param index defines an optional index in the target array to define where to start storing values
  85771. * @returns the current Color4 object
  85772. */
  85773. toArray(array: number[], index?: number): Color4;
  85774. /**
  85775. * Update the current color with values stored in an array from the starting index of the given array
  85776. * @param array defines the source array
  85777. * @param offset defines an offset in the source array
  85778. * @returns the current Color4 object
  85779. */
  85780. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85781. /**
  85782. * Determines equality between Color4 objects
  85783. * @param otherColor defines the second operand
  85784. * @returns true if the rgba values are equal to the given ones
  85785. */
  85786. equals(otherColor: DeepImmutable<Color4>): boolean;
  85787. /**
  85788. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  85789. * @param right defines the second operand
  85790. * @returns a new Color4 object
  85791. */
  85792. add(right: DeepImmutable<Color4>): Color4;
  85793. /**
  85794. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  85795. * @param right defines the second operand
  85796. * @returns a new Color4 object
  85797. */
  85798. subtract(right: DeepImmutable<Color4>): Color4;
  85799. /**
  85800. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  85801. * @param right defines the second operand
  85802. * @param result defines the Color4 object where to store the result
  85803. * @returns the current Color4 object
  85804. */
  85805. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  85806. /**
  85807. * Creates a new Color4 with the current Color4 values multiplied by scale
  85808. * @param scale defines the scaling factor to apply
  85809. * @returns a new Color4 object
  85810. */
  85811. scale(scale: number): Color4;
  85812. /**
  85813. * Multiplies the current Color4 values by scale and stores the result in "result"
  85814. * @param scale defines the scaling factor to apply
  85815. * @param result defines the Color4 object where to store the result
  85816. * @returns the current unmodified Color4
  85817. */
  85818. scaleToRef(scale: number, result: Color4): Color4;
  85819. /**
  85820. * Scale the current Color4 values by a factor and add the result to a given Color4
  85821. * @param scale defines the scale factor
  85822. * @param result defines the Color4 object where to store the result
  85823. * @returns the unmodified current Color4
  85824. */
  85825. scaleAndAddToRef(scale: number, result: Color4): Color4;
  85826. /**
  85827. * Clamps the rgb values by the min and max values and stores the result into "result"
  85828. * @param min defines minimum clamping value (default is 0)
  85829. * @param max defines maximum clamping value (default is 1)
  85830. * @param result defines color to store the result into.
  85831. * @returns the cuurent Color4
  85832. */
  85833. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  85834. /**
  85835. * Multipy an Color4 value by another and return a new Color4 object
  85836. * @param color defines the Color4 value to multiply by
  85837. * @returns a new Color4 object
  85838. */
  85839. multiply(color: Color4): Color4;
  85840. /**
  85841. * Multipy a Color4 value by another and push the result in a reference value
  85842. * @param color defines the Color4 value to multiply by
  85843. * @param result defines the Color4 to fill the result in
  85844. * @returns the result Color4
  85845. */
  85846. multiplyToRef(color: Color4, result: Color4): Color4;
  85847. /**
  85848. * Creates a string with the Color4 current values
  85849. * @returns the string representation of the Color4 object
  85850. */
  85851. toString(): string;
  85852. /**
  85853. * Returns the string "Color4"
  85854. * @returns "Color4"
  85855. */
  85856. getClassName(): string;
  85857. /**
  85858. * Compute the Color4 hash code
  85859. * @returns an unique number that can be used to hash Color4 objects
  85860. */
  85861. getHashCode(): number;
  85862. /**
  85863. * Creates a new Color4 copied from the current one
  85864. * @returns a new Color4 object
  85865. */
  85866. clone(): Color4;
  85867. /**
  85868. * Copies the given Color4 values into the current one
  85869. * @param source defines the source Color4 object
  85870. * @returns the current updated Color4 object
  85871. */
  85872. copyFrom(source: Color4): Color4;
  85873. /**
  85874. * Copies the given float values into the current one
  85875. * @param r defines the red component to read from
  85876. * @param g defines the green component to read from
  85877. * @param b defines the blue component to read from
  85878. * @param a defines the alpha component to read from
  85879. * @returns the current updated Color4 object
  85880. */
  85881. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85882. /**
  85883. * Copies the given float values into the current one
  85884. * @param r defines the red component to read from
  85885. * @param g defines the green component to read from
  85886. * @param b defines the blue component to read from
  85887. * @param a defines the alpha component to read from
  85888. * @returns the current updated Color4 object
  85889. */
  85890. set(r: number, g: number, b: number, a: number): Color4;
  85891. /**
  85892. * Compute the Color4 hexadecimal code as a string
  85893. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85894. * @returns a string containing the hexadecimal representation of the Color4 object
  85895. */
  85896. toHexString(returnAsColor3?: boolean): string;
  85897. /**
  85898. * Computes a new Color4 converted from the current one to linear space
  85899. * @returns a new Color4 object
  85900. */
  85901. toLinearSpace(): Color4;
  85902. /**
  85903. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85904. * @param convertedColor defines the Color4 object where to store the linear space version
  85905. * @returns the unmodified Color4
  85906. */
  85907. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85908. /**
  85909. * Computes a new Color4 converted from the current one to gamma space
  85910. * @returns a new Color4 object
  85911. */
  85912. toGammaSpace(): Color4;
  85913. /**
  85914. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85915. * @param convertedColor defines the Color4 object where to store the gamma space version
  85916. * @returns the unmodified Color4
  85917. */
  85918. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85919. /**
  85920. * Creates a new Color4 from the string containing valid hexadecimal values
  85921. * @param hex defines a string containing valid hexadecimal values
  85922. * @returns a new Color4 object
  85923. */
  85924. static FromHexString(hex: string): Color4;
  85925. /**
  85926. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85927. * @param left defines the start value
  85928. * @param right defines the end value
  85929. * @param amount defines the gradient factor
  85930. * @returns a new Color4 object
  85931. */
  85932. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85933. /**
  85934. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85935. * @param left defines the start value
  85936. * @param right defines the end value
  85937. * @param amount defines the gradient factor
  85938. * @param result defines the Color4 object where to store data
  85939. */
  85940. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85941. /**
  85942. * Creates a new Color4 from a Color3 and an alpha value
  85943. * @param color3 defines the source Color3 to read from
  85944. * @param alpha defines the alpha component (1.0 by default)
  85945. * @returns a new Color4 object
  85946. */
  85947. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85948. /**
  85949. * Creates a new Color4 from the starting index element of the given array
  85950. * @param array defines the source array to read from
  85951. * @param offset defines the offset in the source array
  85952. * @returns a new Color4 object
  85953. */
  85954. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85955. /**
  85956. * Creates a new Color4 from the starting index element of the given array
  85957. * @param array defines the source array to read from
  85958. * @param offset defines the offset in the source array
  85959. * @param result defines the target Color4 object
  85960. */
  85961. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85962. /**
  85963. * Creates a new Color3 from integer values (< 256)
  85964. * @param r defines the red component to read from (value between 0 and 255)
  85965. * @param g defines the green component to read from (value between 0 and 255)
  85966. * @param b defines the blue component to read from (value between 0 and 255)
  85967. * @param a defines the alpha component to read from (value between 0 and 255)
  85968. * @returns a new Color3 object
  85969. */
  85970. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85971. /**
  85972. * Check the content of a given array and convert it to an array containing RGBA data
  85973. * If the original array was already containing count * 4 values then it is returned directly
  85974. * @param colors defines the array to check
  85975. * @param count defines the number of RGBA data to expect
  85976. * @returns an array containing count * 4 values (RGBA)
  85977. */
  85978. static CheckColors4(colors: number[], count: number): number[];
  85979. }
  85980. /**
  85981. * @hidden
  85982. */
  85983. export class TmpColors {
  85984. static Color3: Color3[];
  85985. static Color4: Color4[];
  85986. }
  85987. }
  85988. declare module BABYLON {
  85989. /**
  85990. * Defines an interface which represents an animation key frame
  85991. */
  85992. export interface IAnimationKey {
  85993. /**
  85994. * Frame of the key frame
  85995. */
  85996. frame: number;
  85997. /**
  85998. * Value at the specifies key frame
  85999. */
  86000. value: any;
  86001. /**
  86002. * The input tangent for the cubic hermite spline
  86003. */
  86004. inTangent?: any;
  86005. /**
  86006. * The output tangent for the cubic hermite spline
  86007. */
  86008. outTangent?: any;
  86009. /**
  86010. * The animation interpolation type
  86011. */
  86012. interpolation?: AnimationKeyInterpolation;
  86013. }
  86014. /**
  86015. * Enum for the animation key frame interpolation type
  86016. */
  86017. export enum AnimationKeyInterpolation {
  86018. /**
  86019. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86020. */
  86021. STEP = 1
  86022. }
  86023. }
  86024. declare module BABYLON {
  86025. /**
  86026. * Represents the range of an animation
  86027. */
  86028. export class AnimationRange {
  86029. /**The name of the animation range**/
  86030. name: string;
  86031. /**The starting frame of the animation */
  86032. from: number;
  86033. /**The ending frame of the animation*/
  86034. to: number;
  86035. /**
  86036. * Initializes the range of an animation
  86037. * @param name The name of the animation range
  86038. * @param from The starting frame of the animation
  86039. * @param to The ending frame of the animation
  86040. */
  86041. constructor(
  86042. /**The name of the animation range**/
  86043. name: string,
  86044. /**The starting frame of the animation */
  86045. from: number,
  86046. /**The ending frame of the animation*/
  86047. to: number);
  86048. /**
  86049. * Makes a copy of the animation range
  86050. * @returns A copy of the animation range
  86051. */
  86052. clone(): AnimationRange;
  86053. }
  86054. }
  86055. declare module BABYLON {
  86056. /**
  86057. * Composed of a frame, and an action function
  86058. */
  86059. export class AnimationEvent {
  86060. /** The frame for which the event is triggered **/
  86061. frame: number;
  86062. /** The event to perform when triggered **/
  86063. action: (currentFrame: number) => void;
  86064. /** Specifies if the event should be triggered only once**/
  86065. onlyOnce?: boolean | undefined;
  86066. /**
  86067. * Specifies if the animation event is done
  86068. */
  86069. isDone: boolean;
  86070. /**
  86071. * Initializes the animation event
  86072. * @param frame The frame for which the event is triggered
  86073. * @param action The event to perform when triggered
  86074. * @param onlyOnce Specifies if the event should be triggered only once
  86075. */
  86076. constructor(
  86077. /** The frame for which the event is triggered **/
  86078. frame: number,
  86079. /** The event to perform when triggered **/
  86080. action: (currentFrame: number) => void,
  86081. /** Specifies if the event should be triggered only once**/
  86082. onlyOnce?: boolean | undefined);
  86083. /** @hidden */
  86084. _clone(): AnimationEvent;
  86085. }
  86086. }
  86087. declare module BABYLON {
  86088. /**
  86089. * Interface used to define a behavior
  86090. */
  86091. export interface Behavior<T> {
  86092. /** gets or sets behavior's name */
  86093. name: string;
  86094. /**
  86095. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86096. */
  86097. init(): void;
  86098. /**
  86099. * Called when the behavior is attached to a target
  86100. * @param target defines the target where the behavior is attached to
  86101. */
  86102. attach(target: T): void;
  86103. /**
  86104. * Called when the behavior is detached from its target
  86105. */
  86106. detach(): void;
  86107. }
  86108. /**
  86109. * Interface implemented by classes supporting behaviors
  86110. */
  86111. export interface IBehaviorAware<T> {
  86112. /**
  86113. * Attach a behavior
  86114. * @param behavior defines the behavior to attach
  86115. * @returns the current host
  86116. */
  86117. addBehavior(behavior: Behavior<T>): T;
  86118. /**
  86119. * Remove a behavior from the current object
  86120. * @param behavior defines the behavior to detach
  86121. * @returns the current host
  86122. */
  86123. removeBehavior(behavior: Behavior<T>): T;
  86124. /**
  86125. * Gets a behavior using its name to search
  86126. * @param name defines the name to search
  86127. * @returns the behavior or null if not found
  86128. */
  86129. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86130. }
  86131. }
  86132. declare module BABYLON {
  86133. /**
  86134. * Defines an array and its length.
  86135. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86136. */
  86137. export interface ISmartArrayLike<T> {
  86138. /**
  86139. * The data of the array.
  86140. */
  86141. data: Array<T>;
  86142. /**
  86143. * The active length of the array.
  86144. */
  86145. length: number;
  86146. }
  86147. /**
  86148. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86149. */
  86150. export class SmartArray<T> implements ISmartArrayLike<T> {
  86151. /**
  86152. * The full set of data from the array.
  86153. */
  86154. data: Array<T>;
  86155. /**
  86156. * The active length of the array.
  86157. */
  86158. length: number;
  86159. protected _id: number;
  86160. /**
  86161. * Instantiates a Smart Array.
  86162. * @param capacity defines the default capacity of the array.
  86163. */
  86164. constructor(capacity: number);
  86165. /**
  86166. * Pushes a value at the end of the active data.
  86167. * @param value defines the object to push in the array.
  86168. */
  86169. push(value: T): void;
  86170. /**
  86171. * Iterates over the active data and apply the lambda to them.
  86172. * @param func defines the action to apply on each value.
  86173. */
  86174. forEach(func: (content: T) => void): void;
  86175. /**
  86176. * Sorts the full sets of data.
  86177. * @param compareFn defines the comparison function to apply.
  86178. */
  86179. sort(compareFn: (a: T, b: T) => number): void;
  86180. /**
  86181. * Resets the active data to an empty array.
  86182. */
  86183. reset(): void;
  86184. /**
  86185. * Releases all the data from the array as well as the array.
  86186. */
  86187. dispose(): void;
  86188. /**
  86189. * Concats the active data with a given array.
  86190. * @param array defines the data to concatenate with.
  86191. */
  86192. concat(array: any): void;
  86193. /**
  86194. * Returns the position of a value in the active data.
  86195. * @param value defines the value to find the index for
  86196. * @returns the index if found in the active data otherwise -1
  86197. */
  86198. indexOf(value: T): number;
  86199. /**
  86200. * Returns whether an element is part of the active data.
  86201. * @param value defines the value to look for
  86202. * @returns true if found in the active data otherwise false
  86203. */
  86204. contains(value: T): boolean;
  86205. private static _GlobalId;
  86206. }
  86207. /**
  86208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86209. * The data in this array can only be present once
  86210. */
  86211. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86212. private _duplicateId;
  86213. /**
  86214. * Pushes a value at the end of the active data.
  86215. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86216. * @param value defines the object to push in the array.
  86217. */
  86218. push(value: T): void;
  86219. /**
  86220. * Pushes a value at the end of the active data.
  86221. * If the data is already present, it won t be added again
  86222. * @param value defines the object to push in the array.
  86223. * @returns true if added false if it was already present
  86224. */
  86225. pushNoDuplicate(value: T): boolean;
  86226. /**
  86227. * Resets the active data to an empty array.
  86228. */
  86229. reset(): void;
  86230. /**
  86231. * Concats the active data with a given array.
  86232. * This ensures no dupplicate will be present in the result.
  86233. * @param array defines the data to concatenate with.
  86234. */
  86235. concatWithNoDuplicate(array: any): void;
  86236. }
  86237. }
  86238. declare module BABYLON {
  86239. /**
  86240. * @ignore
  86241. * This is a list of all the different input types that are available in the application.
  86242. * Fo instance: ArcRotateCameraGamepadInput...
  86243. */
  86244. export var CameraInputTypes: {};
  86245. /**
  86246. * This is the contract to implement in order to create a new input class.
  86247. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86248. */
  86249. export interface ICameraInput<TCamera extends Camera> {
  86250. /**
  86251. * Defines the camera the input is attached to.
  86252. */
  86253. camera: Nullable<TCamera>;
  86254. /**
  86255. * Gets the class name of the current intput.
  86256. * @returns the class name
  86257. */
  86258. getClassName(): string;
  86259. /**
  86260. * Get the friendly name associated with the input class.
  86261. * @returns the input friendly name
  86262. */
  86263. getSimpleName(): string;
  86264. /**
  86265. * Attach the input controls to a specific dom element to get the input from.
  86266. * @param element Defines the element the controls should be listened from
  86267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86268. */
  86269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86270. /**
  86271. * Detach the current controls from the specified dom element.
  86272. * @param element Defines the element to stop listening the inputs from
  86273. */
  86274. detachControl(element: Nullable<HTMLElement>): void;
  86275. /**
  86276. * Update the current camera state depending on the inputs that have been used this frame.
  86277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86278. */
  86279. checkInputs?: () => void;
  86280. }
  86281. /**
  86282. * Represents a map of input types to input instance or input index to input instance.
  86283. */
  86284. export interface CameraInputsMap<TCamera extends Camera> {
  86285. /**
  86286. * Accessor to the input by input type.
  86287. */
  86288. [name: string]: ICameraInput<TCamera>;
  86289. /**
  86290. * Accessor to the input by input index.
  86291. */
  86292. [idx: number]: ICameraInput<TCamera>;
  86293. }
  86294. /**
  86295. * This represents the input manager used within a camera.
  86296. * It helps dealing with all the different kind of input attached to a camera.
  86297. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86298. */
  86299. export class CameraInputsManager<TCamera extends Camera> {
  86300. /**
  86301. * Defines the list of inputs attahed to the camera.
  86302. */
  86303. attached: CameraInputsMap<TCamera>;
  86304. /**
  86305. * Defines the dom element the camera is collecting inputs from.
  86306. * This is null if the controls have not been attached.
  86307. */
  86308. attachedElement: Nullable<HTMLElement>;
  86309. /**
  86310. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86311. */
  86312. noPreventDefault: boolean;
  86313. /**
  86314. * Defined the camera the input manager belongs to.
  86315. */
  86316. camera: TCamera;
  86317. /**
  86318. * Update the current camera state depending on the inputs that have been used this frame.
  86319. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86320. */
  86321. checkInputs: () => void;
  86322. /**
  86323. * Instantiate a new Camera Input Manager.
  86324. * @param camera Defines the camera the input manager blongs to
  86325. */
  86326. constructor(camera: TCamera);
  86327. /**
  86328. * Add an input method to a camera
  86329. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86330. * @param input camera input method
  86331. */
  86332. add(input: ICameraInput<TCamera>): void;
  86333. /**
  86334. * Remove a specific input method from a camera
  86335. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86336. * @param inputToRemove camera input method
  86337. */
  86338. remove(inputToRemove: ICameraInput<TCamera>): void;
  86339. /**
  86340. * Remove a specific input type from a camera
  86341. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86342. * @param inputType the type of the input to remove
  86343. */
  86344. removeByType(inputType: string): void;
  86345. private _addCheckInputs;
  86346. /**
  86347. * Attach the input controls to the currently attached dom element to listen the events from.
  86348. * @param input Defines the input to attach
  86349. */
  86350. attachInput(input: ICameraInput<TCamera>): void;
  86351. /**
  86352. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86353. * @param element Defines the dom element to collect the events from
  86354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86355. */
  86356. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86357. /**
  86358. * Detach the current manager inputs controls from a specific dom element.
  86359. * @param element Defines the dom element to collect the events from
  86360. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86361. */
  86362. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86363. /**
  86364. * Rebuild the dynamic inputCheck function from the current list of
  86365. * defined inputs in the manager.
  86366. */
  86367. rebuildInputCheck(): void;
  86368. /**
  86369. * Remove all attached input methods from a camera
  86370. */
  86371. clear(): void;
  86372. /**
  86373. * Serialize the current input manager attached to a camera.
  86374. * This ensures than once parsed,
  86375. * the input associated to the camera will be identical to the current ones
  86376. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86377. */
  86378. serialize(serializedCamera: any): void;
  86379. /**
  86380. * Parses an input manager serialized JSON to restore the previous list of inputs
  86381. * and states associated to a camera.
  86382. * @param parsedCamera Defines the JSON to parse
  86383. */
  86384. parse(parsedCamera: any): void;
  86385. }
  86386. }
  86387. declare module BABYLON {
  86388. /**
  86389. * Class used to store data that will be store in GPU memory
  86390. */
  86391. export class Buffer {
  86392. private _engine;
  86393. private _buffer;
  86394. /** @hidden */
  86395. _data: Nullable<DataArray>;
  86396. private _updatable;
  86397. private _instanced;
  86398. private _divisor;
  86399. /**
  86400. * Gets the byte stride.
  86401. */
  86402. readonly byteStride: number;
  86403. /**
  86404. * Constructor
  86405. * @param engine the engine
  86406. * @param data the data to use for this buffer
  86407. * @param updatable whether the data is updatable
  86408. * @param stride the stride (optional)
  86409. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86410. * @param instanced whether the buffer is instanced (optional)
  86411. * @param useBytes set to true if the stride in in bytes (optional)
  86412. * @param divisor sets an optional divisor for instances (1 by default)
  86413. */
  86414. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86415. /**
  86416. * Create a new VertexBuffer based on the current buffer
  86417. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86418. * @param offset defines offset in the buffer (0 by default)
  86419. * @param size defines the size in floats of attributes (position is 3 for instance)
  86420. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86421. * @param instanced defines if the vertex buffer contains indexed data
  86422. * @param useBytes defines if the offset and stride are in bytes *
  86423. * @param divisor sets an optional divisor for instances (1 by default)
  86424. * @returns the new vertex buffer
  86425. */
  86426. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86427. /**
  86428. * Gets a boolean indicating if the Buffer is updatable?
  86429. * @returns true if the buffer is updatable
  86430. */
  86431. isUpdatable(): boolean;
  86432. /**
  86433. * Gets current buffer's data
  86434. * @returns a DataArray or null
  86435. */
  86436. getData(): Nullable<DataArray>;
  86437. /**
  86438. * Gets underlying native buffer
  86439. * @returns underlying native buffer
  86440. */
  86441. getBuffer(): Nullable<DataBuffer>;
  86442. /**
  86443. * Gets the stride in float32 units (i.e. byte stride / 4).
  86444. * May not be an integer if the byte stride is not divisible by 4.
  86445. * @returns the stride in float32 units
  86446. * @deprecated Please use byteStride instead.
  86447. */
  86448. getStrideSize(): number;
  86449. /**
  86450. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86451. * @param data defines the data to store
  86452. */
  86453. create(data?: Nullable<DataArray>): void;
  86454. /** @hidden */
  86455. _rebuild(): void;
  86456. /**
  86457. * Update current buffer data
  86458. * @param data defines the data to store
  86459. */
  86460. update(data: DataArray): void;
  86461. /**
  86462. * Updates the data directly.
  86463. * @param data the new data
  86464. * @param offset the new offset
  86465. * @param vertexCount the vertex count (optional)
  86466. * @param useBytes set to true if the offset is in bytes
  86467. */
  86468. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86469. /**
  86470. * Release all resources
  86471. */
  86472. dispose(): void;
  86473. }
  86474. /**
  86475. * Specialized buffer used to store vertex data
  86476. */
  86477. export class VertexBuffer {
  86478. /** @hidden */
  86479. _buffer: Buffer;
  86480. private _kind;
  86481. private _size;
  86482. private _ownsBuffer;
  86483. private _instanced;
  86484. private _instanceDivisor;
  86485. /**
  86486. * The byte type.
  86487. */
  86488. static readonly BYTE: number;
  86489. /**
  86490. * The unsigned byte type.
  86491. */
  86492. static readonly UNSIGNED_BYTE: number;
  86493. /**
  86494. * The short type.
  86495. */
  86496. static readonly SHORT: number;
  86497. /**
  86498. * The unsigned short type.
  86499. */
  86500. static readonly UNSIGNED_SHORT: number;
  86501. /**
  86502. * The integer type.
  86503. */
  86504. static readonly INT: number;
  86505. /**
  86506. * The unsigned integer type.
  86507. */
  86508. static readonly UNSIGNED_INT: number;
  86509. /**
  86510. * The float type.
  86511. */
  86512. static readonly FLOAT: number;
  86513. /**
  86514. * Gets or sets the instance divisor when in instanced mode
  86515. */
  86516. get instanceDivisor(): number;
  86517. set instanceDivisor(value: number);
  86518. /**
  86519. * Gets the byte stride.
  86520. */
  86521. readonly byteStride: number;
  86522. /**
  86523. * Gets the byte offset.
  86524. */
  86525. readonly byteOffset: number;
  86526. /**
  86527. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86528. */
  86529. readonly normalized: boolean;
  86530. /**
  86531. * Gets the data type of each component in the array.
  86532. */
  86533. readonly type: number;
  86534. /**
  86535. * Constructor
  86536. * @param engine the engine
  86537. * @param data the data to use for this vertex buffer
  86538. * @param kind the vertex buffer kind
  86539. * @param updatable whether the data is updatable
  86540. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86541. * @param stride the stride (optional)
  86542. * @param instanced whether the buffer is instanced (optional)
  86543. * @param offset the offset of the data (optional)
  86544. * @param size the number of components (optional)
  86545. * @param type the type of the component (optional)
  86546. * @param normalized whether the data contains normalized data (optional)
  86547. * @param useBytes set to true if stride and offset are in bytes (optional)
  86548. * @param divisor defines the instance divisor to use (1 by default)
  86549. */
  86550. 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);
  86551. /** @hidden */
  86552. _rebuild(): void;
  86553. /**
  86554. * Returns the kind of the VertexBuffer (string)
  86555. * @returns a string
  86556. */
  86557. getKind(): string;
  86558. /**
  86559. * Gets a boolean indicating if the VertexBuffer is updatable?
  86560. * @returns true if the buffer is updatable
  86561. */
  86562. isUpdatable(): boolean;
  86563. /**
  86564. * Gets current buffer's data
  86565. * @returns a DataArray or null
  86566. */
  86567. getData(): Nullable<DataArray>;
  86568. /**
  86569. * Gets underlying native buffer
  86570. * @returns underlying native buffer
  86571. */
  86572. getBuffer(): Nullable<DataBuffer>;
  86573. /**
  86574. * Gets the stride in float32 units (i.e. byte stride / 4).
  86575. * May not be an integer if the byte stride is not divisible by 4.
  86576. * @returns the stride in float32 units
  86577. * @deprecated Please use byteStride instead.
  86578. */
  86579. getStrideSize(): number;
  86580. /**
  86581. * Returns the offset as a multiple of the type byte length.
  86582. * @returns the offset in bytes
  86583. * @deprecated Please use byteOffset instead.
  86584. */
  86585. getOffset(): number;
  86586. /**
  86587. * Returns the number of components per vertex attribute (integer)
  86588. * @returns the size in float
  86589. */
  86590. getSize(): number;
  86591. /**
  86592. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86593. * @returns true if this buffer is instanced
  86594. */
  86595. getIsInstanced(): boolean;
  86596. /**
  86597. * Returns the instancing divisor, zero for non-instanced (integer).
  86598. * @returns a number
  86599. */
  86600. getInstanceDivisor(): number;
  86601. /**
  86602. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86603. * @param data defines the data to store
  86604. */
  86605. create(data?: DataArray): void;
  86606. /**
  86607. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86608. * This function will create a new buffer if the current one is not updatable
  86609. * @param data defines the data to store
  86610. */
  86611. update(data: DataArray): void;
  86612. /**
  86613. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86614. * Returns the directly updated WebGLBuffer.
  86615. * @param data the new data
  86616. * @param offset the new offset
  86617. * @param useBytes set to true if the offset is in bytes
  86618. */
  86619. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86620. /**
  86621. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86622. */
  86623. dispose(): void;
  86624. /**
  86625. * Enumerates each value of this vertex buffer as numbers.
  86626. * @param count the number of values to enumerate
  86627. * @param callback the callback function called for each value
  86628. */
  86629. forEach(count: number, callback: (value: number, index: number) => void): void;
  86630. /**
  86631. * Positions
  86632. */
  86633. static readonly PositionKind: string;
  86634. /**
  86635. * Normals
  86636. */
  86637. static readonly NormalKind: string;
  86638. /**
  86639. * Tangents
  86640. */
  86641. static readonly TangentKind: string;
  86642. /**
  86643. * Texture coordinates
  86644. */
  86645. static readonly UVKind: string;
  86646. /**
  86647. * Texture coordinates 2
  86648. */
  86649. static readonly UV2Kind: string;
  86650. /**
  86651. * Texture coordinates 3
  86652. */
  86653. static readonly UV3Kind: string;
  86654. /**
  86655. * Texture coordinates 4
  86656. */
  86657. static readonly UV4Kind: string;
  86658. /**
  86659. * Texture coordinates 5
  86660. */
  86661. static readonly UV5Kind: string;
  86662. /**
  86663. * Texture coordinates 6
  86664. */
  86665. static readonly UV6Kind: string;
  86666. /**
  86667. * Colors
  86668. */
  86669. static readonly ColorKind: string;
  86670. /**
  86671. * Matrix indices (for bones)
  86672. */
  86673. static readonly MatricesIndicesKind: string;
  86674. /**
  86675. * Matrix weights (for bones)
  86676. */
  86677. static readonly MatricesWeightsKind: string;
  86678. /**
  86679. * Additional matrix indices (for bones)
  86680. */
  86681. static readonly MatricesIndicesExtraKind: string;
  86682. /**
  86683. * Additional matrix weights (for bones)
  86684. */
  86685. static readonly MatricesWeightsExtraKind: string;
  86686. /**
  86687. * Deduces the stride given a kind.
  86688. * @param kind The kind string to deduce
  86689. * @returns The deduced stride
  86690. */
  86691. static DeduceStride(kind: string): number;
  86692. /**
  86693. * Gets the byte length of the given type.
  86694. * @param type the type
  86695. * @returns the number of bytes
  86696. */
  86697. static GetTypeByteLength(type: number): number;
  86698. /**
  86699. * Enumerates each value of the given parameters as numbers.
  86700. * @param data the data to enumerate
  86701. * @param byteOffset the byte offset of the data
  86702. * @param byteStride the byte stride of the data
  86703. * @param componentCount the number of components per element
  86704. * @param componentType the type of the component
  86705. * @param count the number of values to enumerate
  86706. * @param normalized whether the data is normalized
  86707. * @param callback the callback function called for each value
  86708. */
  86709. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  86710. private static _GetFloatValue;
  86711. }
  86712. }
  86713. declare module BABYLON {
  86714. /**
  86715. * The options Interface for creating a Capsule Mesh
  86716. */
  86717. export interface ICreateCapsuleOptions {
  86718. /** The Orientation of the capsule. Default : Vector3.Up() */
  86719. orientation?: Vector3;
  86720. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  86721. subdivisions: number;
  86722. /** Number of cylindrical segments on the capsule. */
  86723. tessellation: number;
  86724. /** Height or Length of the capsule. */
  86725. height: number;
  86726. /** Radius of the capsule. */
  86727. radius: number;
  86728. /** Height or Length of the capsule. */
  86729. capSubdivisions: number;
  86730. /** Overwrite for the top radius. */
  86731. radiusTop?: number;
  86732. /** Overwrite for the bottom radius. */
  86733. radiusBottom?: number;
  86734. /** Overwrite for the top capSubdivisions. */
  86735. topCapSubdivisions?: number;
  86736. /** Overwrite for the bottom capSubdivisions. */
  86737. bottomCapSubdivisions?: number;
  86738. }
  86739. /**
  86740. * Class containing static functions to help procedurally build meshes
  86741. */
  86742. export class CapsuleBuilder {
  86743. /**
  86744. * Creates a capsule or a pill mesh
  86745. * @param name defines the name of the mesh
  86746. * @param options The constructors options.
  86747. * @param scene The scene the mesh is scoped to.
  86748. * @returns Capsule Mesh
  86749. */
  86750. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  86751. }
  86752. }
  86753. declare module BABYLON {
  86754. /**
  86755. * @hidden
  86756. */
  86757. export class IntersectionInfo {
  86758. bu: Nullable<number>;
  86759. bv: Nullable<number>;
  86760. distance: number;
  86761. faceId: number;
  86762. subMeshId: number;
  86763. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  86764. }
  86765. }
  86766. declare module BABYLON {
  86767. /**
  86768. * Class used to store bounding sphere information
  86769. */
  86770. export class BoundingSphere {
  86771. /**
  86772. * Gets the center of the bounding sphere in local space
  86773. */
  86774. readonly center: Vector3;
  86775. /**
  86776. * Radius of the bounding sphere in local space
  86777. */
  86778. radius: number;
  86779. /**
  86780. * Gets the center of the bounding sphere in world space
  86781. */
  86782. readonly centerWorld: Vector3;
  86783. /**
  86784. * Radius of the bounding sphere in world space
  86785. */
  86786. radiusWorld: number;
  86787. /**
  86788. * Gets the minimum vector in local space
  86789. */
  86790. readonly minimum: Vector3;
  86791. /**
  86792. * Gets the maximum vector in local space
  86793. */
  86794. readonly maximum: Vector3;
  86795. private _worldMatrix;
  86796. private static readonly TmpVector3;
  86797. /**
  86798. * Creates a new bounding sphere
  86799. * @param min defines the minimum vector (in local space)
  86800. * @param max defines the maximum vector (in local space)
  86801. * @param worldMatrix defines the new world matrix
  86802. */
  86803. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86804. /**
  86805. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  86806. * @param min defines the new minimum vector (in local space)
  86807. * @param max defines the new maximum vector (in local space)
  86808. * @param worldMatrix defines the new world matrix
  86809. */
  86810. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86811. /**
  86812. * Scale the current bounding sphere by applying a scale factor
  86813. * @param factor defines the scale factor to apply
  86814. * @returns the current bounding box
  86815. */
  86816. scale(factor: number): BoundingSphere;
  86817. /**
  86818. * Gets the world matrix of the bounding box
  86819. * @returns a matrix
  86820. */
  86821. getWorldMatrix(): DeepImmutable<Matrix>;
  86822. /** @hidden */
  86823. _update(worldMatrix: DeepImmutable<Matrix>): void;
  86824. /**
  86825. * Tests if the bounding sphere is intersecting the frustum planes
  86826. * @param frustumPlanes defines the frustum planes to test
  86827. * @returns true if there is an intersection
  86828. */
  86829. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86830. /**
  86831. * Tests if the bounding sphere center is in between the frustum planes.
  86832. * Used for optimistic fast inclusion.
  86833. * @param frustumPlanes defines the frustum planes to test
  86834. * @returns true if the sphere center is in between the frustum planes
  86835. */
  86836. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86837. /**
  86838. * Tests if a point is inside the bounding sphere
  86839. * @param point defines the point to test
  86840. * @returns true if the point is inside the bounding sphere
  86841. */
  86842. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86843. /**
  86844. * Checks if two sphere intersct
  86845. * @param sphere0 sphere 0
  86846. * @param sphere1 sphere 1
  86847. * @returns true if the speres intersect
  86848. */
  86849. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  86850. }
  86851. }
  86852. declare module BABYLON {
  86853. /**
  86854. * Class used to store bounding box information
  86855. */
  86856. export class BoundingBox implements ICullable {
  86857. /**
  86858. * Gets the 8 vectors representing the bounding box in local space
  86859. */
  86860. readonly vectors: Vector3[];
  86861. /**
  86862. * Gets the center of the bounding box in local space
  86863. */
  86864. readonly center: Vector3;
  86865. /**
  86866. * Gets the center of the bounding box in world space
  86867. */
  86868. readonly centerWorld: Vector3;
  86869. /**
  86870. * Gets the extend size in local space
  86871. */
  86872. readonly extendSize: Vector3;
  86873. /**
  86874. * Gets the extend size in world space
  86875. */
  86876. readonly extendSizeWorld: Vector3;
  86877. /**
  86878. * Gets the OBB (object bounding box) directions
  86879. */
  86880. readonly directions: Vector3[];
  86881. /**
  86882. * Gets the 8 vectors representing the bounding box in world space
  86883. */
  86884. readonly vectorsWorld: Vector3[];
  86885. /**
  86886. * Gets the minimum vector in world space
  86887. */
  86888. readonly minimumWorld: Vector3;
  86889. /**
  86890. * Gets the maximum vector in world space
  86891. */
  86892. readonly maximumWorld: Vector3;
  86893. /**
  86894. * Gets the minimum vector in local space
  86895. */
  86896. readonly minimum: Vector3;
  86897. /**
  86898. * Gets the maximum vector in local space
  86899. */
  86900. readonly maximum: Vector3;
  86901. private _worldMatrix;
  86902. private static readonly TmpVector3;
  86903. /**
  86904. * @hidden
  86905. */
  86906. _tag: number;
  86907. /**
  86908. * Creates a new bounding box
  86909. * @param min defines the minimum vector (in local space)
  86910. * @param max defines the maximum vector (in local space)
  86911. * @param worldMatrix defines the new world matrix
  86912. */
  86913. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86914. /**
  86915. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86916. * @param min defines the new minimum vector (in local space)
  86917. * @param max defines the new maximum vector (in local space)
  86918. * @param worldMatrix defines the new world matrix
  86919. */
  86920. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86921. /**
  86922. * Scale the current bounding box by applying a scale factor
  86923. * @param factor defines the scale factor to apply
  86924. * @returns the current bounding box
  86925. */
  86926. scale(factor: number): BoundingBox;
  86927. /**
  86928. * Gets the world matrix of the bounding box
  86929. * @returns a matrix
  86930. */
  86931. getWorldMatrix(): DeepImmutable<Matrix>;
  86932. /** @hidden */
  86933. _update(world: DeepImmutable<Matrix>): void;
  86934. /**
  86935. * Tests if the bounding box is intersecting the frustum planes
  86936. * @param frustumPlanes defines the frustum planes to test
  86937. * @returns true if there is an intersection
  86938. */
  86939. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86940. /**
  86941. * Tests if the bounding box is entirely inside the frustum planes
  86942. * @param frustumPlanes defines the frustum planes to test
  86943. * @returns true if there is an inclusion
  86944. */
  86945. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86946. /**
  86947. * Tests if a point is inside the bounding box
  86948. * @param point defines the point to test
  86949. * @returns true if the point is inside the bounding box
  86950. */
  86951. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86952. /**
  86953. * Tests if the bounding box intersects with a bounding sphere
  86954. * @param sphere defines the sphere to test
  86955. * @returns true if there is an intersection
  86956. */
  86957. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86958. /**
  86959. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86960. * @param min defines the min vector to use
  86961. * @param max defines the max vector to use
  86962. * @returns true if there is an intersection
  86963. */
  86964. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86965. /**
  86966. * Tests if two bounding boxes are intersections
  86967. * @param box0 defines the first box to test
  86968. * @param box1 defines the second box to test
  86969. * @returns true if there is an intersection
  86970. */
  86971. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86972. /**
  86973. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86974. * @param minPoint defines the minimum vector of the bounding box
  86975. * @param maxPoint defines the maximum vector of the bounding box
  86976. * @param sphereCenter defines the sphere center
  86977. * @param sphereRadius defines the sphere radius
  86978. * @returns true if there is an intersection
  86979. */
  86980. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86981. /**
  86982. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86983. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86984. * @param frustumPlanes defines the frustum planes to test
  86985. * @return true if there is an inclusion
  86986. */
  86987. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86988. /**
  86989. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86990. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86991. * @param frustumPlanes defines the frustum planes to test
  86992. * @return true if there is an intersection
  86993. */
  86994. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86995. }
  86996. }
  86997. declare module BABYLON {
  86998. /** @hidden */
  86999. export class Collider {
  87000. /** Define if a collision was found */
  87001. collisionFound: boolean;
  87002. /**
  87003. * Define last intersection point in local space
  87004. */
  87005. intersectionPoint: Vector3;
  87006. /**
  87007. * Define last collided mesh
  87008. */
  87009. collidedMesh: Nullable<AbstractMesh>;
  87010. private _collisionPoint;
  87011. private _planeIntersectionPoint;
  87012. private _tempVector;
  87013. private _tempVector2;
  87014. private _tempVector3;
  87015. private _tempVector4;
  87016. private _edge;
  87017. private _baseToVertex;
  87018. private _destinationPoint;
  87019. private _slidePlaneNormal;
  87020. private _displacementVector;
  87021. /** @hidden */
  87022. _radius: Vector3;
  87023. /** @hidden */
  87024. _retry: number;
  87025. private _velocity;
  87026. private _basePoint;
  87027. private _epsilon;
  87028. /** @hidden */
  87029. _velocityWorldLength: number;
  87030. /** @hidden */
  87031. _basePointWorld: Vector3;
  87032. private _velocityWorld;
  87033. private _normalizedVelocity;
  87034. /** @hidden */
  87035. _initialVelocity: Vector3;
  87036. /** @hidden */
  87037. _initialPosition: Vector3;
  87038. private _nearestDistance;
  87039. private _collisionMask;
  87040. get collisionMask(): number;
  87041. set collisionMask(mask: number);
  87042. /**
  87043. * Gets the plane normal used to compute the sliding response (in local space)
  87044. */
  87045. get slidePlaneNormal(): Vector3;
  87046. /** @hidden */
  87047. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87048. /** @hidden */
  87049. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87050. /** @hidden */
  87051. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87052. /** @hidden */
  87053. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87054. /** @hidden */
  87055. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87056. /** @hidden */
  87057. _getResponse(pos: Vector3, vel: Vector3): void;
  87058. }
  87059. }
  87060. declare module BABYLON {
  87061. /**
  87062. * Interface for cullable objects
  87063. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87064. */
  87065. export interface ICullable {
  87066. /**
  87067. * Checks if the object or part of the object is in the frustum
  87068. * @param frustumPlanes Camera near/planes
  87069. * @returns true if the object is in frustum otherwise false
  87070. */
  87071. isInFrustum(frustumPlanes: Plane[]): boolean;
  87072. /**
  87073. * Checks if a cullable object (mesh...) is in the camera frustum
  87074. * Unlike isInFrustum this cheks the full bounding box
  87075. * @param frustumPlanes Camera near/planes
  87076. * @returns true if the object is in frustum otherwise false
  87077. */
  87078. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87079. }
  87080. /**
  87081. * Info for a bounding data of a mesh
  87082. */
  87083. export class BoundingInfo implements ICullable {
  87084. /**
  87085. * Bounding box for the mesh
  87086. */
  87087. readonly boundingBox: BoundingBox;
  87088. /**
  87089. * Bounding sphere for the mesh
  87090. */
  87091. readonly boundingSphere: BoundingSphere;
  87092. private _isLocked;
  87093. private static readonly TmpVector3;
  87094. /**
  87095. * Constructs bounding info
  87096. * @param minimum min vector of the bounding box/sphere
  87097. * @param maximum max vector of the bounding box/sphere
  87098. * @param worldMatrix defines the new world matrix
  87099. */
  87100. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87101. /**
  87102. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87103. * @param min defines the new minimum vector (in local space)
  87104. * @param max defines the new maximum vector (in local space)
  87105. * @param worldMatrix defines the new world matrix
  87106. */
  87107. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87108. /**
  87109. * min vector of the bounding box/sphere
  87110. */
  87111. get minimum(): Vector3;
  87112. /**
  87113. * max vector of the bounding box/sphere
  87114. */
  87115. get maximum(): Vector3;
  87116. /**
  87117. * If the info is locked and won't be updated to avoid perf overhead
  87118. */
  87119. get isLocked(): boolean;
  87120. set isLocked(value: boolean);
  87121. /**
  87122. * Updates the bounding sphere and box
  87123. * @param world world matrix to be used to update
  87124. */
  87125. update(world: DeepImmutable<Matrix>): void;
  87126. /**
  87127. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87128. * @param center New center of the bounding info
  87129. * @param extend New extend of the bounding info
  87130. * @returns the current bounding info
  87131. */
  87132. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87133. /**
  87134. * Scale the current bounding info by applying a scale factor
  87135. * @param factor defines the scale factor to apply
  87136. * @returns the current bounding info
  87137. */
  87138. scale(factor: number): BoundingInfo;
  87139. /**
  87140. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87141. * @param frustumPlanes defines the frustum to test
  87142. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87143. * @returns true if the bounding info is in the frustum planes
  87144. */
  87145. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87146. /**
  87147. * Gets the world distance between the min and max points of the bounding box
  87148. */
  87149. get diagonalLength(): number;
  87150. /**
  87151. * Checks if a cullable object (mesh...) is in the camera frustum
  87152. * Unlike isInFrustum this cheks the full bounding box
  87153. * @param frustumPlanes Camera near/planes
  87154. * @returns true if the object is in frustum otherwise false
  87155. */
  87156. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87157. /** @hidden */
  87158. _checkCollision(collider: Collider): boolean;
  87159. /**
  87160. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87161. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87162. * @param point the point to check intersection with
  87163. * @returns if the point intersects
  87164. */
  87165. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87166. /**
  87167. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87168. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87169. * @param boundingInfo the bounding info to check intersection with
  87170. * @param precise if the intersection should be done using OBB
  87171. * @returns if the bounding info intersects
  87172. */
  87173. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87174. }
  87175. }
  87176. declare module BABYLON {
  87177. /**
  87178. * Extracts minimum and maximum values from a list of indexed positions
  87179. * @param positions defines the positions to use
  87180. * @param indices defines the indices to the positions
  87181. * @param indexStart defines the start index
  87182. * @param indexCount defines the end index
  87183. * @param bias defines bias value to add to the result
  87184. * @return minimum and maximum values
  87185. */
  87186. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87187. minimum: Vector3;
  87188. maximum: Vector3;
  87189. };
  87190. /**
  87191. * Extracts minimum and maximum values from a list of positions
  87192. * @param positions defines the positions to use
  87193. * @param start defines the start index in the positions array
  87194. * @param count defines the number of positions to handle
  87195. * @param bias defines bias value to add to the result
  87196. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87197. * @return minimum and maximum values
  87198. */
  87199. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87200. minimum: Vector3;
  87201. maximum: Vector3;
  87202. };
  87203. }
  87204. declare module BABYLON {
  87205. /** @hidden */
  87206. export class WebGLDataBuffer extends DataBuffer {
  87207. private _buffer;
  87208. constructor(resource: WebGLBuffer);
  87209. get underlyingResource(): any;
  87210. }
  87211. }
  87212. declare module BABYLON {
  87213. /** @hidden */
  87214. export class WebGLPipelineContext implements IPipelineContext {
  87215. engine: ThinEngine;
  87216. program: Nullable<WebGLProgram>;
  87217. context?: WebGLRenderingContext;
  87218. vertexShader?: WebGLShader;
  87219. fragmentShader?: WebGLShader;
  87220. isParallelCompiled: boolean;
  87221. onCompiled?: () => void;
  87222. transformFeedback?: WebGLTransformFeedback | null;
  87223. vertexCompilationError: Nullable<string>;
  87224. fragmentCompilationError: Nullable<string>;
  87225. programLinkError: Nullable<string>;
  87226. programValidationError: Nullable<string>;
  87227. get isAsync(): boolean;
  87228. get isReady(): boolean;
  87229. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87230. _getVertexShaderCode(): string | null;
  87231. _getFragmentShaderCode(): string | null;
  87232. }
  87233. }
  87234. declare module BABYLON {
  87235. interface ThinEngine {
  87236. /**
  87237. * Create an uniform buffer
  87238. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87239. * @param elements defines the content of the uniform buffer
  87240. * @returns the webGL uniform buffer
  87241. */
  87242. createUniformBuffer(elements: FloatArray): DataBuffer;
  87243. /**
  87244. * Create a dynamic uniform buffer
  87245. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87246. * @param elements defines the content of the uniform buffer
  87247. * @returns the webGL uniform buffer
  87248. */
  87249. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87250. /**
  87251. * Update an existing uniform buffer
  87252. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87253. * @param uniformBuffer defines the target uniform buffer
  87254. * @param elements defines the content to update
  87255. * @param offset defines the offset in the uniform buffer where update should start
  87256. * @param count defines the size of the data to update
  87257. */
  87258. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87259. /**
  87260. * Bind an uniform buffer to the current webGL context
  87261. * @param buffer defines the buffer to bind
  87262. */
  87263. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87264. /**
  87265. * Bind a buffer to the current webGL context at a given location
  87266. * @param buffer defines the buffer to bind
  87267. * @param location defines the index where to bind the buffer
  87268. */
  87269. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87270. /**
  87271. * Bind a specific block at a given index in a specific shader program
  87272. * @param pipelineContext defines the pipeline context to use
  87273. * @param blockName defines the block name
  87274. * @param index defines the index where to bind the block
  87275. */
  87276. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87277. }
  87278. }
  87279. declare module BABYLON {
  87280. /**
  87281. * Uniform buffer objects.
  87282. *
  87283. * Handles blocks of uniform on the GPU.
  87284. *
  87285. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87286. *
  87287. * For more information, please refer to :
  87288. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87289. */
  87290. export class UniformBuffer {
  87291. private _engine;
  87292. private _buffer;
  87293. private _data;
  87294. private _bufferData;
  87295. private _dynamic?;
  87296. private _uniformLocations;
  87297. private _uniformSizes;
  87298. private _uniformLocationPointer;
  87299. private _needSync;
  87300. private _noUBO;
  87301. private _currentEffect;
  87302. /** @hidden */
  87303. _alreadyBound: boolean;
  87304. private static _MAX_UNIFORM_SIZE;
  87305. private static _tempBuffer;
  87306. /**
  87307. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87308. * This is dynamic to allow compat with webgl 1 and 2.
  87309. * You will need to pass the name of the uniform as well as the value.
  87310. */
  87311. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87312. /**
  87313. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87314. * This is dynamic to allow compat with webgl 1 and 2.
  87315. * You will need to pass the name of the uniform as well as the value.
  87316. */
  87317. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87318. /**
  87319. * Lambda to Update a single float in a uniform buffer.
  87320. * This is dynamic to allow compat with webgl 1 and 2.
  87321. * You will need to pass the name of the uniform as well as the value.
  87322. */
  87323. updateFloat: (name: string, x: number) => void;
  87324. /**
  87325. * Lambda to Update a vec2 of float in a uniform buffer.
  87326. * This is dynamic to allow compat with webgl 1 and 2.
  87327. * You will need to pass the name of the uniform as well as the value.
  87328. */
  87329. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87330. /**
  87331. * Lambda to Update a vec3 of float in a uniform buffer.
  87332. * This is dynamic to allow compat with webgl 1 and 2.
  87333. * You will need to pass the name of the uniform as well as the value.
  87334. */
  87335. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87336. /**
  87337. * Lambda to Update a vec4 of float in a uniform buffer.
  87338. * This is dynamic to allow compat with webgl 1 and 2.
  87339. * You will need to pass the name of the uniform as well as the value.
  87340. */
  87341. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87342. /**
  87343. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87344. * This is dynamic to allow compat with webgl 1 and 2.
  87345. * You will need to pass the name of the uniform as well as the value.
  87346. */
  87347. updateMatrix: (name: string, mat: Matrix) => void;
  87348. /**
  87349. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87350. * This is dynamic to allow compat with webgl 1 and 2.
  87351. * You will need to pass the name of the uniform as well as the value.
  87352. */
  87353. updateVector3: (name: string, vector: Vector3) => void;
  87354. /**
  87355. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87356. * This is dynamic to allow compat with webgl 1 and 2.
  87357. * You will need to pass the name of the uniform as well as the value.
  87358. */
  87359. updateVector4: (name: string, vector: Vector4) => void;
  87360. /**
  87361. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87362. * This is dynamic to allow compat with webgl 1 and 2.
  87363. * You will need to pass the name of the uniform as well as the value.
  87364. */
  87365. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87366. /**
  87367. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87368. * This is dynamic to allow compat with webgl 1 and 2.
  87369. * You will need to pass the name of the uniform as well as the value.
  87370. */
  87371. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87372. /**
  87373. * Instantiates a new Uniform buffer objects.
  87374. *
  87375. * Handles blocks of uniform on the GPU.
  87376. *
  87377. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87378. *
  87379. * For more information, please refer to :
  87380. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87381. * @param engine Define the engine the buffer is associated with
  87382. * @param data Define the data contained in the buffer
  87383. * @param dynamic Define if the buffer is updatable
  87384. */
  87385. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87386. /**
  87387. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87388. * or just falling back on setUniformXXX calls.
  87389. */
  87390. get useUbo(): boolean;
  87391. /**
  87392. * Indicates if the WebGL underlying uniform buffer is in sync
  87393. * with the javascript cache data.
  87394. */
  87395. get isSync(): boolean;
  87396. /**
  87397. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87398. * Also, a dynamic UniformBuffer will disable cache verification and always
  87399. * update the underlying WebGL uniform buffer to the GPU.
  87400. * @returns if Dynamic, otherwise false
  87401. */
  87402. isDynamic(): boolean;
  87403. /**
  87404. * The data cache on JS side.
  87405. * @returns the underlying data as a float array
  87406. */
  87407. getData(): Float32Array;
  87408. /**
  87409. * The underlying WebGL Uniform buffer.
  87410. * @returns the webgl buffer
  87411. */
  87412. getBuffer(): Nullable<DataBuffer>;
  87413. /**
  87414. * std140 layout specifies how to align data within an UBO structure.
  87415. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87416. * for specs.
  87417. */
  87418. private _fillAlignment;
  87419. /**
  87420. * Adds an uniform in the buffer.
  87421. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87422. * for the layout to be correct !
  87423. * @param name Name of the uniform, as used in the uniform block in the shader.
  87424. * @param size Data size, or data directly.
  87425. */
  87426. addUniform(name: string, size: number | number[]): void;
  87427. /**
  87428. * Adds a Matrix 4x4 to the uniform buffer.
  87429. * @param name Name of the uniform, as used in the uniform block in the shader.
  87430. * @param mat A 4x4 matrix.
  87431. */
  87432. addMatrix(name: string, mat: Matrix): void;
  87433. /**
  87434. * Adds a vec2 to the uniform buffer.
  87435. * @param name Name of the uniform, as used in the uniform block in the shader.
  87436. * @param x Define the x component value of the vec2
  87437. * @param y Define the y component value of the vec2
  87438. */
  87439. addFloat2(name: string, x: number, y: number): void;
  87440. /**
  87441. * Adds a vec3 to the uniform buffer.
  87442. * @param name Name of the uniform, as used in the uniform block in the shader.
  87443. * @param x Define the x component value of the vec3
  87444. * @param y Define the y component value of the vec3
  87445. * @param z Define the z component value of the vec3
  87446. */
  87447. addFloat3(name: string, x: number, y: number, z: number): void;
  87448. /**
  87449. * Adds a vec3 to the uniform buffer.
  87450. * @param name Name of the uniform, as used in the uniform block in the shader.
  87451. * @param color Define the vec3 from a Color
  87452. */
  87453. addColor3(name: string, color: Color3): void;
  87454. /**
  87455. * Adds a vec4 to the uniform buffer.
  87456. * @param name Name of the uniform, as used in the uniform block in the shader.
  87457. * @param color Define the rgb components from a Color
  87458. * @param alpha Define the a component of the vec4
  87459. */
  87460. addColor4(name: string, color: Color3, alpha: number): void;
  87461. /**
  87462. * Adds a vec3 to the uniform buffer.
  87463. * @param name Name of the uniform, as used in the uniform block in the shader.
  87464. * @param vector Define the vec3 components from a Vector
  87465. */
  87466. addVector3(name: string, vector: Vector3): void;
  87467. /**
  87468. * Adds a Matrix 3x3 to the uniform buffer.
  87469. * @param name Name of the uniform, as used in the uniform block in the shader.
  87470. */
  87471. addMatrix3x3(name: string): void;
  87472. /**
  87473. * Adds a Matrix 2x2 to the uniform buffer.
  87474. * @param name Name of the uniform, as used in the uniform block in the shader.
  87475. */
  87476. addMatrix2x2(name: string): void;
  87477. /**
  87478. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87479. */
  87480. create(): void;
  87481. /** @hidden */
  87482. _rebuild(): void;
  87483. /**
  87484. * Updates the WebGL Uniform Buffer on the GPU.
  87485. * If the `dynamic` flag is set to true, no cache comparison is done.
  87486. * Otherwise, the buffer will be updated only if the cache differs.
  87487. */
  87488. update(): void;
  87489. /**
  87490. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87491. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87492. * @param data Define the flattened data
  87493. * @param size Define the size of the data.
  87494. */
  87495. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87496. private _valueCache;
  87497. private _cacheMatrix;
  87498. private _updateMatrix3x3ForUniform;
  87499. private _updateMatrix3x3ForEffect;
  87500. private _updateMatrix2x2ForEffect;
  87501. private _updateMatrix2x2ForUniform;
  87502. private _updateFloatForEffect;
  87503. private _updateFloatForUniform;
  87504. private _updateFloat2ForEffect;
  87505. private _updateFloat2ForUniform;
  87506. private _updateFloat3ForEffect;
  87507. private _updateFloat3ForUniform;
  87508. private _updateFloat4ForEffect;
  87509. private _updateFloat4ForUniform;
  87510. private _updateMatrixForEffect;
  87511. private _updateMatrixForUniform;
  87512. private _updateVector3ForEffect;
  87513. private _updateVector3ForUniform;
  87514. private _updateVector4ForEffect;
  87515. private _updateVector4ForUniform;
  87516. private _updateColor3ForEffect;
  87517. private _updateColor3ForUniform;
  87518. private _updateColor4ForEffect;
  87519. private _updateColor4ForUniform;
  87520. /**
  87521. * Sets a sampler uniform on the effect.
  87522. * @param name Define the name of the sampler.
  87523. * @param texture Define the texture to set in the sampler
  87524. */
  87525. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87526. /**
  87527. * Directly updates the value of the uniform in the cache AND on the GPU.
  87528. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87529. * @param data Define the flattened data
  87530. */
  87531. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87532. /**
  87533. * Binds this uniform buffer to an effect.
  87534. * @param effect Define the effect to bind the buffer to
  87535. * @param name Name of the uniform block in the shader.
  87536. */
  87537. bindToEffect(effect: Effect, name: string): void;
  87538. /**
  87539. * Disposes the uniform buffer.
  87540. */
  87541. dispose(): void;
  87542. }
  87543. }
  87544. declare module BABYLON {
  87545. /**
  87546. * Enum that determines the text-wrapping mode to use.
  87547. */
  87548. export enum InspectableType {
  87549. /**
  87550. * Checkbox for booleans
  87551. */
  87552. Checkbox = 0,
  87553. /**
  87554. * Sliders for numbers
  87555. */
  87556. Slider = 1,
  87557. /**
  87558. * Vector3
  87559. */
  87560. Vector3 = 2,
  87561. /**
  87562. * Quaternions
  87563. */
  87564. Quaternion = 3,
  87565. /**
  87566. * Color3
  87567. */
  87568. Color3 = 4,
  87569. /**
  87570. * String
  87571. */
  87572. String = 5
  87573. }
  87574. /**
  87575. * Interface used to define custom inspectable properties.
  87576. * This interface is used by the inspector to display custom property grids
  87577. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87578. */
  87579. export interface IInspectable {
  87580. /**
  87581. * Gets the label to display
  87582. */
  87583. label: string;
  87584. /**
  87585. * Gets the name of the property to edit
  87586. */
  87587. propertyName: string;
  87588. /**
  87589. * Gets the type of the editor to use
  87590. */
  87591. type: InspectableType;
  87592. /**
  87593. * Gets the minimum value of the property when using in "slider" mode
  87594. */
  87595. min?: number;
  87596. /**
  87597. * Gets the maximum value of the property when using in "slider" mode
  87598. */
  87599. max?: number;
  87600. /**
  87601. * Gets the setp to use when using in "slider" mode
  87602. */
  87603. step?: number;
  87604. }
  87605. }
  87606. declare module BABYLON {
  87607. /**
  87608. * Class used to provide helper for timing
  87609. */
  87610. export class TimingTools {
  87611. /**
  87612. * Polyfill for setImmediate
  87613. * @param action defines the action to execute after the current execution block
  87614. */
  87615. static SetImmediate(action: () => void): void;
  87616. }
  87617. }
  87618. declare module BABYLON {
  87619. /**
  87620. * Class used to enable instatition of objects by class name
  87621. */
  87622. export class InstantiationTools {
  87623. /**
  87624. * Use this object to register external classes like custom textures or material
  87625. * to allow the laoders to instantiate them
  87626. */
  87627. static RegisteredExternalClasses: {
  87628. [key: string]: Object;
  87629. };
  87630. /**
  87631. * Tries to instantiate a new object from a given class name
  87632. * @param className defines the class name to instantiate
  87633. * @returns the new object or null if the system was not able to do the instantiation
  87634. */
  87635. static Instantiate(className: string): any;
  87636. }
  87637. }
  87638. declare module BABYLON {
  87639. /**
  87640. * Define options used to create a depth texture
  87641. */
  87642. export class DepthTextureCreationOptions {
  87643. /** Specifies whether or not a stencil should be allocated in the texture */
  87644. generateStencil?: boolean;
  87645. /** Specifies whether or not bilinear filtering is enable on the texture */
  87646. bilinearFiltering?: boolean;
  87647. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87648. comparisonFunction?: number;
  87649. /** Specifies if the created texture is a cube texture */
  87650. isCube?: boolean;
  87651. }
  87652. }
  87653. declare module BABYLON {
  87654. interface ThinEngine {
  87655. /**
  87656. * Creates a depth stencil cube texture.
  87657. * This is only available in WebGL 2.
  87658. * @param size The size of face edge in the cube texture.
  87659. * @param options The options defining the cube texture.
  87660. * @returns The cube texture
  87661. */
  87662. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  87663. /**
  87664. * Creates a cube texture
  87665. * @param rootUrl defines the url where the files to load is located
  87666. * @param scene defines the current scene
  87667. * @param files defines the list of files to load (1 per face)
  87668. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87669. * @param onLoad defines an optional callback raised when the texture is loaded
  87670. * @param onError defines an optional callback raised if there is an issue to load the texture
  87671. * @param format defines the format of the data
  87672. * @param forcedExtension defines the extension to use to pick the right loader
  87673. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87674. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87675. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87676. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87677. * @returns the cube texture as an InternalTexture
  87678. */
  87679. 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;
  87680. /**
  87681. * Creates a cube texture
  87682. * @param rootUrl defines the url where the files to load is located
  87683. * @param scene defines the current scene
  87684. * @param files defines the list of files to load (1 per face)
  87685. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87686. * @param onLoad defines an optional callback raised when the texture is loaded
  87687. * @param onError defines an optional callback raised if there is an issue to load the texture
  87688. * @param format defines the format of the data
  87689. * @param forcedExtension defines the extension to use to pick the right loader
  87690. * @returns the cube texture as an InternalTexture
  87691. */
  87692. 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;
  87693. /**
  87694. * Creates a cube texture
  87695. * @param rootUrl defines the url where the files to load is located
  87696. * @param scene defines the current scene
  87697. * @param files defines the list of files to load (1 per face)
  87698. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87699. * @param onLoad defines an optional callback raised when the texture is loaded
  87700. * @param onError defines an optional callback raised if there is an issue to load the texture
  87701. * @param format defines the format of the data
  87702. * @param forcedExtension defines the extension to use to pick the right loader
  87703. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87704. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87705. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87706. * @returns the cube texture as an InternalTexture
  87707. */
  87708. 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;
  87709. /** @hidden */
  87710. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  87711. /** @hidden */
  87712. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  87713. /** @hidden */
  87714. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87715. /** @hidden */
  87716. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87717. /**
  87718. * @hidden
  87719. */
  87720. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87721. }
  87722. }
  87723. declare module BABYLON {
  87724. /**
  87725. * Class for creating a cube texture
  87726. */
  87727. export class CubeTexture extends BaseTexture {
  87728. private _delayedOnLoad;
  87729. /**
  87730. * Observable triggered once the texture has been loaded.
  87731. */
  87732. onLoadObservable: Observable<CubeTexture>;
  87733. /**
  87734. * The url of the texture
  87735. */
  87736. url: string;
  87737. /**
  87738. * Gets or sets the center of the bounding box associated with the cube texture.
  87739. * It must define where the camera used to render the texture was set
  87740. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87741. */
  87742. boundingBoxPosition: Vector3;
  87743. private _boundingBoxSize;
  87744. /**
  87745. * Gets or sets the size of the bounding box associated with the cube texture
  87746. * When defined, the cubemap will switch to local mode
  87747. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87748. * @example https://www.babylonjs-playground.com/#RNASML
  87749. */
  87750. set boundingBoxSize(value: Vector3);
  87751. /**
  87752. * Returns the bounding box size
  87753. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87754. */
  87755. get boundingBoxSize(): Vector3;
  87756. protected _rotationY: number;
  87757. /**
  87758. * Sets texture matrix rotation angle around Y axis in radians.
  87759. */
  87760. set rotationY(value: number);
  87761. /**
  87762. * Gets texture matrix rotation angle around Y axis radians.
  87763. */
  87764. get rotationY(): number;
  87765. /**
  87766. * Are mip maps generated for this texture or not.
  87767. */
  87768. get noMipmap(): boolean;
  87769. private _noMipmap;
  87770. private _files;
  87771. protected _forcedExtension: Nullable<string>;
  87772. private _extensions;
  87773. private _textureMatrix;
  87774. private _format;
  87775. private _createPolynomials;
  87776. /**
  87777. * Creates a cube texture from an array of image urls
  87778. * @param files defines an array of image urls
  87779. * @param scene defines the hosting scene
  87780. * @param noMipmap specifies if mip maps are not used
  87781. * @returns a cube texture
  87782. */
  87783. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  87784. /**
  87785. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  87786. * @param url defines the url of the prefiltered texture
  87787. * @param scene defines the scene the texture is attached to
  87788. * @param forcedExtension defines the extension of the file if different from the url
  87789. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87790. * @return the prefiltered texture
  87791. */
  87792. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  87793. /**
  87794. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  87795. * as prefiltered data.
  87796. * @param rootUrl defines the url of the texture or the root name of the six images
  87797. * @param null defines the scene or engine the texture is attached to
  87798. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  87799. * @param noMipmap defines if mipmaps should be created or not
  87800. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  87801. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  87802. * @param onError defines a callback triggered in case of error during load
  87803. * @param format defines the internal format to use for the texture once loaded
  87804. * @param prefiltered defines whether or not the texture is created from prefiltered data
  87805. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  87806. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87807. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87808. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87809. * @return the cube texture
  87810. */
  87811. 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);
  87812. /**
  87813. * Get the current class name of the texture useful for serialization or dynamic coding.
  87814. * @returns "CubeTexture"
  87815. */
  87816. getClassName(): string;
  87817. /**
  87818. * Update the url (and optional buffer) of this texture if url was null during construction.
  87819. * @param url the url of the texture
  87820. * @param forcedExtension defines the extension to use
  87821. * @param onLoad callback called when the texture is loaded (defaults to null)
  87822. * @param prefiltered Defines whether the updated texture is prefiltered or not
  87823. */
  87824. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  87825. /**
  87826. * Delays loading of the cube texture
  87827. * @param forcedExtension defines the extension to use
  87828. */
  87829. delayLoad(forcedExtension?: string): void;
  87830. /**
  87831. * Returns the reflection texture matrix
  87832. * @returns the reflection texture matrix
  87833. */
  87834. getReflectionTextureMatrix(): Matrix;
  87835. /**
  87836. * Sets the reflection texture matrix
  87837. * @param value Reflection texture matrix
  87838. */
  87839. setReflectionTextureMatrix(value: Matrix): void;
  87840. /**
  87841. * Parses text to create a cube texture
  87842. * @param parsedTexture define the serialized text to read from
  87843. * @param scene defines the hosting scene
  87844. * @param rootUrl defines the root url of the cube texture
  87845. * @returns a cube texture
  87846. */
  87847. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  87848. /**
  87849. * Makes a clone, or deep copy, of the cube texture
  87850. * @returns a new cube texture
  87851. */
  87852. clone(): CubeTexture;
  87853. }
  87854. }
  87855. declare module BABYLON {
  87856. /**
  87857. * Manages the defines for the Material
  87858. */
  87859. export class MaterialDefines {
  87860. /** @hidden */
  87861. protected _keys: string[];
  87862. private _isDirty;
  87863. /** @hidden */
  87864. _renderId: number;
  87865. /** @hidden */
  87866. _areLightsDirty: boolean;
  87867. /** @hidden */
  87868. _areLightsDisposed: boolean;
  87869. /** @hidden */
  87870. _areAttributesDirty: boolean;
  87871. /** @hidden */
  87872. _areTexturesDirty: boolean;
  87873. /** @hidden */
  87874. _areFresnelDirty: boolean;
  87875. /** @hidden */
  87876. _areMiscDirty: boolean;
  87877. /** @hidden */
  87878. _areImageProcessingDirty: boolean;
  87879. /** @hidden */
  87880. _normals: boolean;
  87881. /** @hidden */
  87882. _uvs: boolean;
  87883. /** @hidden */
  87884. _needNormals: boolean;
  87885. /** @hidden */
  87886. _needUVs: boolean;
  87887. [id: string]: any;
  87888. /**
  87889. * Specifies if the material needs to be re-calculated
  87890. */
  87891. get isDirty(): boolean;
  87892. /**
  87893. * Marks the material to indicate that it has been re-calculated
  87894. */
  87895. markAsProcessed(): void;
  87896. /**
  87897. * Marks the material to indicate that it needs to be re-calculated
  87898. */
  87899. markAsUnprocessed(): void;
  87900. /**
  87901. * Marks the material to indicate all of its defines need to be re-calculated
  87902. */
  87903. markAllAsDirty(): void;
  87904. /**
  87905. * Marks the material to indicate that image processing needs to be re-calculated
  87906. */
  87907. markAsImageProcessingDirty(): void;
  87908. /**
  87909. * Marks the material to indicate the lights need to be re-calculated
  87910. * @param disposed Defines whether the light is dirty due to dispose or not
  87911. */
  87912. markAsLightDirty(disposed?: boolean): void;
  87913. /**
  87914. * Marks the attribute state as changed
  87915. */
  87916. markAsAttributesDirty(): void;
  87917. /**
  87918. * Marks the texture state as changed
  87919. */
  87920. markAsTexturesDirty(): void;
  87921. /**
  87922. * Marks the fresnel state as changed
  87923. */
  87924. markAsFresnelDirty(): void;
  87925. /**
  87926. * Marks the misc state as changed
  87927. */
  87928. markAsMiscDirty(): void;
  87929. /**
  87930. * Rebuilds the material defines
  87931. */
  87932. rebuild(): void;
  87933. /**
  87934. * Specifies if two material defines are equal
  87935. * @param other - A material define instance to compare to
  87936. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87937. */
  87938. isEqual(other: MaterialDefines): boolean;
  87939. /**
  87940. * Clones this instance's defines to another instance
  87941. * @param other - material defines to clone values to
  87942. */
  87943. cloneTo(other: MaterialDefines): void;
  87944. /**
  87945. * Resets the material define values
  87946. */
  87947. reset(): void;
  87948. /**
  87949. * Converts the material define values to a string
  87950. * @returns - String of material define information
  87951. */
  87952. toString(): string;
  87953. }
  87954. }
  87955. declare module BABYLON {
  87956. /**
  87957. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87958. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87959. * 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;
  87960. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87961. */
  87962. export class ColorCurves {
  87963. private _dirty;
  87964. private _tempColor;
  87965. private _globalCurve;
  87966. private _highlightsCurve;
  87967. private _midtonesCurve;
  87968. private _shadowsCurve;
  87969. private _positiveCurve;
  87970. private _negativeCurve;
  87971. private _globalHue;
  87972. private _globalDensity;
  87973. private _globalSaturation;
  87974. private _globalExposure;
  87975. /**
  87976. * Gets the global Hue value.
  87977. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  87978. */
  87979. get globalHue(): number;
  87980. /**
  87981. * Sets the global Hue value.
  87982. * 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).
  87983. */
  87984. set globalHue(value: number);
  87985. /**
  87986. * Gets the global Density value.
  87987. * 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.
  87988. * Values less than zero provide a filter of opposite hue.
  87989. */
  87990. get globalDensity(): number;
  87991. /**
  87992. * Sets the global Density value.
  87993. * 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.
  87994. * Values less than zero provide a filter of opposite hue.
  87995. */
  87996. set globalDensity(value: number);
  87997. /**
  87998. * Gets the global Saturation value.
  87999. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  88000. */
  88001. get globalSaturation(): number;
  88002. /**
  88003. * Sets the global Saturation value.
  88004. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  88005. */
  88006. set globalSaturation(value: number);
  88007. /**
  88008. * Gets the global Exposure value.
  88009. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  88010. */
  88011. get globalExposure(): number;
  88012. /**
  88013. * Sets the global Exposure value.
  88014. * 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.
  88015. */
  88016. set globalExposure(value: number);
  88017. private _highlightsHue;
  88018. private _highlightsDensity;
  88019. private _highlightsSaturation;
  88020. private _highlightsExposure;
  88021. /**
  88022. * Gets the highlights Hue value.
  88023. * 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).
  88024. */
  88025. get highlightsHue(): number;
  88026. /**
  88027. * Sets the highlights Hue value.
  88028. * 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).
  88029. */
  88030. set highlightsHue(value: number);
  88031. /**
  88032. * Gets the highlights Density value.
  88033. * 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.
  88034. * Values less than zero provide a filter of opposite hue.
  88035. */
  88036. get highlightsDensity(): number;
  88037. /**
  88038. * Sets the highlights Density value.
  88039. * 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.
  88040. * Values less than zero provide a filter of opposite hue.
  88041. */
  88042. set highlightsDensity(value: number);
  88043. /**
  88044. * Gets the highlights Saturation value.
  88045. * 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.
  88046. */
  88047. get highlightsSaturation(): number;
  88048. /**
  88049. * Sets the highlights Saturation value.
  88050. * 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.
  88051. */
  88052. set highlightsSaturation(value: number);
  88053. /**
  88054. * Gets the highlights Exposure value.
  88055. * 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.
  88056. */
  88057. get highlightsExposure(): number;
  88058. /**
  88059. * Sets the highlights Exposure value.
  88060. * 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.
  88061. */
  88062. set highlightsExposure(value: number);
  88063. private _midtonesHue;
  88064. private _midtonesDensity;
  88065. private _midtonesSaturation;
  88066. private _midtonesExposure;
  88067. /**
  88068. * Gets the midtones Hue value.
  88069. * 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).
  88070. */
  88071. get midtonesHue(): number;
  88072. /**
  88073. * Sets the midtones Hue value.
  88074. * 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).
  88075. */
  88076. set midtonesHue(value: number);
  88077. /**
  88078. * Gets the midtones Density value.
  88079. * 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.
  88080. * Values less than zero provide a filter of opposite hue.
  88081. */
  88082. get midtonesDensity(): number;
  88083. /**
  88084. * Sets the midtones Density value.
  88085. * 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.
  88086. * Values less than zero provide a filter of opposite hue.
  88087. */
  88088. set midtonesDensity(value: number);
  88089. /**
  88090. * Gets the midtones Saturation value.
  88091. * 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.
  88092. */
  88093. get midtonesSaturation(): number;
  88094. /**
  88095. * Sets the midtones Saturation value.
  88096. * 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.
  88097. */
  88098. set midtonesSaturation(value: number);
  88099. /**
  88100. * Gets the midtones Exposure value.
  88101. * 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.
  88102. */
  88103. get midtonesExposure(): number;
  88104. /**
  88105. * Sets the midtones Exposure value.
  88106. * 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.
  88107. */
  88108. set midtonesExposure(value: number);
  88109. private _shadowsHue;
  88110. private _shadowsDensity;
  88111. private _shadowsSaturation;
  88112. private _shadowsExposure;
  88113. /**
  88114. * Gets the shadows Hue value.
  88115. * 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).
  88116. */
  88117. get shadowsHue(): number;
  88118. /**
  88119. * Sets the shadows Hue value.
  88120. * 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).
  88121. */
  88122. set shadowsHue(value: number);
  88123. /**
  88124. * Gets the shadows Density value.
  88125. * 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.
  88126. * Values less than zero provide a filter of opposite hue.
  88127. */
  88128. get shadowsDensity(): number;
  88129. /**
  88130. * Sets the shadows Density value.
  88131. * 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.
  88132. * Values less than zero provide a filter of opposite hue.
  88133. */
  88134. set shadowsDensity(value: number);
  88135. /**
  88136. * Gets the shadows Saturation value.
  88137. * 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.
  88138. */
  88139. get shadowsSaturation(): number;
  88140. /**
  88141. * Sets the shadows Saturation value.
  88142. * 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.
  88143. */
  88144. set shadowsSaturation(value: number);
  88145. /**
  88146. * Gets the shadows Exposure value.
  88147. * 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.
  88148. */
  88149. get shadowsExposure(): number;
  88150. /**
  88151. * Sets the shadows Exposure value.
  88152. * 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.
  88153. */
  88154. set shadowsExposure(value: number);
  88155. /**
  88156. * Returns the class name
  88157. * @returns The class name
  88158. */
  88159. getClassName(): string;
  88160. /**
  88161. * Binds the color curves to the shader.
  88162. * @param colorCurves The color curve to bind
  88163. * @param effect The effect to bind to
  88164. * @param positiveUniform The positive uniform shader parameter
  88165. * @param neutralUniform The neutral uniform shader parameter
  88166. * @param negativeUniform The negative uniform shader parameter
  88167. */
  88168. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88169. /**
  88170. * Prepare the list of uniforms associated with the ColorCurves effects.
  88171. * @param uniformsList The list of uniforms used in the effect
  88172. */
  88173. static PrepareUniforms(uniformsList: string[]): void;
  88174. /**
  88175. * Returns color grading data based on a hue, density, saturation and exposure value.
  88176. * @param filterHue The hue of the color filter.
  88177. * @param filterDensity The density of the color filter.
  88178. * @param saturation The saturation.
  88179. * @param exposure The exposure.
  88180. * @param result The result data container.
  88181. */
  88182. private getColorGradingDataToRef;
  88183. /**
  88184. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88185. * @param value The input slider value in range [-100,100].
  88186. * @returns Adjusted value.
  88187. */
  88188. private static applyColorGradingSliderNonlinear;
  88189. /**
  88190. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88191. * @param hue The hue (H) input.
  88192. * @param saturation The saturation (S) input.
  88193. * @param brightness The brightness (B) input.
  88194. * @result An RGBA color represented as Vector4.
  88195. */
  88196. private static fromHSBToRef;
  88197. /**
  88198. * Returns a value clamped between min and max
  88199. * @param value The value to clamp
  88200. * @param min The minimum of value
  88201. * @param max The maximum of value
  88202. * @returns The clamped value.
  88203. */
  88204. private static clamp;
  88205. /**
  88206. * Clones the current color curve instance.
  88207. * @return The cloned curves
  88208. */
  88209. clone(): ColorCurves;
  88210. /**
  88211. * Serializes the current color curve instance to a json representation.
  88212. * @return a JSON representation
  88213. */
  88214. serialize(): any;
  88215. /**
  88216. * Parses the color curve from a json representation.
  88217. * @param source the JSON source to parse
  88218. * @return The parsed curves
  88219. */
  88220. static Parse(source: any): ColorCurves;
  88221. }
  88222. }
  88223. declare module BABYLON {
  88224. /**
  88225. * Interface to follow in your material defines to integrate easily the
  88226. * Image proccessing functions.
  88227. * @hidden
  88228. */
  88229. export interface IImageProcessingConfigurationDefines {
  88230. IMAGEPROCESSING: boolean;
  88231. VIGNETTE: boolean;
  88232. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88233. VIGNETTEBLENDMODEOPAQUE: boolean;
  88234. TONEMAPPING: boolean;
  88235. TONEMAPPING_ACES: boolean;
  88236. CONTRAST: boolean;
  88237. EXPOSURE: boolean;
  88238. COLORCURVES: boolean;
  88239. COLORGRADING: boolean;
  88240. COLORGRADING3D: boolean;
  88241. SAMPLER3DGREENDEPTH: boolean;
  88242. SAMPLER3DBGRMAP: boolean;
  88243. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88244. }
  88245. /**
  88246. * @hidden
  88247. */
  88248. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88249. IMAGEPROCESSING: boolean;
  88250. VIGNETTE: boolean;
  88251. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88252. VIGNETTEBLENDMODEOPAQUE: boolean;
  88253. TONEMAPPING: boolean;
  88254. TONEMAPPING_ACES: boolean;
  88255. CONTRAST: boolean;
  88256. COLORCURVES: boolean;
  88257. COLORGRADING: boolean;
  88258. COLORGRADING3D: boolean;
  88259. SAMPLER3DGREENDEPTH: boolean;
  88260. SAMPLER3DBGRMAP: boolean;
  88261. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88262. EXPOSURE: boolean;
  88263. constructor();
  88264. }
  88265. /**
  88266. * This groups together the common properties used for image processing either in direct forward pass
  88267. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88268. * or not.
  88269. */
  88270. export class ImageProcessingConfiguration {
  88271. /**
  88272. * Default tone mapping applied in BabylonJS.
  88273. */
  88274. static readonly TONEMAPPING_STANDARD: number;
  88275. /**
  88276. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88277. * to other engines rendering to increase portability.
  88278. */
  88279. static readonly TONEMAPPING_ACES: number;
  88280. /**
  88281. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88282. */
  88283. colorCurves: Nullable<ColorCurves>;
  88284. private _colorCurvesEnabled;
  88285. /**
  88286. * Gets wether the color curves effect is enabled.
  88287. */
  88288. get colorCurvesEnabled(): boolean;
  88289. /**
  88290. * Sets wether the color curves effect is enabled.
  88291. */
  88292. set colorCurvesEnabled(value: boolean);
  88293. private _colorGradingTexture;
  88294. /**
  88295. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88296. */
  88297. get colorGradingTexture(): Nullable<BaseTexture>;
  88298. /**
  88299. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88300. */
  88301. set colorGradingTexture(value: Nullable<BaseTexture>);
  88302. private _colorGradingEnabled;
  88303. /**
  88304. * Gets wether the color grading effect is enabled.
  88305. */
  88306. get colorGradingEnabled(): boolean;
  88307. /**
  88308. * Sets wether the color grading effect is enabled.
  88309. */
  88310. set colorGradingEnabled(value: boolean);
  88311. private _colorGradingWithGreenDepth;
  88312. /**
  88313. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88314. */
  88315. get colorGradingWithGreenDepth(): boolean;
  88316. /**
  88317. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88318. */
  88319. set colorGradingWithGreenDepth(value: boolean);
  88320. private _colorGradingBGR;
  88321. /**
  88322. * Gets wether the color grading texture contains BGR values.
  88323. */
  88324. get colorGradingBGR(): boolean;
  88325. /**
  88326. * Sets wether the color grading texture contains BGR values.
  88327. */
  88328. set colorGradingBGR(value: boolean);
  88329. /** @hidden */
  88330. _exposure: number;
  88331. /**
  88332. * Gets the Exposure used in the effect.
  88333. */
  88334. get exposure(): number;
  88335. /**
  88336. * Sets the Exposure used in the effect.
  88337. */
  88338. set exposure(value: number);
  88339. private _toneMappingEnabled;
  88340. /**
  88341. * Gets wether the tone mapping effect is enabled.
  88342. */
  88343. get toneMappingEnabled(): boolean;
  88344. /**
  88345. * Sets wether the tone mapping effect is enabled.
  88346. */
  88347. set toneMappingEnabled(value: boolean);
  88348. private _toneMappingType;
  88349. /**
  88350. * Gets the type of tone mapping effect.
  88351. */
  88352. get toneMappingType(): number;
  88353. /**
  88354. * Sets the type of tone mapping effect used in BabylonJS.
  88355. */
  88356. set toneMappingType(value: number);
  88357. protected _contrast: number;
  88358. /**
  88359. * Gets the contrast used in the effect.
  88360. */
  88361. get contrast(): number;
  88362. /**
  88363. * Sets the contrast used in the effect.
  88364. */
  88365. set contrast(value: number);
  88366. /**
  88367. * Vignette stretch size.
  88368. */
  88369. vignetteStretch: number;
  88370. /**
  88371. * Vignette centre X Offset.
  88372. */
  88373. vignetteCentreX: number;
  88374. /**
  88375. * Vignette centre Y Offset.
  88376. */
  88377. vignetteCentreY: number;
  88378. /**
  88379. * Vignette weight or intensity of the vignette effect.
  88380. */
  88381. vignetteWeight: number;
  88382. /**
  88383. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88384. * if vignetteEnabled is set to true.
  88385. */
  88386. vignetteColor: Color4;
  88387. /**
  88388. * Camera field of view used by the Vignette effect.
  88389. */
  88390. vignetteCameraFov: number;
  88391. private _vignetteBlendMode;
  88392. /**
  88393. * Gets the vignette blend mode allowing different kind of effect.
  88394. */
  88395. get vignetteBlendMode(): number;
  88396. /**
  88397. * Sets the vignette blend mode allowing different kind of effect.
  88398. */
  88399. set vignetteBlendMode(value: number);
  88400. private _vignetteEnabled;
  88401. /**
  88402. * Gets wether the vignette effect is enabled.
  88403. */
  88404. get vignetteEnabled(): boolean;
  88405. /**
  88406. * Sets wether the vignette effect is enabled.
  88407. */
  88408. set vignetteEnabled(value: boolean);
  88409. private _applyByPostProcess;
  88410. /**
  88411. * Gets wether the image processing is applied through a post process or not.
  88412. */
  88413. get applyByPostProcess(): boolean;
  88414. /**
  88415. * Sets wether the image processing is applied through a post process or not.
  88416. */
  88417. set applyByPostProcess(value: boolean);
  88418. private _isEnabled;
  88419. /**
  88420. * Gets wether the image processing is enabled or not.
  88421. */
  88422. get isEnabled(): boolean;
  88423. /**
  88424. * Sets wether the image processing is enabled or not.
  88425. */
  88426. set isEnabled(value: boolean);
  88427. /**
  88428. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88429. */
  88430. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88431. /**
  88432. * Method called each time the image processing information changes requires to recompile the effect.
  88433. */
  88434. protected _updateParameters(): void;
  88435. /**
  88436. * Gets the current class name.
  88437. * @return "ImageProcessingConfiguration"
  88438. */
  88439. getClassName(): string;
  88440. /**
  88441. * Prepare the list of uniforms associated with the Image Processing effects.
  88442. * @param uniforms The list of uniforms used in the effect
  88443. * @param defines the list of defines currently in use
  88444. */
  88445. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88446. /**
  88447. * Prepare the list of samplers associated with the Image Processing effects.
  88448. * @param samplersList The list of uniforms used in the effect
  88449. * @param defines the list of defines currently in use
  88450. */
  88451. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88452. /**
  88453. * Prepare the list of defines associated to the shader.
  88454. * @param defines the list of defines to complete
  88455. * @param forPostProcess Define if we are currently in post process mode or not
  88456. */
  88457. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88458. /**
  88459. * Returns true if all the image processing information are ready.
  88460. * @returns True if ready, otherwise, false
  88461. */
  88462. isReady(): boolean;
  88463. /**
  88464. * Binds the image processing to the shader.
  88465. * @param effect The effect to bind to
  88466. * @param overrideAspectRatio Override the aspect ratio of the effect
  88467. */
  88468. bind(effect: Effect, overrideAspectRatio?: number): void;
  88469. /**
  88470. * Clones the current image processing instance.
  88471. * @return The cloned image processing
  88472. */
  88473. clone(): ImageProcessingConfiguration;
  88474. /**
  88475. * Serializes the current image processing instance to a json representation.
  88476. * @return a JSON representation
  88477. */
  88478. serialize(): any;
  88479. /**
  88480. * Parses the image processing from a json representation.
  88481. * @param source the JSON source to parse
  88482. * @return The parsed image processing
  88483. */
  88484. static Parse(source: any): ImageProcessingConfiguration;
  88485. private static _VIGNETTEMODE_MULTIPLY;
  88486. private static _VIGNETTEMODE_OPAQUE;
  88487. /**
  88488. * Used to apply the vignette as a mix with the pixel color.
  88489. */
  88490. static get VIGNETTEMODE_MULTIPLY(): number;
  88491. /**
  88492. * Used to apply the vignette as a replacement of the pixel color.
  88493. */
  88494. static get VIGNETTEMODE_OPAQUE(): number;
  88495. }
  88496. }
  88497. declare module BABYLON {
  88498. /** @hidden */
  88499. export var postprocessVertexShader: {
  88500. name: string;
  88501. shader: string;
  88502. };
  88503. }
  88504. declare module BABYLON {
  88505. /**
  88506. * Type used to define a render target texture size (either with a number or with a rect width and height)
  88507. */
  88508. export type RenderTargetTextureSize = number | {
  88509. width: number;
  88510. height: number;
  88511. layers?: number;
  88512. };
  88513. interface ThinEngine {
  88514. /**
  88515. * Creates a new render target texture
  88516. * @param size defines the size of the texture
  88517. * @param options defines the options used to create the texture
  88518. * @returns a new render target texture stored in an InternalTexture
  88519. */
  88520. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88521. /**
  88522. * Creates a depth stencil texture.
  88523. * This is only available in WebGL 2 or with the depth texture extension available.
  88524. * @param size The size of face edge in the texture.
  88525. * @param options The options defining the texture.
  88526. * @returns The texture
  88527. */
  88528. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88529. /** @hidden */
  88530. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88531. }
  88532. }
  88533. declare module BABYLON {
  88534. /**
  88535. * Defines the kind of connection point for node based material
  88536. */
  88537. export enum NodeMaterialBlockConnectionPointTypes {
  88538. /** Float */
  88539. Float = 1,
  88540. /** Int */
  88541. Int = 2,
  88542. /** Vector2 */
  88543. Vector2 = 4,
  88544. /** Vector3 */
  88545. Vector3 = 8,
  88546. /** Vector4 */
  88547. Vector4 = 16,
  88548. /** Color3 */
  88549. Color3 = 32,
  88550. /** Color4 */
  88551. Color4 = 64,
  88552. /** Matrix */
  88553. Matrix = 128,
  88554. /** Custom object */
  88555. Object = 256,
  88556. /** Detect type based on connection */
  88557. AutoDetect = 1024,
  88558. /** Output type that will be defined by input type */
  88559. BasedOnInput = 2048
  88560. }
  88561. }
  88562. declare module BABYLON {
  88563. /**
  88564. * Enum used to define the target of a block
  88565. */
  88566. export enum NodeMaterialBlockTargets {
  88567. /** Vertex shader */
  88568. Vertex = 1,
  88569. /** Fragment shader */
  88570. Fragment = 2,
  88571. /** Neutral */
  88572. Neutral = 4,
  88573. /** Vertex and Fragment */
  88574. VertexAndFragment = 3
  88575. }
  88576. }
  88577. declare module BABYLON {
  88578. /**
  88579. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88580. */
  88581. export enum NodeMaterialBlockConnectionPointMode {
  88582. /** Value is an uniform */
  88583. Uniform = 0,
  88584. /** Value is a mesh attribute */
  88585. Attribute = 1,
  88586. /** Value is a varying between vertex and fragment shaders */
  88587. Varying = 2,
  88588. /** Mode is undefined */
  88589. Undefined = 3
  88590. }
  88591. }
  88592. declare module BABYLON {
  88593. /**
  88594. * Enum used to define system values e.g. values automatically provided by the system
  88595. */
  88596. export enum NodeMaterialSystemValues {
  88597. /** World */
  88598. World = 1,
  88599. /** View */
  88600. View = 2,
  88601. /** Projection */
  88602. Projection = 3,
  88603. /** ViewProjection */
  88604. ViewProjection = 4,
  88605. /** WorldView */
  88606. WorldView = 5,
  88607. /** WorldViewProjection */
  88608. WorldViewProjection = 6,
  88609. /** CameraPosition */
  88610. CameraPosition = 7,
  88611. /** Fog Color */
  88612. FogColor = 8,
  88613. /** Delta time */
  88614. DeltaTime = 9
  88615. }
  88616. }
  88617. declare module BABYLON {
  88618. /** Defines supported spaces */
  88619. export enum Space {
  88620. /** Local (object) space */
  88621. LOCAL = 0,
  88622. /** World space */
  88623. WORLD = 1,
  88624. /** Bone space */
  88625. BONE = 2
  88626. }
  88627. /** Defines the 3 main axes */
  88628. export class Axis {
  88629. /** X axis */
  88630. static X: Vector3;
  88631. /** Y axis */
  88632. static Y: Vector3;
  88633. /** Z axis */
  88634. static Z: Vector3;
  88635. }
  88636. }
  88637. declare module BABYLON {
  88638. /**
  88639. * Represents a camera frustum
  88640. */
  88641. export class Frustum {
  88642. /**
  88643. * Gets the planes representing the frustum
  88644. * @param transform matrix to be applied to the returned planes
  88645. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  88646. */
  88647. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  88648. /**
  88649. * Gets the near frustum plane transformed by the transform matrix
  88650. * @param transform transformation matrix to be applied to the resulting frustum plane
  88651. * @param frustumPlane the resuling frustum plane
  88652. */
  88653. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88654. /**
  88655. * Gets the far frustum plane transformed by the transform matrix
  88656. * @param transform transformation matrix to be applied to the resulting frustum plane
  88657. * @param frustumPlane the resuling frustum plane
  88658. */
  88659. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88660. /**
  88661. * Gets the left frustum plane transformed by the transform matrix
  88662. * @param transform transformation matrix to be applied to the resulting frustum plane
  88663. * @param frustumPlane the resuling frustum plane
  88664. */
  88665. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88666. /**
  88667. * Gets the right frustum plane transformed by the transform matrix
  88668. * @param transform transformation matrix to be applied to the resulting frustum plane
  88669. * @param frustumPlane the resuling frustum plane
  88670. */
  88671. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88672. /**
  88673. * Gets the top frustum plane transformed by the transform matrix
  88674. * @param transform transformation matrix to be applied to the resulting frustum plane
  88675. * @param frustumPlane the resuling frustum plane
  88676. */
  88677. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88678. /**
  88679. * Gets the bottom frustum plane transformed by the transform matrix
  88680. * @param transform transformation matrix to be applied to the resulting frustum plane
  88681. * @param frustumPlane the resuling frustum plane
  88682. */
  88683. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88684. /**
  88685. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88686. * @param transform transformation matrix to be applied to the resulting frustum planes
  88687. * @param frustumPlanes the resuling frustum planes
  88688. */
  88689. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88690. }
  88691. }
  88692. declare module BABYLON {
  88693. /**
  88694. * Interface for the size containing width and height
  88695. */
  88696. export interface ISize {
  88697. /**
  88698. * Width
  88699. */
  88700. width: number;
  88701. /**
  88702. * Heighht
  88703. */
  88704. height: number;
  88705. }
  88706. /**
  88707. * Size containing widht and height
  88708. */
  88709. export class Size implements ISize {
  88710. /**
  88711. * Width
  88712. */
  88713. width: number;
  88714. /**
  88715. * Height
  88716. */
  88717. height: number;
  88718. /**
  88719. * Creates a Size object from the given width and height (floats).
  88720. * @param width width of the new size
  88721. * @param height height of the new size
  88722. */
  88723. constructor(width: number, height: number);
  88724. /**
  88725. * Returns a string with the Size width and height
  88726. * @returns a string with the Size width and height
  88727. */
  88728. toString(): string;
  88729. /**
  88730. * "Size"
  88731. * @returns the string "Size"
  88732. */
  88733. getClassName(): string;
  88734. /**
  88735. * Returns the Size hash code.
  88736. * @returns a hash code for a unique width and height
  88737. */
  88738. getHashCode(): number;
  88739. /**
  88740. * Updates the current size from the given one.
  88741. * @param src the given size
  88742. */
  88743. copyFrom(src: Size): void;
  88744. /**
  88745. * Updates in place the current Size from the given floats.
  88746. * @param width width of the new size
  88747. * @param height height of the new size
  88748. * @returns the updated Size.
  88749. */
  88750. copyFromFloats(width: number, height: number): Size;
  88751. /**
  88752. * Updates in place the current Size from the given floats.
  88753. * @param width width to set
  88754. * @param height height to set
  88755. * @returns the updated Size.
  88756. */
  88757. set(width: number, height: number): Size;
  88758. /**
  88759. * Multiplies the width and height by numbers
  88760. * @param w factor to multiple the width by
  88761. * @param h factor to multiple the height by
  88762. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  88763. */
  88764. multiplyByFloats(w: number, h: number): Size;
  88765. /**
  88766. * Clones the size
  88767. * @returns a new Size copied from the given one.
  88768. */
  88769. clone(): Size;
  88770. /**
  88771. * True if the current Size and the given one width and height are strictly equal.
  88772. * @param other the other size to compare against
  88773. * @returns True if the current Size and the given one width and height are strictly equal.
  88774. */
  88775. equals(other: Size): boolean;
  88776. /**
  88777. * The surface of the Size : width * height (float).
  88778. */
  88779. get surface(): number;
  88780. /**
  88781. * Create a new size of zero
  88782. * @returns a new Size set to (0.0, 0.0)
  88783. */
  88784. static Zero(): Size;
  88785. /**
  88786. * Sums the width and height of two sizes
  88787. * @param otherSize size to add to this size
  88788. * @returns a new Size set as the addition result of the current Size and the given one.
  88789. */
  88790. add(otherSize: Size): Size;
  88791. /**
  88792. * Subtracts the width and height of two
  88793. * @param otherSize size to subtract to this size
  88794. * @returns a new Size set as the subtraction result of the given one from the current Size.
  88795. */
  88796. subtract(otherSize: Size): Size;
  88797. /**
  88798. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  88799. * @param start starting size to lerp between
  88800. * @param end end size to lerp between
  88801. * @param amount amount to lerp between the start and end values
  88802. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  88803. */
  88804. static Lerp(start: Size, end: Size, amount: number): Size;
  88805. }
  88806. }
  88807. declare module BABYLON {
  88808. /**
  88809. * Contains position and normal vectors for a vertex
  88810. */
  88811. export class PositionNormalVertex {
  88812. /** the position of the vertex (defaut: 0,0,0) */
  88813. position: Vector3;
  88814. /** the normal of the vertex (defaut: 0,1,0) */
  88815. normal: Vector3;
  88816. /**
  88817. * Creates a PositionNormalVertex
  88818. * @param position the position of the vertex (defaut: 0,0,0)
  88819. * @param normal the normal of the vertex (defaut: 0,1,0)
  88820. */
  88821. constructor(
  88822. /** the position of the vertex (defaut: 0,0,0) */
  88823. position?: Vector3,
  88824. /** the normal of the vertex (defaut: 0,1,0) */
  88825. normal?: Vector3);
  88826. /**
  88827. * Clones the PositionNormalVertex
  88828. * @returns the cloned PositionNormalVertex
  88829. */
  88830. clone(): PositionNormalVertex;
  88831. }
  88832. /**
  88833. * Contains position, normal and uv vectors for a vertex
  88834. */
  88835. export class PositionNormalTextureVertex {
  88836. /** the position of the vertex (defaut: 0,0,0) */
  88837. position: Vector3;
  88838. /** the normal of the vertex (defaut: 0,1,0) */
  88839. normal: Vector3;
  88840. /** the uv of the vertex (default: 0,0) */
  88841. uv: Vector2;
  88842. /**
  88843. * Creates a PositionNormalTextureVertex
  88844. * @param position the position of the vertex (defaut: 0,0,0)
  88845. * @param normal the normal of the vertex (defaut: 0,1,0)
  88846. * @param uv the uv of the vertex (default: 0,0)
  88847. */
  88848. constructor(
  88849. /** the position of the vertex (defaut: 0,0,0) */
  88850. position?: Vector3,
  88851. /** the normal of the vertex (defaut: 0,1,0) */
  88852. normal?: Vector3,
  88853. /** the uv of the vertex (default: 0,0) */
  88854. uv?: Vector2);
  88855. /**
  88856. * Clones the PositionNormalTextureVertex
  88857. * @returns the cloned PositionNormalTextureVertex
  88858. */
  88859. clone(): PositionNormalTextureVertex;
  88860. }
  88861. }
  88862. declare module BABYLON {
  88863. /**
  88864. * Enum defining the type of animations supported by InputBlock
  88865. */
  88866. export enum AnimatedInputBlockTypes {
  88867. /** No animation */
  88868. None = 0,
  88869. /** Time based animation. Will only work for floats */
  88870. Time = 1
  88871. }
  88872. }
  88873. declare module BABYLON {
  88874. /**
  88875. * Interface describing all the common properties and methods a shadow light needs to implement.
  88876. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  88877. * as well as binding the different shadow properties to the effects.
  88878. */
  88879. export interface IShadowLight extends Light {
  88880. /**
  88881. * The light id in the scene (used in scene.findLighById for instance)
  88882. */
  88883. id: string;
  88884. /**
  88885. * The position the shdow will be casted from.
  88886. */
  88887. position: Vector3;
  88888. /**
  88889. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88890. */
  88891. direction: Vector3;
  88892. /**
  88893. * The transformed position. Position of the light in world space taking parenting in account.
  88894. */
  88895. transformedPosition: Vector3;
  88896. /**
  88897. * The transformed direction. Direction of the light in world space taking parenting in account.
  88898. */
  88899. transformedDirection: Vector3;
  88900. /**
  88901. * The friendly name of the light in the scene.
  88902. */
  88903. name: string;
  88904. /**
  88905. * Defines the shadow projection clipping minimum z value.
  88906. */
  88907. shadowMinZ: number;
  88908. /**
  88909. * Defines the shadow projection clipping maximum z value.
  88910. */
  88911. shadowMaxZ: number;
  88912. /**
  88913. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88914. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88915. */
  88916. computeTransformedInformation(): boolean;
  88917. /**
  88918. * Gets the scene the light belongs to.
  88919. * @returns The scene
  88920. */
  88921. getScene(): Scene;
  88922. /**
  88923. * Callback defining a custom Projection Matrix Builder.
  88924. * This can be used to override the default projection matrix computation.
  88925. */
  88926. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88927. /**
  88928. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88929. * @param matrix The materix to updated with the projection information
  88930. * @param viewMatrix The transform matrix of the light
  88931. * @param renderList The list of mesh to render in the map
  88932. * @returns The current light
  88933. */
  88934. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88935. /**
  88936. * Gets the current depth scale used in ESM.
  88937. * @returns The scale
  88938. */
  88939. getDepthScale(): number;
  88940. /**
  88941. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88942. * @returns true if a cube texture needs to be use
  88943. */
  88944. needCube(): boolean;
  88945. /**
  88946. * Detects if the projection matrix requires to be recomputed this frame.
  88947. * @returns true if it requires to be recomputed otherwise, false.
  88948. */
  88949. needProjectionMatrixCompute(): boolean;
  88950. /**
  88951. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88952. */
  88953. forceProjectionMatrixCompute(): void;
  88954. /**
  88955. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88956. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88957. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88958. */
  88959. getShadowDirection(faceIndex?: number): Vector3;
  88960. /**
  88961. * Gets the minZ used for shadow according to both the scene and the light.
  88962. * @param activeCamera The camera we are returning the min for
  88963. * @returns the depth min z
  88964. */
  88965. getDepthMinZ(activeCamera: Camera): number;
  88966. /**
  88967. * Gets the maxZ used for shadow according to both the scene and the light.
  88968. * @param activeCamera The camera we are returning the max for
  88969. * @returns the depth max z
  88970. */
  88971. getDepthMaxZ(activeCamera: Camera): number;
  88972. }
  88973. /**
  88974. * Base implementation IShadowLight
  88975. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88976. */
  88977. export abstract class ShadowLight extends Light implements IShadowLight {
  88978. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88979. protected _position: Vector3;
  88980. protected _setPosition(value: Vector3): void;
  88981. /**
  88982. * Sets the position the shadow will be casted from. Also use as the light position for both
  88983. * point and spot lights.
  88984. */
  88985. get position(): Vector3;
  88986. /**
  88987. * Sets the position the shadow will be casted from. Also use as the light position for both
  88988. * point and spot lights.
  88989. */
  88990. set position(value: Vector3);
  88991. protected _direction: Vector3;
  88992. protected _setDirection(value: Vector3): void;
  88993. /**
  88994. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88995. * Also use as the light direction on spot and directional lights.
  88996. */
  88997. get direction(): Vector3;
  88998. /**
  88999. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89000. * Also use as the light direction on spot and directional lights.
  89001. */
  89002. set direction(value: Vector3);
  89003. protected _shadowMinZ: number;
  89004. /**
  89005. * Gets the shadow projection clipping minimum z value.
  89006. */
  89007. get shadowMinZ(): number;
  89008. /**
  89009. * Sets the shadow projection clipping minimum z value.
  89010. */
  89011. set shadowMinZ(value: number);
  89012. protected _shadowMaxZ: number;
  89013. /**
  89014. * Sets the shadow projection clipping maximum z value.
  89015. */
  89016. get shadowMaxZ(): number;
  89017. /**
  89018. * Gets the shadow projection clipping maximum z value.
  89019. */
  89020. set shadowMaxZ(value: number);
  89021. /**
  89022. * Callback defining a custom Projection Matrix Builder.
  89023. * This can be used to override the default projection matrix computation.
  89024. */
  89025. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89026. /**
  89027. * The transformed position. Position of the light in world space taking parenting in account.
  89028. */
  89029. transformedPosition: Vector3;
  89030. /**
  89031. * The transformed direction. Direction of the light in world space taking parenting in account.
  89032. */
  89033. transformedDirection: Vector3;
  89034. private _needProjectionMatrixCompute;
  89035. /**
  89036. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89037. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89038. */
  89039. computeTransformedInformation(): boolean;
  89040. /**
  89041. * Return the depth scale used for the shadow map.
  89042. * @returns the depth scale.
  89043. */
  89044. getDepthScale(): number;
  89045. /**
  89046. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89047. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89048. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89049. */
  89050. getShadowDirection(faceIndex?: number): Vector3;
  89051. /**
  89052. * Returns the ShadowLight absolute position in the World.
  89053. * @returns the position vector in world space
  89054. */
  89055. getAbsolutePosition(): Vector3;
  89056. /**
  89057. * Sets the ShadowLight direction toward the passed target.
  89058. * @param target The point to target in local space
  89059. * @returns the updated ShadowLight direction
  89060. */
  89061. setDirectionToTarget(target: Vector3): Vector3;
  89062. /**
  89063. * Returns the light rotation in euler definition.
  89064. * @returns the x y z rotation in local space.
  89065. */
  89066. getRotation(): Vector3;
  89067. /**
  89068. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89069. * @returns true if a cube texture needs to be use
  89070. */
  89071. needCube(): boolean;
  89072. /**
  89073. * Detects if the projection matrix requires to be recomputed this frame.
  89074. * @returns true if it requires to be recomputed otherwise, false.
  89075. */
  89076. needProjectionMatrixCompute(): boolean;
  89077. /**
  89078. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89079. */
  89080. forceProjectionMatrixCompute(): void;
  89081. /** @hidden */
  89082. _initCache(): void;
  89083. /** @hidden */
  89084. _isSynchronized(): boolean;
  89085. /**
  89086. * Computes the world matrix of the node
  89087. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89088. * @returns the world matrix
  89089. */
  89090. computeWorldMatrix(force?: boolean): Matrix;
  89091. /**
  89092. * Gets the minZ used for shadow according to both the scene and the light.
  89093. * @param activeCamera The camera we are returning the min for
  89094. * @returns the depth min z
  89095. */
  89096. getDepthMinZ(activeCamera: Camera): number;
  89097. /**
  89098. * Gets the maxZ used for shadow according to both the scene and the light.
  89099. * @param activeCamera The camera we are returning the max for
  89100. * @returns the depth max z
  89101. */
  89102. getDepthMaxZ(activeCamera: Camera): number;
  89103. /**
  89104. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89105. * @param matrix The materix to updated with the projection information
  89106. * @param viewMatrix The transform matrix of the light
  89107. * @param renderList The list of mesh to render in the map
  89108. * @returns The current light
  89109. */
  89110. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89111. }
  89112. }
  89113. declare module BABYLON {
  89114. /** @hidden */
  89115. export var packingFunctions: {
  89116. name: string;
  89117. shader: string;
  89118. };
  89119. }
  89120. declare module BABYLON {
  89121. /** @hidden */
  89122. export var bayerDitherFunctions: {
  89123. name: string;
  89124. shader: string;
  89125. };
  89126. }
  89127. declare module BABYLON {
  89128. /** @hidden */
  89129. export var shadowMapFragmentDeclaration: {
  89130. name: string;
  89131. shader: string;
  89132. };
  89133. }
  89134. declare module BABYLON {
  89135. /** @hidden */
  89136. export var clipPlaneFragmentDeclaration: {
  89137. name: string;
  89138. shader: string;
  89139. };
  89140. }
  89141. declare module BABYLON {
  89142. /** @hidden */
  89143. export var clipPlaneFragment: {
  89144. name: string;
  89145. shader: string;
  89146. };
  89147. }
  89148. declare module BABYLON {
  89149. /** @hidden */
  89150. export var shadowMapFragment: {
  89151. name: string;
  89152. shader: string;
  89153. };
  89154. }
  89155. declare module BABYLON {
  89156. /** @hidden */
  89157. export var shadowMapPixelShader: {
  89158. name: string;
  89159. shader: string;
  89160. };
  89161. }
  89162. declare module BABYLON {
  89163. /** @hidden */
  89164. export var bonesDeclaration: {
  89165. name: string;
  89166. shader: string;
  89167. };
  89168. }
  89169. declare module BABYLON {
  89170. /** @hidden */
  89171. export var morphTargetsVertexGlobalDeclaration: {
  89172. name: string;
  89173. shader: string;
  89174. };
  89175. }
  89176. declare module BABYLON {
  89177. /** @hidden */
  89178. export var morphTargetsVertexDeclaration: {
  89179. name: string;
  89180. shader: string;
  89181. };
  89182. }
  89183. declare module BABYLON {
  89184. /** @hidden */
  89185. export var instancesDeclaration: {
  89186. name: string;
  89187. shader: string;
  89188. };
  89189. }
  89190. declare module BABYLON {
  89191. /** @hidden */
  89192. export var helperFunctions: {
  89193. name: string;
  89194. shader: string;
  89195. };
  89196. }
  89197. declare module BABYLON {
  89198. /** @hidden */
  89199. export var shadowMapVertexDeclaration: {
  89200. name: string;
  89201. shader: string;
  89202. };
  89203. }
  89204. declare module BABYLON {
  89205. /** @hidden */
  89206. export var clipPlaneVertexDeclaration: {
  89207. name: string;
  89208. shader: string;
  89209. };
  89210. }
  89211. declare module BABYLON {
  89212. /** @hidden */
  89213. export var morphTargetsVertex: {
  89214. name: string;
  89215. shader: string;
  89216. };
  89217. }
  89218. declare module BABYLON {
  89219. /** @hidden */
  89220. export var instancesVertex: {
  89221. name: string;
  89222. shader: string;
  89223. };
  89224. }
  89225. declare module BABYLON {
  89226. /** @hidden */
  89227. export var bonesVertex: {
  89228. name: string;
  89229. shader: string;
  89230. };
  89231. }
  89232. declare module BABYLON {
  89233. /** @hidden */
  89234. export var shadowMapVertexNormalBias: {
  89235. name: string;
  89236. shader: string;
  89237. };
  89238. }
  89239. declare module BABYLON {
  89240. /** @hidden */
  89241. export var shadowMapVertexMetric: {
  89242. name: string;
  89243. shader: string;
  89244. };
  89245. }
  89246. declare module BABYLON {
  89247. /** @hidden */
  89248. export var clipPlaneVertex: {
  89249. name: string;
  89250. shader: string;
  89251. };
  89252. }
  89253. declare module BABYLON {
  89254. /** @hidden */
  89255. export var shadowMapVertexShader: {
  89256. name: string;
  89257. shader: string;
  89258. };
  89259. }
  89260. declare module BABYLON {
  89261. /** @hidden */
  89262. export var depthBoxBlurPixelShader: {
  89263. name: string;
  89264. shader: string;
  89265. };
  89266. }
  89267. declare module BABYLON {
  89268. /** @hidden */
  89269. export var shadowMapFragmentSoftTransparentShadow: {
  89270. name: string;
  89271. shader: string;
  89272. };
  89273. }
  89274. declare module BABYLON {
  89275. /**
  89276. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89277. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89278. */
  89279. export class EffectFallbacks implements IEffectFallbacks {
  89280. private _defines;
  89281. private _currentRank;
  89282. private _maxRank;
  89283. private _mesh;
  89284. /**
  89285. * Removes the fallback from the bound mesh.
  89286. */
  89287. unBindMesh(): void;
  89288. /**
  89289. * Adds a fallback on the specified property.
  89290. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89291. * @param define The name of the define in the shader
  89292. */
  89293. addFallback(rank: number, define: string): void;
  89294. /**
  89295. * Sets the mesh to use CPU skinning when needing to fallback.
  89296. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89297. * @param mesh The mesh to use the fallbacks.
  89298. */
  89299. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89300. /**
  89301. * Checks to see if more fallbacks are still availible.
  89302. */
  89303. get hasMoreFallbacks(): boolean;
  89304. /**
  89305. * Removes the defines that should be removed when falling back.
  89306. * @param currentDefines defines the current define statements for the shader.
  89307. * @param effect defines the current effect we try to compile
  89308. * @returns The resulting defines with defines of the current rank removed.
  89309. */
  89310. reduce(currentDefines: string, effect: Effect): string;
  89311. }
  89312. }
  89313. declare module BABYLON {
  89314. /**
  89315. * Interface used to define Action
  89316. */
  89317. export interface IAction {
  89318. /**
  89319. * Trigger for the action
  89320. */
  89321. trigger: number;
  89322. /** Options of the trigger */
  89323. triggerOptions: any;
  89324. /**
  89325. * Gets the trigger parameters
  89326. * @returns the trigger parameters
  89327. */
  89328. getTriggerParameter(): any;
  89329. /**
  89330. * Internal only - executes current action event
  89331. * @hidden
  89332. */
  89333. _executeCurrent(evt?: ActionEvent): void;
  89334. /**
  89335. * Serialize placeholder for child classes
  89336. * @param parent of child
  89337. * @returns the serialized object
  89338. */
  89339. serialize(parent: any): any;
  89340. /**
  89341. * Internal only
  89342. * @hidden
  89343. */
  89344. _prepare(): void;
  89345. /**
  89346. * Internal only - manager for action
  89347. * @hidden
  89348. */
  89349. _actionManager: Nullable<AbstractActionManager>;
  89350. /**
  89351. * Adds action to chain of actions, may be a DoNothingAction
  89352. * @param action defines the next action to execute
  89353. * @returns The action passed in
  89354. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89355. */
  89356. then(action: IAction): IAction;
  89357. }
  89358. /**
  89359. * The action to be carried out following a trigger
  89360. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89361. */
  89362. export class Action implements IAction {
  89363. /** the trigger, with or without parameters, for the action */
  89364. triggerOptions: any;
  89365. /**
  89366. * Trigger for the action
  89367. */
  89368. trigger: number;
  89369. /**
  89370. * Internal only - manager for action
  89371. * @hidden
  89372. */
  89373. _actionManager: ActionManager;
  89374. private _nextActiveAction;
  89375. private _child;
  89376. private _condition?;
  89377. private _triggerParameter;
  89378. /**
  89379. * An event triggered prior to action being executed.
  89380. */
  89381. onBeforeExecuteObservable: Observable<Action>;
  89382. /**
  89383. * Creates a new Action
  89384. * @param triggerOptions the trigger, with or without parameters, for the action
  89385. * @param condition an optional determinant of action
  89386. */
  89387. constructor(
  89388. /** the trigger, with or without parameters, for the action */
  89389. triggerOptions: any, condition?: Condition);
  89390. /**
  89391. * Internal only
  89392. * @hidden
  89393. */
  89394. _prepare(): void;
  89395. /**
  89396. * Gets the trigger parameters
  89397. * @returns the trigger parameters
  89398. */
  89399. getTriggerParameter(): any;
  89400. /**
  89401. * Internal only - executes current action event
  89402. * @hidden
  89403. */
  89404. _executeCurrent(evt?: ActionEvent): void;
  89405. /**
  89406. * Execute placeholder for child classes
  89407. * @param evt optional action event
  89408. */
  89409. execute(evt?: ActionEvent): void;
  89410. /**
  89411. * Skips to next active action
  89412. */
  89413. skipToNextActiveAction(): void;
  89414. /**
  89415. * Adds action to chain of actions, may be a DoNothingAction
  89416. * @param action defines the next action to execute
  89417. * @returns The action passed in
  89418. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89419. */
  89420. then(action: Action): Action;
  89421. /**
  89422. * Internal only
  89423. * @hidden
  89424. */
  89425. _getProperty(propertyPath: string): string;
  89426. /**
  89427. * Internal only
  89428. * @hidden
  89429. */
  89430. _getEffectiveTarget(target: any, propertyPath: string): any;
  89431. /**
  89432. * Serialize placeholder for child classes
  89433. * @param parent of child
  89434. * @returns the serialized object
  89435. */
  89436. serialize(parent: any): any;
  89437. /**
  89438. * Internal only called by serialize
  89439. * @hidden
  89440. */
  89441. protected _serialize(serializedAction: any, parent?: any): any;
  89442. /**
  89443. * Internal only
  89444. * @hidden
  89445. */
  89446. static _SerializeValueAsString: (value: any) => string;
  89447. /**
  89448. * Internal only
  89449. * @hidden
  89450. */
  89451. static _GetTargetProperty: (target: Scene | Node) => {
  89452. name: string;
  89453. targetType: string;
  89454. value: string;
  89455. };
  89456. }
  89457. }
  89458. declare module BABYLON {
  89459. /**
  89460. * A Condition applied to an Action
  89461. */
  89462. export class Condition {
  89463. /**
  89464. * Internal only - manager for action
  89465. * @hidden
  89466. */
  89467. _actionManager: ActionManager;
  89468. /**
  89469. * Internal only
  89470. * @hidden
  89471. */
  89472. _evaluationId: number;
  89473. /**
  89474. * Internal only
  89475. * @hidden
  89476. */
  89477. _currentResult: boolean;
  89478. /**
  89479. * Creates a new Condition
  89480. * @param actionManager the manager of the action the condition is applied to
  89481. */
  89482. constructor(actionManager: ActionManager);
  89483. /**
  89484. * Check if the current condition is valid
  89485. * @returns a boolean
  89486. */
  89487. isValid(): boolean;
  89488. /**
  89489. * Internal only
  89490. * @hidden
  89491. */
  89492. _getProperty(propertyPath: string): string;
  89493. /**
  89494. * Internal only
  89495. * @hidden
  89496. */
  89497. _getEffectiveTarget(target: any, propertyPath: string): any;
  89498. /**
  89499. * Serialize placeholder for child classes
  89500. * @returns the serialized object
  89501. */
  89502. serialize(): any;
  89503. /**
  89504. * Internal only
  89505. * @hidden
  89506. */
  89507. protected _serialize(serializedCondition: any): any;
  89508. }
  89509. /**
  89510. * Defines specific conditional operators as extensions of Condition
  89511. */
  89512. export class ValueCondition extends Condition {
  89513. /** path to specify the property of the target the conditional operator uses */
  89514. propertyPath: string;
  89515. /** the value compared by the conditional operator against the current value of the property */
  89516. value: any;
  89517. /** the conditional operator, default ValueCondition.IsEqual */
  89518. operator: number;
  89519. /**
  89520. * Internal only
  89521. * @hidden
  89522. */
  89523. private static _IsEqual;
  89524. /**
  89525. * Internal only
  89526. * @hidden
  89527. */
  89528. private static _IsDifferent;
  89529. /**
  89530. * Internal only
  89531. * @hidden
  89532. */
  89533. private static _IsGreater;
  89534. /**
  89535. * Internal only
  89536. * @hidden
  89537. */
  89538. private static _IsLesser;
  89539. /**
  89540. * returns the number for IsEqual
  89541. */
  89542. static get IsEqual(): number;
  89543. /**
  89544. * Returns the number for IsDifferent
  89545. */
  89546. static get IsDifferent(): number;
  89547. /**
  89548. * Returns the number for IsGreater
  89549. */
  89550. static get IsGreater(): number;
  89551. /**
  89552. * Returns the number for IsLesser
  89553. */
  89554. static get IsLesser(): number;
  89555. /**
  89556. * Internal only The action manager for the condition
  89557. * @hidden
  89558. */
  89559. _actionManager: ActionManager;
  89560. /**
  89561. * Internal only
  89562. * @hidden
  89563. */
  89564. private _target;
  89565. /**
  89566. * Internal only
  89567. * @hidden
  89568. */
  89569. private _effectiveTarget;
  89570. /**
  89571. * Internal only
  89572. * @hidden
  89573. */
  89574. private _property;
  89575. /**
  89576. * Creates a new ValueCondition
  89577. * @param actionManager manager for the action the condition applies to
  89578. * @param target for the action
  89579. * @param propertyPath path to specify the property of the target the conditional operator uses
  89580. * @param value the value compared by the conditional operator against the current value of the property
  89581. * @param operator the conditional operator, default ValueCondition.IsEqual
  89582. */
  89583. constructor(actionManager: ActionManager, target: any,
  89584. /** path to specify the property of the target the conditional operator uses */
  89585. propertyPath: string,
  89586. /** the value compared by the conditional operator against the current value of the property */
  89587. value: any,
  89588. /** the conditional operator, default ValueCondition.IsEqual */
  89589. operator?: number);
  89590. /**
  89591. * Compares the given value with the property value for the specified conditional operator
  89592. * @returns the result of the comparison
  89593. */
  89594. isValid(): boolean;
  89595. /**
  89596. * Serialize the ValueCondition into a JSON compatible object
  89597. * @returns serialization object
  89598. */
  89599. serialize(): any;
  89600. /**
  89601. * Gets the name of the conditional operator for the ValueCondition
  89602. * @param operator the conditional operator
  89603. * @returns the name
  89604. */
  89605. static GetOperatorName(operator: number): string;
  89606. }
  89607. /**
  89608. * Defines a predicate condition as an extension of Condition
  89609. */
  89610. export class PredicateCondition extends Condition {
  89611. /** defines the predicate function used to validate the condition */
  89612. predicate: () => boolean;
  89613. /**
  89614. * Internal only - manager for action
  89615. * @hidden
  89616. */
  89617. _actionManager: ActionManager;
  89618. /**
  89619. * Creates a new PredicateCondition
  89620. * @param actionManager manager for the action the condition applies to
  89621. * @param predicate defines the predicate function used to validate the condition
  89622. */
  89623. constructor(actionManager: ActionManager,
  89624. /** defines the predicate function used to validate the condition */
  89625. predicate: () => boolean);
  89626. /**
  89627. * @returns the validity of the predicate condition
  89628. */
  89629. isValid(): boolean;
  89630. }
  89631. /**
  89632. * Defines a state condition as an extension of Condition
  89633. */
  89634. export class StateCondition extends Condition {
  89635. /** Value to compare with target state */
  89636. value: string;
  89637. /**
  89638. * Internal only - manager for action
  89639. * @hidden
  89640. */
  89641. _actionManager: ActionManager;
  89642. /**
  89643. * Internal only
  89644. * @hidden
  89645. */
  89646. private _target;
  89647. /**
  89648. * Creates a new StateCondition
  89649. * @param actionManager manager for the action the condition applies to
  89650. * @param target of the condition
  89651. * @param value to compare with target state
  89652. */
  89653. constructor(actionManager: ActionManager, target: any,
  89654. /** Value to compare with target state */
  89655. value: string);
  89656. /**
  89657. * Gets a boolean indicating if the current condition is met
  89658. * @returns the validity of the state
  89659. */
  89660. isValid(): boolean;
  89661. /**
  89662. * Serialize the StateCondition into a JSON compatible object
  89663. * @returns serialization object
  89664. */
  89665. serialize(): any;
  89666. }
  89667. }
  89668. declare module BABYLON {
  89669. /**
  89670. * This defines an action responsible to toggle a boolean once triggered.
  89671. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89672. */
  89673. export class SwitchBooleanAction extends Action {
  89674. /**
  89675. * The path to the boolean property in the target object
  89676. */
  89677. propertyPath: string;
  89678. private _target;
  89679. private _effectiveTarget;
  89680. private _property;
  89681. /**
  89682. * Instantiate the action
  89683. * @param triggerOptions defines the trigger options
  89684. * @param target defines the object containing the boolean
  89685. * @param propertyPath defines the path to the boolean property in the target object
  89686. * @param condition defines the trigger related conditions
  89687. */
  89688. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  89689. /** @hidden */
  89690. _prepare(): void;
  89691. /**
  89692. * Execute the action toggle the boolean value.
  89693. */
  89694. execute(): void;
  89695. /**
  89696. * Serializes the actions and its related information.
  89697. * @param parent defines the object to serialize in
  89698. * @returns the serialized object
  89699. */
  89700. serialize(parent: any): any;
  89701. }
  89702. /**
  89703. * This defines an action responsible to set a the state field of the target
  89704. * to a desired value once triggered.
  89705. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89706. */
  89707. export class SetStateAction extends Action {
  89708. /**
  89709. * The value to store in the state field.
  89710. */
  89711. value: string;
  89712. private _target;
  89713. /**
  89714. * Instantiate the action
  89715. * @param triggerOptions defines the trigger options
  89716. * @param target defines the object containing the state property
  89717. * @param value defines the value to store in the state field
  89718. * @param condition defines the trigger related conditions
  89719. */
  89720. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  89721. /**
  89722. * Execute the action and store the value on the target state property.
  89723. */
  89724. execute(): void;
  89725. /**
  89726. * Serializes the actions and its related information.
  89727. * @param parent defines the object to serialize in
  89728. * @returns the serialized object
  89729. */
  89730. serialize(parent: any): any;
  89731. }
  89732. /**
  89733. * This defines an action responsible to set a property of the target
  89734. * to a desired value once triggered.
  89735. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89736. */
  89737. export class SetValueAction extends Action {
  89738. /**
  89739. * The path of the property to set in the target.
  89740. */
  89741. propertyPath: string;
  89742. /**
  89743. * The value to set in the property
  89744. */
  89745. value: any;
  89746. private _target;
  89747. private _effectiveTarget;
  89748. private _property;
  89749. /**
  89750. * Instantiate the action
  89751. * @param triggerOptions defines the trigger options
  89752. * @param target defines the object containing the property
  89753. * @param propertyPath defines the path of the property to set in the target
  89754. * @param value defines the value to set in the property
  89755. * @param condition defines the trigger related conditions
  89756. */
  89757. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89758. /** @hidden */
  89759. _prepare(): void;
  89760. /**
  89761. * Execute the action and set the targetted property to the desired value.
  89762. */
  89763. execute(): void;
  89764. /**
  89765. * Serializes the actions and its related information.
  89766. * @param parent defines the object to serialize in
  89767. * @returns the serialized object
  89768. */
  89769. serialize(parent: any): any;
  89770. }
  89771. /**
  89772. * This defines an action responsible to increment the target value
  89773. * to a desired value once triggered.
  89774. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89775. */
  89776. export class IncrementValueAction extends Action {
  89777. /**
  89778. * The path of the property to increment in the target.
  89779. */
  89780. propertyPath: string;
  89781. /**
  89782. * The value we should increment the property by.
  89783. */
  89784. value: any;
  89785. private _target;
  89786. private _effectiveTarget;
  89787. private _property;
  89788. /**
  89789. * Instantiate the action
  89790. * @param triggerOptions defines the trigger options
  89791. * @param target defines the object containing the property
  89792. * @param propertyPath defines the path of the property to increment in the target
  89793. * @param value defines the value value we should increment the property by
  89794. * @param condition defines the trigger related conditions
  89795. */
  89796. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89797. /** @hidden */
  89798. _prepare(): void;
  89799. /**
  89800. * Execute the action and increment the target of the value amount.
  89801. */
  89802. execute(): void;
  89803. /**
  89804. * Serializes the actions and its related information.
  89805. * @param parent defines the object to serialize in
  89806. * @returns the serialized object
  89807. */
  89808. serialize(parent: any): any;
  89809. }
  89810. /**
  89811. * This defines an action responsible to start an animation once triggered.
  89812. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89813. */
  89814. export class PlayAnimationAction extends Action {
  89815. /**
  89816. * Where the animation should start (animation frame)
  89817. */
  89818. from: number;
  89819. /**
  89820. * Where the animation should stop (animation frame)
  89821. */
  89822. to: number;
  89823. /**
  89824. * Define if the animation should loop or stop after the first play.
  89825. */
  89826. loop?: boolean;
  89827. private _target;
  89828. /**
  89829. * Instantiate the action
  89830. * @param triggerOptions defines the trigger options
  89831. * @param target defines the target animation or animation name
  89832. * @param from defines from where the animation should start (animation frame)
  89833. * @param end defines where the animation should stop (animation frame)
  89834. * @param loop defines if the animation should loop or stop after the first play
  89835. * @param condition defines the trigger related conditions
  89836. */
  89837. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  89838. /** @hidden */
  89839. _prepare(): void;
  89840. /**
  89841. * Execute the action and play the animation.
  89842. */
  89843. execute(): void;
  89844. /**
  89845. * Serializes the actions and its related information.
  89846. * @param parent defines the object to serialize in
  89847. * @returns the serialized object
  89848. */
  89849. serialize(parent: any): any;
  89850. }
  89851. /**
  89852. * This defines an action responsible to stop an animation once triggered.
  89853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89854. */
  89855. export class StopAnimationAction extends Action {
  89856. private _target;
  89857. /**
  89858. * Instantiate the action
  89859. * @param triggerOptions defines the trigger options
  89860. * @param target defines the target animation or animation name
  89861. * @param condition defines the trigger related conditions
  89862. */
  89863. constructor(triggerOptions: any, target: any, condition?: Condition);
  89864. /** @hidden */
  89865. _prepare(): void;
  89866. /**
  89867. * Execute the action and stop the animation.
  89868. */
  89869. execute(): void;
  89870. /**
  89871. * Serializes the actions and its related information.
  89872. * @param parent defines the object to serialize in
  89873. * @returns the serialized object
  89874. */
  89875. serialize(parent: any): any;
  89876. }
  89877. /**
  89878. * This defines an action responsible that does nothing once triggered.
  89879. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89880. */
  89881. export class DoNothingAction extends Action {
  89882. /**
  89883. * Instantiate the action
  89884. * @param triggerOptions defines the trigger options
  89885. * @param condition defines the trigger related conditions
  89886. */
  89887. constructor(triggerOptions?: any, condition?: Condition);
  89888. /**
  89889. * Execute the action and do nothing.
  89890. */
  89891. execute(): void;
  89892. /**
  89893. * Serializes the actions and its related information.
  89894. * @param parent defines the object to serialize in
  89895. * @returns the serialized object
  89896. */
  89897. serialize(parent: any): any;
  89898. }
  89899. /**
  89900. * This defines an action responsible to trigger several actions once triggered.
  89901. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89902. */
  89903. export class CombineAction extends Action {
  89904. /**
  89905. * The list of aggregated animations to run.
  89906. */
  89907. children: Action[];
  89908. /**
  89909. * Instantiate the action
  89910. * @param triggerOptions defines the trigger options
  89911. * @param children defines the list of aggregated animations to run
  89912. * @param condition defines the trigger related conditions
  89913. */
  89914. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89915. /** @hidden */
  89916. _prepare(): void;
  89917. /**
  89918. * Execute the action and executes all the aggregated actions.
  89919. */
  89920. execute(evt: ActionEvent): void;
  89921. /**
  89922. * Serializes the actions and its related information.
  89923. * @param parent defines the object to serialize in
  89924. * @returns the serialized object
  89925. */
  89926. serialize(parent: any): any;
  89927. }
  89928. /**
  89929. * This defines an action responsible to run code (external event) once triggered.
  89930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89931. */
  89932. export class ExecuteCodeAction extends Action {
  89933. /**
  89934. * The callback function to run.
  89935. */
  89936. func: (evt: ActionEvent) => void;
  89937. /**
  89938. * Instantiate the action
  89939. * @param triggerOptions defines the trigger options
  89940. * @param func defines the callback function to run
  89941. * @param condition defines the trigger related conditions
  89942. */
  89943. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89944. /**
  89945. * Execute the action and run the attached code.
  89946. */
  89947. execute(evt: ActionEvent): void;
  89948. }
  89949. /**
  89950. * This defines an action responsible to set the parent property of the target once triggered.
  89951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89952. */
  89953. export class SetParentAction extends Action {
  89954. private _parent;
  89955. private _target;
  89956. /**
  89957. * Instantiate the action
  89958. * @param triggerOptions defines the trigger options
  89959. * @param target defines the target containing the parent property
  89960. * @param parent defines from where the animation should start (animation frame)
  89961. * @param condition defines the trigger related conditions
  89962. */
  89963. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89964. /** @hidden */
  89965. _prepare(): void;
  89966. /**
  89967. * Execute the action and set the parent property.
  89968. */
  89969. execute(): void;
  89970. /**
  89971. * Serializes the actions and its related information.
  89972. * @param parent defines the object to serialize in
  89973. * @returns the serialized object
  89974. */
  89975. serialize(parent: any): any;
  89976. }
  89977. }
  89978. declare module BABYLON {
  89979. /**
  89980. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89981. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89983. */
  89984. export class ActionManager extends AbstractActionManager {
  89985. /**
  89986. * Nothing
  89987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89988. */
  89989. static readonly NothingTrigger: number;
  89990. /**
  89991. * On pick
  89992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89993. */
  89994. static readonly OnPickTrigger: number;
  89995. /**
  89996. * On left pick
  89997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89998. */
  89999. static readonly OnLeftPickTrigger: number;
  90000. /**
  90001. * On right pick
  90002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90003. */
  90004. static readonly OnRightPickTrigger: number;
  90005. /**
  90006. * On center pick
  90007. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90008. */
  90009. static readonly OnCenterPickTrigger: number;
  90010. /**
  90011. * On pick down
  90012. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90013. */
  90014. static readonly OnPickDownTrigger: number;
  90015. /**
  90016. * On double pick
  90017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90018. */
  90019. static readonly OnDoublePickTrigger: number;
  90020. /**
  90021. * On pick up
  90022. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90023. */
  90024. static readonly OnPickUpTrigger: number;
  90025. /**
  90026. * On pick out.
  90027. * This trigger will only be raised if you also declared a OnPickDown
  90028. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90029. */
  90030. static readonly OnPickOutTrigger: number;
  90031. /**
  90032. * On long press
  90033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90034. */
  90035. static readonly OnLongPressTrigger: number;
  90036. /**
  90037. * On pointer over
  90038. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90039. */
  90040. static readonly OnPointerOverTrigger: number;
  90041. /**
  90042. * On pointer out
  90043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90044. */
  90045. static readonly OnPointerOutTrigger: number;
  90046. /**
  90047. * On every frame
  90048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90049. */
  90050. static readonly OnEveryFrameTrigger: number;
  90051. /**
  90052. * On intersection enter
  90053. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90054. */
  90055. static readonly OnIntersectionEnterTrigger: number;
  90056. /**
  90057. * On intersection exit
  90058. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90059. */
  90060. static readonly OnIntersectionExitTrigger: number;
  90061. /**
  90062. * On key down
  90063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90064. */
  90065. static readonly OnKeyDownTrigger: number;
  90066. /**
  90067. * On key up
  90068. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90069. */
  90070. static readonly OnKeyUpTrigger: number;
  90071. private _scene;
  90072. /**
  90073. * Creates a new action manager
  90074. * @param scene defines the hosting scene
  90075. */
  90076. constructor(scene: Scene);
  90077. /**
  90078. * Releases all associated resources
  90079. */
  90080. dispose(): void;
  90081. /**
  90082. * Gets hosting scene
  90083. * @returns the hosting scene
  90084. */
  90085. getScene(): Scene;
  90086. /**
  90087. * Does this action manager handles actions of any of the given triggers
  90088. * @param triggers defines the triggers to be tested
  90089. * @return a boolean indicating whether one (or more) of the triggers is handled
  90090. */
  90091. hasSpecificTriggers(triggers: number[]): boolean;
  90092. /**
  90093. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90094. * speed.
  90095. * @param triggerA defines the trigger to be tested
  90096. * @param triggerB defines the trigger to be tested
  90097. * @return a boolean indicating whether one (or more) of the triggers is handled
  90098. */
  90099. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90100. /**
  90101. * Does this action manager handles actions of a given trigger
  90102. * @param trigger defines the trigger to be tested
  90103. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90104. * @return whether the trigger is handled
  90105. */
  90106. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90107. /**
  90108. * Does this action manager has pointer triggers
  90109. */
  90110. get hasPointerTriggers(): boolean;
  90111. /**
  90112. * Does this action manager has pick triggers
  90113. */
  90114. get hasPickTriggers(): boolean;
  90115. /**
  90116. * Registers an action to this action manager
  90117. * @param action defines the action to be registered
  90118. * @return the action amended (prepared) after registration
  90119. */
  90120. registerAction(action: IAction): Nullable<IAction>;
  90121. /**
  90122. * Unregisters an action to this action manager
  90123. * @param action defines the action to be unregistered
  90124. * @return a boolean indicating whether the action has been unregistered
  90125. */
  90126. unregisterAction(action: IAction): Boolean;
  90127. /**
  90128. * Process a specific trigger
  90129. * @param trigger defines the trigger to process
  90130. * @param evt defines the event details to be processed
  90131. */
  90132. processTrigger(trigger: number, evt?: IActionEvent): void;
  90133. /** @hidden */
  90134. _getEffectiveTarget(target: any, propertyPath: string): any;
  90135. /** @hidden */
  90136. _getProperty(propertyPath: string): string;
  90137. /**
  90138. * Serialize this manager to a JSON object
  90139. * @param name defines the property name to store this manager
  90140. * @returns a JSON representation of this manager
  90141. */
  90142. serialize(name: string): any;
  90143. /**
  90144. * Creates a new ActionManager from a JSON data
  90145. * @param parsedActions defines the JSON data to read from
  90146. * @param object defines the hosting mesh
  90147. * @param scene defines the hosting scene
  90148. */
  90149. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90150. /**
  90151. * Get a trigger name by index
  90152. * @param trigger defines the trigger index
  90153. * @returns a trigger name
  90154. */
  90155. static GetTriggerName(trigger: number): string;
  90156. }
  90157. }
  90158. declare module BABYLON {
  90159. /**
  90160. * Class used to represent a sprite
  90161. * @see https://doc.babylonjs.com/babylon101/sprites
  90162. */
  90163. export class Sprite implements IAnimatable {
  90164. /** defines the name */
  90165. name: string;
  90166. /** Gets or sets the current world position */
  90167. position: Vector3;
  90168. /** Gets or sets the main color */
  90169. color: Color4;
  90170. /** Gets or sets the width */
  90171. width: number;
  90172. /** Gets or sets the height */
  90173. height: number;
  90174. /** Gets or sets rotation angle */
  90175. angle: number;
  90176. /** Gets or sets the cell index in the sprite sheet */
  90177. cellIndex: number;
  90178. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90179. cellRef: string;
  90180. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90181. invertU: boolean;
  90182. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90183. invertV: boolean;
  90184. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90185. disposeWhenFinishedAnimating: boolean;
  90186. /** Gets the list of attached animations */
  90187. animations: Nullable<Array<Animation>>;
  90188. /** Gets or sets a boolean indicating if the sprite can be picked */
  90189. isPickable: boolean;
  90190. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90191. useAlphaForPicking: boolean;
  90192. /** @hidden */
  90193. _xOffset: number;
  90194. /** @hidden */
  90195. _yOffset: number;
  90196. /** @hidden */
  90197. _xSize: number;
  90198. /** @hidden */
  90199. _ySize: number;
  90200. /**
  90201. * Gets or sets the associated action manager
  90202. */
  90203. actionManager: Nullable<ActionManager>;
  90204. /**
  90205. * An event triggered when the control has been disposed
  90206. */
  90207. onDisposeObservable: Observable<Sprite>;
  90208. private _animationStarted;
  90209. private _loopAnimation;
  90210. private _fromIndex;
  90211. private _toIndex;
  90212. private _delay;
  90213. private _direction;
  90214. private _manager;
  90215. private _time;
  90216. private _onAnimationEnd;
  90217. /**
  90218. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90219. */
  90220. isVisible: boolean;
  90221. /**
  90222. * Gets or sets the sprite size
  90223. */
  90224. get size(): number;
  90225. set size(value: number);
  90226. /**
  90227. * Returns a boolean indicating if the animation is started
  90228. */
  90229. get animationStarted(): boolean;
  90230. /**
  90231. * Gets or sets the unique id of the sprite
  90232. */
  90233. uniqueId: number;
  90234. /**
  90235. * Gets the manager of this sprite
  90236. */
  90237. get manager(): ISpriteManager;
  90238. /**
  90239. * Creates a new Sprite
  90240. * @param name defines the name
  90241. * @param manager defines the manager
  90242. */
  90243. constructor(
  90244. /** defines the name */
  90245. name: string, manager: ISpriteManager);
  90246. /**
  90247. * Returns the string "Sprite"
  90248. * @returns "Sprite"
  90249. */
  90250. getClassName(): string;
  90251. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90252. get fromIndex(): number;
  90253. set fromIndex(value: number);
  90254. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90255. get toIndex(): number;
  90256. set toIndex(value: number);
  90257. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90258. get loopAnimation(): boolean;
  90259. set loopAnimation(value: boolean);
  90260. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90261. get delay(): number;
  90262. set delay(value: number);
  90263. /**
  90264. * Starts an animation
  90265. * @param from defines the initial key
  90266. * @param to defines the end key
  90267. * @param loop defines if the animation must loop
  90268. * @param delay defines the start delay (in ms)
  90269. * @param onAnimationEnd defines a callback to call when animation ends
  90270. */
  90271. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90272. /** Stops current animation (if any) */
  90273. stopAnimation(): void;
  90274. /** @hidden */
  90275. _animate(deltaTime: number): void;
  90276. /** Release associated resources */
  90277. dispose(): void;
  90278. /**
  90279. * Serializes the sprite to a JSON object
  90280. * @returns the JSON object
  90281. */
  90282. serialize(): any;
  90283. /**
  90284. * Parses a JSON object to create a new sprite
  90285. * @param parsedSprite The JSON object to parse
  90286. * @param manager defines the hosting manager
  90287. * @returns the new sprite
  90288. */
  90289. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90290. }
  90291. }
  90292. declare module BABYLON {
  90293. /**
  90294. * Information about the result of picking within a scene
  90295. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90296. */
  90297. export class PickingInfo {
  90298. /** @hidden */
  90299. _pickingUnavailable: boolean;
  90300. /**
  90301. * If the pick collided with an object
  90302. */
  90303. hit: boolean;
  90304. /**
  90305. * Distance away where the pick collided
  90306. */
  90307. distance: number;
  90308. /**
  90309. * The location of pick collision
  90310. */
  90311. pickedPoint: Nullable<Vector3>;
  90312. /**
  90313. * The mesh corresponding the the pick collision
  90314. */
  90315. pickedMesh: Nullable<AbstractMesh>;
  90316. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90317. bu: number;
  90318. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90319. bv: number;
  90320. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90321. faceId: number;
  90322. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90323. subMeshFaceId: number;
  90324. /** Id of the the submesh that was picked */
  90325. subMeshId: number;
  90326. /** If a sprite was picked, this will be the sprite the pick collided with */
  90327. pickedSprite: Nullable<Sprite>;
  90328. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90329. thinInstanceIndex: number;
  90330. /**
  90331. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90332. */
  90333. originMesh: Nullable<AbstractMesh>;
  90334. /**
  90335. * The ray that was used to perform the picking.
  90336. */
  90337. ray: Nullable<Ray>;
  90338. /**
  90339. * Gets the normal correspodning to the face the pick collided with
  90340. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90341. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90342. * @returns The normal correspodning to the face the pick collided with
  90343. */
  90344. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90345. /**
  90346. * Gets the texture coordinates of where the pick occured
  90347. * @returns the vector containing the coordnates of the texture
  90348. */
  90349. getTextureCoordinates(): Nullable<Vector2>;
  90350. }
  90351. }
  90352. declare module BABYLON {
  90353. /**
  90354. * Class representing a ray with position and direction
  90355. */
  90356. export class Ray {
  90357. /** origin point */
  90358. origin: Vector3;
  90359. /** direction */
  90360. direction: Vector3;
  90361. /** length of the ray */
  90362. length: number;
  90363. private static readonly _TmpVector3;
  90364. private _tmpRay;
  90365. /**
  90366. * Creates a new ray
  90367. * @param origin origin point
  90368. * @param direction direction
  90369. * @param length length of the ray
  90370. */
  90371. constructor(
  90372. /** origin point */
  90373. origin: Vector3,
  90374. /** direction */
  90375. direction: Vector3,
  90376. /** length of the ray */
  90377. length?: number);
  90378. /**
  90379. * Checks if the ray intersects a box
  90380. * This does not account for the ray lenght by design to improve perfs.
  90381. * @param minimum bound of the box
  90382. * @param maximum bound of the box
  90383. * @param intersectionTreshold extra extend to be added to the box in all direction
  90384. * @returns if the box was hit
  90385. */
  90386. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90387. /**
  90388. * Checks if the ray intersects a box
  90389. * This does not account for the ray lenght by design to improve perfs.
  90390. * @param box the bounding box to check
  90391. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90392. * @returns if the box was hit
  90393. */
  90394. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90395. /**
  90396. * If the ray hits a sphere
  90397. * @param sphere the bounding sphere to check
  90398. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90399. * @returns true if it hits the sphere
  90400. */
  90401. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90402. /**
  90403. * If the ray hits a triange
  90404. * @param vertex0 triangle vertex
  90405. * @param vertex1 triangle vertex
  90406. * @param vertex2 triangle vertex
  90407. * @returns intersection information if hit
  90408. */
  90409. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90410. /**
  90411. * Checks if ray intersects a plane
  90412. * @param plane the plane to check
  90413. * @returns the distance away it was hit
  90414. */
  90415. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90416. /**
  90417. * Calculate the intercept of a ray on a given axis
  90418. * @param axis to check 'x' | 'y' | 'z'
  90419. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90420. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90421. */
  90422. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90423. /**
  90424. * Checks if ray intersects a mesh
  90425. * @param mesh the mesh to check
  90426. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90427. * @returns picking info of the intersecton
  90428. */
  90429. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90430. /**
  90431. * Checks if ray intersects a mesh
  90432. * @param meshes the meshes to check
  90433. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90434. * @param results array to store result in
  90435. * @returns Array of picking infos
  90436. */
  90437. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90438. private _comparePickingInfo;
  90439. private static smallnum;
  90440. private static rayl;
  90441. /**
  90442. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90443. * @param sega the first point of the segment to test the intersection against
  90444. * @param segb the second point of the segment to test the intersection against
  90445. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90446. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90447. */
  90448. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90449. /**
  90450. * Update the ray from viewport position
  90451. * @param x position
  90452. * @param y y position
  90453. * @param viewportWidth viewport width
  90454. * @param viewportHeight viewport height
  90455. * @param world world matrix
  90456. * @param view view matrix
  90457. * @param projection projection matrix
  90458. * @returns this ray updated
  90459. */
  90460. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90461. /**
  90462. * Creates a ray with origin and direction of 0,0,0
  90463. * @returns the new ray
  90464. */
  90465. static Zero(): Ray;
  90466. /**
  90467. * Creates a new ray from screen space and viewport
  90468. * @param x position
  90469. * @param y y position
  90470. * @param viewportWidth viewport width
  90471. * @param viewportHeight viewport height
  90472. * @param world world matrix
  90473. * @param view view matrix
  90474. * @param projection projection matrix
  90475. * @returns new ray
  90476. */
  90477. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90478. /**
  90479. * 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
  90480. * transformed to the given world matrix.
  90481. * @param origin The origin point
  90482. * @param end The end point
  90483. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90484. * @returns the new ray
  90485. */
  90486. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90487. /**
  90488. * Transforms a ray by a matrix
  90489. * @param ray ray to transform
  90490. * @param matrix matrix to apply
  90491. * @returns the resulting new ray
  90492. */
  90493. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90494. /**
  90495. * Transforms a ray by a matrix
  90496. * @param ray ray to transform
  90497. * @param matrix matrix to apply
  90498. * @param result ray to store result in
  90499. */
  90500. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90501. /**
  90502. * Unproject a ray from screen space to object space
  90503. * @param sourceX defines the screen space x coordinate to use
  90504. * @param sourceY defines the screen space y coordinate to use
  90505. * @param viewportWidth defines the current width of the viewport
  90506. * @param viewportHeight defines the current height of the viewport
  90507. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90508. * @param view defines the view matrix to use
  90509. * @param projection defines the projection matrix to use
  90510. */
  90511. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90512. }
  90513. /**
  90514. * Type used to define predicate used to select faces when a mesh intersection is detected
  90515. */
  90516. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90517. interface Scene {
  90518. /** @hidden */
  90519. _tempPickingRay: Nullable<Ray>;
  90520. /** @hidden */
  90521. _cachedRayForTransform: Ray;
  90522. /** @hidden */
  90523. _pickWithRayInverseMatrix: Matrix;
  90524. /** @hidden */
  90525. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90526. /** @hidden */
  90527. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90528. /** @hidden */
  90529. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90530. }
  90531. }
  90532. declare module BABYLON {
  90533. /**
  90534. * Groups all the scene component constants in one place to ease maintenance.
  90535. * @hidden
  90536. */
  90537. export class SceneComponentConstants {
  90538. static readonly NAME_EFFECTLAYER: string;
  90539. static readonly NAME_LAYER: string;
  90540. static readonly NAME_LENSFLARESYSTEM: string;
  90541. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90542. static readonly NAME_PARTICLESYSTEM: string;
  90543. static readonly NAME_GAMEPAD: string;
  90544. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90545. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90546. static readonly NAME_PREPASSRENDERER: string;
  90547. static readonly NAME_DEPTHRENDERER: string;
  90548. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90549. static readonly NAME_SPRITE: string;
  90550. static readonly NAME_OUTLINERENDERER: string;
  90551. static readonly NAME_PROCEDURALTEXTURE: string;
  90552. static readonly NAME_SHADOWGENERATOR: string;
  90553. static readonly NAME_OCTREE: string;
  90554. static readonly NAME_PHYSICSENGINE: string;
  90555. static readonly NAME_AUDIO: string;
  90556. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90557. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90558. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90559. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90560. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90561. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90562. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90563. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90564. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90565. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90566. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90567. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90568. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90569. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90570. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90571. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90572. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90573. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90574. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90575. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90576. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90577. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90578. static readonly STEP_AFTERRENDER_AUDIO: number;
  90579. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90580. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90581. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90582. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90583. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90584. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90585. static readonly STEP_POINTERMOVE_SPRITE: number;
  90586. static readonly STEP_POINTERDOWN_SPRITE: number;
  90587. static readonly STEP_POINTERUP_SPRITE: number;
  90588. }
  90589. /**
  90590. * This represents a scene component.
  90591. *
  90592. * This is used to decouple the dependency the scene is having on the different workloads like
  90593. * layers, post processes...
  90594. */
  90595. export interface ISceneComponent {
  90596. /**
  90597. * The name of the component. Each component must have a unique name.
  90598. */
  90599. name: string;
  90600. /**
  90601. * The scene the component belongs to.
  90602. */
  90603. scene: Scene;
  90604. /**
  90605. * Register the component to one instance of a scene.
  90606. */
  90607. register(): void;
  90608. /**
  90609. * Rebuilds the elements related to this component in case of
  90610. * context lost for instance.
  90611. */
  90612. rebuild(): void;
  90613. /**
  90614. * Disposes the component and the associated ressources.
  90615. */
  90616. dispose(): void;
  90617. }
  90618. /**
  90619. * This represents a SERIALIZABLE scene component.
  90620. *
  90621. * This extends Scene Component to add Serialization methods on top.
  90622. */
  90623. export interface ISceneSerializableComponent extends ISceneComponent {
  90624. /**
  90625. * Adds all the elements from the container to the scene
  90626. * @param container the container holding the elements
  90627. */
  90628. addFromContainer(container: AbstractScene): void;
  90629. /**
  90630. * Removes all the elements in the container from the scene
  90631. * @param container contains the elements to remove
  90632. * @param dispose if the removed element should be disposed (default: false)
  90633. */
  90634. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  90635. /**
  90636. * Serializes the component data to the specified json object
  90637. * @param serializationObject The object to serialize to
  90638. */
  90639. serialize(serializationObject: any): void;
  90640. }
  90641. /**
  90642. * Strong typing of a Mesh related stage step action
  90643. */
  90644. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  90645. /**
  90646. * Strong typing of a Evaluate Sub Mesh related stage step action
  90647. */
  90648. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  90649. /**
  90650. * Strong typing of a Active Mesh related stage step action
  90651. */
  90652. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  90653. /**
  90654. * Strong typing of a Camera related stage step action
  90655. */
  90656. export type CameraStageAction = (camera: Camera) => void;
  90657. /**
  90658. * Strong typing of a Camera Frame buffer related stage step action
  90659. */
  90660. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  90661. /**
  90662. * Strong typing of a Render Target related stage step action
  90663. */
  90664. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  90665. /**
  90666. * Strong typing of a RenderingGroup related stage step action
  90667. */
  90668. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  90669. /**
  90670. * Strong typing of a Mesh Render related stage step action
  90671. */
  90672. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  90673. /**
  90674. * Strong typing of a simple stage step action
  90675. */
  90676. export type SimpleStageAction = () => void;
  90677. /**
  90678. * Strong typing of a render target action.
  90679. */
  90680. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  90681. /**
  90682. * Strong typing of a pointer move action.
  90683. */
  90684. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  90685. /**
  90686. * Strong typing of a pointer up/down action.
  90687. */
  90688. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  90689. /**
  90690. * Representation of a stage in the scene (Basically a list of ordered steps)
  90691. * @hidden
  90692. */
  90693. export class Stage<T extends Function> extends Array<{
  90694. index: number;
  90695. component: ISceneComponent;
  90696. action: T;
  90697. }> {
  90698. /**
  90699. * Hide ctor from the rest of the world.
  90700. * @param items The items to add.
  90701. */
  90702. private constructor();
  90703. /**
  90704. * Creates a new Stage.
  90705. * @returns A new instance of a Stage
  90706. */
  90707. static Create<T extends Function>(): Stage<T>;
  90708. /**
  90709. * Registers a step in an ordered way in the targeted stage.
  90710. * @param index Defines the position to register the step in
  90711. * @param component Defines the component attached to the step
  90712. * @param action Defines the action to launch during the step
  90713. */
  90714. registerStep(index: number, component: ISceneComponent, action: T): void;
  90715. /**
  90716. * Clears all the steps from the stage.
  90717. */
  90718. clear(): void;
  90719. }
  90720. }
  90721. declare module BABYLON {
  90722. interface Scene {
  90723. /** @hidden */
  90724. _pointerOverSprite: Nullable<Sprite>;
  90725. /** @hidden */
  90726. _pickedDownSprite: Nullable<Sprite>;
  90727. /** @hidden */
  90728. _tempSpritePickingRay: Nullable<Ray>;
  90729. /**
  90730. * All of the sprite managers added to this scene
  90731. * @see https://doc.babylonjs.com/babylon101/sprites
  90732. */
  90733. spriteManagers: Array<ISpriteManager>;
  90734. /**
  90735. * An event triggered when sprites rendering is about to start
  90736. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90737. */
  90738. onBeforeSpritesRenderingObservable: Observable<Scene>;
  90739. /**
  90740. * An event triggered when sprites rendering is done
  90741. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90742. */
  90743. onAfterSpritesRenderingObservable: Observable<Scene>;
  90744. /** @hidden */
  90745. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90746. /** Launch a ray to try to pick a sprite in the scene
  90747. * @param x position on screen
  90748. * @param y position on screen
  90749. * @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
  90750. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90751. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90752. * @returns a PickingInfo
  90753. */
  90754. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90755. /** Use the given ray to pick a sprite in the scene
  90756. * @param ray The ray (in world space) to use to pick meshes
  90757. * @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
  90758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90759. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90760. * @returns a PickingInfo
  90761. */
  90762. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90763. /** @hidden */
  90764. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90765. /** Launch a ray to try to pick sprites in the scene
  90766. * @param x position on screen
  90767. * @param y position on screen
  90768. * @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
  90769. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90770. * @returns a PickingInfo array
  90771. */
  90772. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90773. /** Use the given ray to pick sprites in the scene
  90774. * @param ray The ray (in world space) to use to pick meshes
  90775. * @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
  90776. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90777. * @returns a PickingInfo array
  90778. */
  90779. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90780. /**
  90781. * Force the sprite under the pointer
  90782. * @param sprite defines the sprite to use
  90783. */
  90784. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  90785. /**
  90786. * Gets the sprite under the pointer
  90787. * @returns a Sprite or null if no sprite is under the pointer
  90788. */
  90789. getPointerOverSprite(): Nullable<Sprite>;
  90790. }
  90791. /**
  90792. * Defines the sprite scene component responsible to manage sprites
  90793. * in a given scene.
  90794. */
  90795. export class SpriteSceneComponent implements ISceneComponent {
  90796. /**
  90797. * The component name helpfull to identify the component in the list of scene components.
  90798. */
  90799. readonly name: string;
  90800. /**
  90801. * The scene the component belongs to.
  90802. */
  90803. scene: Scene;
  90804. /** @hidden */
  90805. private _spritePredicate;
  90806. /**
  90807. * Creates a new instance of the component for the given scene
  90808. * @param scene Defines the scene to register the component in
  90809. */
  90810. constructor(scene: Scene);
  90811. /**
  90812. * Registers the component in a given scene
  90813. */
  90814. register(): void;
  90815. /**
  90816. * Rebuilds the elements related to this component in case of
  90817. * context lost for instance.
  90818. */
  90819. rebuild(): void;
  90820. /**
  90821. * Disposes the component and the associated ressources.
  90822. */
  90823. dispose(): void;
  90824. private _pickSpriteButKeepRay;
  90825. private _pointerMove;
  90826. private _pointerDown;
  90827. private _pointerUp;
  90828. }
  90829. }
  90830. declare module BABYLON {
  90831. /** @hidden */
  90832. export var fogFragmentDeclaration: {
  90833. name: string;
  90834. shader: string;
  90835. };
  90836. }
  90837. declare module BABYLON {
  90838. /** @hidden */
  90839. export var fogFragment: {
  90840. name: string;
  90841. shader: string;
  90842. };
  90843. }
  90844. declare module BABYLON {
  90845. /** @hidden */
  90846. export var spritesPixelShader: {
  90847. name: string;
  90848. shader: string;
  90849. };
  90850. }
  90851. declare module BABYLON {
  90852. /** @hidden */
  90853. export var fogVertexDeclaration: {
  90854. name: string;
  90855. shader: string;
  90856. };
  90857. }
  90858. declare module BABYLON {
  90859. /** @hidden */
  90860. export var spritesVertexShader: {
  90861. name: string;
  90862. shader: string;
  90863. };
  90864. }
  90865. declare module BABYLON {
  90866. /**
  90867. * Defines the minimum interface to fullfil in order to be a sprite manager.
  90868. */
  90869. export interface ISpriteManager extends IDisposable {
  90870. /**
  90871. * Gets manager's name
  90872. */
  90873. name: string;
  90874. /**
  90875. * Restricts the camera to viewing objects with the same layerMask.
  90876. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  90877. */
  90878. layerMask: number;
  90879. /**
  90880. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90881. */
  90882. isPickable: boolean;
  90883. /**
  90884. * Gets the hosting scene
  90885. */
  90886. scene: Scene;
  90887. /**
  90888. * Specifies the rendering group id for this mesh (0 by default)
  90889. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90890. */
  90891. renderingGroupId: number;
  90892. /**
  90893. * Defines the list of sprites managed by the manager.
  90894. */
  90895. sprites: Array<Sprite>;
  90896. /**
  90897. * Gets or sets the spritesheet texture
  90898. */
  90899. texture: Texture;
  90900. /** Defines the default width of a cell in the spritesheet */
  90901. cellWidth: number;
  90902. /** Defines the default height of a cell in the spritesheet */
  90903. cellHeight: number;
  90904. /**
  90905. * Tests the intersection of a sprite with a specific ray.
  90906. * @param ray The ray we are sending to test the collision
  90907. * @param camera The camera space we are sending rays in
  90908. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90909. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90910. * @returns picking info or null.
  90911. */
  90912. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90913. /**
  90914. * Intersects the sprites with a ray
  90915. * @param ray defines the ray to intersect with
  90916. * @param camera defines the current active camera
  90917. * @param predicate defines a predicate used to select candidate sprites
  90918. * @returns null if no hit or a PickingInfo array
  90919. */
  90920. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90921. /**
  90922. * Renders the list of sprites on screen.
  90923. */
  90924. render(): void;
  90925. }
  90926. /**
  90927. * Class used to manage multiple sprites on the same spritesheet
  90928. * @see https://doc.babylonjs.com/babylon101/sprites
  90929. */
  90930. export class SpriteManager implements ISpriteManager {
  90931. /** defines the manager's name */
  90932. name: string;
  90933. /** Define the Url to load snippets */
  90934. static SnippetUrl: string;
  90935. /** Snippet ID if the manager was created from the snippet server */
  90936. snippetId: string;
  90937. /** Gets the list of sprites */
  90938. sprites: Sprite[];
  90939. /** Gets or sets the rendering group id (0 by default) */
  90940. renderingGroupId: number;
  90941. /** Gets or sets camera layer mask */
  90942. layerMask: number;
  90943. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90944. fogEnabled: boolean;
  90945. /** Gets or sets a boolean indicating if the sprites are pickable */
  90946. isPickable: boolean;
  90947. /** Defines the default width of a cell in the spritesheet */
  90948. cellWidth: number;
  90949. /** Defines the default height of a cell in the spritesheet */
  90950. cellHeight: number;
  90951. /** Associative array from JSON sprite data file */
  90952. private _cellData;
  90953. /** Array of sprite names from JSON sprite data file */
  90954. private _spriteMap;
  90955. /** True when packed cell data from JSON file is ready*/
  90956. private _packedAndReady;
  90957. private _textureContent;
  90958. private _useInstancing;
  90959. /**
  90960. * An event triggered when the manager is disposed.
  90961. */
  90962. onDisposeObservable: Observable<SpriteManager>;
  90963. private _onDisposeObserver;
  90964. /**
  90965. * Callback called when the manager is disposed
  90966. */
  90967. set onDispose(callback: () => void);
  90968. private _capacity;
  90969. private _fromPacked;
  90970. private _spriteTexture;
  90971. private _epsilon;
  90972. private _scene;
  90973. private _vertexData;
  90974. private _buffer;
  90975. private _vertexBuffers;
  90976. private _spriteBuffer;
  90977. private _indexBuffer;
  90978. private _effectBase;
  90979. private _effectFog;
  90980. private _vertexBufferSize;
  90981. /**
  90982. * Gets or sets the unique id of the sprite
  90983. */
  90984. uniqueId: number;
  90985. /**
  90986. * Gets the array of sprites
  90987. */
  90988. get children(): Sprite[];
  90989. /**
  90990. * Gets the hosting scene
  90991. */
  90992. get scene(): Scene;
  90993. /**
  90994. * Gets the capacity of the manager
  90995. */
  90996. get capacity(): number;
  90997. /**
  90998. * Gets or sets the spritesheet texture
  90999. */
  91000. get texture(): Texture;
  91001. set texture(value: Texture);
  91002. private _blendMode;
  91003. /**
  91004. * Blend mode use to render the particle, it can be any of
  91005. * the static Constants.ALPHA_x properties provided in this class.
  91006. * Default value is Constants.ALPHA_COMBINE
  91007. */
  91008. get blendMode(): number;
  91009. set blendMode(blendMode: number);
  91010. /** Disables writing to the depth buffer when rendering the sprites.
  91011. * It can be handy to disable depth writing when using textures without alpha channel
  91012. * and setting some specific blend modes.
  91013. */
  91014. disableDepthWrite: boolean;
  91015. /**
  91016. * Creates a new sprite manager
  91017. * @param name defines the manager's name
  91018. * @param imgUrl defines the sprite sheet url
  91019. * @param capacity defines the maximum allowed number of sprites
  91020. * @param cellSize defines the size of a sprite cell
  91021. * @param scene defines the hosting scene
  91022. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91023. * @param samplingMode defines the smapling mode to use with spritesheet
  91024. * @param fromPacked set to false; do not alter
  91025. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91026. */
  91027. constructor(
  91028. /** defines the manager's name */
  91029. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91030. /**
  91031. * Returns the string "SpriteManager"
  91032. * @returns "SpriteManager"
  91033. */
  91034. getClassName(): string;
  91035. private _makePacked;
  91036. private _appendSpriteVertex;
  91037. private _checkTextureAlpha;
  91038. /**
  91039. * Intersects the sprites with a ray
  91040. * @param ray defines the ray to intersect with
  91041. * @param camera defines the current active camera
  91042. * @param predicate defines a predicate used to select candidate sprites
  91043. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91044. * @returns null if no hit or a PickingInfo
  91045. */
  91046. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91047. /**
  91048. * Intersects the sprites with a ray
  91049. * @param ray defines the ray to intersect with
  91050. * @param camera defines the current active camera
  91051. * @param predicate defines a predicate used to select candidate sprites
  91052. * @returns null if no hit or a PickingInfo array
  91053. */
  91054. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91055. /**
  91056. * Render all child sprites
  91057. */
  91058. render(): void;
  91059. /**
  91060. * Release associated resources
  91061. */
  91062. dispose(): void;
  91063. /**
  91064. * Serializes the sprite manager to a JSON object
  91065. * @param serializeTexture defines if the texture must be serialized as well
  91066. * @returns the JSON object
  91067. */
  91068. serialize(serializeTexture?: boolean): any;
  91069. /**
  91070. * Parses a JSON object to create a new sprite manager.
  91071. * @param parsedManager The JSON object to parse
  91072. * @param scene The scene to create the sprite managerin
  91073. * @param rootUrl The root url to use to load external dependencies like texture
  91074. * @returns the new sprite manager
  91075. */
  91076. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91077. /**
  91078. * Creates a sprite manager from a snippet saved in a remote file
  91079. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91080. * @param url defines the url to load from
  91081. * @param scene defines the hosting scene
  91082. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91083. * @returns a promise that will resolve to the new sprite manager
  91084. */
  91085. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91086. /**
  91087. * Creates a sprite manager from a snippet saved by the sprite editor
  91088. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91089. * @param scene defines the hosting scene
  91090. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91091. * @returns a promise that will resolve to the new sprite manager
  91092. */
  91093. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91094. }
  91095. }
  91096. declare module BABYLON {
  91097. /** Interface used by value gradients (color, factor, ...) */
  91098. export interface IValueGradient {
  91099. /**
  91100. * Gets or sets the gradient value (between 0 and 1)
  91101. */
  91102. gradient: number;
  91103. }
  91104. /** Class used to store color4 gradient */
  91105. export class ColorGradient implements IValueGradient {
  91106. /**
  91107. * Gets or sets the gradient value (between 0 and 1)
  91108. */
  91109. gradient: number;
  91110. /**
  91111. * Gets or sets first associated color
  91112. */
  91113. color1: Color4;
  91114. /**
  91115. * Gets or sets second associated color
  91116. */
  91117. color2?: Color4 | undefined;
  91118. /**
  91119. * Creates a new color4 gradient
  91120. * @param gradient gets or sets the gradient value (between 0 and 1)
  91121. * @param color1 gets or sets first associated color
  91122. * @param color2 gets or sets first second color
  91123. */
  91124. constructor(
  91125. /**
  91126. * Gets or sets the gradient value (between 0 and 1)
  91127. */
  91128. gradient: number,
  91129. /**
  91130. * Gets or sets first associated color
  91131. */
  91132. color1: Color4,
  91133. /**
  91134. * Gets or sets second associated color
  91135. */
  91136. color2?: Color4 | undefined);
  91137. /**
  91138. * Will get a color picked randomly between color1 and color2.
  91139. * If color2 is undefined then color1 will be used
  91140. * @param result defines the target Color4 to store the result in
  91141. */
  91142. getColorToRef(result: Color4): void;
  91143. }
  91144. /** Class used to store color 3 gradient */
  91145. export class Color3Gradient implements IValueGradient {
  91146. /**
  91147. * Gets or sets the gradient value (between 0 and 1)
  91148. */
  91149. gradient: number;
  91150. /**
  91151. * Gets or sets the associated color
  91152. */
  91153. color: Color3;
  91154. /**
  91155. * Creates a new color3 gradient
  91156. * @param gradient gets or sets the gradient value (between 0 and 1)
  91157. * @param color gets or sets associated color
  91158. */
  91159. constructor(
  91160. /**
  91161. * Gets or sets the gradient value (between 0 and 1)
  91162. */
  91163. gradient: number,
  91164. /**
  91165. * Gets or sets the associated color
  91166. */
  91167. color: Color3);
  91168. }
  91169. /** Class used to store factor gradient */
  91170. export class FactorGradient implements IValueGradient {
  91171. /**
  91172. * Gets or sets the gradient value (between 0 and 1)
  91173. */
  91174. gradient: number;
  91175. /**
  91176. * Gets or sets first associated factor
  91177. */
  91178. factor1: number;
  91179. /**
  91180. * Gets or sets second associated factor
  91181. */
  91182. factor2?: number | undefined;
  91183. /**
  91184. * Creates a new factor gradient
  91185. * @param gradient gets or sets the gradient value (between 0 and 1)
  91186. * @param factor1 gets or sets first associated factor
  91187. * @param factor2 gets or sets second associated factor
  91188. */
  91189. constructor(
  91190. /**
  91191. * Gets or sets the gradient value (between 0 and 1)
  91192. */
  91193. gradient: number,
  91194. /**
  91195. * Gets or sets first associated factor
  91196. */
  91197. factor1: number,
  91198. /**
  91199. * Gets or sets second associated factor
  91200. */
  91201. factor2?: number | undefined);
  91202. /**
  91203. * Will get a number picked randomly between factor1 and factor2.
  91204. * If factor2 is undefined then factor1 will be used
  91205. * @returns the picked number
  91206. */
  91207. getFactor(): number;
  91208. }
  91209. /**
  91210. * Helper used to simplify some generic gradient tasks
  91211. */
  91212. export class GradientHelper {
  91213. /**
  91214. * Gets the current gradient from an array of IValueGradient
  91215. * @param ratio defines the current ratio to get
  91216. * @param gradients defines the array of IValueGradient
  91217. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91218. */
  91219. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91220. }
  91221. }
  91222. declare module BABYLON {
  91223. interface ThinEngine {
  91224. /**
  91225. * Creates a raw texture
  91226. * @param data defines the data to store in the texture
  91227. * @param width defines the width of the texture
  91228. * @param height defines the height of the texture
  91229. * @param format defines the format of the data
  91230. * @param generateMipMaps defines if the engine should generate the mip levels
  91231. * @param invertY defines if data must be stored with Y axis inverted
  91232. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91233. * @param compression defines the compression used (null by default)
  91234. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91235. * @returns the raw texture inside an InternalTexture
  91236. */
  91237. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91238. /**
  91239. * Update a raw texture
  91240. * @param texture defines the texture to update
  91241. * @param data defines the data to store in the texture
  91242. * @param format defines the format of the data
  91243. * @param invertY defines if data must be stored with Y axis inverted
  91244. */
  91245. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91246. /**
  91247. * Update a raw texture
  91248. * @param texture defines the texture to update
  91249. * @param data defines the data to store in the texture
  91250. * @param format defines the format of the data
  91251. * @param invertY defines if data must be stored with Y axis inverted
  91252. * @param compression defines the compression used (null by default)
  91253. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91254. */
  91255. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91256. /**
  91257. * Creates a new raw cube texture
  91258. * @param data defines the array of data to use to create each face
  91259. * @param size defines the size of the textures
  91260. * @param format defines the format of the data
  91261. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91262. * @param generateMipMaps defines if the engine should generate the mip levels
  91263. * @param invertY defines if data must be stored with Y axis inverted
  91264. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91265. * @param compression defines the compression used (null by default)
  91266. * @returns the cube texture as an InternalTexture
  91267. */
  91268. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91269. /**
  91270. * Update a raw cube texture
  91271. * @param texture defines the texture to udpdate
  91272. * @param data defines the data to store
  91273. * @param format defines the data format
  91274. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91275. * @param invertY defines if data must be stored with Y axis inverted
  91276. */
  91277. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91278. /**
  91279. * Update a raw cube texture
  91280. * @param texture defines the texture to udpdate
  91281. * @param data defines the data to store
  91282. * @param format defines the data format
  91283. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91284. * @param invertY defines if data must be stored with Y axis inverted
  91285. * @param compression defines the compression used (null by default)
  91286. */
  91287. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91288. /**
  91289. * Update a raw cube texture
  91290. * @param texture defines the texture to udpdate
  91291. * @param data defines the data to store
  91292. * @param format defines the data format
  91293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91294. * @param invertY defines if data must be stored with Y axis inverted
  91295. * @param compression defines the compression used (null by default)
  91296. * @param level defines which level of the texture to update
  91297. */
  91298. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91299. /**
  91300. * Creates a new raw cube texture from a specified url
  91301. * @param url defines the url where the data is located
  91302. * @param scene defines the current scene
  91303. * @param size defines the size of the textures
  91304. * @param format defines the format of the data
  91305. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91306. * @param noMipmap defines if the engine should avoid generating the mip levels
  91307. * @param callback defines a callback used to extract texture data from loaded data
  91308. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91309. * @param onLoad defines a callback called when texture is loaded
  91310. * @param onError defines a callback called if there is an error
  91311. * @returns the cube texture as an InternalTexture
  91312. */
  91313. 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;
  91314. /**
  91315. * Creates a new raw cube texture from a specified url
  91316. * @param url defines the url where the data is located
  91317. * @param scene defines the current scene
  91318. * @param size defines the size of the textures
  91319. * @param format defines the format of the data
  91320. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91321. * @param noMipmap defines if the engine should avoid generating the mip levels
  91322. * @param callback defines a callback used to extract texture data from loaded data
  91323. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91324. * @param onLoad defines a callback called when texture is loaded
  91325. * @param onError defines a callback called if there is an error
  91326. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91327. * @param invertY defines if data must be stored with Y axis inverted
  91328. * @returns the cube texture as an InternalTexture
  91329. */
  91330. 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;
  91331. /**
  91332. * Creates a new raw 3D texture
  91333. * @param data defines the data used to create the texture
  91334. * @param width defines the width of the texture
  91335. * @param height defines the height of the texture
  91336. * @param depth defines the depth of the texture
  91337. * @param format defines the format of the texture
  91338. * @param generateMipMaps defines if the engine must generate mip levels
  91339. * @param invertY defines if data must be stored with Y axis inverted
  91340. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91341. * @param compression defines the compressed used (can be null)
  91342. * @param textureType defines the compressed used (can be null)
  91343. * @returns a new raw 3D texture (stored in an InternalTexture)
  91344. */
  91345. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91346. /**
  91347. * Update a raw 3D texture
  91348. * @param texture defines the texture to update
  91349. * @param data defines the data to store
  91350. * @param format defines the data format
  91351. * @param invertY defines if data must be stored with Y axis inverted
  91352. */
  91353. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91354. /**
  91355. * Update a raw 3D texture
  91356. * @param texture defines the texture to update
  91357. * @param data defines the data to store
  91358. * @param format defines the data format
  91359. * @param invertY defines if data must be stored with Y axis inverted
  91360. * @param compression defines the used compression (can be null)
  91361. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91362. */
  91363. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91364. /**
  91365. * Creates a new raw 2D array texture
  91366. * @param data defines the data used to create the texture
  91367. * @param width defines the width of the texture
  91368. * @param height defines the height of the texture
  91369. * @param depth defines the number of layers of the texture
  91370. * @param format defines the format of the texture
  91371. * @param generateMipMaps defines if the engine must generate mip levels
  91372. * @param invertY defines if data must be stored with Y axis inverted
  91373. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91374. * @param compression defines the compressed used (can be null)
  91375. * @param textureType defines the compressed used (can be null)
  91376. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91377. */
  91378. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91379. /**
  91380. * Update a raw 2D array texture
  91381. * @param texture defines the texture to update
  91382. * @param data defines the data to store
  91383. * @param format defines the data format
  91384. * @param invertY defines if data must be stored with Y axis inverted
  91385. */
  91386. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91387. /**
  91388. * Update a raw 2D array texture
  91389. * @param texture defines the texture to update
  91390. * @param data defines the data to store
  91391. * @param format defines the data format
  91392. * @param invertY defines if data must be stored with Y axis inverted
  91393. * @param compression defines the used compression (can be null)
  91394. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91395. */
  91396. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91397. }
  91398. }
  91399. declare module BABYLON {
  91400. /**
  91401. * Raw texture can help creating a texture directly from an array of data.
  91402. * This can be super useful if you either get the data from an uncompressed source or
  91403. * if you wish to create your texture pixel by pixel.
  91404. */
  91405. export class RawTexture extends Texture {
  91406. /**
  91407. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91408. */
  91409. format: number;
  91410. /**
  91411. * Instantiates a new RawTexture.
  91412. * Raw texture can help creating a texture directly from an array of data.
  91413. * This can be super useful if you either get the data from an uncompressed source or
  91414. * if you wish to create your texture pixel by pixel.
  91415. * @param data define the array of data to use to create the texture
  91416. * @param width define the width of the texture
  91417. * @param height define the height of the texture
  91418. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91419. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91420. * @param generateMipMaps define whether mip maps should be generated or not
  91421. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91422. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91423. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91424. */
  91425. constructor(data: ArrayBufferView, width: number, height: number,
  91426. /**
  91427. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91428. */
  91429. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91430. /**
  91431. * Updates the texture underlying data.
  91432. * @param data Define the new data of the texture
  91433. */
  91434. update(data: ArrayBufferView): void;
  91435. /**
  91436. * Creates a luminance texture from some data.
  91437. * @param data Define the texture data
  91438. * @param width Define the width of the texture
  91439. * @param height Define the height of the texture
  91440. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91441. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91442. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91443. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91444. * @returns the luminance texture
  91445. */
  91446. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91447. /**
  91448. * Creates a luminance alpha texture from some data.
  91449. * @param data Define the texture data
  91450. * @param width Define the width of the texture
  91451. * @param height Define the height of the texture
  91452. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91456. * @returns the luminance alpha texture
  91457. */
  91458. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91459. /**
  91460. * Creates an alpha texture from some data.
  91461. * @param data Define the texture data
  91462. * @param width Define the width of the texture
  91463. * @param height Define the height of the texture
  91464. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91465. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91466. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91467. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91468. * @returns the alpha texture
  91469. */
  91470. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91471. /**
  91472. * Creates a RGB texture from some data.
  91473. * @param data Define the texture data
  91474. * @param width Define the width of the texture
  91475. * @param height Define the height of the texture
  91476. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91477. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91480. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91481. * @returns the RGB alpha texture
  91482. */
  91483. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91484. /**
  91485. * Creates a RGBA texture from some data.
  91486. * @param data Define the texture data
  91487. * @param width Define the width of the texture
  91488. * @param height Define the height of the texture
  91489. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91490. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91491. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91492. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91493. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91494. * @returns the RGBA texture
  91495. */
  91496. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91497. /**
  91498. * Creates a R texture from some data.
  91499. * @param data Define the texture data
  91500. * @param width Define the width of the texture
  91501. * @param height Define the height of the texture
  91502. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91503. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91504. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91505. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91506. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91507. * @returns the R texture
  91508. */
  91509. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91510. }
  91511. }
  91512. declare module BABYLON {
  91513. interface ThinEngine {
  91514. /**
  91515. * Update a dynamic index buffer
  91516. * @param indexBuffer defines the target index buffer
  91517. * @param indices defines the data to update
  91518. * @param offset defines the offset in the target index buffer where update should start
  91519. */
  91520. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91521. /**
  91522. * Updates a dynamic vertex buffer.
  91523. * @param vertexBuffer the vertex buffer to update
  91524. * @param data the data used to update the vertex buffer
  91525. * @param byteOffset the byte offset of the data
  91526. * @param byteLength the byte length of the data
  91527. */
  91528. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91529. }
  91530. }
  91531. declare module BABYLON {
  91532. interface AbstractScene {
  91533. /**
  91534. * The list of procedural textures added to the scene
  91535. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91536. */
  91537. proceduralTextures: Array<ProceduralTexture>;
  91538. }
  91539. /**
  91540. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91541. * in a given scene.
  91542. */
  91543. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91544. /**
  91545. * The component name helpfull to identify the component in the list of scene components.
  91546. */
  91547. readonly name: string;
  91548. /**
  91549. * The scene the component belongs to.
  91550. */
  91551. scene: Scene;
  91552. /**
  91553. * Creates a new instance of the component for the given scene
  91554. * @param scene Defines the scene to register the component in
  91555. */
  91556. constructor(scene: Scene);
  91557. /**
  91558. * Registers the component in a given scene
  91559. */
  91560. register(): void;
  91561. /**
  91562. * Rebuilds the elements related to this component in case of
  91563. * context lost for instance.
  91564. */
  91565. rebuild(): void;
  91566. /**
  91567. * Disposes the component and the associated ressources.
  91568. */
  91569. dispose(): void;
  91570. private _beforeClear;
  91571. }
  91572. }
  91573. declare module BABYLON {
  91574. interface ThinEngine {
  91575. /**
  91576. * Creates a new render target cube texture
  91577. * @param size defines the size of the texture
  91578. * @param options defines the options used to create the texture
  91579. * @returns a new render target cube texture stored in an InternalTexture
  91580. */
  91581. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91582. }
  91583. }
  91584. declare module BABYLON {
  91585. /** @hidden */
  91586. export var proceduralVertexShader: {
  91587. name: string;
  91588. shader: string;
  91589. };
  91590. }
  91591. declare module BABYLON {
  91592. /**
  91593. * 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.
  91594. * This is the base class of any Procedural texture and contains most of the shareable code.
  91595. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91596. */
  91597. export class ProceduralTexture extends Texture {
  91598. /**
  91599. * Define if the texture is enabled or not (disabled texture will not render)
  91600. */
  91601. isEnabled: boolean;
  91602. /**
  91603. * Define if the texture must be cleared before rendering (default is true)
  91604. */
  91605. autoClear: boolean;
  91606. /**
  91607. * Callback called when the texture is generated
  91608. */
  91609. onGenerated: () => void;
  91610. /**
  91611. * Event raised when the texture is generated
  91612. */
  91613. onGeneratedObservable: Observable<ProceduralTexture>;
  91614. /**
  91615. * Event raised before the texture is generated
  91616. */
  91617. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  91618. /**
  91619. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  91620. */
  91621. nodeMaterialSource: Nullable<NodeMaterial>;
  91622. /** @hidden */
  91623. _generateMipMaps: boolean;
  91624. /** @hidden **/
  91625. _effect: Effect;
  91626. /** @hidden */
  91627. _textures: {
  91628. [key: string]: Texture;
  91629. };
  91630. /** @hidden */
  91631. protected _fallbackTexture: Nullable<Texture>;
  91632. private _size;
  91633. private _currentRefreshId;
  91634. private _frameId;
  91635. private _refreshRate;
  91636. private _vertexBuffers;
  91637. private _indexBuffer;
  91638. private _uniforms;
  91639. private _samplers;
  91640. private _fragment;
  91641. private _floats;
  91642. private _ints;
  91643. private _floatsArrays;
  91644. private _colors3;
  91645. private _colors4;
  91646. private _vectors2;
  91647. private _vectors3;
  91648. private _matrices;
  91649. private _fallbackTextureUsed;
  91650. private _fullEngine;
  91651. private _cachedDefines;
  91652. private _contentUpdateId;
  91653. private _contentData;
  91654. /**
  91655. * Instantiates a new procedural texture.
  91656. * 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.
  91657. * This is the base class of any Procedural texture and contains most of the shareable code.
  91658. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91659. * @param name Define the name of the texture
  91660. * @param size Define the size of the texture to create
  91661. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  91662. * @param scene Define the scene the texture belongs to
  91663. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  91664. * @param generateMipMaps Define if the texture should creates mip maps or not
  91665. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  91666. */
  91667. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  91668. /**
  91669. * The effect that is created when initializing the post process.
  91670. * @returns The created effect corresponding the the postprocess.
  91671. */
  91672. getEffect(): Effect;
  91673. /**
  91674. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  91675. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  91676. */
  91677. getContent(): Nullable<ArrayBufferView>;
  91678. private _createIndexBuffer;
  91679. /** @hidden */
  91680. _rebuild(): void;
  91681. /**
  91682. * Resets the texture in order to recreate its associated resources.
  91683. * This can be called in case of context loss
  91684. */
  91685. reset(): void;
  91686. protected _getDefines(): string;
  91687. /**
  91688. * Is the texture ready to be used ? (rendered at least once)
  91689. * @returns true if ready, otherwise, false.
  91690. */
  91691. isReady(): boolean;
  91692. /**
  91693. * Resets the refresh counter of the texture and start bak from scratch.
  91694. * Could be useful to regenerate the texture if it is setup to render only once.
  91695. */
  91696. resetRefreshCounter(): void;
  91697. /**
  91698. * Set the fragment shader to use in order to render the texture.
  91699. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  91700. */
  91701. setFragment(fragment: any): void;
  91702. /**
  91703. * Define the refresh rate of the texture or the rendering frequency.
  91704. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91705. */
  91706. get refreshRate(): number;
  91707. set refreshRate(value: number);
  91708. /** @hidden */
  91709. _shouldRender(): boolean;
  91710. /**
  91711. * Get the size the texture is rendering at.
  91712. * @returns the size (on cube texture it is always squared)
  91713. */
  91714. getRenderSize(): RenderTargetTextureSize;
  91715. /**
  91716. * Resize the texture to new value.
  91717. * @param size Define the new size the texture should have
  91718. * @param generateMipMaps Define whether the new texture should create mip maps
  91719. */
  91720. resize(size: number, generateMipMaps: boolean): void;
  91721. private _checkUniform;
  91722. /**
  91723. * Set a texture in the shader program used to render.
  91724. * @param name Define the name of the uniform samplers as defined in the shader
  91725. * @param texture Define the texture to bind to this sampler
  91726. * @return the texture itself allowing "fluent" like uniform updates
  91727. */
  91728. setTexture(name: string, texture: Texture): ProceduralTexture;
  91729. /**
  91730. * Set a float in the shader.
  91731. * @param name Define the name of the uniform as defined in the shader
  91732. * @param value Define the value to give to the uniform
  91733. * @return the texture itself allowing "fluent" like uniform updates
  91734. */
  91735. setFloat(name: string, value: number): ProceduralTexture;
  91736. /**
  91737. * Set a int in the shader.
  91738. * @param name Define the name of the uniform as defined in the shader
  91739. * @param value Define the value to give to the uniform
  91740. * @return the texture itself allowing "fluent" like uniform updates
  91741. */
  91742. setInt(name: string, value: number): ProceduralTexture;
  91743. /**
  91744. * Set an array of floats in the shader.
  91745. * @param name Define the name of the uniform as defined in the shader
  91746. * @param value Define the value to give to the uniform
  91747. * @return the texture itself allowing "fluent" like uniform updates
  91748. */
  91749. setFloats(name: string, value: number[]): ProceduralTexture;
  91750. /**
  91751. * Set a vec3 in the shader from a Color3.
  91752. * @param name Define the name of the uniform as defined in the shader
  91753. * @param value Define the value to give to the uniform
  91754. * @return the texture itself allowing "fluent" like uniform updates
  91755. */
  91756. setColor3(name: string, value: Color3): ProceduralTexture;
  91757. /**
  91758. * Set a vec4 in the shader from a Color4.
  91759. * @param name Define the name of the uniform as defined in the shader
  91760. * @param value Define the value to give to the uniform
  91761. * @return the texture itself allowing "fluent" like uniform updates
  91762. */
  91763. setColor4(name: string, value: Color4): ProceduralTexture;
  91764. /**
  91765. * Set a vec2 in the shader from a Vector2.
  91766. * @param name Define the name of the uniform as defined in the shader
  91767. * @param value Define the value to give to the uniform
  91768. * @return the texture itself allowing "fluent" like uniform updates
  91769. */
  91770. setVector2(name: string, value: Vector2): ProceduralTexture;
  91771. /**
  91772. * Set a vec3 in the shader from a Vector3.
  91773. * @param name Define the name of the uniform as defined in the shader
  91774. * @param value Define the value to give to the uniform
  91775. * @return the texture itself allowing "fluent" like uniform updates
  91776. */
  91777. setVector3(name: string, value: Vector3): ProceduralTexture;
  91778. /**
  91779. * Set a mat4 in the shader from a MAtrix.
  91780. * @param name Define the name of the uniform as defined in the shader
  91781. * @param value Define the value to give to the uniform
  91782. * @return the texture itself allowing "fluent" like uniform updates
  91783. */
  91784. setMatrix(name: string, value: Matrix): ProceduralTexture;
  91785. /**
  91786. * Render the texture to its associated render target.
  91787. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  91788. */
  91789. render(useCameraPostProcess?: boolean): void;
  91790. /**
  91791. * Clone the texture.
  91792. * @returns the cloned texture
  91793. */
  91794. clone(): ProceduralTexture;
  91795. /**
  91796. * Dispose the texture and release its asoociated resources.
  91797. */
  91798. dispose(): void;
  91799. }
  91800. }
  91801. declare module BABYLON {
  91802. /**
  91803. * This represents the base class for particle system in Babylon.
  91804. * 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.
  91805. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91806. * @example https://doc.babylonjs.com/babylon101/particles
  91807. */
  91808. export class BaseParticleSystem {
  91809. /**
  91810. * Source color is added to the destination color without alpha affecting the result
  91811. */
  91812. static BLENDMODE_ONEONE: number;
  91813. /**
  91814. * Blend current color and particle color using particle’s alpha
  91815. */
  91816. static BLENDMODE_STANDARD: number;
  91817. /**
  91818. * Add current color and particle color multiplied by particle’s alpha
  91819. */
  91820. static BLENDMODE_ADD: number;
  91821. /**
  91822. * Multiply current color with particle color
  91823. */
  91824. static BLENDMODE_MULTIPLY: number;
  91825. /**
  91826. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  91827. */
  91828. static BLENDMODE_MULTIPLYADD: number;
  91829. /**
  91830. * List of animations used by the particle system.
  91831. */
  91832. animations: Animation[];
  91833. /**
  91834. * Gets or sets the unique id of the particle system
  91835. */
  91836. uniqueId: number;
  91837. /**
  91838. * The id of the Particle system.
  91839. */
  91840. id: string;
  91841. /**
  91842. * The friendly name of the Particle system.
  91843. */
  91844. name: string;
  91845. /**
  91846. * Snippet ID if the particle system was created from the snippet server
  91847. */
  91848. snippetId: string;
  91849. /**
  91850. * The rendering group used by the Particle system to chose when to render.
  91851. */
  91852. renderingGroupId: number;
  91853. /**
  91854. * The emitter represents the Mesh or position we are attaching the particle system to.
  91855. */
  91856. emitter: Nullable<AbstractMesh | Vector3>;
  91857. /**
  91858. * The maximum number of particles to emit per frame
  91859. */
  91860. emitRate: number;
  91861. /**
  91862. * If you want to launch only a few particles at once, that can be done, as well.
  91863. */
  91864. manualEmitCount: number;
  91865. /**
  91866. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91867. */
  91868. updateSpeed: number;
  91869. /**
  91870. * The amount of time the particle system is running (depends of the overall update speed).
  91871. */
  91872. targetStopDuration: number;
  91873. /**
  91874. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91875. */
  91876. disposeOnStop: boolean;
  91877. /**
  91878. * Minimum power of emitting particles.
  91879. */
  91880. minEmitPower: number;
  91881. /**
  91882. * Maximum power of emitting particles.
  91883. */
  91884. maxEmitPower: number;
  91885. /**
  91886. * Minimum life time of emitting particles.
  91887. */
  91888. minLifeTime: number;
  91889. /**
  91890. * Maximum life time of emitting particles.
  91891. */
  91892. maxLifeTime: number;
  91893. /**
  91894. * Minimum Size of emitting particles.
  91895. */
  91896. minSize: number;
  91897. /**
  91898. * Maximum Size of emitting particles.
  91899. */
  91900. maxSize: number;
  91901. /**
  91902. * Minimum scale of emitting particles on X axis.
  91903. */
  91904. minScaleX: number;
  91905. /**
  91906. * Maximum scale of emitting particles on X axis.
  91907. */
  91908. maxScaleX: number;
  91909. /**
  91910. * Minimum scale of emitting particles on Y axis.
  91911. */
  91912. minScaleY: number;
  91913. /**
  91914. * Maximum scale of emitting particles on Y axis.
  91915. */
  91916. maxScaleY: number;
  91917. /**
  91918. * Gets or sets the minimal initial rotation in radians.
  91919. */
  91920. minInitialRotation: number;
  91921. /**
  91922. * Gets or sets the maximal initial rotation in radians.
  91923. */
  91924. maxInitialRotation: number;
  91925. /**
  91926. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91927. */
  91928. minAngularSpeed: number;
  91929. /**
  91930. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91931. */
  91932. maxAngularSpeed: number;
  91933. /**
  91934. * The texture used to render each particle. (this can be a spritesheet)
  91935. */
  91936. particleTexture: Nullable<BaseTexture>;
  91937. /**
  91938. * The layer mask we are rendering the particles through.
  91939. */
  91940. layerMask: number;
  91941. /**
  91942. * This can help using your own shader to render the particle system.
  91943. * The according effect will be created
  91944. */
  91945. customShader: any;
  91946. /**
  91947. * By default particle system starts as soon as they are created. This prevents the
  91948. * automatic start to happen and let you decide when to start emitting particles.
  91949. */
  91950. preventAutoStart: boolean;
  91951. private _noiseTexture;
  91952. /**
  91953. * Gets or sets a texture used to add random noise to particle positions
  91954. */
  91955. get noiseTexture(): Nullable<ProceduralTexture>;
  91956. set noiseTexture(value: Nullable<ProceduralTexture>);
  91957. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91958. noiseStrength: Vector3;
  91959. /**
  91960. * Callback triggered when the particle animation is ending.
  91961. */
  91962. onAnimationEnd: Nullable<() => void>;
  91963. /**
  91964. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91965. */
  91966. blendMode: number;
  91967. /**
  91968. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91969. * to override the particles.
  91970. */
  91971. forceDepthWrite: boolean;
  91972. /** 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 */
  91973. preWarmCycles: number;
  91974. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91975. preWarmStepOffset: number;
  91976. /**
  91977. * 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)
  91978. */
  91979. spriteCellChangeSpeed: number;
  91980. /**
  91981. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91982. */
  91983. startSpriteCellID: number;
  91984. /**
  91985. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91986. */
  91987. endSpriteCellID: number;
  91988. /**
  91989. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91990. */
  91991. spriteCellWidth: number;
  91992. /**
  91993. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91994. */
  91995. spriteCellHeight: number;
  91996. /**
  91997. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91998. */
  91999. spriteRandomStartCell: boolean;
  92000. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92001. translationPivot: Vector2;
  92002. /** @hidden */
  92003. protected _isAnimationSheetEnabled: boolean;
  92004. /**
  92005. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92006. */
  92007. beginAnimationOnStart: boolean;
  92008. /**
  92009. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92010. */
  92011. beginAnimationFrom: number;
  92012. /**
  92013. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92014. */
  92015. beginAnimationTo: number;
  92016. /**
  92017. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92018. */
  92019. beginAnimationLoop: boolean;
  92020. /**
  92021. * Gets or sets a world offset applied to all particles
  92022. */
  92023. worldOffset: Vector3;
  92024. /**
  92025. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92026. */
  92027. get isAnimationSheetEnabled(): boolean;
  92028. set isAnimationSheetEnabled(value: boolean);
  92029. /**
  92030. * Get hosting scene
  92031. * @returns the scene
  92032. */
  92033. getScene(): Nullable<Scene>;
  92034. /**
  92035. * You can use gravity if you want to give an orientation to your particles.
  92036. */
  92037. gravity: Vector3;
  92038. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92039. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92040. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92041. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92042. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92043. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92044. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92045. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92046. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92047. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92048. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92049. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92050. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92051. /**
  92052. * Defines the delay in milliseconds before starting the system (0 by default)
  92053. */
  92054. startDelay: number;
  92055. /**
  92056. * Gets the current list of drag gradients.
  92057. * You must use addDragGradient and removeDragGradient to udpate this list
  92058. * @returns the list of drag gradients
  92059. */
  92060. getDragGradients(): Nullable<Array<FactorGradient>>;
  92061. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92062. limitVelocityDamping: number;
  92063. /**
  92064. * Gets the current list of limit velocity gradients.
  92065. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92066. * @returns the list of limit velocity gradients
  92067. */
  92068. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92069. /**
  92070. * Gets the current list of color gradients.
  92071. * You must use addColorGradient and removeColorGradient to udpate this list
  92072. * @returns the list of color gradients
  92073. */
  92074. getColorGradients(): Nullable<Array<ColorGradient>>;
  92075. /**
  92076. * Gets the current list of size gradients.
  92077. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92078. * @returns the list of size gradients
  92079. */
  92080. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92081. /**
  92082. * Gets the current list of color remap gradients.
  92083. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92084. * @returns the list of color remap gradients
  92085. */
  92086. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92087. /**
  92088. * Gets the current list of alpha remap gradients.
  92089. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92090. * @returns the list of alpha remap gradients
  92091. */
  92092. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92093. /**
  92094. * Gets the current list of life time gradients.
  92095. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92096. * @returns the list of life time gradients
  92097. */
  92098. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92099. /**
  92100. * Gets the current list of angular speed gradients.
  92101. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92102. * @returns the list of angular speed gradients
  92103. */
  92104. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92105. /**
  92106. * Gets the current list of velocity gradients.
  92107. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92108. * @returns the list of velocity gradients
  92109. */
  92110. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92111. /**
  92112. * Gets the current list of start size gradients.
  92113. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92114. * @returns the list of start size gradients
  92115. */
  92116. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92117. /**
  92118. * Gets the current list of emit rate gradients.
  92119. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92120. * @returns the list of emit rate gradients
  92121. */
  92122. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92123. /**
  92124. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92125. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92126. */
  92127. get direction1(): Vector3;
  92128. set direction1(value: Vector3);
  92129. /**
  92130. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92131. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92132. */
  92133. get direction2(): Vector3;
  92134. set direction2(value: Vector3);
  92135. /**
  92136. * 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.
  92137. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92138. */
  92139. get minEmitBox(): Vector3;
  92140. set minEmitBox(value: Vector3);
  92141. /**
  92142. * 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.
  92143. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92144. */
  92145. get maxEmitBox(): Vector3;
  92146. set maxEmitBox(value: Vector3);
  92147. /**
  92148. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92149. */
  92150. color1: Color4;
  92151. /**
  92152. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92153. */
  92154. color2: Color4;
  92155. /**
  92156. * Color the particle will have at the end of its lifetime
  92157. */
  92158. colorDead: Color4;
  92159. /**
  92160. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92161. */
  92162. textureMask: Color4;
  92163. /**
  92164. * The particle emitter type defines the emitter used by the particle system.
  92165. * It can be for example box, sphere, or cone...
  92166. */
  92167. particleEmitterType: IParticleEmitterType;
  92168. /** @hidden */
  92169. _isSubEmitter: boolean;
  92170. /**
  92171. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92172. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92173. */
  92174. billboardMode: number;
  92175. protected _isBillboardBased: boolean;
  92176. /**
  92177. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92178. */
  92179. get isBillboardBased(): boolean;
  92180. set isBillboardBased(value: boolean);
  92181. /**
  92182. * The scene the particle system belongs to.
  92183. */
  92184. protected _scene: Nullable<Scene>;
  92185. /**
  92186. * The engine the particle system belongs to.
  92187. */
  92188. protected _engine: ThinEngine;
  92189. /**
  92190. * Local cache of defines for image processing.
  92191. */
  92192. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92193. /**
  92194. * Default configuration related to image processing available in the standard Material.
  92195. */
  92196. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92197. /**
  92198. * Gets the image processing configuration used either in this material.
  92199. */
  92200. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92201. /**
  92202. * Sets the Default image processing configuration used either in the this material.
  92203. *
  92204. * If sets to null, the scene one is in use.
  92205. */
  92206. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92207. /**
  92208. * Attaches a new image processing configuration to the Standard Material.
  92209. * @param configuration
  92210. */
  92211. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92212. /** @hidden */
  92213. protected _reset(): void;
  92214. /** @hidden */
  92215. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92216. /**
  92217. * Instantiates a particle system.
  92218. * 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.
  92219. * @param name The name of the particle system
  92220. */
  92221. constructor(name: string);
  92222. /**
  92223. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92224. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92225. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92226. * @returns the emitter
  92227. */
  92228. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92229. /**
  92230. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92231. * @param radius The radius of the hemisphere to emit from
  92232. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92233. * @returns the emitter
  92234. */
  92235. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92236. /**
  92237. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92238. * @param radius The radius of the sphere to emit from
  92239. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92240. * @returns the emitter
  92241. */
  92242. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92243. /**
  92244. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92245. * @param radius The radius of the sphere to emit from
  92246. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92247. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92248. * @returns the emitter
  92249. */
  92250. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92251. /**
  92252. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92253. * @param radius The radius of the emission cylinder
  92254. * @param height The height of the emission cylinder
  92255. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92256. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92257. * @returns the emitter
  92258. */
  92259. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92260. /**
  92261. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92262. * @param radius The radius of the cylinder to emit from
  92263. * @param height The height of the emission cylinder
  92264. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92265. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92266. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92267. * @returns the emitter
  92268. */
  92269. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92270. /**
  92271. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92272. * @param radius The radius of the cone to emit from
  92273. * @param angle The base angle of the cone
  92274. * @returns the emitter
  92275. */
  92276. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92277. /**
  92278. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92279. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92280. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92281. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92282. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92283. * @returns the emitter
  92284. */
  92285. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92286. }
  92287. }
  92288. declare module BABYLON {
  92289. /**
  92290. * Type of sub emitter
  92291. */
  92292. export enum SubEmitterType {
  92293. /**
  92294. * Attached to the particle over it's lifetime
  92295. */
  92296. ATTACHED = 0,
  92297. /**
  92298. * Created when the particle dies
  92299. */
  92300. END = 1
  92301. }
  92302. /**
  92303. * Sub emitter class used to emit particles from an existing particle
  92304. */
  92305. export class SubEmitter {
  92306. /**
  92307. * the particle system to be used by the sub emitter
  92308. */
  92309. particleSystem: ParticleSystem;
  92310. /**
  92311. * Type of the submitter (Default: END)
  92312. */
  92313. type: SubEmitterType;
  92314. /**
  92315. * 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)
  92316. * Note: This only is supported when using an emitter of type Mesh
  92317. */
  92318. inheritDirection: boolean;
  92319. /**
  92320. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92321. */
  92322. inheritedVelocityAmount: number;
  92323. /**
  92324. * Creates a sub emitter
  92325. * @param particleSystem the particle system to be used by the sub emitter
  92326. */
  92327. constructor(
  92328. /**
  92329. * the particle system to be used by the sub emitter
  92330. */
  92331. particleSystem: ParticleSystem);
  92332. /**
  92333. * Clones the sub emitter
  92334. * @returns the cloned sub emitter
  92335. */
  92336. clone(): SubEmitter;
  92337. /**
  92338. * Serialize current object to a JSON object
  92339. * @returns the serialized object
  92340. */
  92341. serialize(): any;
  92342. /** @hidden */
  92343. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92344. /**
  92345. * Creates a new SubEmitter from a serialized JSON version
  92346. * @param serializationObject defines the JSON object to read from
  92347. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92348. * @param rootUrl defines the rootUrl for data loading
  92349. * @returns a new SubEmitter
  92350. */
  92351. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92352. /** Release associated resources */
  92353. dispose(): void;
  92354. }
  92355. }
  92356. declare module BABYLON {
  92357. /** @hidden */
  92358. export var imageProcessingDeclaration: {
  92359. name: string;
  92360. shader: string;
  92361. };
  92362. }
  92363. declare module BABYLON {
  92364. /** @hidden */
  92365. export var imageProcessingFunctions: {
  92366. name: string;
  92367. shader: string;
  92368. };
  92369. }
  92370. declare module BABYLON {
  92371. /** @hidden */
  92372. export var particlesPixelShader: {
  92373. name: string;
  92374. shader: string;
  92375. };
  92376. }
  92377. declare module BABYLON {
  92378. /** @hidden */
  92379. export var particlesVertexShader: {
  92380. name: string;
  92381. shader: string;
  92382. };
  92383. }
  92384. declare module BABYLON {
  92385. /**
  92386. * Interface used to define entities containing multiple clip planes
  92387. */
  92388. export interface IClipPlanesHolder {
  92389. /**
  92390. * Gets or sets the active clipplane 1
  92391. */
  92392. clipPlane: Nullable<Plane>;
  92393. /**
  92394. * Gets or sets the active clipplane 2
  92395. */
  92396. clipPlane2: Nullable<Plane>;
  92397. /**
  92398. * Gets or sets the active clipplane 3
  92399. */
  92400. clipPlane3: Nullable<Plane>;
  92401. /**
  92402. * Gets or sets the active clipplane 4
  92403. */
  92404. clipPlane4: Nullable<Plane>;
  92405. /**
  92406. * Gets or sets the active clipplane 5
  92407. */
  92408. clipPlane5: Nullable<Plane>;
  92409. /**
  92410. * Gets or sets the active clipplane 6
  92411. */
  92412. clipPlane6: Nullable<Plane>;
  92413. }
  92414. }
  92415. declare module BABYLON {
  92416. /**
  92417. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92418. *
  92419. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92420. *
  92421. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92422. */
  92423. export class ThinMaterialHelper {
  92424. /**
  92425. * Binds the clip plane information from the holder to the effect.
  92426. * @param effect The effect we are binding the data to
  92427. * @param holder The entity containing the clip plane information
  92428. */
  92429. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92430. }
  92431. }
  92432. declare module BABYLON {
  92433. interface ThinEngine {
  92434. /**
  92435. * Sets alpha constants used by some alpha blending modes
  92436. * @param r defines the red component
  92437. * @param g defines the green component
  92438. * @param b defines the blue component
  92439. * @param a defines the alpha component
  92440. */
  92441. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92442. /**
  92443. * Sets the current alpha mode
  92444. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92445. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92446. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92447. */
  92448. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92449. /**
  92450. * Gets the current alpha mode
  92451. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92452. * @returns the current alpha mode
  92453. */
  92454. getAlphaMode(): number;
  92455. /**
  92456. * Sets the current alpha equation
  92457. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92458. */
  92459. setAlphaEquation(equation: number): void;
  92460. /**
  92461. * Gets the current alpha equation.
  92462. * @returns the current alpha equation
  92463. */
  92464. getAlphaEquation(): number;
  92465. }
  92466. }
  92467. declare module BABYLON {
  92468. /**
  92469. * This represents a particle system in Babylon.
  92470. * 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.
  92471. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92472. * @example https://doc.babylonjs.com/babylon101/particles
  92473. */
  92474. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92475. /**
  92476. * Billboard mode will only apply to Y axis
  92477. */
  92478. static readonly BILLBOARDMODE_Y: number;
  92479. /**
  92480. * Billboard mode will apply to all axes
  92481. */
  92482. static readonly BILLBOARDMODE_ALL: number;
  92483. /**
  92484. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92485. */
  92486. static readonly BILLBOARDMODE_STRETCHED: number;
  92487. /**
  92488. * This function can be defined to provide custom update for active particles.
  92489. * This function will be called instead of regular update (age, position, color, etc.).
  92490. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92491. */
  92492. updateFunction: (particles: Particle[]) => void;
  92493. private _emitterWorldMatrix;
  92494. /**
  92495. * This function can be defined to specify initial direction for every new particle.
  92496. * It by default use the emitterType defined function
  92497. */
  92498. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92499. /**
  92500. * This function can be defined to specify initial position for every new particle.
  92501. * It by default use the emitterType defined function
  92502. */
  92503. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92504. /**
  92505. * @hidden
  92506. */
  92507. _inheritedVelocityOffset: Vector3;
  92508. /**
  92509. * An event triggered when the system is disposed
  92510. */
  92511. onDisposeObservable: Observable<IParticleSystem>;
  92512. private _onDisposeObserver;
  92513. /**
  92514. * Sets a callback that will be triggered when the system is disposed
  92515. */
  92516. set onDispose(callback: () => void);
  92517. private _particles;
  92518. private _epsilon;
  92519. private _capacity;
  92520. private _stockParticles;
  92521. private _newPartsExcess;
  92522. private _vertexData;
  92523. private _vertexBuffer;
  92524. private _vertexBuffers;
  92525. private _spriteBuffer;
  92526. private _indexBuffer;
  92527. private _effect;
  92528. private _customEffect;
  92529. private _cachedDefines;
  92530. private _scaledColorStep;
  92531. private _colorDiff;
  92532. private _scaledDirection;
  92533. private _scaledGravity;
  92534. private _currentRenderId;
  92535. private _alive;
  92536. private _useInstancing;
  92537. private _started;
  92538. private _stopped;
  92539. private _actualFrame;
  92540. private _scaledUpdateSpeed;
  92541. private _vertexBufferSize;
  92542. /** @hidden */
  92543. _currentEmitRateGradient: Nullable<FactorGradient>;
  92544. /** @hidden */
  92545. _currentEmitRate1: number;
  92546. /** @hidden */
  92547. _currentEmitRate2: number;
  92548. /** @hidden */
  92549. _currentStartSizeGradient: Nullable<FactorGradient>;
  92550. /** @hidden */
  92551. _currentStartSize1: number;
  92552. /** @hidden */
  92553. _currentStartSize2: number;
  92554. private readonly _rawTextureWidth;
  92555. private _rampGradientsTexture;
  92556. private _useRampGradients;
  92557. /** Gets or sets a matrix to use to compute projection */
  92558. defaultProjectionMatrix: Matrix;
  92559. /** Gets or sets a matrix to use to compute view */
  92560. defaultViewMatrix: Matrix;
  92561. /** Gets or sets a boolean indicating that ramp gradients must be used
  92562. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92563. */
  92564. get useRampGradients(): boolean;
  92565. set useRampGradients(value: boolean);
  92566. /**
  92567. * 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.
  92568. * 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: [])
  92569. */
  92570. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92571. private _subEmitters;
  92572. /**
  92573. * @hidden
  92574. * If the particle systems emitter should be disposed when the particle system is disposed
  92575. */
  92576. _disposeEmitterOnDispose: boolean;
  92577. /**
  92578. * The current active Sub-systems, this property is used by the root particle system only.
  92579. */
  92580. activeSubSystems: Array<ParticleSystem>;
  92581. /**
  92582. * Specifies if the particles are updated in emitter local space or world space
  92583. */
  92584. isLocal: boolean;
  92585. private _rootParticleSystem;
  92586. /**
  92587. * Gets the current list of active particles
  92588. */
  92589. get particles(): Particle[];
  92590. /**
  92591. * Gets the number of particles active at the same time.
  92592. * @returns The number of active particles.
  92593. */
  92594. getActiveCount(): number;
  92595. /**
  92596. * Returns the string "ParticleSystem"
  92597. * @returns a string containing the class name
  92598. */
  92599. getClassName(): string;
  92600. /**
  92601. * Gets a boolean indicating that the system is stopping
  92602. * @returns true if the system is currently stopping
  92603. */
  92604. isStopping(): boolean;
  92605. /**
  92606. * Gets the custom effect used to render the particles
  92607. * @param blendMode Blend mode for which the effect should be retrieved
  92608. * @returns The effect
  92609. */
  92610. getCustomEffect(blendMode?: number): Nullable<Effect>;
  92611. /**
  92612. * Sets the custom effect used to render the particles
  92613. * @param effect The effect to set
  92614. * @param blendMode Blend mode for which the effect should be set
  92615. */
  92616. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  92617. /** @hidden */
  92618. private _onBeforeDrawParticlesObservable;
  92619. /**
  92620. * Observable that will be called just before the particles are drawn
  92621. */
  92622. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  92623. /**
  92624. * Gets the name of the particle vertex shader
  92625. */
  92626. get vertexShaderName(): string;
  92627. /**
  92628. * Instantiates a particle system.
  92629. * 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.
  92630. * @param name The name of the particle system
  92631. * @param capacity The max number of particles alive at the same time
  92632. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  92633. * @param customEffect a custom effect used to change the way particles are rendered by default
  92634. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  92635. * @param epsilon Offset used to render the particles
  92636. */
  92637. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  92638. private _addFactorGradient;
  92639. private _removeFactorGradient;
  92640. /**
  92641. * Adds a new life time gradient
  92642. * @param gradient defines the gradient to use (between 0 and 1)
  92643. * @param factor defines the life time factor to affect to the specified gradient
  92644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92645. * @returns the current particle system
  92646. */
  92647. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92648. /**
  92649. * Remove a specific life time gradient
  92650. * @param gradient defines the gradient to remove
  92651. * @returns the current particle system
  92652. */
  92653. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92654. /**
  92655. * Adds a new size gradient
  92656. * @param gradient defines the gradient to use (between 0 and 1)
  92657. * @param factor defines the size factor to affect to the specified gradient
  92658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92659. * @returns the current particle system
  92660. */
  92661. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92662. /**
  92663. * Remove a specific size gradient
  92664. * @param gradient defines the gradient to remove
  92665. * @returns the current particle system
  92666. */
  92667. removeSizeGradient(gradient: number): IParticleSystem;
  92668. /**
  92669. * Adds a new color remap gradient
  92670. * @param gradient defines the gradient to use (between 0 and 1)
  92671. * @param min defines the color remap minimal range
  92672. * @param max defines the color remap maximal range
  92673. * @returns the current particle system
  92674. */
  92675. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92676. /**
  92677. * Remove a specific color remap gradient
  92678. * @param gradient defines the gradient to remove
  92679. * @returns the current particle system
  92680. */
  92681. removeColorRemapGradient(gradient: number): IParticleSystem;
  92682. /**
  92683. * Adds a new alpha remap gradient
  92684. * @param gradient defines the gradient to use (between 0 and 1)
  92685. * @param min defines the alpha remap minimal range
  92686. * @param max defines the alpha remap maximal range
  92687. * @returns the current particle system
  92688. */
  92689. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92690. /**
  92691. * Remove a specific alpha remap gradient
  92692. * @param gradient defines the gradient to remove
  92693. * @returns the current particle system
  92694. */
  92695. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  92696. /**
  92697. * Adds a new angular speed gradient
  92698. * @param gradient defines the gradient to use (between 0 and 1)
  92699. * @param factor defines the angular speed to affect to the specified gradient
  92700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92701. * @returns the current particle system
  92702. */
  92703. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92704. /**
  92705. * Remove a specific angular speed gradient
  92706. * @param gradient defines the gradient to remove
  92707. * @returns the current particle system
  92708. */
  92709. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92710. /**
  92711. * Adds a new velocity gradient
  92712. * @param gradient defines the gradient to use (between 0 and 1)
  92713. * @param factor defines the velocity to affect to the specified gradient
  92714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92715. * @returns the current particle system
  92716. */
  92717. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92718. /**
  92719. * Remove a specific velocity gradient
  92720. * @param gradient defines the gradient to remove
  92721. * @returns the current particle system
  92722. */
  92723. removeVelocityGradient(gradient: number): IParticleSystem;
  92724. /**
  92725. * Adds a new limit velocity gradient
  92726. * @param gradient defines the gradient to use (between 0 and 1)
  92727. * @param factor defines the limit velocity value to affect to the specified gradient
  92728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92729. * @returns the current particle system
  92730. */
  92731. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92732. /**
  92733. * Remove a specific limit velocity gradient
  92734. * @param gradient defines the gradient to remove
  92735. * @returns the current particle system
  92736. */
  92737. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92738. /**
  92739. * Adds a new drag gradient
  92740. * @param gradient defines the gradient to use (between 0 and 1)
  92741. * @param factor defines the drag value to affect to the specified gradient
  92742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92743. * @returns the current particle system
  92744. */
  92745. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92746. /**
  92747. * Remove a specific drag gradient
  92748. * @param gradient defines the gradient to remove
  92749. * @returns the current particle system
  92750. */
  92751. removeDragGradient(gradient: number): IParticleSystem;
  92752. /**
  92753. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92754. * @param gradient defines the gradient to use (between 0 and 1)
  92755. * @param factor defines the emit rate value to affect to the specified gradient
  92756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92757. * @returns the current particle system
  92758. */
  92759. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92760. /**
  92761. * Remove a specific emit rate gradient
  92762. * @param gradient defines the gradient to remove
  92763. * @returns the current particle system
  92764. */
  92765. removeEmitRateGradient(gradient: number): IParticleSystem;
  92766. /**
  92767. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92768. * @param gradient defines the gradient to use (between 0 and 1)
  92769. * @param factor defines the start size value to affect to the specified gradient
  92770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92771. * @returns the current particle system
  92772. */
  92773. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92774. /**
  92775. * Remove a specific start size gradient
  92776. * @param gradient defines the gradient to remove
  92777. * @returns the current particle system
  92778. */
  92779. removeStartSizeGradient(gradient: number): IParticleSystem;
  92780. private _createRampGradientTexture;
  92781. /**
  92782. * Gets the current list of ramp gradients.
  92783. * You must use addRampGradient and removeRampGradient to udpate this list
  92784. * @returns the list of ramp gradients
  92785. */
  92786. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92787. /** Force the system to rebuild all gradients that need to be resync */
  92788. forceRefreshGradients(): void;
  92789. private _syncRampGradientTexture;
  92790. /**
  92791. * Adds a new ramp gradient used to remap particle colors
  92792. * @param gradient defines the gradient to use (between 0 and 1)
  92793. * @param color defines the color to affect to the specified gradient
  92794. * @returns the current particle system
  92795. */
  92796. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  92797. /**
  92798. * Remove a specific ramp gradient
  92799. * @param gradient defines the gradient to remove
  92800. * @returns the current particle system
  92801. */
  92802. removeRampGradient(gradient: number): ParticleSystem;
  92803. /**
  92804. * Adds a new color gradient
  92805. * @param gradient defines the gradient to use (between 0 and 1)
  92806. * @param color1 defines the color to affect to the specified gradient
  92807. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92808. * @returns this particle system
  92809. */
  92810. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92811. /**
  92812. * Remove a specific color gradient
  92813. * @param gradient defines the gradient to remove
  92814. * @returns this particle system
  92815. */
  92816. removeColorGradient(gradient: number): IParticleSystem;
  92817. private _fetchR;
  92818. protected _reset(): void;
  92819. private _resetEffect;
  92820. private _createVertexBuffers;
  92821. private _createIndexBuffer;
  92822. /**
  92823. * Gets the maximum number of particles active at the same time.
  92824. * @returns The max number of active particles.
  92825. */
  92826. getCapacity(): number;
  92827. /**
  92828. * Gets whether there are still active particles in the system.
  92829. * @returns True if it is alive, otherwise false.
  92830. */
  92831. isAlive(): boolean;
  92832. /**
  92833. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92834. * @returns True if it has been started, otherwise false.
  92835. */
  92836. isStarted(): boolean;
  92837. private _prepareSubEmitterInternalArray;
  92838. /**
  92839. * Starts the particle system and begins to emit
  92840. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  92841. */
  92842. start(delay?: number): void;
  92843. /**
  92844. * Stops the particle system.
  92845. * @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.
  92846. */
  92847. stop(stopSubEmitters?: boolean): void;
  92848. /**
  92849. * Remove all active particles
  92850. */
  92851. reset(): void;
  92852. /**
  92853. * @hidden (for internal use only)
  92854. */
  92855. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  92856. /**
  92857. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  92858. * Its lifetime will start back at 0.
  92859. */
  92860. recycleParticle: (particle: Particle) => void;
  92861. private _stopSubEmitters;
  92862. private _createParticle;
  92863. private _removeFromRoot;
  92864. private _emitFromParticle;
  92865. private _update;
  92866. /** @hidden */
  92867. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  92868. /** @hidden */
  92869. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  92870. /**
  92871. * Fill the defines array according to the current settings of the particle system
  92872. * @param defines Array to be updated
  92873. * @param blendMode blend mode to take into account when updating the array
  92874. */
  92875. fillDefines(defines: Array<string>, blendMode: number): void;
  92876. /**
  92877. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92878. * @param uniforms Uniforms array to fill
  92879. * @param attributes Attributes array to fill
  92880. * @param samplers Samplers array to fill
  92881. */
  92882. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92883. /** @hidden */
  92884. private _getEffect;
  92885. /**
  92886. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  92887. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  92888. */
  92889. animate(preWarmOnly?: boolean): void;
  92890. private _appendParticleVertices;
  92891. /**
  92892. * Rebuilds the particle system.
  92893. */
  92894. rebuild(): void;
  92895. /**
  92896. * Is this system ready to be used/rendered
  92897. * @return true if the system is ready
  92898. */
  92899. isReady(): boolean;
  92900. private _render;
  92901. /**
  92902. * Renders the particle system in its current state.
  92903. * @returns the current number of particles
  92904. */
  92905. render(): number;
  92906. /**
  92907. * Disposes the particle system and free the associated resources
  92908. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92909. */
  92910. dispose(disposeTexture?: boolean): void;
  92911. /**
  92912. * Clones the particle system.
  92913. * @param name The name of the cloned object
  92914. * @param newEmitter The new emitter to use
  92915. * @returns the cloned particle system
  92916. */
  92917. clone(name: string, newEmitter: any): ParticleSystem;
  92918. /**
  92919. * Serializes the particle system to a JSON object
  92920. * @param serializeTexture defines if the texture must be serialized as well
  92921. * @returns the JSON object
  92922. */
  92923. serialize(serializeTexture?: boolean): any;
  92924. /** @hidden */
  92925. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  92926. /** @hidden */
  92927. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  92928. /**
  92929. * Parses a JSON object to create a particle system.
  92930. * @param parsedParticleSystem The JSON object to parse
  92931. * @param sceneOrEngine The scene or the engine to create the particle system in
  92932. * @param rootUrl The root url to use to load external dependencies like texture
  92933. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  92934. * @returns the Parsed particle system
  92935. */
  92936. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  92937. }
  92938. }
  92939. declare module BABYLON {
  92940. /**
  92941. * A particle represents one of the element emitted by a particle system.
  92942. * This is mainly define by its coordinates, direction, velocity and age.
  92943. */
  92944. export class Particle {
  92945. /**
  92946. * The particle system the particle belongs to.
  92947. */
  92948. particleSystem: ParticleSystem;
  92949. private static _Count;
  92950. /**
  92951. * Unique ID of the particle
  92952. */
  92953. id: number;
  92954. /**
  92955. * The world position of the particle in the scene.
  92956. */
  92957. position: Vector3;
  92958. /**
  92959. * The world direction of the particle in the scene.
  92960. */
  92961. direction: Vector3;
  92962. /**
  92963. * The color of the particle.
  92964. */
  92965. color: Color4;
  92966. /**
  92967. * The color change of the particle per step.
  92968. */
  92969. colorStep: Color4;
  92970. /**
  92971. * Defines how long will the life of the particle be.
  92972. */
  92973. lifeTime: number;
  92974. /**
  92975. * The current age of the particle.
  92976. */
  92977. age: number;
  92978. /**
  92979. * The current size of the particle.
  92980. */
  92981. size: number;
  92982. /**
  92983. * The current scale of the particle.
  92984. */
  92985. scale: Vector2;
  92986. /**
  92987. * The current angle of the particle.
  92988. */
  92989. angle: number;
  92990. /**
  92991. * Defines how fast is the angle changing.
  92992. */
  92993. angularSpeed: number;
  92994. /**
  92995. * Defines the cell index used by the particle to be rendered from a sprite.
  92996. */
  92997. cellIndex: number;
  92998. /**
  92999. * The information required to support color remapping
  93000. */
  93001. remapData: Vector4;
  93002. /** @hidden */
  93003. _randomCellOffset?: number;
  93004. /** @hidden */
  93005. _initialDirection: Nullable<Vector3>;
  93006. /** @hidden */
  93007. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93008. /** @hidden */
  93009. _initialStartSpriteCellID: number;
  93010. /** @hidden */
  93011. _initialEndSpriteCellID: number;
  93012. /** @hidden */
  93013. _currentColorGradient: Nullable<ColorGradient>;
  93014. /** @hidden */
  93015. _currentColor1: Color4;
  93016. /** @hidden */
  93017. _currentColor2: Color4;
  93018. /** @hidden */
  93019. _currentSizeGradient: Nullable<FactorGradient>;
  93020. /** @hidden */
  93021. _currentSize1: number;
  93022. /** @hidden */
  93023. _currentSize2: number;
  93024. /** @hidden */
  93025. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93026. /** @hidden */
  93027. _currentAngularSpeed1: number;
  93028. /** @hidden */
  93029. _currentAngularSpeed2: number;
  93030. /** @hidden */
  93031. _currentVelocityGradient: Nullable<FactorGradient>;
  93032. /** @hidden */
  93033. _currentVelocity1: number;
  93034. /** @hidden */
  93035. _currentVelocity2: number;
  93036. /** @hidden */
  93037. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93038. /** @hidden */
  93039. _currentLimitVelocity1: number;
  93040. /** @hidden */
  93041. _currentLimitVelocity2: number;
  93042. /** @hidden */
  93043. _currentDragGradient: Nullable<FactorGradient>;
  93044. /** @hidden */
  93045. _currentDrag1: number;
  93046. /** @hidden */
  93047. _currentDrag2: number;
  93048. /** @hidden */
  93049. _randomNoiseCoordinates1: Vector3;
  93050. /** @hidden */
  93051. _randomNoiseCoordinates2: Vector3;
  93052. /** @hidden */
  93053. _localPosition?: Vector3;
  93054. /**
  93055. * Creates a new instance Particle
  93056. * @param particleSystem the particle system the particle belongs to
  93057. */
  93058. constructor(
  93059. /**
  93060. * The particle system the particle belongs to.
  93061. */
  93062. particleSystem: ParticleSystem);
  93063. private updateCellInfoFromSystem;
  93064. /**
  93065. * Defines how the sprite cell index is updated for the particle
  93066. */
  93067. updateCellIndex(): void;
  93068. /** @hidden */
  93069. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93070. /** @hidden */
  93071. _inheritParticleInfoToSubEmitters(): void;
  93072. /** @hidden */
  93073. _reset(): void;
  93074. /**
  93075. * Copy the properties of particle to another one.
  93076. * @param other the particle to copy the information to.
  93077. */
  93078. copyTo(other: Particle): void;
  93079. }
  93080. }
  93081. declare module BABYLON {
  93082. /**
  93083. * Particle emitter represents a volume emitting particles.
  93084. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93085. */
  93086. export interface IParticleEmitterType {
  93087. /**
  93088. * Called by the particle System when the direction is computed for the created particle.
  93089. * @param worldMatrix is the world matrix of the particle system
  93090. * @param directionToUpdate is the direction vector to update with the result
  93091. * @param particle is the particle we are computed the direction for
  93092. * @param isLocal defines if the direction should be set in local space
  93093. */
  93094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93095. /**
  93096. * Called by the particle System when the position is computed for the created particle.
  93097. * @param worldMatrix is the world matrix of the particle system
  93098. * @param positionToUpdate is the position vector to update with the result
  93099. * @param particle is the particle we are computed the position for
  93100. * @param isLocal defines if the position should be set in local space
  93101. */
  93102. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93103. /**
  93104. * Clones the current emitter and returns a copy of it
  93105. * @returns the new emitter
  93106. */
  93107. clone(): IParticleEmitterType;
  93108. /**
  93109. * Called by the GPUParticleSystem to setup the update shader
  93110. * @param effect defines the update shader
  93111. */
  93112. applyToShader(effect: Effect): void;
  93113. /**
  93114. * Returns a string to use to update the GPU particles update shader
  93115. * @returns the effect defines string
  93116. */
  93117. getEffectDefines(): string;
  93118. /**
  93119. * Returns a string representing the class name
  93120. * @returns a string containing the class name
  93121. */
  93122. getClassName(): string;
  93123. /**
  93124. * Serializes the particle system to a JSON object.
  93125. * @returns the JSON object
  93126. */
  93127. serialize(): any;
  93128. /**
  93129. * Parse properties from a JSON object
  93130. * @param serializationObject defines the JSON object
  93131. * @param scene defines the hosting scene
  93132. */
  93133. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93134. }
  93135. }
  93136. declare module BABYLON {
  93137. /**
  93138. * Particle emitter emitting particles from the inside of a box.
  93139. * It emits the particles randomly between 2 given directions.
  93140. */
  93141. export class BoxParticleEmitter implements IParticleEmitterType {
  93142. /**
  93143. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93144. */
  93145. direction1: Vector3;
  93146. /**
  93147. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93148. */
  93149. direction2: Vector3;
  93150. /**
  93151. * 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.
  93152. */
  93153. minEmitBox: Vector3;
  93154. /**
  93155. * 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.
  93156. */
  93157. maxEmitBox: Vector3;
  93158. /**
  93159. * Creates a new instance BoxParticleEmitter
  93160. */
  93161. constructor();
  93162. /**
  93163. * Called by the particle System when the direction is computed for the created particle.
  93164. * @param worldMatrix is the world matrix of the particle system
  93165. * @param directionToUpdate is the direction vector to update with the result
  93166. * @param particle is the particle we are computed the direction for
  93167. * @param isLocal defines if the direction should be set in local space
  93168. */
  93169. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93170. /**
  93171. * Called by the particle System when the position is computed for the created particle.
  93172. * @param worldMatrix is the world matrix of the particle system
  93173. * @param positionToUpdate is the position vector to update with the result
  93174. * @param particle is the particle we are computed the position for
  93175. * @param isLocal defines if the position should be set in local space
  93176. */
  93177. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93178. /**
  93179. * Clones the current emitter and returns a copy of it
  93180. * @returns the new emitter
  93181. */
  93182. clone(): BoxParticleEmitter;
  93183. /**
  93184. * Called by the GPUParticleSystem to setup the update shader
  93185. * @param effect defines the update shader
  93186. */
  93187. applyToShader(effect: Effect): void;
  93188. /**
  93189. * Returns a string to use to update the GPU particles update shader
  93190. * @returns a string containng the defines string
  93191. */
  93192. getEffectDefines(): string;
  93193. /**
  93194. * Returns the string "BoxParticleEmitter"
  93195. * @returns a string containing the class name
  93196. */
  93197. getClassName(): string;
  93198. /**
  93199. * Serializes the particle system to a JSON object.
  93200. * @returns the JSON object
  93201. */
  93202. serialize(): any;
  93203. /**
  93204. * Parse properties from a JSON object
  93205. * @param serializationObject defines the JSON object
  93206. */
  93207. parse(serializationObject: any): void;
  93208. }
  93209. }
  93210. declare module BABYLON {
  93211. /**
  93212. * Particle emitter emitting particles from the inside of a cone.
  93213. * It emits the particles alongside the cone volume from the base to the particle.
  93214. * The emission direction might be randomized.
  93215. */
  93216. export class ConeParticleEmitter implements IParticleEmitterType {
  93217. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93218. directionRandomizer: number;
  93219. private _radius;
  93220. private _angle;
  93221. private _height;
  93222. /**
  93223. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93224. */
  93225. radiusRange: number;
  93226. /**
  93227. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93228. */
  93229. heightRange: number;
  93230. /**
  93231. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93232. */
  93233. emitFromSpawnPointOnly: boolean;
  93234. /**
  93235. * Gets or sets the radius of the emission cone
  93236. */
  93237. get radius(): number;
  93238. set radius(value: number);
  93239. /**
  93240. * Gets or sets the angle of the emission cone
  93241. */
  93242. get angle(): number;
  93243. set angle(value: number);
  93244. private _buildHeight;
  93245. /**
  93246. * Creates a new instance ConeParticleEmitter
  93247. * @param radius the radius of the emission cone (1 by default)
  93248. * @param angle the cone base angle (PI by default)
  93249. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93250. */
  93251. constructor(radius?: number, angle?: number,
  93252. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93253. directionRandomizer?: number);
  93254. /**
  93255. * Called by the particle System when the direction is computed for the created particle.
  93256. * @param worldMatrix is the world matrix of the particle system
  93257. * @param directionToUpdate is the direction vector to update with the result
  93258. * @param particle is the particle we are computed the direction for
  93259. * @param isLocal defines if the direction should be set in local space
  93260. */
  93261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93262. /**
  93263. * Called by the particle System when the position is computed for the created particle.
  93264. * @param worldMatrix is the world matrix of the particle system
  93265. * @param positionToUpdate is the position vector to update with the result
  93266. * @param particle is the particle we are computed the position for
  93267. * @param isLocal defines if the position should be set in local space
  93268. */
  93269. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93270. /**
  93271. * Clones the current emitter and returns a copy of it
  93272. * @returns the new emitter
  93273. */
  93274. clone(): ConeParticleEmitter;
  93275. /**
  93276. * Called by the GPUParticleSystem to setup the update shader
  93277. * @param effect defines the update shader
  93278. */
  93279. applyToShader(effect: Effect): void;
  93280. /**
  93281. * Returns a string to use to update the GPU particles update shader
  93282. * @returns a string containng the defines string
  93283. */
  93284. getEffectDefines(): string;
  93285. /**
  93286. * Returns the string "ConeParticleEmitter"
  93287. * @returns a string containing the class name
  93288. */
  93289. getClassName(): string;
  93290. /**
  93291. * Serializes the particle system to a JSON object.
  93292. * @returns the JSON object
  93293. */
  93294. serialize(): any;
  93295. /**
  93296. * Parse properties from a JSON object
  93297. * @param serializationObject defines the JSON object
  93298. */
  93299. parse(serializationObject: any): void;
  93300. }
  93301. }
  93302. declare module BABYLON {
  93303. /**
  93304. * Particle emitter emitting particles from the inside of a cylinder.
  93305. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93306. */
  93307. export class CylinderParticleEmitter implements IParticleEmitterType {
  93308. /**
  93309. * The radius of the emission cylinder.
  93310. */
  93311. radius: number;
  93312. /**
  93313. * The height of the emission cylinder.
  93314. */
  93315. height: number;
  93316. /**
  93317. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93318. */
  93319. radiusRange: number;
  93320. /**
  93321. * How much to randomize the particle direction [0-1].
  93322. */
  93323. directionRandomizer: number;
  93324. /**
  93325. * Creates a new instance CylinderParticleEmitter
  93326. * @param radius the radius of the emission cylinder (1 by default)
  93327. * @param height the height of the emission cylinder (1 by default)
  93328. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93329. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93330. */
  93331. constructor(
  93332. /**
  93333. * The radius of the emission cylinder.
  93334. */
  93335. radius?: number,
  93336. /**
  93337. * The height of the emission cylinder.
  93338. */
  93339. height?: number,
  93340. /**
  93341. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93342. */
  93343. radiusRange?: number,
  93344. /**
  93345. * How much to randomize the particle direction [0-1].
  93346. */
  93347. directionRandomizer?: number);
  93348. /**
  93349. * Called by the particle System when the direction is computed for the created particle.
  93350. * @param worldMatrix is the world matrix of the particle system
  93351. * @param directionToUpdate is the direction vector to update with the result
  93352. * @param particle is the particle we are computed the direction for
  93353. * @param isLocal defines if the direction should be set in local space
  93354. */
  93355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93356. /**
  93357. * Called by the particle System when the position is computed for the created particle.
  93358. * @param worldMatrix is the world matrix of the particle system
  93359. * @param positionToUpdate is the position vector to update with the result
  93360. * @param particle is the particle we are computed the position for
  93361. * @param isLocal defines if the position should be set in local space
  93362. */
  93363. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93364. /**
  93365. * Clones the current emitter and returns a copy of it
  93366. * @returns the new emitter
  93367. */
  93368. clone(): CylinderParticleEmitter;
  93369. /**
  93370. * Called by the GPUParticleSystem to setup the update shader
  93371. * @param effect defines the update shader
  93372. */
  93373. applyToShader(effect: Effect): void;
  93374. /**
  93375. * Returns a string to use to update the GPU particles update shader
  93376. * @returns a string containng the defines string
  93377. */
  93378. getEffectDefines(): string;
  93379. /**
  93380. * Returns the string "CylinderParticleEmitter"
  93381. * @returns a string containing the class name
  93382. */
  93383. getClassName(): string;
  93384. /**
  93385. * Serializes the particle system to a JSON object.
  93386. * @returns the JSON object
  93387. */
  93388. serialize(): any;
  93389. /**
  93390. * Parse properties from a JSON object
  93391. * @param serializationObject defines the JSON object
  93392. */
  93393. parse(serializationObject: any): void;
  93394. }
  93395. /**
  93396. * Particle emitter emitting particles from the inside of a cylinder.
  93397. * It emits the particles randomly between two vectors.
  93398. */
  93399. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93400. /**
  93401. * The min limit of the emission direction.
  93402. */
  93403. direction1: Vector3;
  93404. /**
  93405. * The max limit of the emission direction.
  93406. */
  93407. direction2: Vector3;
  93408. /**
  93409. * Creates a new instance CylinderDirectedParticleEmitter
  93410. * @param radius the radius of the emission cylinder (1 by default)
  93411. * @param height the height of the emission cylinder (1 by default)
  93412. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93413. * @param direction1 the min limit of the emission direction (up vector by default)
  93414. * @param direction2 the max limit of the emission direction (up vector by default)
  93415. */
  93416. constructor(radius?: number, height?: number, radiusRange?: number,
  93417. /**
  93418. * The min limit of the emission direction.
  93419. */
  93420. direction1?: Vector3,
  93421. /**
  93422. * The max limit of the emission direction.
  93423. */
  93424. direction2?: Vector3);
  93425. /**
  93426. * Called by the particle System when the direction is computed for the created particle.
  93427. * @param worldMatrix is the world matrix of the particle system
  93428. * @param directionToUpdate is the direction vector to update with the result
  93429. * @param particle is the particle we are computed the direction for
  93430. */
  93431. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93432. /**
  93433. * Clones the current emitter and returns a copy of it
  93434. * @returns the new emitter
  93435. */
  93436. clone(): CylinderDirectedParticleEmitter;
  93437. /**
  93438. * Called by the GPUParticleSystem to setup the update shader
  93439. * @param effect defines the update shader
  93440. */
  93441. applyToShader(effect: Effect): void;
  93442. /**
  93443. * Returns a string to use to update the GPU particles update shader
  93444. * @returns a string containng the defines string
  93445. */
  93446. getEffectDefines(): string;
  93447. /**
  93448. * Returns the string "CylinderDirectedParticleEmitter"
  93449. * @returns a string containing the class name
  93450. */
  93451. getClassName(): string;
  93452. /**
  93453. * Serializes the particle system to a JSON object.
  93454. * @returns the JSON object
  93455. */
  93456. serialize(): any;
  93457. /**
  93458. * Parse properties from a JSON object
  93459. * @param serializationObject defines the JSON object
  93460. */
  93461. parse(serializationObject: any): void;
  93462. }
  93463. }
  93464. declare module BABYLON {
  93465. /**
  93466. * Particle emitter emitting particles from the inside of a hemisphere.
  93467. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93468. */
  93469. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93470. /**
  93471. * The radius of the emission hemisphere.
  93472. */
  93473. radius: number;
  93474. /**
  93475. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93476. */
  93477. radiusRange: number;
  93478. /**
  93479. * How much to randomize the particle direction [0-1].
  93480. */
  93481. directionRandomizer: number;
  93482. /**
  93483. * Creates a new instance HemisphericParticleEmitter
  93484. * @param radius the radius of the emission hemisphere (1 by default)
  93485. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93486. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93487. */
  93488. constructor(
  93489. /**
  93490. * The radius of the emission hemisphere.
  93491. */
  93492. radius?: number,
  93493. /**
  93494. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93495. */
  93496. radiusRange?: number,
  93497. /**
  93498. * How much to randomize the particle direction [0-1].
  93499. */
  93500. directionRandomizer?: number);
  93501. /**
  93502. * Called by the particle System when the direction is computed for the created particle.
  93503. * @param worldMatrix is the world matrix of the particle system
  93504. * @param directionToUpdate is the direction vector to update with the result
  93505. * @param particle is the particle we are computed the direction for
  93506. * @param isLocal defines if the direction should be set in local space
  93507. */
  93508. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93509. /**
  93510. * Called by the particle System when the position is computed for the created particle.
  93511. * @param worldMatrix is the world matrix of the particle system
  93512. * @param positionToUpdate is the position vector to update with the result
  93513. * @param particle is the particle we are computed the position for
  93514. * @param isLocal defines if the position should be set in local space
  93515. */
  93516. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93517. /**
  93518. * Clones the current emitter and returns a copy of it
  93519. * @returns the new emitter
  93520. */
  93521. clone(): HemisphericParticleEmitter;
  93522. /**
  93523. * Called by the GPUParticleSystem to setup the update shader
  93524. * @param effect defines the update shader
  93525. */
  93526. applyToShader(effect: Effect): void;
  93527. /**
  93528. * Returns a string to use to update the GPU particles update shader
  93529. * @returns a string containng the defines string
  93530. */
  93531. getEffectDefines(): string;
  93532. /**
  93533. * Returns the string "HemisphericParticleEmitter"
  93534. * @returns a string containing the class name
  93535. */
  93536. getClassName(): string;
  93537. /**
  93538. * Serializes the particle system to a JSON object.
  93539. * @returns the JSON object
  93540. */
  93541. serialize(): any;
  93542. /**
  93543. * Parse properties from a JSON object
  93544. * @param serializationObject defines the JSON object
  93545. */
  93546. parse(serializationObject: any): void;
  93547. }
  93548. }
  93549. declare module BABYLON {
  93550. /**
  93551. * Particle emitter emitting particles from a point.
  93552. * It emits the particles randomly between 2 given directions.
  93553. */
  93554. export class PointParticleEmitter implements IParticleEmitterType {
  93555. /**
  93556. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93557. */
  93558. direction1: Vector3;
  93559. /**
  93560. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93561. */
  93562. direction2: Vector3;
  93563. /**
  93564. * Creates a new instance PointParticleEmitter
  93565. */
  93566. constructor();
  93567. /**
  93568. * Called by the particle System when the direction is computed for the created particle.
  93569. * @param worldMatrix is the world matrix of the particle system
  93570. * @param directionToUpdate is the direction vector to update with the result
  93571. * @param particle is the particle we are computed the direction for
  93572. * @param isLocal defines if the direction should be set in local space
  93573. */
  93574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93575. /**
  93576. * Called by the particle System when the position is computed for the created particle.
  93577. * @param worldMatrix is the world matrix of the particle system
  93578. * @param positionToUpdate is the position vector to update with the result
  93579. * @param particle is the particle we are computed the position for
  93580. * @param isLocal defines if the position should be set in local space
  93581. */
  93582. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93583. /**
  93584. * Clones the current emitter and returns a copy of it
  93585. * @returns the new emitter
  93586. */
  93587. clone(): PointParticleEmitter;
  93588. /**
  93589. * Called by the GPUParticleSystem to setup the update shader
  93590. * @param effect defines the update shader
  93591. */
  93592. applyToShader(effect: Effect): void;
  93593. /**
  93594. * Returns a string to use to update the GPU particles update shader
  93595. * @returns a string containng the defines string
  93596. */
  93597. getEffectDefines(): string;
  93598. /**
  93599. * Returns the string "PointParticleEmitter"
  93600. * @returns a string containing the class name
  93601. */
  93602. getClassName(): string;
  93603. /**
  93604. * Serializes the particle system to a JSON object.
  93605. * @returns the JSON object
  93606. */
  93607. serialize(): any;
  93608. /**
  93609. * Parse properties from a JSON object
  93610. * @param serializationObject defines the JSON object
  93611. */
  93612. parse(serializationObject: any): void;
  93613. }
  93614. }
  93615. declare module BABYLON {
  93616. /**
  93617. * Particle emitter emitting particles from the inside of a sphere.
  93618. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  93619. */
  93620. export class SphereParticleEmitter implements IParticleEmitterType {
  93621. /**
  93622. * The radius of the emission sphere.
  93623. */
  93624. radius: number;
  93625. /**
  93626. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93627. */
  93628. radiusRange: number;
  93629. /**
  93630. * How much to randomize the particle direction [0-1].
  93631. */
  93632. directionRandomizer: number;
  93633. /**
  93634. * Creates a new instance SphereParticleEmitter
  93635. * @param radius the radius of the emission sphere (1 by default)
  93636. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93637. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93638. */
  93639. constructor(
  93640. /**
  93641. * The radius of the emission sphere.
  93642. */
  93643. radius?: number,
  93644. /**
  93645. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93646. */
  93647. radiusRange?: number,
  93648. /**
  93649. * How much to randomize the particle direction [0-1].
  93650. */
  93651. directionRandomizer?: number);
  93652. /**
  93653. * Called by the particle System when the direction is computed for the created particle.
  93654. * @param worldMatrix is the world matrix of the particle system
  93655. * @param directionToUpdate is the direction vector to update with the result
  93656. * @param particle is the particle we are computed the direction for
  93657. * @param isLocal defines if the direction should be set in local space
  93658. */
  93659. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93660. /**
  93661. * Called by the particle System when the position is computed for the created particle.
  93662. * @param worldMatrix is the world matrix of the particle system
  93663. * @param positionToUpdate is the position vector to update with the result
  93664. * @param particle is the particle we are computed the position for
  93665. * @param isLocal defines if the position should be set in local space
  93666. */
  93667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93668. /**
  93669. * Clones the current emitter and returns a copy of it
  93670. * @returns the new emitter
  93671. */
  93672. clone(): SphereParticleEmitter;
  93673. /**
  93674. * Called by the GPUParticleSystem to setup the update shader
  93675. * @param effect defines the update shader
  93676. */
  93677. applyToShader(effect: Effect): void;
  93678. /**
  93679. * Returns a string to use to update the GPU particles update shader
  93680. * @returns a string containng the defines string
  93681. */
  93682. getEffectDefines(): string;
  93683. /**
  93684. * Returns the string "SphereParticleEmitter"
  93685. * @returns a string containing the class name
  93686. */
  93687. getClassName(): string;
  93688. /**
  93689. * Serializes the particle system to a JSON object.
  93690. * @returns the JSON object
  93691. */
  93692. serialize(): any;
  93693. /**
  93694. * Parse properties from a JSON object
  93695. * @param serializationObject defines the JSON object
  93696. */
  93697. parse(serializationObject: any): void;
  93698. }
  93699. /**
  93700. * Particle emitter emitting particles from the inside of a sphere.
  93701. * It emits the particles randomly between two vectors.
  93702. */
  93703. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  93704. /**
  93705. * The min limit of the emission direction.
  93706. */
  93707. direction1: Vector3;
  93708. /**
  93709. * The max limit of the emission direction.
  93710. */
  93711. direction2: Vector3;
  93712. /**
  93713. * Creates a new instance SphereDirectedParticleEmitter
  93714. * @param radius the radius of the emission sphere (1 by default)
  93715. * @param direction1 the min limit of the emission direction (up vector by default)
  93716. * @param direction2 the max limit of the emission direction (up vector by default)
  93717. */
  93718. constructor(radius?: number,
  93719. /**
  93720. * The min limit of the emission direction.
  93721. */
  93722. direction1?: Vector3,
  93723. /**
  93724. * The max limit of the emission direction.
  93725. */
  93726. direction2?: Vector3);
  93727. /**
  93728. * Called by the particle System when the direction is computed for the created particle.
  93729. * @param worldMatrix is the world matrix of the particle system
  93730. * @param directionToUpdate is the direction vector to update with the result
  93731. * @param particle is the particle we are computed the direction for
  93732. */
  93733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93734. /**
  93735. * Clones the current emitter and returns a copy of it
  93736. * @returns the new emitter
  93737. */
  93738. clone(): SphereDirectedParticleEmitter;
  93739. /**
  93740. * Called by the GPUParticleSystem to setup the update shader
  93741. * @param effect defines the update shader
  93742. */
  93743. applyToShader(effect: Effect): void;
  93744. /**
  93745. * Returns a string to use to update the GPU particles update shader
  93746. * @returns a string containng the defines string
  93747. */
  93748. getEffectDefines(): string;
  93749. /**
  93750. * Returns the string "SphereDirectedParticleEmitter"
  93751. * @returns a string containing the class name
  93752. */
  93753. getClassName(): string;
  93754. /**
  93755. * Serializes the particle system to a JSON object.
  93756. * @returns the JSON object
  93757. */
  93758. serialize(): any;
  93759. /**
  93760. * Parse properties from a JSON object
  93761. * @param serializationObject defines the JSON object
  93762. */
  93763. parse(serializationObject: any): void;
  93764. }
  93765. }
  93766. declare module BABYLON {
  93767. /**
  93768. * Particle emitter emitting particles from a custom list of positions.
  93769. */
  93770. export class CustomParticleEmitter implements IParticleEmitterType {
  93771. /**
  93772. * Gets or sets the position generator that will create the inital position of each particle.
  93773. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93774. */
  93775. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  93776. /**
  93777. * Gets or sets the destination generator that will create the final destination of each particle.
  93778. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93779. */
  93780. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  93781. /**
  93782. * Creates a new instance CustomParticleEmitter
  93783. */
  93784. constructor();
  93785. /**
  93786. * Called by the particle System when the direction is computed for the created particle.
  93787. * @param worldMatrix is the world matrix of the particle system
  93788. * @param directionToUpdate is the direction vector to update with the result
  93789. * @param particle is the particle we are computed the direction for
  93790. * @param isLocal defines if the direction should be set in local space
  93791. */
  93792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93793. /**
  93794. * Called by the particle System when the position is computed for the created particle.
  93795. * @param worldMatrix is the world matrix of the particle system
  93796. * @param positionToUpdate is the position vector to update with the result
  93797. * @param particle is the particle we are computed the position for
  93798. * @param isLocal defines if the position should be set in local space
  93799. */
  93800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93801. /**
  93802. * Clones the current emitter and returns a copy of it
  93803. * @returns the new emitter
  93804. */
  93805. clone(): CustomParticleEmitter;
  93806. /**
  93807. * Called by the GPUParticleSystem to setup the update shader
  93808. * @param effect defines the update shader
  93809. */
  93810. applyToShader(effect: Effect): void;
  93811. /**
  93812. * Returns a string to use to update the GPU particles update shader
  93813. * @returns a string containng the defines string
  93814. */
  93815. getEffectDefines(): string;
  93816. /**
  93817. * Returns the string "PointParticleEmitter"
  93818. * @returns a string containing the class name
  93819. */
  93820. getClassName(): string;
  93821. /**
  93822. * Serializes the particle system to a JSON object.
  93823. * @returns the JSON object
  93824. */
  93825. serialize(): any;
  93826. /**
  93827. * Parse properties from a JSON object
  93828. * @param serializationObject defines the JSON object
  93829. */
  93830. parse(serializationObject: any): void;
  93831. }
  93832. }
  93833. declare module BABYLON {
  93834. /**
  93835. * Particle emitter emitting particles from the inside of a box.
  93836. * It emits the particles randomly between 2 given directions.
  93837. */
  93838. export class MeshParticleEmitter implements IParticleEmitterType {
  93839. private _indices;
  93840. private _positions;
  93841. private _normals;
  93842. private _storedNormal;
  93843. private _mesh;
  93844. /**
  93845. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93846. */
  93847. direction1: Vector3;
  93848. /**
  93849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93850. */
  93851. direction2: Vector3;
  93852. /**
  93853. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  93854. */
  93855. useMeshNormalsForDirection: boolean;
  93856. /** Defines the mesh to use as source */
  93857. get mesh(): Nullable<AbstractMesh>;
  93858. set mesh(value: Nullable<AbstractMesh>);
  93859. /**
  93860. * Creates a new instance MeshParticleEmitter
  93861. * @param mesh defines the mesh to use as source
  93862. */
  93863. constructor(mesh?: Nullable<AbstractMesh>);
  93864. /**
  93865. * Called by the particle System when the direction is computed for the created particle.
  93866. * @param worldMatrix is the world matrix of the particle system
  93867. * @param directionToUpdate is the direction vector to update with the result
  93868. * @param particle is the particle we are computed the direction for
  93869. * @param isLocal defines if the direction should be set in local space
  93870. */
  93871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93872. /**
  93873. * Called by the particle System when the position is computed for the created particle.
  93874. * @param worldMatrix is the world matrix of the particle system
  93875. * @param positionToUpdate is the position vector to update with the result
  93876. * @param particle is the particle we are computed the position for
  93877. * @param isLocal defines if the position should be set in local space
  93878. */
  93879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93880. /**
  93881. * Clones the current emitter and returns a copy of it
  93882. * @returns the new emitter
  93883. */
  93884. clone(): MeshParticleEmitter;
  93885. /**
  93886. * Called by the GPUParticleSystem to setup the update shader
  93887. * @param effect defines the update shader
  93888. */
  93889. applyToShader(effect: Effect): void;
  93890. /**
  93891. * Returns a string to use to update the GPU particles update shader
  93892. * @returns a string containng the defines string
  93893. */
  93894. getEffectDefines(): string;
  93895. /**
  93896. * Returns the string "BoxParticleEmitter"
  93897. * @returns a string containing the class name
  93898. */
  93899. getClassName(): string;
  93900. /**
  93901. * Serializes the particle system to a JSON object.
  93902. * @returns the JSON object
  93903. */
  93904. serialize(): any;
  93905. /**
  93906. * Parse properties from a JSON object
  93907. * @param serializationObject defines the JSON object
  93908. * @param scene defines the hosting scene
  93909. */
  93910. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93911. }
  93912. }
  93913. declare module BABYLON {
  93914. /**
  93915. * Interface representing a particle system in Babylon.js.
  93916. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  93917. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  93918. */
  93919. export interface IParticleSystem {
  93920. /**
  93921. * List of animations used by the particle system.
  93922. */
  93923. animations: Animation[];
  93924. /**
  93925. * The id of the Particle system.
  93926. */
  93927. id: string;
  93928. /**
  93929. * The name of the Particle system.
  93930. */
  93931. name: string;
  93932. /**
  93933. * The emitter represents the Mesh or position we are attaching the particle system to.
  93934. */
  93935. emitter: Nullable<AbstractMesh | Vector3>;
  93936. /**
  93937. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93938. */
  93939. isBillboardBased: boolean;
  93940. /**
  93941. * The rendering group used by the Particle system to chose when to render.
  93942. */
  93943. renderingGroupId: number;
  93944. /**
  93945. * The layer mask we are rendering the particles through.
  93946. */
  93947. layerMask: number;
  93948. /**
  93949. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93950. */
  93951. updateSpeed: number;
  93952. /**
  93953. * The amount of time the particle system is running (depends of the overall update speed).
  93954. */
  93955. targetStopDuration: number;
  93956. /**
  93957. * The texture used to render each particle. (this can be a spritesheet)
  93958. */
  93959. particleTexture: Nullable<BaseTexture>;
  93960. /**
  93961. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93962. */
  93963. blendMode: number;
  93964. /**
  93965. * Minimum life time of emitting particles.
  93966. */
  93967. minLifeTime: number;
  93968. /**
  93969. * Maximum life time of emitting particles.
  93970. */
  93971. maxLifeTime: number;
  93972. /**
  93973. * Minimum Size of emitting particles.
  93974. */
  93975. minSize: number;
  93976. /**
  93977. * Maximum Size of emitting particles.
  93978. */
  93979. maxSize: number;
  93980. /**
  93981. * Minimum scale of emitting particles on X axis.
  93982. */
  93983. minScaleX: number;
  93984. /**
  93985. * Maximum scale of emitting particles on X axis.
  93986. */
  93987. maxScaleX: number;
  93988. /**
  93989. * Minimum scale of emitting particles on Y axis.
  93990. */
  93991. minScaleY: number;
  93992. /**
  93993. * Maximum scale of emitting particles on Y axis.
  93994. */
  93995. maxScaleY: number;
  93996. /**
  93997. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93998. */
  93999. color1: Color4;
  94000. /**
  94001. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94002. */
  94003. color2: Color4;
  94004. /**
  94005. * Color the particle will have at the end of its lifetime.
  94006. */
  94007. colorDead: Color4;
  94008. /**
  94009. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94010. */
  94011. emitRate: number;
  94012. /**
  94013. * You can use gravity if you want to give an orientation to your particles.
  94014. */
  94015. gravity: Vector3;
  94016. /**
  94017. * Minimum power of emitting particles.
  94018. */
  94019. minEmitPower: number;
  94020. /**
  94021. * Maximum power of emitting particles.
  94022. */
  94023. maxEmitPower: number;
  94024. /**
  94025. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94026. */
  94027. minAngularSpeed: number;
  94028. /**
  94029. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94030. */
  94031. maxAngularSpeed: number;
  94032. /**
  94033. * Gets or sets the minimal initial rotation in radians.
  94034. */
  94035. minInitialRotation: number;
  94036. /**
  94037. * Gets or sets the maximal initial rotation in radians.
  94038. */
  94039. maxInitialRotation: number;
  94040. /**
  94041. * The particle emitter type defines the emitter used by the particle system.
  94042. * It can be for example box, sphere, or cone...
  94043. */
  94044. particleEmitterType: Nullable<IParticleEmitterType>;
  94045. /**
  94046. * Defines the delay in milliseconds before starting the system (0 by default)
  94047. */
  94048. startDelay: number;
  94049. /**
  94050. * 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
  94051. */
  94052. preWarmCycles: number;
  94053. /**
  94054. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94055. */
  94056. preWarmStepOffset: number;
  94057. /**
  94058. * 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)
  94059. */
  94060. spriteCellChangeSpeed: number;
  94061. /**
  94062. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94063. */
  94064. startSpriteCellID: number;
  94065. /**
  94066. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94067. */
  94068. endSpriteCellID: number;
  94069. /**
  94070. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94071. */
  94072. spriteCellWidth: number;
  94073. /**
  94074. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94075. */
  94076. spriteCellHeight: number;
  94077. /**
  94078. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94079. */
  94080. spriteRandomStartCell: boolean;
  94081. /**
  94082. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94083. */
  94084. isAnimationSheetEnabled: boolean;
  94085. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94086. translationPivot: Vector2;
  94087. /**
  94088. * Gets or sets a texture used to add random noise to particle positions
  94089. */
  94090. noiseTexture: Nullable<BaseTexture>;
  94091. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94092. noiseStrength: Vector3;
  94093. /**
  94094. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94095. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94096. */
  94097. billboardMode: number;
  94098. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94099. limitVelocityDamping: number;
  94100. /**
  94101. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94102. */
  94103. beginAnimationOnStart: boolean;
  94104. /**
  94105. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94106. */
  94107. beginAnimationFrom: number;
  94108. /**
  94109. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94110. */
  94111. beginAnimationTo: number;
  94112. /**
  94113. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94114. */
  94115. beginAnimationLoop: boolean;
  94116. /**
  94117. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94118. */
  94119. disposeOnStop: boolean;
  94120. /**
  94121. * Specifies if the particles are updated in emitter local space or world space
  94122. */
  94123. isLocal: boolean;
  94124. /** Snippet ID if the particle system was created from the snippet server */
  94125. snippetId: string;
  94126. /** Gets or sets a matrix to use to compute projection */
  94127. defaultProjectionMatrix: Matrix;
  94128. /**
  94129. * Gets the maximum number of particles active at the same time.
  94130. * @returns The max number of active particles.
  94131. */
  94132. getCapacity(): number;
  94133. /**
  94134. * Gets the number of particles active at the same time.
  94135. * @returns The number of active particles.
  94136. */
  94137. getActiveCount(): number;
  94138. /**
  94139. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94140. * @returns True if it has been started, otherwise false.
  94141. */
  94142. isStarted(): boolean;
  94143. /**
  94144. * Animates the particle system for this frame.
  94145. */
  94146. animate(): void;
  94147. /**
  94148. * Renders the particle system in its current state.
  94149. * @returns the current number of particles
  94150. */
  94151. render(): number;
  94152. /**
  94153. * Dispose the particle system and frees its associated resources.
  94154. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94155. */
  94156. dispose(disposeTexture?: boolean): void;
  94157. /**
  94158. * An event triggered when the system is disposed
  94159. */
  94160. onDisposeObservable: Observable<IParticleSystem>;
  94161. /**
  94162. * Clones the particle system.
  94163. * @param name The name of the cloned object
  94164. * @param newEmitter The new emitter to use
  94165. * @returns the cloned particle system
  94166. */
  94167. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94168. /**
  94169. * Serializes the particle system to a JSON object
  94170. * @param serializeTexture defines if the texture must be serialized as well
  94171. * @returns the JSON object
  94172. */
  94173. serialize(serializeTexture: boolean): any;
  94174. /**
  94175. * Rebuild the particle system
  94176. */
  94177. rebuild(): void;
  94178. /** Force the system to rebuild all gradients that need to be resync */
  94179. forceRefreshGradients(): void;
  94180. /**
  94181. * Starts the particle system and begins to emit
  94182. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94183. */
  94184. start(delay?: number): void;
  94185. /**
  94186. * Stops the particle system.
  94187. */
  94188. stop(): void;
  94189. /**
  94190. * Remove all active particles
  94191. */
  94192. reset(): void;
  94193. /**
  94194. * Gets a boolean indicating that the system is stopping
  94195. * @returns true if the system is currently stopping
  94196. */
  94197. isStopping(): boolean;
  94198. /**
  94199. * Is this system ready to be used/rendered
  94200. * @return true if the system is ready
  94201. */
  94202. isReady(): boolean;
  94203. /**
  94204. * Returns the string "ParticleSystem"
  94205. * @returns a string containing the class name
  94206. */
  94207. getClassName(): string;
  94208. /**
  94209. * Gets the custom effect used to render the particles
  94210. * @param blendMode Blend mode for which the effect should be retrieved
  94211. * @returns The effect
  94212. */
  94213. getCustomEffect(blendMode: number): Nullable<Effect>;
  94214. /**
  94215. * Sets the custom effect used to render the particles
  94216. * @param effect The effect to set
  94217. * @param blendMode Blend mode for which the effect should be set
  94218. */
  94219. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94220. /**
  94221. * Fill the defines array according to the current settings of the particle system
  94222. * @param defines Array to be updated
  94223. * @param blendMode blend mode to take into account when updating the array
  94224. */
  94225. fillDefines(defines: Array<string>, blendMode: number): void;
  94226. /**
  94227. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94228. * @param uniforms Uniforms array to fill
  94229. * @param attributes Attributes array to fill
  94230. * @param samplers Samplers array to fill
  94231. */
  94232. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94233. /**
  94234. * Observable that will be called just before the particles are drawn
  94235. */
  94236. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94237. /**
  94238. * Gets the name of the particle vertex shader
  94239. */
  94240. vertexShaderName: string;
  94241. /**
  94242. * Adds a new color gradient
  94243. * @param gradient defines the gradient to use (between 0 and 1)
  94244. * @param color1 defines the color to affect to the specified gradient
  94245. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94246. * @returns the current particle system
  94247. */
  94248. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94249. /**
  94250. * Remove a specific color gradient
  94251. * @param gradient defines the gradient to remove
  94252. * @returns the current particle system
  94253. */
  94254. removeColorGradient(gradient: number): IParticleSystem;
  94255. /**
  94256. * Adds a new size gradient
  94257. * @param gradient defines the gradient to use (between 0 and 1)
  94258. * @param factor defines the size factor to affect to the specified gradient
  94259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94260. * @returns the current particle system
  94261. */
  94262. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94263. /**
  94264. * Remove a specific size gradient
  94265. * @param gradient defines the gradient to remove
  94266. * @returns the current particle system
  94267. */
  94268. removeSizeGradient(gradient: number): IParticleSystem;
  94269. /**
  94270. * Gets the current list of color gradients.
  94271. * You must use addColorGradient and removeColorGradient to udpate this list
  94272. * @returns the list of color gradients
  94273. */
  94274. getColorGradients(): Nullable<Array<ColorGradient>>;
  94275. /**
  94276. * Gets the current list of size gradients.
  94277. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94278. * @returns the list of size gradients
  94279. */
  94280. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94281. /**
  94282. * Gets the current list of angular speed gradients.
  94283. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94284. * @returns the list of angular speed gradients
  94285. */
  94286. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94287. /**
  94288. * Adds a new angular speed gradient
  94289. * @param gradient defines the gradient to use (between 0 and 1)
  94290. * @param factor defines the angular speed to affect to the specified gradient
  94291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94292. * @returns the current particle system
  94293. */
  94294. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94295. /**
  94296. * Remove a specific angular speed gradient
  94297. * @param gradient defines the gradient to remove
  94298. * @returns the current particle system
  94299. */
  94300. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94301. /**
  94302. * Gets the current list of velocity gradients.
  94303. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94304. * @returns the list of velocity gradients
  94305. */
  94306. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94307. /**
  94308. * Adds a new velocity gradient
  94309. * @param gradient defines the gradient to use (between 0 and 1)
  94310. * @param factor defines the velocity to affect to the specified gradient
  94311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94312. * @returns the current particle system
  94313. */
  94314. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94315. /**
  94316. * Remove a specific velocity gradient
  94317. * @param gradient defines the gradient to remove
  94318. * @returns the current particle system
  94319. */
  94320. removeVelocityGradient(gradient: number): IParticleSystem;
  94321. /**
  94322. * Gets the current list of limit velocity gradients.
  94323. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94324. * @returns the list of limit velocity gradients
  94325. */
  94326. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94327. /**
  94328. * Adds a new limit velocity gradient
  94329. * @param gradient defines the gradient to use (between 0 and 1)
  94330. * @param factor defines the limit velocity to affect to the specified gradient
  94331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94332. * @returns the current particle system
  94333. */
  94334. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94335. /**
  94336. * Remove a specific limit velocity gradient
  94337. * @param gradient defines the gradient to remove
  94338. * @returns the current particle system
  94339. */
  94340. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94341. /**
  94342. * Adds a new drag gradient
  94343. * @param gradient defines the gradient to use (between 0 and 1)
  94344. * @param factor defines the drag to affect to the specified gradient
  94345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94346. * @returns the current particle system
  94347. */
  94348. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94349. /**
  94350. * Remove a specific drag gradient
  94351. * @param gradient defines the gradient to remove
  94352. * @returns the current particle system
  94353. */
  94354. removeDragGradient(gradient: number): IParticleSystem;
  94355. /**
  94356. * Gets the current list of drag gradients.
  94357. * You must use addDragGradient and removeDragGradient to udpate this list
  94358. * @returns the list of drag gradients
  94359. */
  94360. getDragGradients(): Nullable<Array<FactorGradient>>;
  94361. /**
  94362. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94363. * @param gradient defines the gradient to use (between 0 and 1)
  94364. * @param factor defines the emit rate to affect to the specified gradient
  94365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94366. * @returns the current particle system
  94367. */
  94368. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94369. /**
  94370. * Remove a specific emit rate gradient
  94371. * @param gradient defines the gradient to remove
  94372. * @returns the current particle system
  94373. */
  94374. removeEmitRateGradient(gradient: number): IParticleSystem;
  94375. /**
  94376. * Gets the current list of emit rate gradients.
  94377. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94378. * @returns the list of emit rate gradients
  94379. */
  94380. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94381. /**
  94382. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94383. * @param gradient defines the gradient to use (between 0 and 1)
  94384. * @param factor defines the start size to affect to the specified gradient
  94385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94386. * @returns the current particle system
  94387. */
  94388. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94389. /**
  94390. * Remove a specific start size gradient
  94391. * @param gradient defines the gradient to remove
  94392. * @returns the current particle system
  94393. */
  94394. removeStartSizeGradient(gradient: number): IParticleSystem;
  94395. /**
  94396. * Gets the current list of start size gradients.
  94397. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94398. * @returns the list of start size gradients
  94399. */
  94400. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94401. /**
  94402. * Adds a new life time gradient
  94403. * @param gradient defines the gradient to use (between 0 and 1)
  94404. * @param factor defines the life time factor to affect to the specified gradient
  94405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94406. * @returns the current particle system
  94407. */
  94408. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94409. /**
  94410. * Remove a specific life time gradient
  94411. * @param gradient defines the gradient to remove
  94412. * @returns the current particle system
  94413. */
  94414. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94415. /**
  94416. * Gets the current list of life time gradients.
  94417. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94418. * @returns the list of life time gradients
  94419. */
  94420. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94421. /**
  94422. * Gets the current list of color gradients.
  94423. * You must use addColorGradient and removeColorGradient to udpate this list
  94424. * @returns the list of color gradients
  94425. */
  94426. getColorGradients(): Nullable<Array<ColorGradient>>;
  94427. /**
  94428. * Adds a new ramp gradient used to remap particle colors
  94429. * @param gradient defines the gradient to use (between 0 and 1)
  94430. * @param color defines the color to affect to the specified gradient
  94431. * @returns the current particle system
  94432. */
  94433. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94434. /**
  94435. * Gets the current list of ramp gradients.
  94436. * You must use addRampGradient and removeRampGradient to udpate this list
  94437. * @returns the list of ramp gradients
  94438. */
  94439. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94440. /** Gets or sets a boolean indicating that ramp gradients must be used
  94441. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94442. */
  94443. useRampGradients: boolean;
  94444. /**
  94445. * Adds a new color remap gradient
  94446. * @param gradient defines the gradient to use (between 0 and 1)
  94447. * @param min defines the color remap minimal range
  94448. * @param max defines the color remap maximal range
  94449. * @returns the current particle system
  94450. */
  94451. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94452. /**
  94453. * Gets the current list of color remap gradients.
  94454. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94455. * @returns the list of color remap gradients
  94456. */
  94457. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94458. /**
  94459. * Adds a new alpha remap gradient
  94460. * @param gradient defines the gradient to use (between 0 and 1)
  94461. * @param min defines the alpha remap minimal range
  94462. * @param max defines the alpha remap maximal range
  94463. * @returns the current particle system
  94464. */
  94465. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94466. /**
  94467. * Gets the current list of alpha remap gradients.
  94468. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94469. * @returns the list of alpha remap gradients
  94470. */
  94471. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94472. /**
  94473. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94476. * @returns the emitter
  94477. */
  94478. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94479. /**
  94480. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94481. * @param radius The radius of the hemisphere to emit from
  94482. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94483. * @returns the emitter
  94484. */
  94485. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94486. /**
  94487. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94488. * @param radius The radius of the sphere to emit from
  94489. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94490. * @returns the emitter
  94491. */
  94492. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94493. /**
  94494. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94495. * @param radius The radius of the sphere to emit from
  94496. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94497. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94498. * @returns the emitter
  94499. */
  94500. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94501. /**
  94502. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94503. * @param radius The radius of the emission cylinder
  94504. * @param height The height of the emission cylinder
  94505. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94506. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94507. * @returns the emitter
  94508. */
  94509. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94510. /**
  94511. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94512. * @param radius The radius of the cylinder to emit from
  94513. * @param height The height of the emission cylinder
  94514. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94515. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94516. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94517. * @returns the emitter
  94518. */
  94519. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94520. /**
  94521. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94522. * @param radius The radius of the cone to emit from
  94523. * @param angle The base angle of the cone
  94524. * @returns the emitter
  94525. */
  94526. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94527. /**
  94528. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94531. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94532. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94533. * @returns the emitter
  94534. */
  94535. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94536. /**
  94537. * Get hosting scene
  94538. * @returns the scene
  94539. */
  94540. getScene(): Nullable<Scene>;
  94541. }
  94542. }
  94543. declare module BABYLON {
  94544. /**
  94545. * 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.
  94546. * @see https://doc.babylonjs.com/how_to/transformnode
  94547. */
  94548. export class TransformNode extends Node {
  94549. /**
  94550. * Object will not rotate to face the camera
  94551. */
  94552. static BILLBOARDMODE_NONE: number;
  94553. /**
  94554. * Object will rotate to face the camera but only on the x axis
  94555. */
  94556. static BILLBOARDMODE_X: number;
  94557. /**
  94558. * Object will rotate to face the camera but only on the y axis
  94559. */
  94560. static BILLBOARDMODE_Y: number;
  94561. /**
  94562. * Object will rotate to face the camera but only on the z axis
  94563. */
  94564. static BILLBOARDMODE_Z: number;
  94565. /**
  94566. * Object will rotate to face the camera
  94567. */
  94568. static BILLBOARDMODE_ALL: number;
  94569. /**
  94570. * Object will rotate to face the camera's position instead of orientation
  94571. */
  94572. static BILLBOARDMODE_USE_POSITION: number;
  94573. private static _TmpRotation;
  94574. private static _TmpScaling;
  94575. private static _TmpTranslation;
  94576. private _forward;
  94577. private _forwardInverted;
  94578. private _up;
  94579. private _right;
  94580. private _rightInverted;
  94581. private _position;
  94582. private _rotation;
  94583. private _rotationQuaternion;
  94584. protected _scaling: Vector3;
  94585. protected _isDirty: boolean;
  94586. private _transformToBoneReferal;
  94587. private _isAbsoluteSynced;
  94588. private _billboardMode;
  94589. /**
  94590. * Gets or sets the billboard mode. Default is 0.
  94591. *
  94592. * | Value | Type | Description |
  94593. * | --- | --- | --- |
  94594. * | 0 | BILLBOARDMODE_NONE | |
  94595. * | 1 | BILLBOARDMODE_X | |
  94596. * | 2 | BILLBOARDMODE_Y | |
  94597. * | 4 | BILLBOARDMODE_Z | |
  94598. * | 7 | BILLBOARDMODE_ALL | |
  94599. *
  94600. */
  94601. get billboardMode(): number;
  94602. set billboardMode(value: number);
  94603. private _preserveParentRotationForBillboard;
  94604. /**
  94605. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94606. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94607. */
  94608. get preserveParentRotationForBillboard(): boolean;
  94609. set preserveParentRotationForBillboard(value: boolean);
  94610. /**
  94611. * 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
  94612. */
  94613. scalingDeterminant: number;
  94614. private _infiniteDistance;
  94615. /**
  94616. * Gets or sets the distance of the object to max, often used by skybox
  94617. */
  94618. get infiniteDistance(): boolean;
  94619. set infiniteDistance(value: boolean);
  94620. /**
  94621. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94622. * By default the system will update normals to compensate
  94623. */
  94624. ignoreNonUniformScaling: boolean;
  94625. /**
  94626. * 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
  94627. */
  94628. reIntegrateRotationIntoRotationQuaternion: boolean;
  94629. /** @hidden */
  94630. _poseMatrix: Nullable<Matrix>;
  94631. /** @hidden */
  94632. _localMatrix: Matrix;
  94633. private _usePivotMatrix;
  94634. private _absolutePosition;
  94635. private _absoluteScaling;
  94636. private _absoluteRotationQuaternion;
  94637. private _pivotMatrix;
  94638. private _pivotMatrixInverse;
  94639. /** @hidden */
  94640. _postMultiplyPivotMatrix: boolean;
  94641. protected _isWorldMatrixFrozen: boolean;
  94642. /** @hidden */
  94643. _indexInSceneTransformNodesArray: number;
  94644. /**
  94645. * An event triggered after the world matrix is updated
  94646. */
  94647. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  94648. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  94649. /**
  94650. * Gets a string identifying the name of the class
  94651. * @returns "TransformNode" string
  94652. */
  94653. getClassName(): string;
  94654. /**
  94655. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94656. */
  94657. get position(): Vector3;
  94658. set position(newPosition: Vector3);
  94659. /**
  94660. * 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)).
  94661. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94662. */
  94663. get rotation(): Vector3;
  94664. set rotation(newRotation: Vector3);
  94665. /**
  94666. * 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)).
  94667. */
  94668. get scaling(): Vector3;
  94669. set scaling(newScaling: Vector3);
  94670. /**
  94671. * 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).
  94672. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94673. */
  94674. get rotationQuaternion(): Nullable<Quaternion>;
  94675. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  94676. /**
  94677. * The forward direction of that transform in world space.
  94678. */
  94679. get forward(): Vector3;
  94680. /**
  94681. * The up direction of that transform in world space.
  94682. */
  94683. get up(): Vector3;
  94684. /**
  94685. * The right direction of that transform in world space.
  94686. */
  94687. get right(): Vector3;
  94688. /**
  94689. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94690. * @param matrix the matrix to copy the pose from
  94691. * @returns this TransformNode.
  94692. */
  94693. updatePoseMatrix(matrix: Matrix): TransformNode;
  94694. /**
  94695. * Returns the mesh Pose matrix.
  94696. * @returns the pose matrix
  94697. */
  94698. getPoseMatrix(): Matrix;
  94699. /** @hidden */
  94700. _isSynchronized(): boolean;
  94701. /** @hidden */
  94702. _initCache(): void;
  94703. /**
  94704. * Flag the transform node as dirty (Forcing it to update everything)
  94705. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94706. * @returns this transform node
  94707. */
  94708. markAsDirty(property: string): TransformNode;
  94709. /**
  94710. * Returns the current mesh absolute position.
  94711. * Returns a Vector3.
  94712. */
  94713. get absolutePosition(): Vector3;
  94714. /**
  94715. * Returns the current mesh absolute scaling.
  94716. * Returns a Vector3.
  94717. */
  94718. get absoluteScaling(): Vector3;
  94719. /**
  94720. * Returns the current mesh absolute rotation.
  94721. * Returns a Quaternion.
  94722. */
  94723. get absoluteRotationQuaternion(): Quaternion;
  94724. /**
  94725. * Sets a new matrix to apply before all other transformation
  94726. * @param matrix defines the transform matrix
  94727. * @returns the current TransformNode
  94728. */
  94729. setPreTransformMatrix(matrix: Matrix): TransformNode;
  94730. /**
  94731. * Sets a new pivot matrix to the current node
  94732. * @param matrix defines the new pivot matrix to use
  94733. * @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
  94734. * @returns the current TransformNode
  94735. */
  94736. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  94737. /**
  94738. * Returns the mesh pivot matrix.
  94739. * Default : Identity.
  94740. * @returns the matrix
  94741. */
  94742. getPivotMatrix(): Matrix;
  94743. /**
  94744. * Instantiate (when possible) or clone that node with its hierarchy
  94745. * @param newParent defines the new parent to use for the instance (or clone)
  94746. * @param options defines options to configure how copy is done
  94747. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  94748. * @returns an instance (or a clone) of the current node with its hiearchy
  94749. */
  94750. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94751. doNotInstantiate: boolean;
  94752. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94753. /**
  94754. * Prevents the World matrix to be computed any longer
  94755. * @param newWorldMatrix defines an optional matrix to use as world matrix
  94756. * @returns the TransformNode.
  94757. */
  94758. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  94759. /**
  94760. * Allows back the World matrix computation.
  94761. * @returns the TransformNode.
  94762. */
  94763. unfreezeWorldMatrix(): this;
  94764. /**
  94765. * True if the World matrix has been frozen.
  94766. */
  94767. get isWorldMatrixFrozen(): boolean;
  94768. /**
  94769. * Retuns the mesh absolute position in the World.
  94770. * @returns a Vector3.
  94771. */
  94772. getAbsolutePosition(): Vector3;
  94773. /**
  94774. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94775. * @param absolutePosition the absolute position to set
  94776. * @returns the TransformNode.
  94777. */
  94778. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94779. /**
  94780. * Sets the mesh position in its local space.
  94781. * @param vector3 the position to set in localspace
  94782. * @returns the TransformNode.
  94783. */
  94784. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  94785. /**
  94786. * Returns the mesh position in the local space from the current World matrix values.
  94787. * @returns a new Vector3.
  94788. */
  94789. getPositionExpressedInLocalSpace(): Vector3;
  94790. /**
  94791. * Translates the mesh along the passed Vector3 in its local space.
  94792. * @param vector3 the distance to translate in localspace
  94793. * @returns the TransformNode.
  94794. */
  94795. locallyTranslate(vector3: Vector3): TransformNode;
  94796. private static _lookAtVectorCache;
  94797. /**
  94798. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94799. * @param targetPoint the position (must be in same space as current mesh) to look at
  94800. * @param yawCor optional yaw (y-axis) correction in radians
  94801. * @param pitchCor optional pitch (x-axis) correction in radians
  94802. * @param rollCor optional roll (z-axis) correction in radians
  94803. * @param space the choosen space of the target
  94804. * @returns the TransformNode.
  94805. */
  94806. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  94807. /**
  94808. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94809. * This Vector3 is expressed in the World space.
  94810. * @param localAxis axis to rotate
  94811. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94812. */
  94813. getDirection(localAxis: Vector3): Vector3;
  94814. /**
  94815. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94816. * localAxis is expressed in the mesh local space.
  94817. * result is computed in the Wordl space from the mesh World matrix.
  94818. * @param localAxis axis to rotate
  94819. * @param result the resulting transformnode
  94820. * @returns this TransformNode.
  94821. */
  94822. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  94823. /**
  94824. * Sets this transform node rotation to the given local axis.
  94825. * @param localAxis the axis in local space
  94826. * @param yawCor optional yaw (y-axis) correction in radians
  94827. * @param pitchCor optional pitch (x-axis) correction in radians
  94828. * @param rollCor optional roll (z-axis) correction in radians
  94829. * @returns this TransformNode
  94830. */
  94831. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  94832. /**
  94833. * Sets a new pivot point to the current node
  94834. * @param point defines the new pivot point to use
  94835. * @param space defines if the point is in world or local space (local by default)
  94836. * @returns the current TransformNode
  94837. */
  94838. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  94839. /**
  94840. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94841. * @returns the pivot point
  94842. */
  94843. getPivotPoint(): Vector3;
  94844. /**
  94845. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94846. * @param result the vector3 to store the result
  94847. * @returns this TransformNode.
  94848. */
  94849. getPivotPointToRef(result: Vector3): TransformNode;
  94850. /**
  94851. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94852. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94853. */
  94854. getAbsolutePivotPoint(): Vector3;
  94855. /**
  94856. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94857. * @param result vector3 to store the result
  94858. * @returns this TransformNode.
  94859. */
  94860. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  94861. /**
  94862. * Defines the passed node as the parent of the current node.
  94863. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94864. * @see https://doc.babylonjs.com/how_to/parenting
  94865. * @param node the node ot set as the parent
  94866. * @returns this TransformNode.
  94867. */
  94868. setParent(node: Nullable<Node>): TransformNode;
  94869. private _nonUniformScaling;
  94870. /**
  94871. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94872. */
  94873. get nonUniformScaling(): boolean;
  94874. /** @hidden */
  94875. _updateNonUniformScalingState(value: boolean): boolean;
  94876. /**
  94877. * Attach the current TransformNode to another TransformNode associated with a bone
  94878. * @param bone Bone affecting the TransformNode
  94879. * @param affectedTransformNode TransformNode associated with the bone
  94880. * @returns this object
  94881. */
  94882. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  94883. /**
  94884. * Detach the transform node if its associated with a bone
  94885. * @returns this object
  94886. */
  94887. detachFromBone(): TransformNode;
  94888. private static _rotationAxisCache;
  94889. /**
  94890. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94891. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94892. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94893. * The passed axis is also normalized.
  94894. * @param axis the axis to rotate around
  94895. * @param amount the amount to rotate in radians
  94896. * @param space Space to rotate in (Default: local)
  94897. * @returns the TransformNode.
  94898. */
  94899. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94900. /**
  94901. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94902. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94903. * The passed axis is also normalized. .
  94904. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94905. * @param point the point to rotate around
  94906. * @param axis the axis to rotate around
  94907. * @param amount the amount to rotate in radians
  94908. * @returns the TransformNode
  94909. */
  94910. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  94911. /**
  94912. * Translates the mesh along the axis vector for the passed distance in the given space.
  94913. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94914. * @param axis the axis to translate in
  94915. * @param distance the distance to translate
  94916. * @param space Space to rotate in (Default: local)
  94917. * @returns the TransformNode.
  94918. */
  94919. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94920. /**
  94921. * Adds a rotation step to the mesh current rotation.
  94922. * x, y, z are Euler angles expressed in radians.
  94923. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94924. * This means this rotation is made in the mesh local space only.
  94925. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94926. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94927. * ```javascript
  94928. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94929. * ```
  94930. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94931. * 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.
  94932. * @param x Rotation to add
  94933. * @param y Rotation to add
  94934. * @param z Rotation to add
  94935. * @returns the TransformNode.
  94936. */
  94937. addRotation(x: number, y: number, z: number): TransformNode;
  94938. /**
  94939. * @hidden
  94940. */
  94941. protected _getEffectiveParent(): Nullable<Node>;
  94942. /**
  94943. * Computes the world matrix of the node
  94944. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94945. * @returns the world matrix
  94946. */
  94947. computeWorldMatrix(force?: boolean): Matrix;
  94948. /**
  94949. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94950. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94951. */
  94952. resetLocalMatrix(independentOfChildren?: boolean): void;
  94953. protected _afterComputeWorldMatrix(): void;
  94954. /**
  94955. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94956. * @param func callback function to add
  94957. *
  94958. * @returns the TransformNode.
  94959. */
  94960. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94961. /**
  94962. * Removes a registered callback function.
  94963. * @param func callback function to remove
  94964. * @returns the TransformNode.
  94965. */
  94966. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94967. /**
  94968. * Gets the position of the current mesh in camera space
  94969. * @param camera defines the camera to use
  94970. * @returns a position
  94971. */
  94972. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94973. /**
  94974. * Returns the distance from the mesh to the active camera
  94975. * @param camera defines the camera to use
  94976. * @returns the distance
  94977. */
  94978. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94979. /**
  94980. * Clone the current transform node
  94981. * @param name Name of the new clone
  94982. * @param newParent New parent for the clone
  94983. * @param doNotCloneChildren Do not clone children hierarchy
  94984. * @returns the new transform node
  94985. */
  94986. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94987. /**
  94988. * Serializes the objects information.
  94989. * @param currentSerializationObject defines the object to serialize in
  94990. * @returns the serialized object
  94991. */
  94992. serialize(currentSerializationObject?: any): any;
  94993. /**
  94994. * Returns a new TransformNode object parsed from the source provided.
  94995. * @param parsedTransformNode is the source.
  94996. * @param scene the scne the object belongs to
  94997. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94998. * @returns a new TransformNode object parsed from the source provided.
  94999. */
  95000. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95001. /**
  95002. * Get all child-transformNodes of this node
  95003. * @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
  95004. * @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
  95005. * @returns an array of TransformNode
  95006. */
  95007. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95008. /**
  95009. * Releases resources associated with this transform node.
  95010. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95011. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95012. */
  95013. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95014. /**
  95015. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95016. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95017. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95018. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95019. * @returns the current mesh
  95020. */
  95021. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95022. private _syncAbsoluteScalingAndRotation;
  95023. }
  95024. }
  95025. declare module BABYLON {
  95026. /**
  95027. * Class used to override all child animations of a given target
  95028. */
  95029. export class AnimationPropertiesOverride {
  95030. /**
  95031. * Gets or sets a value indicating if animation blending must be used
  95032. */
  95033. enableBlending: boolean;
  95034. /**
  95035. * Gets or sets the blending speed to use when enableBlending is true
  95036. */
  95037. blendingSpeed: number;
  95038. /**
  95039. * Gets or sets the default loop mode to use
  95040. */
  95041. loopMode: number;
  95042. }
  95043. }
  95044. declare module BABYLON {
  95045. /**
  95046. * Class used to store bone information
  95047. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95048. */
  95049. export class Bone extends Node {
  95050. /**
  95051. * defines the bone name
  95052. */
  95053. name: string;
  95054. private static _tmpVecs;
  95055. private static _tmpQuat;
  95056. private static _tmpMats;
  95057. /**
  95058. * Gets the list of child bones
  95059. */
  95060. children: Bone[];
  95061. /** Gets the animations associated with this bone */
  95062. animations: Animation[];
  95063. /**
  95064. * Gets or sets bone length
  95065. */
  95066. length: number;
  95067. /**
  95068. * @hidden Internal only
  95069. * Set this value to map this bone to a different index in the transform matrices
  95070. * Set this value to -1 to exclude the bone from the transform matrices
  95071. */
  95072. _index: Nullable<number>;
  95073. private _skeleton;
  95074. private _localMatrix;
  95075. private _restPose;
  95076. private _bindPose;
  95077. private _baseMatrix;
  95078. private _absoluteTransform;
  95079. private _invertedAbsoluteTransform;
  95080. private _parent;
  95081. private _scalingDeterminant;
  95082. private _worldTransform;
  95083. private _localScaling;
  95084. private _localRotation;
  95085. private _localPosition;
  95086. private _needToDecompose;
  95087. private _needToCompose;
  95088. /** @hidden */
  95089. _linkedTransformNode: Nullable<TransformNode>;
  95090. /** @hidden */
  95091. _waitingTransformNodeId: Nullable<string>;
  95092. /** @hidden */
  95093. get _matrix(): Matrix;
  95094. /** @hidden */
  95095. set _matrix(value: Matrix);
  95096. /**
  95097. * Create a new bone
  95098. * @param name defines the bone name
  95099. * @param skeleton defines the parent skeleton
  95100. * @param parentBone defines the parent (can be null if the bone is the root)
  95101. * @param localMatrix defines the local matrix
  95102. * @param restPose defines the rest pose matrix
  95103. * @param baseMatrix defines the base matrix
  95104. * @param index defines index of the bone in the hiearchy
  95105. */
  95106. constructor(
  95107. /**
  95108. * defines the bone name
  95109. */
  95110. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95111. /**
  95112. * Gets the current object class name.
  95113. * @return the class name
  95114. */
  95115. getClassName(): string;
  95116. /**
  95117. * Gets the parent skeleton
  95118. * @returns a skeleton
  95119. */
  95120. getSkeleton(): Skeleton;
  95121. /**
  95122. * Gets parent bone
  95123. * @returns a bone or null if the bone is the root of the bone hierarchy
  95124. */
  95125. getParent(): Nullable<Bone>;
  95126. /**
  95127. * Returns an array containing the root bones
  95128. * @returns an array containing the root bones
  95129. */
  95130. getChildren(): Array<Bone>;
  95131. /**
  95132. * Gets the node index in matrix array generated for rendering
  95133. * @returns the node index
  95134. */
  95135. getIndex(): number;
  95136. /**
  95137. * Sets the parent bone
  95138. * @param parent defines the parent (can be null if the bone is the root)
  95139. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95140. */
  95141. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95142. /**
  95143. * Gets the local matrix
  95144. * @returns a matrix
  95145. */
  95146. getLocalMatrix(): Matrix;
  95147. /**
  95148. * Gets the base matrix (initial matrix which remains unchanged)
  95149. * @returns a matrix
  95150. */
  95151. getBaseMatrix(): Matrix;
  95152. /**
  95153. * Gets the rest pose matrix
  95154. * @returns a matrix
  95155. */
  95156. getRestPose(): Matrix;
  95157. /**
  95158. * Sets the rest pose matrix
  95159. * @param matrix the local-space rest pose to set for this bone
  95160. */
  95161. setRestPose(matrix: Matrix): void;
  95162. /**
  95163. * Gets the bind pose matrix
  95164. * @returns the bind pose matrix
  95165. */
  95166. getBindPose(): Matrix;
  95167. /**
  95168. * Sets the bind pose matrix
  95169. * @param matrix the local-space bind pose to set for this bone
  95170. */
  95171. setBindPose(matrix: Matrix): void;
  95172. /**
  95173. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95174. */
  95175. getWorldMatrix(): Matrix;
  95176. /**
  95177. * Sets the local matrix to rest pose matrix
  95178. */
  95179. returnToRest(): void;
  95180. /**
  95181. * Gets the inverse of the absolute transform matrix.
  95182. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95183. * @returns a matrix
  95184. */
  95185. getInvertedAbsoluteTransform(): Matrix;
  95186. /**
  95187. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95188. * @returns a matrix
  95189. */
  95190. getAbsoluteTransform(): Matrix;
  95191. /**
  95192. * Links with the given transform node.
  95193. * The local matrix of this bone is copied from the transform node every frame.
  95194. * @param transformNode defines the transform node to link to
  95195. */
  95196. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95197. /**
  95198. * Gets the node used to drive the bone's transformation
  95199. * @returns a transform node or null
  95200. */
  95201. getTransformNode(): Nullable<TransformNode>;
  95202. /** Gets or sets current position (in local space) */
  95203. get position(): Vector3;
  95204. set position(newPosition: Vector3);
  95205. /** Gets or sets current rotation (in local space) */
  95206. get rotation(): Vector3;
  95207. set rotation(newRotation: Vector3);
  95208. /** Gets or sets current rotation quaternion (in local space) */
  95209. get rotationQuaternion(): Quaternion;
  95210. set rotationQuaternion(newRotation: Quaternion);
  95211. /** Gets or sets current scaling (in local space) */
  95212. get scaling(): Vector3;
  95213. set scaling(newScaling: Vector3);
  95214. /**
  95215. * Gets the animation properties override
  95216. */
  95217. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95218. private _decompose;
  95219. private _compose;
  95220. /**
  95221. * Update the base and local matrices
  95222. * @param matrix defines the new base or local matrix
  95223. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95224. * @param updateLocalMatrix defines if the local matrix should be updated
  95225. */
  95226. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95227. /** @hidden */
  95228. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95229. /**
  95230. * Flag the bone as dirty (Forcing it to update everything)
  95231. */
  95232. markAsDirty(): void;
  95233. /** @hidden */
  95234. _markAsDirtyAndCompose(): void;
  95235. private _markAsDirtyAndDecompose;
  95236. /**
  95237. * Translate the bone in local or world space
  95238. * @param vec The amount to translate the bone
  95239. * @param space The space that the translation is in
  95240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95241. */
  95242. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95243. /**
  95244. * Set the postion of the bone in local or world space
  95245. * @param position The position to set the bone
  95246. * @param space The space that the position is in
  95247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95248. */
  95249. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95250. /**
  95251. * Set the absolute position of the bone (world space)
  95252. * @param position The position to set the bone
  95253. * @param mesh The mesh that this bone is attached to
  95254. */
  95255. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95256. /**
  95257. * Scale the bone on the x, y and z axes (in local space)
  95258. * @param x The amount to scale the bone on the x axis
  95259. * @param y The amount to scale the bone on the y axis
  95260. * @param z The amount to scale the bone on the z axis
  95261. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95262. */
  95263. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95264. /**
  95265. * Set the bone scaling in local space
  95266. * @param scale defines the scaling vector
  95267. */
  95268. setScale(scale: Vector3): void;
  95269. /**
  95270. * Gets the current scaling in local space
  95271. * @returns the current scaling vector
  95272. */
  95273. getScale(): Vector3;
  95274. /**
  95275. * Gets the current scaling in local space and stores it in a target vector
  95276. * @param result defines the target vector
  95277. */
  95278. getScaleToRef(result: Vector3): void;
  95279. /**
  95280. * Set the yaw, pitch, and roll of the bone in local or world space
  95281. * @param yaw The rotation of the bone on the y axis
  95282. * @param pitch The rotation of the bone on the x axis
  95283. * @param roll The rotation of the bone on the z axis
  95284. * @param space The space that the axes of rotation are in
  95285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95286. */
  95287. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95288. /**
  95289. * Add a rotation to the bone on an axis in local or world space
  95290. * @param axis The axis to rotate the bone on
  95291. * @param amount The amount to rotate the bone
  95292. * @param space The space that the axis is in
  95293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95294. */
  95295. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95296. /**
  95297. * Set the rotation of the bone to a particular axis angle in local or world space
  95298. * @param axis The axis to rotate the bone on
  95299. * @param angle The angle that the bone should be rotated to
  95300. * @param space The space that the axis is in
  95301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95302. */
  95303. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95304. /**
  95305. * Set the euler rotation of the bone in local or world space
  95306. * @param rotation The euler rotation that the bone should be set to
  95307. * @param space The space that the rotation is in
  95308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95309. */
  95310. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95311. /**
  95312. * Set the quaternion rotation of the bone in local or world space
  95313. * @param quat The quaternion rotation that the bone should be set to
  95314. * @param space The space that the rotation is in
  95315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95316. */
  95317. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95318. /**
  95319. * Set the rotation matrix of the bone in local or world space
  95320. * @param rotMat The rotation matrix that the bone should be set to
  95321. * @param space The space that the rotation is in
  95322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95323. */
  95324. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95325. private _rotateWithMatrix;
  95326. private _getNegativeRotationToRef;
  95327. /**
  95328. * Get the position of the bone in local or world space
  95329. * @param space The space that the returned position is in
  95330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95331. * @returns The position of the bone
  95332. */
  95333. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95334. /**
  95335. * Copy the position of the bone to a vector3 in local or world space
  95336. * @param space The space that the returned position is in
  95337. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95338. * @param result The vector3 to copy the position to
  95339. */
  95340. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95341. /**
  95342. * Get the absolute position of the bone (world space)
  95343. * @param mesh The mesh that this bone is attached to
  95344. * @returns The absolute position of the bone
  95345. */
  95346. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95347. /**
  95348. * Copy the absolute position of the bone (world space) to the result param
  95349. * @param mesh The mesh that this bone is attached to
  95350. * @param result The vector3 to copy the absolute position to
  95351. */
  95352. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95353. /**
  95354. * Compute the absolute transforms of this bone and its children
  95355. */
  95356. computeAbsoluteTransforms(): void;
  95357. /**
  95358. * Get the world direction from an axis that is in the local space of the bone
  95359. * @param localAxis The local direction that is used to compute the world direction
  95360. * @param mesh The mesh that this bone is attached to
  95361. * @returns The world direction
  95362. */
  95363. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95364. /**
  95365. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95366. * @param localAxis The local direction that is used to compute the world direction
  95367. * @param mesh The mesh that this bone is attached to
  95368. * @param result The vector3 that the world direction will be copied to
  95369. */
  95370. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95371. /**
  95372. * Get the euler rotation of the bone in local or world space
  95373. * @param space The space that the rotation should be in
  95374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95375. * @returns The euler rotation
  95376. */
  95377. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95378. /**
  95379. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95380. * @param space The space that the rotation should be in
  95381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95382. * @param result The vector3 that the rotation should be copied to
  95383. */
  95384. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95385. /**
  95386. * Get the quaternion rotation of the bone in either local or world space
  95387. * @param space The space that the rotation should be in
  95388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95389. * @returns The quaternion rotation
  95390. */
  95391. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95392. /**
  95393. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95394. * @param space The space that the rotation should be in
  95395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95396. * @param result The quaternion that the rotation should be copied to
  95397. */
  95398. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95399. /**
  95400. * Get the rotation matrix of the bone in local or world space
  95401. * @param space The space that the rotation should be in
  95402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95403. * @returns The rotation matrix
  95404. */
  95405. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95406. /**
  95407. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95408. * @param space The space that the rotation should be in
  95409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95410. * @param result The quaternion that the rotation should be copied to
  95411. */
  95412. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95413. /**
  95414. * Get the world position of a point that is in the local space of the bone
  95415. * @param position The local position
  95416. * @param mesh The mesh that this bone is attached to
  95417. * @returns The world position
  95418. */
  95419. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95420. /**
  95421. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95422. * @param position The local position
  95423. * @param mesh The mesh that this bone is attached to
  95424. * @param result The vector3 that the world position should be copied to
  95425. */
  95426. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95427. /**
  95428. * Get the local position of a point that is in world space
  95429. * @param position The world position
  95430. * @param mesh The mesh that this bone is attached to
  95431. * @returns The local position
  95432. */
  95433. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95434. /**
  95435. * Get the local position of a point that is in world space and copy it to the result param
  95436. * @param position The world position
  95437. * @param mesh The mesh that this bone is attached to
  95438. * @param result The vector3 that the local position should be copied to
  95439. */
  95440. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95441. /**
  95442. * Set the current local matrix as the restPose for this bone.
  95443. */
  95444. setCurrentPoseAsRest(): void;
  95445. }
  95446. }
  95447. declare module BABYLON {
  95448. /**
  95449. * Defines a runtime animation
  95450. */
  95451. export class RuntimeAnimation {
  95452. private _events;
  95453. /**
  95454. * The current frame of the runtime animation
  95455. */
  95456. private _currentFrame;
  95457. /**
  95458. * The animation used by the runtime animation
  95459. */
  95460. private _animation;
  95461. /**
  95462. * The target of the runtime animation
  95463. */
  95464. private _target;
  95465. /**
  95466. * The initiating animatable
  95467. */
  95468. private _host;
  95469. /**
  95470. * The original value of the runtime animation
  95471. */
  95472. private _originalValue;
  95473. /**
  95474. * The original blend value of the runtime animation
  95475. */
  95476. private _originalBlendValue;
  95477. /**
  95478. * The offsets cache of the runtime animation
  95479. */
  95480. private _offsetsCache;
  95481. /**
  95482. * The high limits cache of the runtime animation
  95483. */
  95484. private _highLimitsCache;
  95485. /**
  95486. * Specifies if the runtime animation has been stopped
  95487. */
  95488. private _stopped;
  95489. /**
  95490. * The blending factor of the runtime animation
  95491. */
  95492. private _blendingFactor;
  95493. /**
  95494. * The BabylonJS scene
  95495. */
  95496. private _scene;
  95497. /**
  95498. * The current value of the runtime animation
  95499. */
  95500. private _currentValue;
  95501. /** @hidden */
  95502. _animationState: _IAnimationState;
  95503. /**
  95504. * The active target of the runtime animation
  95505. */
  95506. private _activeTargets;
  95507. private _currentActiveTarget;
  95508. private _directTarget;
  95509. /**
  95510. * The target path of the runtime animation
  95511. */
  95512. private _targetPath;
  95513. /**
  95514. * The weight of the runtime animation
  95515. */
  95516. private _weight;
  95517. /**
  95518. * The ratio offset of the runtime animation
  95519. */
  95520. private _ratioOffset;
  95521. /**
  95522. * The previous delay of the runtime animation
  95523. */
  95524. private _previousDelay;
  95525. /**
  95526. * The previous ratio of the runtime animation
  95527. */
  95528. private _previousRatio;
  95529. private _enableBlending;
  95530. private _keys;
  95531. private _minFrame;
  95532. private _maxFrame;
  95533. private _minValue;
  95534. private _maxValue;
  95535. private _targetIsArray;
  95536. /**
  95537. * Gets the current frame of the runtime animation
  95538. */
  95539. get currentFrame(): number;
  95540. /**
  95541. * Gets the weight of the runtime animation
  95542. */
  95543. get weight(): number;
  95544. /**
  95545. * Gets the current value of the runtime animation
  95546. */
  95547. get currentValue(): any;
  95548. /**
  95549. * Gets the target path of the runtime animation
  95550. */
  95551. get targetPath(): string;
  95552. /**
  95553. * Gets the actual target of the runtime animation
  95554. */
  95555. get target(): any;
  95556. /**
  95557. * Gets the additive state of the runtime animation
  95558. */
  95559. get isAdditive(): boolean;
  95560. /** @hidden */
  95561. _onLoop: () => void;
  95562. /**
  95563. * Create a new RuntimeAnimation object
  95564. * @param target defines the target of the animation
  95565. * @param animation defines the source animation object
  95566. * @param scene defines the hosting scene
  95567. * @param host defines the initiating Animatable
  95568. */
  95569. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95570. private _preparePath;
  95571. /**
  95572. * Gets the animation from the runtime animation
  95573. */
  95574. get animation(): Animation;
  95575. /**
  95576. * Resets the runtime animation to the beginning
  95577. * @param restoreOriginal defines whether to restore the target property to the original value
  95578. */
  95579. reset(restoreOriginal?: boolean): void;
  95580. /**
  95581. * Specifies if the runtime animation is stopped
  95582. * @returns Boolean specifying if the runtime animation is stopped
  95583. */
  95584. isStopped(): boolean;
  95585. /**
  95586. * Disposes of the runtime animation
  95587. */
  95588. dispose(): void;
  95589. /**
  95590. * Apply the interpolated value to the target
  95591. * @param currentValue defines the value computed by the animation
  95592. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95593. */
  95594. setValue(currentValue: any, weight: number): void;
  95595. private _getOriginalValues;
  95596. private _setValue;
  95597. /**
  95598. * Gets the loop pmode of the runtime animation
  95599. * @returns Loop Mode
  95600. */
  95601. private _getCorrectLoopMode;
  95602. /**
  95603. * Move the current animation to a given frame
  95604. * @param frame defines the frame to move to
  95605. */
  95606. goToFrame(frame: number): void;
  95607. /**
  95608. * @hidden Internal use only
  95609. */
  95610. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  95611. /**
  95612. * Execute the current animation
  95613. * @param delay defines the delay to add to the current frame
  95614. * @param from defines the lower bound of the animation range
  95615. * @param to defines the upper bound of the animation range
  95616. * @param loop defines if the current animation must loop
  95617. * @param speedRatio defines the current speed ratio
  95618. * @param weight defines the weight of the animation (default is -1 so no weight)
  95619. * @param onLoop optional callback called when animation loops
  95620. * @returns a boolean indicating if the animation is running
  95621. */
  95622. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  95623. }
  95624. }
  95625. declare module BABYLON {
  95626. /**
  95627. * Class used to store an actual running animation
  95628. */
  95629. export class Animatable {
  95630. /** defines the target object */
  95631. target: any;
  95632. /** defines the starting frame number (default is 0) */
  95633. fromFrame: number;
  95634. /** defines the ending frame number (default is 100) */
  95635. toFrame: number;
  95636. /** defines if the animation must loop (default is false) */
  95637. loopAnimation: boolean;
  95638. /** defines a callback to call when animation ends if it is not looping */
  95639. onAnimationEnd?: (() => void) | null | undefined;
  95640. /** defines a callback to call when animation loops */
  95641. onAnimationLoop?: (() => void) | null | undefined;
  95642. /** defines whether the animation should be evaluated additively */
  95643. isAdditive: boolean;
  95644. private _localDelayOffset;
  95645. private _pausedDelay;
  95646. private _runtimeAnimations;
  95647. private _paused;
  95648. private _scene;
  95649. private _speedRatio;
  95650. private _weight;
  95651. private _syncRoot;
  95652. /**
  95653. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  95654. * This will only apply for non looping animation (default is true)
  95655. */
  95656. disposeOnEnd: boolean;
  95657. /**
  95658. * Gets a boolean indicating if the animation has started
  95659. */
  95660. animationStarted: boolean;
  95661. /**
  95662. * Observer raised when the animation ends
  95663. */
  95664. onAnimationEndObservable: Observable<Animatable>;
  95665. /**
  95666. * Observer raised when the animation loops
  95667. */
  95668. onAnimationLoopObservable: Observable<Animatable>;
  95669. /**
  95670. * Gets the root Animatable used to synchronize and normalize animations
  95671. */
  95672. get syncRoot(): Nullable<Animatable>;
  95673. /**
  95674. * Gets the current frame of the first RuntimeAnimation
  95675. * Used to synchronize Animatables
  95676. */
  95677. get masterFrame(): number;
  95678. /**
  95679. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  95680. */
  95681. get weight(): number;
  95682. set weight(value: number);
  95683. /**
  95684. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  95685. */
  95686. get speedRatio(): number;
  95687. set speedRatio(value: number);
  95688. /**
  95689. * Creates a new Animatable
  95690. * @param scene defines the hosting scene
  95691. * @param target defines the target object
  95692. * @param fromFrame defines the starting frame number (default is 0)
  95693. * @param toFrame defines the ending frame number (default is 100)
  95694. * @param loopAnimation defines if the animation must loop (default is false)
  95695. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  95696. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  95697. * @param animations defines a group of animation to add to the new Animatable
  95698. * @param onAnimationLoop defines a callback to call when animation loops
  95699. * @param isAdditive defines whether the animation should be evaluated additively
  95700. */
  95701. constructor(scene: Scene,
  95702. /** defines the target object */
  95703. target: any,
  95704. /** defines the starting frame number (default is 0) */
  95705. fromFrame?: number,
  95706. /** defines the ending frame number (default is 100) */
  95707. toFrame?: number,
  95708. /** defines if the animation must loop (default is false) */
  95709. loopAnimation?: boolean, speedRatio?: number,
  95710. /** defines a callback to call when animation ends if it is not looping */
  95711. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  95712. /** defines a callback to call when animation loops */
  95713. onAnimationLoop?: (() => void) | null | undefined,
  95714. /** defines whether the animation should be evaluated additively */
  95715. isAdditive?: boolean);
  95716. /**
  95717. * Synchronize and normalize current Animatable with a source Animatable
  95718. * This is useful when using animation weights and when animations are not of the same length
  95719. * @param root defines the root Animatable to synchronize with
  95720. * @returns the current Animatable
  95721. */
  95722. syncWith(root: Animatable): Animatable;
  95723. /**
  95724. * Gets the list of runtime animations
  95725. * @returns an array of RuntimeAnimation
  95726. */
  95727. getAnimations(): RuntimeAnimation[];
  95728. /**
  95729. * Adds more animations to the current animatable
  95730. * @param target defines the target of the animations
  95731. * @param animations defines the new animations to add
  95732. */
  95733. appendAnimations(target: any, animations: Animation[]): void;
  95734. /**
  95735. * Gets the source animation for a specific property
  95736. * @param property defines the propertyu to look for
  95737. * @returns null or the source animation for the given property
  95738. */
  95739. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  95740. /**
  95741. * Gets the runtime animation for a specific property
  95742. * @param property defines the propertyu to look for
  95743. * @returns null or the runtime animation for the given property
  95744. */
  95745. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  95746. /**
  95747. * Resets the animatable to its original state
  95748. */
  95749. reset(): void;
  95750. /**
  95751. * Allows the animatable to blend with current running animations
  95752. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95753. * @param blendingSpeed defines the blending speed to use
  95754. */
  95755. enableBlending(blendingSpeed: number): void;
  95756. /**
  95757. * Disable animation blending
  95758. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95759. */
  95760. disableBlending(): void;
  95761. /**
  95762. * Jump directly to a given frame
  95763. * @param frame defines the frame to jump to
  95764. */
  95765. goToFrame(frame: number): void;
  95766. /**
  95767. * Pause the animation
  95768. */
  95769. pause(): void;
  95770. /**
  95771. * Restart the animation
  95772. */
  95773. restart(): void;
  95774. private _raiseOnAnimationEnd;
  95775. /**
  95776. * Stop and delete the current animation
  95777. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  95778. * @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)
  95779. */
  95780. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  95781. /**
  95782. * Wait asynchronously for the animation to end
  95783. * @returns a promise which will be fullfilled when the animation ends
  95784. */
  95785. waitAsync(): Promise<Animatable>;
  95786. /** @hidden */
  95787. _animate(delay: number): boolean;
  95788. }
  95789. interface Scene {
  95790. /** @hidden */
  95791. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  95792. /** @hidden */
  95793. _processLateAnimationBindingsForMatrices(holder: {
  95794. totalWeight: number;
  95795. totalAdditiveWeight: number;
  95796. animations: RuntimeAnimation[];
  95797. additiveAnimations: RuntimeAnimation[];
  95798. originalValue: Matrix;
  95799. }): any;
  95800. /** @hidden */
  95801. _processLateAnimationBindingsForQuaternions(holder: {
  95802. totalWeight: number;
  95803. totalAdditiveWeight: number;
  95804. animations: RuntimeAnimation[];
  95805. additiveAnimations: RuntimeAnimation[];
  95806. originalValue: Quaternion;
  95807. }, refQuaternion: Quaternion): Quaternion;
  95808. /** @hidden */
  95809. _processLateAnimationBindings(): void;
  95810. /**
  95811. * Will start the animation sequence of a given target
  95812. * @param target defines the target
  95813. * @param from defines from which frame should animation start
  95814. * @param to defines until which frame should animation run.
  95815. * @param weight defines the weight to apply to the animation (1.0 by default)
  95816. * @param loop defines if the animation loops
  95817. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95818. * @param onAnimationEnd defines the function to be executed when the animation ends
  95819. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95820. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95821. * @param onAnimationLoop defines the callback to call when an animation loops
  95822. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95823. * @returns the animatable object created for this animation
  95824. */
  95825. 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;
  95826. /**
  95827. * Will start the animation sequence of a given target
  95828. * @param target defines the target
  95829. * @param from defines from which frame should animation start
  95830. * @param to defines until which frame should animation run.
  95831. * @param loop defines if the animation loops
  95832. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95833. * @param onAnimationEnd defines the function to be executed when the animation ends
  95834. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95835. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95836. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  95837. * @param onAnimationLoop defines the callback to call when an animation loops
  95838. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95839. * @returns the animatable object created for this animation
  95840. */
  95841. 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;
  95842. /**
  95843. * Will start the animation sequence of a given target and its hierarchy
  95844. * @param target defines the target
  95845. * @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.
  95846. * @param from defines from which frame should animation start
  95847. * @param to defines until which frame should animation run.
  95848. * @param loop defines if the animation loops
  95849. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95850. * @param onAnimationEnd defines the function to be executed when the animation ends
  95851. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95852. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95853. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95854. * @param onAnimationLoop defines the callback to call when an animation loops
  95855. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95856. * @returns the list of created animatables
  95857. */
  95858. 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[];
  95859. /**
  95860. * Begin a new animation on a given node
  95861. * @param target defines the target where the animation will take place
  95862. * @param animations defines the list of animations to start
  95863. * @param from defines the initial value
  95864. * @param to defines the final value
  95865. * @param loop defines if you want animation to loop (off by default)
  95866. * @param speedRatio defines the speed ratio to apply to all animations
  95867. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95868. * @param onAnimationLoop defines the callback to call when an animation loops
  95869. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95870. * @returns the list of created animatables
  95871. */
  95872. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  95873. /**
  95874. * Begin a new animation on a given node and its hierarchy
  95875. * @param target defines the root node where the animation will take place
  95876. * @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.
  95877. * @param animations defines the list of animations to start
  95878. * @param from defines the initial value
  95879. * @param to defines the final value
  95880. * @param loop defines if you want animation to loop (off by default)
  95881. * @param speedRatio defines the speed ratio to apply to all animations
  95882. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95883. * @param onAnimationLoop defines the callback to call when an animation loops
  95884. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95885. * @returns the list of animatables created for all nodes
  95886. */
  95887. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  95888. /**
  95889. * Gets the animatable associated with a specific target
  95890. * @param target defines the target of the animatable
  95891. * @returns the required animatable if found
  95892. */
  95893. getAnimatableByTarget(target: any): Nullable<Animatable>;
  95894. /**
  95895. * Gets all animatables associated with a given target
  95896. * @param target defines the target to look animatables for
  95897. * @returns an array of Animatables
  95898. */
  95899. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  95900. /**
  95901. * Stops and removes all animations that have been applied to the scene
  95902. */
  95903. stopAllAnimations(): void;
  95904. /**
  95905. * Gets the current delta time used by animation engine
  95906. */
  95907. deltaTime: number;
  95908. }
  95909. interface Bone {
  95910. /**
  95911. * Copy an animation range from another bone
  95912. * @param source defines the source bone
  95913. * @param rangeName defines the range name to copy
  95914. * @param frameOffset defines the frame offset
  95915. * @param rescaleAsRequired defines if rescaling must be applied if required
  95916. * @param skelDimensionsRatio defines the scaling ratio
  95917. * @returns true if operation was successful
  95918. */
  95919. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  95920. }
  95921. }
  95922. declare module BABYLON {
  95923. /**
  95924. * Class used to handle skinning animations
  95925. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95926. */
  95927. export class Skeleton implements IAnimatable {
  95928. /** defines the skeleton name */
  95929. name: string;
  95930. /** defines the skeleton Id */
  95931. id: string;
  95932. /**
  95933. * Defines the list of child bones
  95934. */
  95935. bones: Bone[];
  95936. /**
  95937. * Defines an estimate of the dimension of the skeleton at rest
  95938. */
  95939. dimensionsAtRest: Vector3;
  95940. /**
  95941. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  95942. */
  95943. needInitialSkinMatrix: boolean;
  95944. /**
  95945. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  95946. */
  95947. overrideMesh: Nullable<AbstractMesh>;
  95948. /**
  95949. * Gets the list of animations attached to this skeleton
  95950. */
  95951. animations: Array<Animation>;
  95952. private _scene;
  95953. private _isDirty;
  95954. private _transformMatrices;
  95955. private _transformMatrixTexture;
  95956. private _meshesWithPoseMatrix;
  95957. private _animatables;
  95958. private _identity;
  95959. private _synchronizedWithMesh;
  95960. private _ranges;
  95961. private _lastAbsoluteTransformsUpdateId;
  95962. private _canUseTextureForBones;
  95963. private _uniqueId;
  95964. /** @hidden */
  95965. _numBonesWithLinkedTransformNode: number;
  95966. /** @hidden */
  95967. _hasWaitingData: Nullable<boolean>;
  95968. /** @hidden */
  95969. _waitingOverrideMeshId: Nullable<string>;
  95970. /**
  95971. * Specifies if the skeleton should be serialized
  95972. */
  95973. doNotSerialize: boolean;
  95974. private _useTextureToStoreBoneMatrices;
  95975. /**
  95976. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95977. * Please note that this option is not available if the hardware does not support it
  95978. */
  95979. get useTextureToStoreBoneMatrices(): boolean;
  95980. set useTextureToStoreBoneMatrices(value: boolean);
  95981. private _animationPropertiesOverride;
  95982. /**
  95983. * Gets or sets the animation properties override
  95984. */
  95985. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95986. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95987. /**
  95988. * List of inspectable custom properties (used by the Inspector)
  95989. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95990. */
  95991. inspectableCustomProperties: IInspectable[];
  95992. /**
  95993. * An observable triggered before computing the skeleton's matrices
  95994. */
  95995. onBeforeComputeObservable: Observable<Skeleton>;
  95996. /**
  95997. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95998. */
  95999. get isUsingTextureForMatrices(): boolean;
  96000. /**
  96001. * Gets the unique ID of this skeleton
  96002. */
  96003. get uniqueId(): number;
  96004. /**
  96005. * Creates a new skeleton
  96006. * @param name defines the skeleton name
  96007. * @param id defines the skeleton Id
  96008. * @param scene defines the hosting scene
  96009. */
  96010. constructor(
  96011. /** defines the skeleton name */
  96012. name: string,
  96013. /** defines the skeleton Id */
  96014. id: string, scene: Scene);
  96015. /**
  96016. * Gets the current object class name.
  96017. * @return the class name
  96018. */
  96019. getClassName(): string;
  96020. /**
  96021. * Returns an array containing the root bones
  96022. * @returns an array containing the root bones
  96023. */
  96024. getChildren(): Array<Bone>;
  96025. /**
  96026. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96027. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96028. * @returns a Float32Array containing matrices data
  96029. */
  96030. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96031. /**
  96032. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96033. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96034. * @returns a raw texture containing the data
  96035. */
  96036. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96037. /**
  96038. * Gets the current hosting scene
  96039. * @returns a scene object
  96040. */
  96041. getScene(): Scene;
  96042. /**
  96043. * Gets a string representing the current skeleton data
  96044. * @param fullDetails defines a boolean indicating if we want a verbose version
  96045. * @returns a string representing the current skeleton data
  96046. */
  96047. toString(fullDetails?: boolean): string;
  96048. /**
  96049. * Get bone's index searching by name
  96050. * @param name defines bone's name to search for
  96051. * @return the indice of the bone. Returns -1 if not found
  96052. */
  96053. getBoneIndexByName(name: string): number;
  96054. /**
  96055. * Creater a new animation range
  96056. * @param name defines the name of the range
  96057. * @param from defines the start key
  96058. * @param to defines the end key
  96059. */
  96060. createAnimationRange(name: string, from: number, to: number): void;
  96061. /**
  96062. * Delete a specific animation range
  96063. * @param name defines the name of the range
  96064. * @param deleteFrames defines if frames must be removed as well
  96065. */
  96066. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96067. /**
  96068. * Gets a specific animation range
  96069. * @param name defines the name of the range to look for
  96070. * @returns the requested animation range or null if not found
  96071. */
  96072. getAnimationRange(name: string): Nullable<AnimationRange>;
  96073. /**
  96074. * Gets the list of all animation ranges defined on this skeleton
  96075. * @returns an array
  96076. */
  96077. getAnimationRanges(): Nullable<AnimationRange>[];
  96078. /**
  96079. * Copy animation range from a source skeleton.
  96080. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96081. * @param source defines the source skeleton
  96082. * @param name defines the name of the range to copy
  96083. * @param rescaleAsRequired defines if rescaling must be applied if required
  96084. * @returns true if operation was successful
  96085. */
  96086. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96087. /**
  96088. * Forces the skeleton to go to rest pose
  96089. */
  96090. returnToRest(): void;
  96091. private _getHighestAnimationFrame;
  96092. /**
  96093. * Begin a specific animation range
  96094. * @param name defines the name of the range to start
  96095. * @param loop defines if looping must be turned on (false by default)
  96096. * @param speedRatio defines the speed ratio to apply (1 by default)
  96097. * @param onAnimationEnd defines a callback which will be called when animation will end
  96098. * @returns a new animatable
  96099. */
  96100. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96101. /**
  96102. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96103. * @param skeleton defines the Skeleton containing the animation range to convert
  96104. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96105. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96106. * @returns the original skeleton
  96107. */
  96108. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96109. /** @hidden */
  96110. _markAsDirty(): void;
  96111. /** @hidden */
  96112. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96113. /** @hidden */
  96114. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96115. private _computeTransformMatrices;
  96116. /**
  96117. * Build all resources required to render a skeleton
  96118. */
  96119. prepare(): void;
  96120. /**
  96121. * Gets the list of animatables currently running for this skeleton
  96122. * @returns an array of animatables
  96123. */
  96124. getAnimatables(): IAnimatable[];
  96125. /**
  96126. * Clone the current skeleton
  96127. * @param name defines the name of the new skeleton
  96128. * @param id defines the id of the new skeleton
  96129. * @returns the new skeleton
  96130. */
  96131. clone(name: string, id?: string): Skeleton;
  96132. /**
  96133. * Enable animation blending for this skeleton
  96134. * @param blendingSpeed defines the blending speed to apply
  96135. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96136. */
  96137. enableBlending(blendingSpeed?: number): void;
  96138. /**
  96139. * Releases all resources associated with the current skeleton
  96140. */
  96141. dispose(): void;
  96142. /**
  96143. * Serialize the skeleton in a JSON object
  96144. * @returns a JSON object
  96145. */
  96146. serialize(): any;
  96147. /**
  96148. * Creates a new skeleton from serialized data
  96149. * @param parsedSkeleton defines the serialized data
  96150. * @param scene defines the hosting scene
  96151. * @returns a new skeleton
  96152. */
  96153. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96154. /**
  96155. * Compute all node absolute transforms
  96156. * @param forceUpdate defines if computation must be done even if cache is up to date
  96157. */
  96158. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96159. /**
  96160. * Gets the root pose matrix
  96161. * @returns a matrix
  96162. */
  96163. getPoseMatrix(): Nullable<Matrix>;
  96164. /**
  96165. * Sorts bones per internal index
  96166. */
  96167. sortBones(): void;
  96168. private _sortBones;
  96169. /**
  96170. * Set the current local matrix as the restPose for all bones in the skeleton.
  96171. */
  96172. setCurrentPoseAsRest(): void;
  96173. }
  96174. }
  96175. declare module BABYLON {
  96176. /**
  96177. * Creates an instance based on a source mesh.
  96178. */
  96179. export class InstancedMesh extends AbstractMesh {
  96180. private _sourceMesh;
  96181. private _currentLOD;
  96182. /** @hidden */
  96183. _indexInSourceMeshInstanceArray: number;
  96184. constructor(name: string, source: Mesh);
  96185. /**
  96186. * Returns the string "InstancedMesh".
  96187. */
  96188. getClassName(): string;
  96189. /** Gets the list of lights affecting that mesh */
  96190. get lightSources(): Light[];
  96191. _resyncLightSources(): void;
  96192. _resyncLightSource(light: Light): void;
  96193. _removeLightSource(light: Light, dispose: boolean): void;
  96194. /**
  96195. * If the source mesh receives shadows
  96196. */
  96197. get receiveShadows(): boolean;
  96198. /**
  96199. * The material of the source mesh
  96200. */
  96201. get material(): Nullable<Material>;
  96202. /**
  96203. * Visibility of the source mesh
  96204. */
  96205. get visibility(): number;
  96206. /**
  96207. * Skeleton of the source mesh
  96208. */
  96209. get skeleton(): Nullable<Skeleton>;
  96210. /**
  96211. * Rendering ground id of the source mesh
  96212. */
  96213. get renderingGroupId(): number;
  96214. set renderingGroupId(value: number);
  96215. /**
  96216. * Returns the total number of vertices (integer).
  96217. */
  96218. getTotalVertices(): number;
  96219. /**
  96220. * Returns a positive integer : the total number of indices in this mesh geometry.
  96221. * @returns the numner of indices or zero if the mesh has no geometry.
  96222. */
  96223. getTotalIndices(): number;
  96224. /**
  96225. * The source mesh of the instance
  96226. */
  96227. get sourceMesh(): Mesh;
  96228. /**
  96229. * Creates a new InstancedMesh object from the mesh model.
  96230. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96231. * @param name defines the name of the new instance
  96232. * @returns a new InstancedMesh
  96233. */
  96234. createInstance(name: string): InstancedMesh;
  96235. /**
  96236. * Is this node ready to be used/rendered
  96237. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96238. * @return {boolean} is it ready
  96239. */
  96240. isReady(completeCheck?: boolean): boolean;
  96241. /**
  96242. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96243. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96244. * @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.
  96245. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96246. */
  96247. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96248. /**
  96249. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96250. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96251. * The `data` are either a numeric array either a Float32Array.
  96252. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96253. * 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).
  96254. * Note that a new underlying VertexBuffer object is created each call.
  96255. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96256. *
  96257. * Possible `kind` values :
  96258. * - VertexBuffer.PositionKind
  96259. * - VertexBuffer.UVKind
  96260. * - VertexBuffer.UV2Kind
  96261. * - VertexBuffer.UV3Kind
  96262. * - VertexBuffer.UV4Kind
  96263. * - VertexBuffer.UV5Kind
  96264. * - VertexBuffer.UV6Kind
  96265. * - VertexBuffer.ColorKind
  96266. * - VertexBuffer.MatricesIndicesKind
  96267. * - VertexBuffer.MatricesIndicesExtraKind
  96268. * - VertexBuffer.MatricesWeightsKind
  96269. * - VertexBuffer.MatricesWeightsExtraKind
  96270. *
  96271. * Returns the Mesh.
  96272. */
  96273. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96274. /**
  96275. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96276. * If the mesh has no geometry, it is simply returned as it is.
  96277. * The `data` are either a numeric array either a Float32Array.
  96278. * No new underlying VertexBuffer object is created.
  96279. * 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.
  96280. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96281. *
  96282. * Possible `kind` values :
  96283. * - VertexBuffer.PositionKind
  96284. * - VertexBuffer.UVKind
  96285. * - VertexBuffer.UV2Kind
  96286. * - VertexBuffer.UV3Kind
  96287. * - VertexBuffer.UV4Kind
  96288. * - VertexBuffer.UV5Kind
  96289. * - VertexBuffer.UV6Kind
  96290. * - VertexBuffer.ColorKind
  96291. * - VertexBuffer.MatricesIndicesKind
  96292. * - VertexBuffer.MatricesIndicesExtraKind
  96293. * - VertexBuffer.MatricesWeightsKind
  96294. * - VertexBuffer.MatricesWeightsExtraKind
  96295. *
  96296. * Returns the Mesh.
  96297. */
  96298. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96299. /**
  96300. * Sets the mesh indices.
  96301. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96302. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96303. * This method creates a new index buffer each call.
  96304. * Returns the Mesh.
  96305. */
  96306. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96307. /**
  96308. * Boolean : True if the mesh owns the requested kind of data.
  96309. */
  96310. isVerticesDataPresent(kind: string): boolean;
  96311. /**
  96312. * Returns an array of indices (IndicesArray).
  96313. */
  96314. getIndices(): Nullable<IndicesArray>;
  96315. get _positions(): Nullable<Vector3[]>;
  96316. /**
  96317. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96318. * This means the mesh underlying bounding box and sphere are recomputed.
  96319. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96320. * @returns the current mesh
  96321. */
  96322. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96323. /** @hidden */
  96324. _preActivate(): InstancedMesh;
  96325. /** @hidden */
  96326. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96327. /** @hidden */
  96328. _postActivate(): void;
  96329. getWorldMatrix(): Matrix;
  96330. get isAnInstance(): boolean;
  96331. /**
  96332. * Returns the current associated LOD AbstractMesh.
  96333. */
  96334. getLOD(camera: Camera): AbstractMesh;
  96335. /** @hidden */
  96336. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96337. /** @hidden */
  96338. _syncSubMeshes(): InstancedMesh;
  96339. /** @hidden */
  96340. _generatePointsArray(): boolean;
  96341. /** @hidden */
  96342. _updateBoundingInfo(): AbstractMesh;
  96343. /**
  96344. * Creates a new InstancedMesh from the current mesh.
  96345. * - name (string) : the cloned mesh name
  96346. * - newParent (optional Node) : the optional Node to parent the clone to.
  96347. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96348. *
  96349. * Returns the clone.
  96350. */
  96351. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96352. /**
  96353. * Disposes the InstancedMesh.
  96354. * Returns nothing.
  96355. */
  96356. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96357. }
  96358. interface Mesh {
  96359. /**
  96360. * Register a custom buffer that will be instanced
  96361. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96362. * @param kind defines the buffer kind
  96363. * @param stride defines the stride in floats
  96364. */
  96365. registerInstancedBuffer(kind: string, stride: number): void;
  96366. /**
  96367. * true to use the edge renderer for all instances of this mesh
  96368. */
  96369. edgesShareWithInstances: boolean;
  96370. /** @hidden */
  96371. _userInstancedBuffersStorage: {
  96372. data: {
  96373. [key: string]: Float32Array;
  96374. };
  96375. sizes: {
  96376. [key: string]: number;
  96377. };
  96378. vertexBuffers: {
  96379. [key: string]: Nullable<VertexBuffer>;
  96380. };
  96381. strides: {
  96382. [key: string]: number;
  96383. };
  96384. };
  96385. }
  96386. interface AbstractMesh {
  96387. /**
  96388. * Object used to store instanced buffers defined by user
  96389. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96390. */
  96391. instancedBuffers: {
  96392. [key: string]: any;
  96393. };
  96394. }
  96395. }
  96396. declare module BABYLON {
  96397. /**
  96398. * Defines the options associated with the creation of a shader material.
  96399. */
  96400. export interface IShaderMaterialOptions {
  96401. /**
  96402. * Does the material work in alpha blend mode
  96403. */
  96404. needAlphaBlending: boolean;
  96405. /**
  96406. * Does the material work in alpha test mode
  96407. */
  96408. needAlphaTesting: boolean;
  96409. /**
  96410. * The list of attribute names used in the shader
  96411. */
  96412. attributes: string[];
  96413. /**
  96414. * The list of unifrom names used in the shader
  96415. */
  96416. uniforms: string[];
  96417. /**
  96418. * The list of UBO names used in the shader
  96419. */
  96420. uniformBuffers: string[];
  96421. /**
  96422. * The list of sampler names used in the shader
  96423. */
  96424. samplers: string[];
  96425. /**
  96426. * The list of defines used in the shader
  96427. */
  96428. defines: string[];
  96429. }
  96430. /**
  96431. * 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.
  96432. *
  96433. * This returned material effects how the mesh will look based on the code in the shaders.
  96434. *
  96435. * @see https://doc.babylonjs.com/how_to/shader_material
  96436. */
  96437. export class ShaderMaterial extends Material {
  96438. private _shaderPath;
  96439. private _options;
  96440. private _textures;
  96441. private _textureArrays;
  96442. private _floats;
  96443. private _ints;
  96444. private _floatsArrays;
  96445. private _colors3;
  96446. private _colors3Arrays;
  96447. private _colors4;
  96448. private _colors4Arrays;
  96449. private _vectors2;
  96450. private _vectors3;
  96451. private _vectors4;
  96452. private _matrices;
  96453. private _matrixArrays;
  96454. private _matrices3x3;
  96455. private _matrices2x2;
  96456. private _vectors2Arrays;
  96457. private _vectors3Arrays;
  96458. private _vectors4Arrays;
  96459. private _cachedWorldViewMatrix;
  96460. private _cachedWorldViewProjectionMatrix;
  96461. private _renderId;
  96462. private _multiview;
  96463. private _cachedDefines;
  96464. /** Define the Url to load snippets */
  96465. static SnippetUrl: string;
  96466. /** Snippet ID if the material was created from the snippet server */
  96467. snippetId: string;
  96468. /**
  96469. * Instantiate a new shader material.
  96470. * 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.
  96471. * This returned material effects how the mesh will look based on the code in the shaders.
  96472. * @see https://doc.babylonjs.com/how_to/shader_material
  96473. * @param name Define the name of the material in the scene
  96474. * @param scene Define the scene the material belongs to
  96475. * @param shaderPath Defines the route to the shader code in one of three ways:
  96476. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96477. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96478. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96479. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96480. * @param options Define the options used to create the shader
  96481. */
  96482. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96483. /**
  96484. * Gets the shader path used to define the shader code
  96485. * It can be modified to trigger a new compilation
  96486. */
  96487. get shaderPath(): any;
  96488. /**
  96489. * Sets the shader path used to define the shader code
  96490. * It can be modified to trigger a new compilation
  96491. */
  96492. set shaderPath(shaderPath: any);
  96493. /**
  96494. * Gets the options used to compile the shader.
  96495. * They can be modified to trigger a new compilation
  96496. */
  96497. get options(): IShaderMaterialOptions;
  96498. /**
  96499. * Gets the current class name of the material e.g. "ShaderMaterial"
  96500. * Mainly use in serialization.
  96501. * @returns the class name
  96502. */
  96503. getClassName(): string;
  96504. /**
  96505. * Specifies if the material will require alpha blending
  96506. * @returns a boolean specifying if alpha blending is needed
  96507. */
  96508. needAlphaBlending(): boolean;
  96509. /**
  96510. * Specifies if this material should be rendered in alpha test mode
  96511. * @returns a boolean specifying if an alpha test is needed.
  96512. */
  96513. needAlphaTesting(): boolean;
  96514. private _checkUniform;
  96515. /**
  96516. * Set a texture in the shader.
  96517. * @param name Define the name of the uniform samplers as defined in the shader
  96518. * @param texture Define the texture to bind to this sampler
  96519. * @return the material itself allowing "fluent" like uniform updates
  96520. */
  96521. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96522. /**
  96523. * Set a texture array in the shader.
  96524. * @param name Define the name of the uniform sampler array as defined in the shader
  96525. * @param textures Define the list of textures to bind to this sampler
  96526. * @return the material itself allowing "fluent" like uniform updates
  96527. */
  96528. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96529. /**
  96530. * Set a float in the shader.
  96531. * @param name Define the name of the uniform as defined in the shader
  96532. * @param value Define the value to give to the uniform
  96533. * @return the material itself allowing "fluent" like uniform updates
  96534. */
  96535. setFloat(name: string, value: number): ShaderMaterial;
  96536. /**
  96537. * Set a int in the shader.
  96538. * @param name Define the name of the uniform as defined in the shader
  96539. * @param value Define the value to give to the uniform
  96540. * @return the material itself allowing "fluent" like uniform updates
  96541. */
  96542. setInt(name: string, value: number): ShaderMaterial;
  96543. /**
  96544. * Set an array of floats in the shader.
  96545. * @param name Define the name of the uniform as defined in the shader
  96546. * @param value Define the value to give to the uniform
  96547. * @return the material itself allowing "fluent" like uniform updates
  96548. */
  96549. setFloats(name: string, value: number[]): ShaderMaterial;
  96550. /**
  96551. * Set a vec3 in the shader from a Color3.
  96552. * @param name Define the name of the uniform as defined in the shader
  96553. * @param value Define the value to give to the uniform
  96554. * @return the material itself allowing "fluent" like uniform updates
  96555. */
  96556. setColor3(name: string, value: Color3): ShaderMaterial;
  96557. /**
  96558. * Set a vec3 array in the shader from a Color3 array.
  96559. * @param name Define the name of the uniform as defined in the shader
  96560. * @param value Define the value to give to the uniform
  96561. * @return the material itself allowing "fluent" like uniform updates
  96562. */
  96563. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96564. /**
  96565. * Set a vec4 in the shader from a Color4.
  96566. * @param name Define the name of the uniform as defined in the shader
  96567. * @param value Define the value to give to the uniform
  96568. * @return the material itself allowing "fluent" like uniform updates
  96569. */
  96570. setColor4(name: string, value: Color4): ShaderMaterial;
  96571. /**
  96572. * Set a vec4 array in the shader from a Color4 array.
  96573. * @param name Define the name of the uniform as defined in the shader
  96574. * @param value Define the value to give to the uniform
  96575. * @return the material itself allowing "fluent" like uniform updates
  96576. */
  96577. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96578. /**
  96579. * Set a vec2 in the shader from a Vector2.
  96580. * @param name Define the name of the uniform as defined in the shader
  96581. * @param value Define the value to give to the uniform
  96582. * @return the material itself allowing "fluent" like uniform updates
  96583. */
  96584. setVector2(name: string, value: Vector2): ShaderMaterial;
  96585. /**
  96586. * Set a vec3 in the shader from a Vector3.
  96587. * @param name Define the name of the uniform as defined in the shader
  96588. * @param value Define the value to give to the uniform
  96589. * @return the material itself allowing "fluent" like uniform updates
  96590. */
  96591. setVector3(name: string, value: Vector3): ShaderMaterial;
  96592. /**
  96593. * Set a vec4 in the shader from a Vector4.
  96594. * @param name Define the name of the uniform as defined in the shader
  96595. * @param value Define the value to give to the uniform
  96596. * @return the material itself allowing "fluent" like uniform updates
  96597. */
  96598. setVector4(name: string, value: Vector4): ShaderMaterial;
  96599. /**
  96600. * Set a mat4 in the shader from a Matrix.
  96601. * @param name Define the name of the uniform as defined in the shader
  96602. * @param value Define the value to give to the uniform
  96603. * @return the material itself allowing "fluent" like uniform updates
  96604. */
  96605. setMatrix(name: string, value: Matrix): ShaderMaterial;
  96606. /**
  96607. * Set a float32Array in the shader from a matrix array.
  96608. * @param name Define the name of the uniform as defined in the shader
  96609. * @param value Define the value to give to the uniform
  96610. * @return the material itself allowing "fluent" like uniform updates
  96611. */
  96612. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  96613. /**
  96614. * Set a mat3 in the shader from a Float32Array.
  96615. * @param name Define the name of the uniform as defined in the shader
  96616. * @param value Define the value to give to the uniform
  96617. * @return the material itself allowing "fluent" like uniform updates
  96618. */
  96619. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96620. /**
  96621. * Set a mat2 in the shader from a Float32Array.
  96622. * @param name Define the name of the uniform as defined in the shader
  96623. * @param value Define the value to give to the uniform
  96624. * @return the material itself allowing "fluent" like uniform updates
  96625. */
  96626. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96627. /**
  96628. * Set a vec2 array in the shader from a number array.
  96629. * @param name Define the name of the uniform as defined in the shader
  96630. * @param value Define the value to give to the uniform
  96631. * @return the material itself allowing "fluent" like uniform updates
  96632. */
  96633. setArray2(name: string, value: number[]): ShaderMaterial;
  96634. /**
  96635. * Set a vec3 array in the shader from a number array.
  96636. * @param name Define the name of the uniform as defined in the shader
  96637. * @param value Define the value to give to the uniform
  96638. * @return the material itself allowing "fluent" like uniform updates
  96639. */
  96640. setArray3(name: string, value: number[]): ShaderMaterial;
  96641. /**
  96642. * Set a vec4 array in the shader from a number array.
  96643. * @param name Define the name of the uniform as defined in the shader
  96644. * @param value Define the value to give to the uniform
  96645. * @return the material itself allowing "fluent" like uniform updates
  96646. */
  96647. setArray4(name: string, value: number[]): ShaderMaterial;
  96648. private _checkCache;
  96649. /**
  96650. * Specifies that the submesh is ready to be used
  96651. * @param mesh defines the mesh to check
  96652. * @param subMesh defines which submesh to check
  96653. * @param useInstances specifies that instances should be used
  96654. * @returns a boolean indicating that the submesh is ready or not
  96655. */
  96656. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96657. /**
  96658. * Checks if the material is ready to render the requested mesh
  96659. * @param mesh Define the mesh to render
  96660. * @param useInstances Define whether or not the material is used with instances
  96661. * @returns true if ready, otherwise false
  96662. */
  96663. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96664. /**
  96665. * Binds the world matrix to the material
  96666. * @param world defines the world transformation matrix
  96667. * @param effectOverride - If provided, use this effect instead of internal effect
  96668. */
  96669. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  96670. /**
  96671. * Binds the submesh to this material by preparing the effect and shader to draw
  96672. * @param world defines the world transformation matrix
  96673. * @param mesh defines the mesh containing the submesh
  96674. * @param subMesh defines the submesh to bind the material to
  96675. */
  96676. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96677. /**
  96678. * Binds the material to the mesh
  96679. * @param world defines the world transformation matrix
  96680. * @param mesh defines the mesh to bind the material to
  96681. * @param effectOverride - If provided, use this effect instead of internal effect
  96682. */
  96683. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  96684. protected _afterBind(mesh?: Mesh): void;
  96685. /**
  96686. * Gets the active textures from the material
  96687. * @returns an array of textures
  96688. */
  96689. getActiveTextures(): BaseTexture[];
  96690. /**
  96691. * Specifies if the material uses a texture
  96692. * @param texture defines the texture to check against the material
  96693. * @returns a boolean specifying if the material uses the texture
  96694. */
  96695. hasTexture(texture: BaseTexture): boolean;
  96696. /**
  96697. * Makes a duplicate of the material, and gives it a new name
  96698. * @param name defines the new name for the duplicated material
  96699. * @returns the cloned material
  96700. */
  96701. clone(name: string): ShaderMaterial;
  96702. /**
  96703. * Disposes the material
  96704. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96705. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96706. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96707. */
  96708. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96709. /**
  96710. * Serializes this material in a JSON representation
  96711. * @returns the serialized material object
  96712. */
  96713. serialize(): any;
  96714. /**
  96715. * Creates a shader material from parsed shader material data
  96716. * @param source defines the JSON represnetation of the material
  96717. * @param scene defines the hosting scene
  96718. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96719. * @returns a new material
  96720. */
  96721. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  96722. /**
  96723. * Creates a new ShaderMaterial from a snippet saved in a remote file
  96724. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  96725. * @param url defines the url to load from
  96726. * @param scene defines the hosting scene
  96727. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96728. * @returns a promise that will resolve to the new ShaderMaterial
  96729. */
  96730. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96731. /**
  96732. * Creates a ShaderMaterial from a snippet saved by the Inspector
  96733. * @param snippetId defines the snippet to load
  96734. * @param scene defines the hosting scene
  96735. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96736. * @returns a promise that will resolve to the new ShaderMaterial
  96737. */
  96738. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96739. }
  96740. }
  96741. declare module BABYLON {
  96742. /** @hidden */
  96743. export var colorPixelShader: {
  96744. name: string;
  96745. shader: string;
  96746. };
  96747. }
  96748. declare module BABYLON {
  96749. /** @hidden */
  96750. export var colorVertexShader: {
  96751. name: string;
  96752. shader: string;
  96753. };
  96754. }
  96755. declare module BABYLON {
  96756. /**
  96757. * Line mesh
  96758. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  96759. */
  96760. export class LinesMesh extends Mesh {
  96761. /**
  96762. * If vertex color should be applied to the mesh
  96763. */
  96764. readonly useVertexColor?: boolean | undefined;
  96765. /**
  96766. * If vertex alpha should be applied to the mesh
  96767. */
  96768. readonly useVertexAlpha?: boolean | undefined;
  96769. /**
  96770. * Color of the line (Default: White)
  96771. */
  96772. color: Color3;
  96773. /**
  96774. * Alpha of the line (Default: 1)
  96775. */
  96776. alpha: number;
  96777. /**
  96778. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96779. * This margin is expressed in world space coordinates, so its value may vary.
  96780. * Default value is 0.1
  96781. */
  96782. intersectionThreshold: number;
  96783. private _colorShader;
  96784. private color4;
  96785. /**
  96786. * Creates a new LinesMesh
  96787. * @param name defines the name
  96788. * @param scene defines the hosting scene
  96789. * @param parent defines the parent mesh if any
  96790. * @param source defines the optional source LinesMesh used to clone data from
  96791. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96792. * When false, achieved by calling a clone(), also passing False.
  96793. * This will make creation of children, recursive.
  96794. * @param useVertexColor defines if this LinesMesh supports vertex color
  96795. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  96796. */
  96797. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  96798. /**
  96799. * If vertex color should be applied to the mesh
  96800. */
  96801. useVertexColor?: boolean | undefined,
  96802. /**
  96803. * If vertex alpha should be applied to the mesh
  96804. */
  96805. useVertexAlpha?: boolean | undefined);
  96806. private _addClipPlaneDefine;
  96807. private _removeClipPlaneDefine;
  96808. isReady(): boolean;
  96809. /**
  96810. * Returns the string "LineMesh"
  96811. */
  96812. getClassName(): string;
  96813. /**
  96814. * @hidden
  96815. */
  96816. get material(): Material;
  96817. /**
  96818. * @hidden
  96819. */
  96820. set material(value: Material);
  96821. /**
  96822. * @hidden
  96823. */
  96824. get checkCollisions(): boolean;
  96825. /** @hidden */
  96826. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  96827. /** @hidden */
  96828. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  96829. /**
  96830. * Disposes of the line mesh
  96831. * @param doNotRecurse If children should be disposed
  96832. */
  96833. dispose(doNotRecurse?: boolean): void;
  96834. /**
  96835. * Returns a new LineMesh object cloned from the current one.
  96836. */
  96837. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  96838. /**
  96839. * Creates a new InstancedLinesMesh object from the mesh model.
  96840. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96841. * @param name defines the name of the new instance
  96842. * @returns a new InstancedLinesMesh
  96843. */
  96844. createInstance(name: string): InstancedLinesMesh;
  96845. }
  96846. /**
  96847. * Creates an instance based on a source LinesMesh
  96848. */
  96849. export class InstancedLinesMesh extends InstancedMesh {
  96850. /**
  96851. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96852. * This margin is expressed in world space coordinates, so its value may vary.
  96853. * Initilized with the intersectionThreshold value of the source LinesMesh
  96854. */
  96855. intersectionThreshold: number;
  96856. constructor(name: string, source: LinesMesh);
  96857. /**
  96858. * Returns the string "InstancedLinesMesh".
  96859. */
  96860. getClassName(): string;
  96861. }
  96862. }
  96863. declare module BABYLON {
  96864. /** @hidden */
  96865. export var linePixelShader: {
  96866. name: string;
  96867. shader: string;
  96868. };
  96869. }
  96870. declare module BABYLON {
  96871. /** @hidden */
  96872. export var lineVertexShader: {
  96873. name: string;
  96874. shader: string;
  96875. };
  96876. }
  96877. declare module BABYLON {
  96878. interface Scene {
  96879. /** @hidden */
  96880. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  96881. }
  96882. interface AbstractMesh {
  96883. /**
  96884. * Gets the edgesRenderer associated with the mesh
  96885. */
  96886. edgesRenderer: Nullable<EdgesRenderer>;
  96887. }
  96888. interface LinesMesh {
  96889. /**
  96890. * Enables the edge rendering mode on the mesh.
  96891. * This mode makes the mesh edges visible
  96892. * @param epsilon defines the maximal distance between two angles to detect a face
  96893. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96894. * @returns the currentAbstractMesh
  96895. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96896. */
  96897. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96898. }
  96899. interface InstancedLinesMesh {
  96900. /**
  96901. * Enables the edge rendering mode on the mesh.
  96902. * This mode makes the mesh edges visible
  96903. * @param epsilon defines the maximal distance between two angles to detect a face
  96904. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96905. * @returns the current InstancedLinesMesh
  96906. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96907. */
  96908. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  96909. }
  96910. /**
  96911. * Defines the minimum contract an Edges renderer should follow.
  96912. */
  96913. export interface IEdgesRenderer extends IDisposable {
  96914. /**
  96915. * Gets or sets a boolean indicating if the edgesRenderer is active
  96916. */
  96917. isEnabled: boolean;
  96918. /**
  96919. * Renders the edges of the attached mesh,
  96920. */
  96921. render(): void;
  96922. /**
  96923. * Checks wether or not the edges renderer is ready to render.
  96924. * @return true if ready, otherwise false.
  96925. */
  96926. isReady(): boolean;
  96927. /**
  96928. * List of instances to render in case the source mesh has instances
  96929. */
  96930. customInstances: SmartArray<Matrix>;
  96931. }
  96932. /**
  96933. * Defines the additional options of the edges renderer
  96934. */
  96935. export interface IEdgesRendererOptions {
  96936. /**
  96937. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  96938. * If not defined, the default value is true
  96939. */
  96940. useAlternateEdgeFinder?: boolean;
  96941. /**
  96942. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  96943. * If not defined, the default value is true.
  96944. * 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)
  96945. * This option is used only if useAlternateEdgeFinder = true
  96946. */
  96947. useFastVertexMerger?: boolean;
  96948. /**
  96949. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  96950. * The default value is 1e-6
  96951. * This option is used only if useAlternateEdgeFinder = true
  96952. */
  96953. epsilonVertexMerge?: number;
  96954. /**
  96955. * 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
  96956. * 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.
  96957. * This option is used only if useAlternateEdgeFinder = true
  96958. */
  96959. applyTessellation?: boolean;
  96960. /**
  96961. * 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
  96962. * The default value is 1e-6
  96963. * This option is used only if useAlternateEdgeFinder = true
  96964. */
  96965. epsilonVertexAligned?: number;
  96966. }
  96967. /**
  96968. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96969. */
  96970. export class EdgesRenderer implements IEdgesRenderer {
  96971. /**
  96972. * Define the size of the edges with an orthographic camera
  96973. */
  96974. edgesWidthScalerForOrthographic: number;
  96975. /**
  96976. * Define the size of the edges with a perspective camera
  96977. */
  96978. edgesWidthScalerForPerspective: number;
  96979. protected _source: AbstractMesh;
  96980. protected _linesPositions: number[];
  96981. protected _linesNormals: number[];
  96982. protected _linesIndices: number[];
  96983. protected _epsilon: number;
  96984. protected _indicesCount: number;
  96985. protected _lineShader: ShaderMaterial;
  96986. protected _ib: DataBuffer;
  96987. protected _buffers: {
  96988. [key: string]: Nullable<VertexBuffer>;
  96989. };
  96990. protected _buffersForInstances: {
  96991. [key: string]: Nullable<VertexBuffer>;
  96992. };
  96993. protected _checkVerticesInsteadOfIndices: boolean;
  96994. protected _options: Nullable<IEdgesRendererOptions>;
  96995. private _meshRebuildObserver;
  96996. private _meshDisposeObserver;
  96997. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96998. isEnabled: boolean;
  96999. /**
  97000. * List of instances to render in case the source mesh has instances
  97001. */
  97002. customInstances: SmartArray<Matrix>;
  97003. private static GetShader;
  97004. /**
  97005. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97006. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97007. * @param source Mesh used to create edges
  97008. * @param epsilon sum of angles in adjacency to check for edge
  97009. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97010. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97011. * @param options The options to apply when generating the edges
  97012. */
  97013. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97014. protected _prepareRessources(): void;
  97015. /** @hidden */
  97016. _rebuild(): void;
  97017. /**
  97018. * Releases the required resources for the edges renderer
  97019. */
  97020. dispose(): void;
  97021. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97022. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97023. /**
  97024. * Checks if the pair of p0 and p1 is en edge
  97025. * @param faceIndex
  97026. * @param edge
  97027. * @param faceNormals
  97028. * @param p0
  97029. * @param p1
  97030. * @private
  97031. */
  97032. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97033. /**
  97034. * push line into the position, normal and index buffer
  97035. * @protected
  97036. */
  97037. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97038. /**
  97039. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97040. */
  97041. private _tessellateTriangle;
  97042. private _generateEdgesLinesAlternate;
  97043. /**
  97044. * Generates lines edges from adjacencjes
  97045. * @private
  97046. */
  97047. _generateEdgesLines(): void;
  97048. /**
  97049. * Checks wether or not the edges renderer is ready to render.
  97050. * @return true if ready, otherwise false.
  97051. */
  97052. isReady(): boolean;
  97053. /**
  97054. * Renders the edges of the attached mesh,
  97055. */
  97056. render(): void;
  97057. }
  97058. /**
  97059. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97060. */
  97061. export class LineEdgesRenderer extends EdgesRenderer {
  97062. /**
  97063. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97064. * @param source LineMesh used to generate edges
  97065. * @param epsilon not important (specified angle for edge detection)
  97066. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97067. */
  97068. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97069. /**
  97070. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97071. */
  97072. _generateEdgesLines(): void;
  97073. }
  97074. }
  97075. declare module BABYLON {
  97076. /**
  97077. * This represents the object necessary to create a rendering group.
  97078. * This is exclusively used and created by the rendering manager.
  97079. * To modify the behavior, you use the available helpers in your scene or meshes.
  97080. * @hidden
  97081. */
  97082. export class RenderingGroup {
  97083. index: number;
  97084. private static _zeroVector;
  97085. private _scene;
  97086. private _opaqueSubMeshes;
  97087. private _transparentSubMeshes;
  97088. private _alphaTestSubMeshes;
  97089. private _depthOnlySubMeshes;
  97090. private _particleSystems;
  97091. private _spriteManagers;
  97092. private _opaqueSortCompareFn;
  97093. private _alphaTestSortCompareFn;
  97094. private _transparentSortCompareFn;
  97095. private _renderOpaque;
  97096. private _renderAlphaTest;
  97097. private _renderTransparent;
  97098. /** @hidden */
  97099. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97100. onBeforeTransparentRendering: () => void;
  97101. /**
  97102. * Set the opaque sort comparison function.
  97103. * If null the sub meshes will be render in the order they were created
  97104. */
  97105. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97106. /**
  97107. * Set the alpha test sort comparison function.
  97108. * If null the sub meshes will be render in the order they were created
  97109. */
  97110. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97111. /**
  97112. * Set the transparent sort comparison function.
  97113. * If null the sub meshes will be render in the order they were created
  97114. */
  97115. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97116. /**
  97117. * Creates a new rendering group.
  97118. * @param index The rendering group index
  97119. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97120. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97121. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97122. */
  97123. 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>);
  97124. /**
  97125. * Render all the sub meshes contained in the group.
  97126. * @param customRenderFunction Used to override the default render behaviour of the group.
  97127. * @returns true if rendered some submeshes.
  97128. */
  97129. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97130. /**
  97131. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97132. * @param subMeshes The submeshes to render
  97133. */
  97134. private renderOpaqueSorted;
  97135. /**
  97136. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97137. * @param subMeshes The submeshes to render
  97138. */
  97139. private renderAlphaTestSorted;
  97140. /**
  97141. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97142. * @param subMeshes The submeshes to render
  97143. */
  97144. private renderTransparentSorted;
  97145. /**
  97146. * Renders the submeshes in a specified order.
  97147. * @param subMeshes The submeshes to sort before render
  97148. * @param sortCompareFn The comparison function use to sort
  97149. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97150. * @param transparent Specifies to activate blending if true
  97151. */
  97152. private static renderSorted;
  97153. /**
  97154. * Renders the submeshes in the order they were dispatched (no sort applied).
  97155. * @param subMeshes The submeshes to render
  97156. */
  97157. private static renderUnsorted;
  97158. /**
  97159. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97160. * are rendered back to front if in the same alpha index.
  97161. *
  97162. * @param a The first submesh
  97163. * @param b The second submesh
  97164. * @returns The result of the comparison
  97165. */
  97166. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97167. /**
  97168. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97169. * are rendered back to front.
  97170. *
  97171. * @param a The first submesh
  97172. * @param b The second submesh
  97173. * @returns The result of the comparison
  97174. */
  97175. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97176. /**
  97177. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97178. * are rendered front to back (prevent overdraw).
  97179. *
  97180. * @param a The first submesh
  97181. * @param b The second submesh
  97182. * @returns The result of the comparison
  97183. */
  97184. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97185. /**
  97186. * Resets the different lists of submeshes to prepare a new frame.
  97187. */
  97188. prepare(): void;
  97189. dispose(): void;
  97190. /**
  97191. * Inserts the submesh in its correct queue depending on its material.
  97192. * @param subMesh The submesh to dispatch
  97193. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97194. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97195. */
  97196. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97197. dispatchSprites(spriteManager: ISpriteManager): void;
  97198. dispatchParticles(particleSystem: IParticleSystem): void;
  97199. private _renderParticles;
  97200. private _renderSprites;
  97201. }
  97202. }
  97203. declare module BABYLON {
  97204. /**
  97205. * Interface describing the different options available in the rendering manager
  97206. * regarding Auto Clear between groups.
  97207. */
  97208. export interface IRenderingManagerAutoClearSetup {
  97209. /**
  97210. * Defines whether or not autoclear is enable.
  97211. */
  97212. autoClear: boolean;
  97213. /**
  97214. * Defines whether or not to autoclear the depth buffer.
  97215. */
  97216. depth: boolean;
  97217. /**
  97218. * Defines whether or not to autoclear the stencil buffer.
  97219. */
  97220. stencil: boolean;
  97221. }
  97222. /**
  97223. * This class is used by the onRenderingGroupObservable
  97224. */
  97225. export class RenderingGroupInfo {
  97226. /**
  97227. * The Scene that being rendered
  97228. */
  97229. scene: Scene;
  97230. /**
  97231. * The camera currently used for the rendering pass
  97232. */
  97233. camera: Nullable<Camera>;
  97234. /**
  97235. * The ID of the renderingGroup being processed
  97236. */
  97237. renderingGroupId: number;
  97238. }
  97239. /**
  97240. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97241. * It is enable to manage the different groups as well as the different necessary sort functions.
  97242. * This should not be used directly aside of the few static configurations
  97243. */
  97244. export class RenderingManager {
  97245. /**
  97246. * The max id used for rendering groups (not included)
  97247. */
  97248. static MAX_RENDERINGGROUPS: number;
  97249. /**
  97250. * The min id used for rendering groups (included)
  97251. */
  97252. static MIN_RENDERINGGROUPS: number;
  97253. /**
  97254. * Used to globally prevent autoclearing scenes.
  97255. */
  97256. static AUTOCLEAR: boolean;
  97257. /**
  97258. * @hidden
  97259. */
  97260. _useSceneAutoClearSetup: boolean;
  97261. private _scene;
  97262. private _renderingGroups;
  97263. private _depthStencilBufferAlreadyCleaned;
  97264. private _autoClearDepthStencil;
  97265. private _customOpaqueSortCompareFn;
  97266. private _customAlphaTestSortCompareFn;
  97267. private _customTransparentSortCompareFn;
  97268. private _renderingGroupInfo;
  97269. /**
  97270. * Instantiates a new rendering group for a particular scene
  97271. * @param scene Defines the scene the groups belongs to
  97272. */
  97273. constructor(scene: Scene);
  97274. private _clearDepthStencilBuffer;
  97275. /**
  97276. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97277. * @hidden
  97278. */
  97279. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97280. /**
  97281. * Resets the different information of the group to prepare a new frame
  97282. * @hidden
  97283. */
  97284. reset(): void;
  97285. /**
  97286. * Dispose and release the group and its associated resources.
  97287. * @hidden
  97288. */
  97289. dispose(): void;
  97290. /**
  97291. * Clear the info related to rendering groups preventing retention points during dispose.
  97292. */
  97293. freeRenderingGroups(): void;
  97294. private _prepareRenderingGroup;
  97295. /**
  97296. * Add a sprite manager to the rendering manager in order to render it this frame.
  97297. * @param spriteManager Define the sprite manager to render
  97298. */
  97299. dispatchSprites(spriteManager: ISpriteManager): void;
  97300. /**
  97301. * Add a particle system to the rendering manager in order to render it this frame.
  97302. * @param particleSystem Define the particle system to render
  97303. */
  97304. dispatchParticles(particleSystem: IParticleSystem): void;
  97305. /**
  97306. * Add a submesh to the manager in order to render it this frame
  97307. * @param subMesh The submesh to dispatch
  97308. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97309. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97310. */
  97311. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97312. /**
  97313. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97314. * This allowed control for front to back rendering or reversly depending of the special needs.
  97315. *
  97316. * @param renderingGroupId The rendering group id corresponding to its index
  97317. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97318. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97319. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97320. */
  97321. 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;
  97322. /**
  97323. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97324. *
  97325. * @param renderingGroupId The rendering group id corresponding to its index
  97326. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97327. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97328. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97329. */
  97330. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97331. /**
  97332. * Gets the current auto clear configuration for one rendering group of the rendering
  97333. * manager.
  97334. * @param index the rendering group index to get the information for
  97335. * @returns The auto clear setup for the requested rendering group
  97336. */
  97337. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97338. }
  97339. }
  97340. declare module BABYLON {
  97341. /**
  97342. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97343. */
  97344. export interface ICustomShaderOptions {
  97345. /**
  97346. * Gets or sets the custom shader name to use
  97347. */
  97348. shaderName: string;
  97349. /**
  97350. * The list of attribute names used in the shader
  97351. */
  97352. attributes?: string[];
  97353. /**
  97354. * The list of unifrom names used in the shader
  97355. */
  97356. uniforms?: string[];
  97357. /**
  97358. * The list of sampler names used in the shader
  97359. */
  97360. samplers?: string[];
  97361. /**
  97362. * The list of defines used in the shader
  97363. */
  97364. defines?: string[];
  97365. }
  97366. /**
  97367. * Interface to implement to create a shadow generator compatible with BJS.
  97368. */
  97369. export interface IShadowGenerator {
  97370. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97371. id: string;
  97372. /**
  97373. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97374. * @returns The render target texture if present otherwise, null
  97375. */
  97376. getShadowMap(): Nullable<RenderTargetTexture>;
  97377. /**
  97378. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97379. * @param subMesh The submesh we want to render in the shadow map
  97380. * @param useInstances Defines wether will draw in the map using instances
  97381. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97382. * @returns true if ready otherwise, false
  97383. */
  97384. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97385. /**
  97386. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97387. * @param defines Defines of the material we want to update
  97388. * @param lightIndex Index of the light in the enabled light list of the material
  97389. */
  97390. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97391. /**
  97392. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97393. * defined in the generator but impacting the effect).
  97394. * It implies the unifroms available on the materials are the standard BJS ones.
  97395. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97396. * @param effect The effect we are binfing the information for
  97397. */
  97398. bindShadowLight(lightIndex: string, effect: Effect): void;
  97399. /**
  97400. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97401. * (eq to shadow prjection matrix * light transform matrix)
  97402. * @returns The transform matrix used to create the shadow map
  97403. */
  97404. getTransformMatrix(): Matrix;
  97405. /**
  97406. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97407. * Cube and 2D textures for instance.
  97408. */
  97409. recreateShadowMap(): void;
  97410. /**
  97411. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97412. * @param onCompiled Callback triggered at the and of the effects compilation
  97413. * @param options Sets of optional options forcing the compilation with different modes
  97414. */
  97415. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97416. useInstances: boolean;
  97417. }>): void;
  97418. /**
  97419. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97420. * @param options Sets of optional options forcing the compilation with different modes
  97421. * @returns A promise that resolves when the compilation completes
  97422. */
  97423. forceCompilationAsync(options?: Partial<{
  97424. useInstances: boolean;
  97425. }>): Promise<void>;
  97426. /**
  97427. * Serializes the shadow generator setup to a json object.
  97428. * @returns The serialized JSON object
  97429. */
  97430. serialize(): any;
  97431. /**
  97432. * Disposes the Shadow map and related Textures and effects.
  97433. */
  97434. dispose(): void;
  97435. }
  97436. /**
  97437. * Default implementation IShadowGenerator.
  97438. * This is the main object responsible of generating shadows in the framework.
  97439. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97440. */
  97441. export class ShadowGenerator implements IShadowGenerator {
  97442. /**
  97443. * Name of the shadow generator class
  97444. */
  97445. static CLASSNAME: string;
  97446. /**
  97447. * Shadow generator mode None: no filtering applied.
  97448. */
  97449. static readonly FILTER_NONE: number;
  97450. /**
  97451. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97452. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97453. */
  97454. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97455. /**
  97456. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97457. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97458. */
  97459. static readonly FILTER_POISSONSAMPLING: number;
  97460. /**
  97461. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97462. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97463. */
  97464. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97465. /**
  97466. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97467. * edge artifacts on steep falloff.
  97468. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97469. */
  97470. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97471. /**
  97472. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97473. * edge artifacts on steep falloff.
  97474. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97475. */
  97476. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97477. /**
  97478. * Shadow generator mode PCF: Percentage Closer Filtering
  97479. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97480. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97481. */
  97482. static readonly FILTER_PCF: number;
  97483. /**
  97484. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97485. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97486. * Contact Hardening
  97487. */
  97488. static readonly FILTER_PCSS: number;
  97489. /**
  97490. * Reserved for PCF and PCSS
  97491. * Highest Quality.
  97492. *
  97493. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97494. *
  97495. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97496. */
  97497. static readonly QUALITY_HIGH: number;
  97498. /**
  97499. * Reserved for PCF and PCSS
  97500. * Good tradeoff for quality/perf cross devices
  97501. *
  97502. * Execute PCF on a 3*3 kernel.
  97503. *
  97504. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97505. */
  97506. static readonly QUALITY_MEDIUM: number;
  97507. /**
  97508. * Reserved for PCF and PCSS
  97509. * The lowest quality but the fastest.
  97510. *
  97511. * Execute PCF on a 1*1 kernel.
  97512. *
  97513. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97514. */
  97515. static readonly QUALITY_LOW: number;
  97516. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97517. id: string;
  97518. /** Gets or sets the custom shader name to use */
  97519. customShaderOptions: ICustomShaderOptions;
  97520. /**
  97521. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97522. */
  97523. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97524. /**
  97525. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97526. */
  97527. onAfterShadowMapRenderObservable: Observable<Effect>;
  97528. /**
  97529. * Observable triggered before a mesh is rendered in the shadow map.
  97530. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97531. */
  97532. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97533. /**
  97534. * Observable triggered after a mesh is rendered in the shadow map.
  97535. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97536. */
  97537. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97538. protected _bias: number;
  97539. /**
  97540. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97541. */
  97542. get bias(): number;
  97543. /**
  97544. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97545. */
  97546. set bias(bias: number);
  97547. protected _normalBias: number;
  97548. /**
  97549. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97550. */
  97551. get normalBias(): number;
  97552. /**
  97553. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97554. */
  97555. set normalBias(normalBias: number);
  97556. protected _blurBoxOffset: number;
  97557. /**
  97558. * Gets the blur box offset: offset applied during the blur pass.
  97559. * Only useful if useKernelBlur = false
  97560. */
  97561. get blurBoxOffset(): number;
  97562. /**
  97563. * Sets the blur box offset: offset applied during the blur pass.
  97564. * Only useful if useKernelBlur = false
  97565. */
  97566. set blurBoxOffset(value: number);
  97567. protected _blurScale: number;
  97568. /**
  97569. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97570. * 2 means half of the size.
  97571. */
  97572. get blurScale(): number;
  97573. /**
  97574. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97575. * 2 means half of the size.
  97576. */
  97577. set blurScale(value: number);
  97578. protected _blurKernel: number;
  97579. /**
  97580. * Gets the blur kernel: kernel size of the blur pass.
  97581. * Only useful if useKernelBlur = true
  97582. */
  97583. get blurKernel(): number;
  97584. /**
  97585. * Sets the blur kernel: kernel size of the blur pass.
  97586. * Only useful if useKernelBlur = true
  97587. */
  97588. set blurKernel(value: number);
  97589. protected _useKernelBlur: boolean;
  97590. /**
  97591. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97592. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97593. */
  97594. get useKernelBlur(): boolean;
  97595. /**
  97596. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97597. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97598. */
  97599. set useKernelBlur(value: boolean);
  97600. protected _depthScale: number;
  97601. /**
  97602. * Gets the depth scale used in ESM mode.
  97603. */
  97604. get depthScale(): number;
  97605. /**
  97606. * Sets the depth scale used in ESM mode.
  97607. * This can override the scale stored on the light.
  97608. */
  97609. set depthScale(value: number);
  97610. protected _validateFilter(filter: number): number;
  97611. protected _filter: number;
  97612. /**
  97613. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  97614. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97615. */
  97616. get filter(): number;
  97617. /**
  97618. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  97619. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97620. */
  97621. set filter(value: number);
  97622. /**
  97623. * Gets if the current filter is set to Poisson Sampling.
  97624. */
  97625. get usePoissonSampling(): boolean;
  97626. /**
  97627. * Sets the current filter to Poisson Sampling.
  97628. */
  97629. set usePoissonSampling(value: boolean);
  97630. /**
  97631. * Gets if the current filter is set to ESM.
  97632. */
  97633. get useExponentialShadowMap(): boolean;
  97634. /**
  97635. * Sets the current filter is to ESM.
  97636. */
  97637. set useExponentialShadowMap(value: boolean);
  97638. /**
  97639. * Gets if the current filter is set to filtered ESM.
  97640. */
  97641. get useBlurExponentialShadowMap(): boolean;
  97642. /**
  97643. * Gets if the current filter is set to filtered ESM.
  97644. */
  97645. set useBlurExponentialShadowMap(value: boolean);
  97646. /**
  97647. * Gets if the current filter is set to "close ESM" (using the inverse of the
  97648. * exponential to prevent steep falloff artifacts).
  97649. */
  97650. get useCloseExponentialShadowMap(): boolean;
  97651. /**
  97652. * Sets the current filter to "close ESM" (using the inverse of the
  97653. * exponential to prevent steep falloff artifacts).
  97654. */
  97655. set useCloseExponentialShadowMap(value: boolean);
  97656. /**
  97657. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  97658. * exponential to prevent steep falloff artifacts).
  97659. */
  97660. get useBlurCloseExponentialShadowMap(): boolean;
  97661. /**
  97662. * Sets the current filter to filtered "close ESM" (using the inverse of the
  97663. * exponential to prevent steep falloff artifacts).
  97664. */
  97665. set useBlurCloseExponentialShadowMap(value: boolean);
  97666. /**
  97667. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  97668. */
  97669. get usePercentageCloserFiltering(): boolean;
  97670. /**
  97671. * Sets the current filter to "PCF" (percentage closer filtering).
  97672. */
  97673. set usePercentageCloserFiltering(value: boolean);
  97674. protected _filteringQuality: number;
  97675. /**
  97676. * Gets the PCF or PCSS Quality.
  97677. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97678. */
  97679. get filteringQuality(): number;
  97680. /**
  97681. * Sets the PCF or PCSS Quality.
  97682. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97683. */
  97684. set filteringQuality(filteringQuality: number);
  97685. /**
  97686. * Gets if the current filter is set to "PCSS" (contact hardening).
  97687. */
  97688. get useContactHardeningShadow(): boolean;
  97689. /**
  97690. * Sets the current filter to "PCSS" (contact hardening).
  97691. */
  97692. set useContactHardeningShadow(value: boolean);
  97693. protected _contactHardeningLightSizeUVRatio: number;
  97694. /**
  97695. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97696. * Using a ratio helps keeping shape stability independently of the map size.
  97697. *
  97698. * It does not account for the light projection as it was having too much
  97699. * instability during the light setup or during light position changes.
  97700. *
  97701. * Only valid if useContactHardeningShadow is true.
  97702. */
  97703. get contactHardeningLightSizeUVRatio(): number;
  97704. /**
  97705. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97706. * Using a ratio helps keeping shape stability independently of the map size.
  97707. *
  97708. * It does not account for the light projection as it was having too much
  97709. * instability during the light setup or during light position changes.
  97710. *
  97711. * Only valid if useContactHardeningShadow is true.
  97712. */
  97713. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  97714. protected _darkness: number;
  97715. /** Gets or sets the actual darkness of a shadow */
  97716. get darkness(): number;
  97717. set darkness(value: number);
  97718. /**
  97719. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  97720. * 0 means strongest and 1 would means no shadow.
  97721. * @returns the darkness.
  97722. */
  97723. getDarkness(): number;
  97724. /**
  97725. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  97726. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  97727. * @returns the shadow generator allowing fluent coding.
  97728. */
  97729. setDarkness(darkness: number): ShadowGenerator;
  97730. protected _transparencyShadow: boolean;
  97731. /** Gets or sets the ability to have transparent shadow */
  97732. get transparencyShadow(): boolean;
  97733. set transparencyShadow(value: boolean);
  97734. /**
  97735. * Sets the ability to have transparent shadow (boolean).
  97736. * @param transparent True if transparent else False
  97737. * @returns the shadow generator allowing fluent coding
  97738. */
  97739. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  97740. /**
  97741. * Enables or disables shadows with varying strength based on the transparency
  97742. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  97743. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  97744. * mesh.visibility * alphaTexture.a
  97745. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  97746. */
  97747. enableSoftTransparentShadow: boolean;
  97748. protected _shadowMap: Nullable<RenderTargetTexture>;
  97749. protected _shadowMap2: Nullable<RenderTargetTexture>;
  97750. /**
  97751. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97752. * @returns The render target texture if present otherwise, null
  97753. */
  97754. getShadowMap(): Nullable<RenderTargetTexture>;
  97755. /**
  97756. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  97757. * @returns The render target texture if the shadow map is present otherwise, null
  97758. */
  97759. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  97760. /**
  97761. * Gets the class name of that object
  97762. * @returns "ShadowGenerator"
  97763. */
  97764. getClassName(): string;
  97765. /**
  97766. * Helper function to add a mesh and its descendants to the list of shadow casters.
  97767. * @param mesh Mesh to add
  97768. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  97769. * @returns the Shadow Generator itself
  97770. */
  97771. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97772. /**
  97773. * Helper function to remove a mesh and its descendants from the list of shadow casters
  97774. * @param mesh Mesh to remove
  97775. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  97776. * @returns the Shadow Generator itself
  97777. */
  97778. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97779. /**
  97780. * Controls the extent to which the shadows fade out at the edge of the frustum
  97781. */
  97782. frustumEdgeFalloff: number;
  97783. protected _light: IShadowLight;
  97784. /**
  97785. * Returns the associated light object.
  97786. * @returns the light generating the shadow
  97787. */
  97788. getLight(): IShadowLight;
  97789. /**
  97790. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  97791. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  97792. * It might on the other hand introduce peter panning.
  97793. */
  97794. forceBackFacesOnly: boolean;
  97795. protected _scene: Scene;
  97796. protected _lightDirection: Vector3;
  97797. protected _effect: Effect;
  97798. protected _viewMatrix: Matrix;
  97799. protected _projectionMatrix: Matrix;
  97800. protected _transformMatrix: Matrix;
  97801. protected _cachedPosition: Vector3;
  97802. protected _cachedDirection: Vector3;
  97803. protected _cachedDefines: string;
  97804. protected _currentRenderID: number;
  97805. protected _boxBlurPostprocess: Nullable<PostProcess>;
  97806. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  97807. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  97808. protected _blurPostProcesses: PostProcess[];
  97809. protected _mapSize: number;
  97810. protected _currentFaceIndex: number;
  97811. protected _currentFaceIndexCache: number;
  97812. protected _textureType: number;
  97813. protected _defaultTextureMatrix: Matrix;
  97814. protected _storedUniqueId: Nullable<number>;
  97815. /** @hidden */
  97816. static _SceneComponentInitialization: (scene: Scene) => void;
  97817. /**
  97818. * Creates a ShadowGenerator object.
  97819. * A ShadowGenerator is the required tool to use the shadows.
  97820. * Each light casting shadows needs to use its own ShadowGenerator.
  97821. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  97822. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  97823. * @param light The light object generating the shadows.
  97824. * @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.
  97825. */
  97826. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  97827. protected _initializeGenerator(): void;
  97828. protected _createTargetRenderTexture(): void;
  97829. protected _initializeShadowMap(): void;
  97830. protected _initializeBlurRTTAndPostProcesses(): void;
  97831. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  97832. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  97833. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  97834. protected _applyFilterValues(): void;
  97835. /**
  97836. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97837. * @param onCompiled Callback triggered at the and of the effects compilation
  97838. * @param options Sets of optional options forcing the compilation with different modes
  97839. */
  97840. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97841. useInstances: boolean;
  97842. }>): void;
  97843. /**
  97844. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97845. * @param options Sets of optional options forcing the compilation with different modes
  97846. * @returns A promise that resolves when the compilation completes
  97847. */
  97848. forceCompilationAsync(options?: Partial<{
  97849. useInstances: boolean;
  97850. }>): Promise<void>;
  97851. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  97852. private _prepareShadowDefines;
  97853. /**
  97854. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97855. * @param subMesh The submesh we want to render in the shadow map
  97856. * @param useInstances Defines wether will draw in the map using instances
  97857. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97858. * @returns true if ready otherwise, false
  97859. */
  97860. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97861. /**
  97862. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97863. * @param defines Defines of the material we want to update
  97864. * @param lightIndex Index of the light in the enabled light list of the material
  97865. */
  97866. prepareDefines(defines: any, lightIndex: number): void;
  97867. /**
  97868. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97869. * defined in the generator but impacting the effect).
  97870. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97871. * @param effect The effect we are binfing the information for
  97872. */
  97873. bindShadowLight(lightIndex: string, effect: Effect): void;
  97874. /**
  97875. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97876. * (eq to shadow prjection matrix * light transform matrix)
  97877. * @returns The transform matrix used to create the shadow map
  97878. */
  97879. getTransformMatrix(): Matrix;
  97880. /**
  97881. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97882. * Cube and 2D textures for instance.
  97883. */
  97884. recreateShadowMap(): void;
  97885. protected _disposeBlurPostProcesses(): void;
  97886. protected _disposeRTTandPostProcesses(): void;
  97887. /**
  97888. * Disposes the ShadowGenerator.
  97889. * Returns nothing.
  97890. */
  97891. dispose(): void;
  97892. /**
  97893. * Serializes the shadow generator setup to a json object.
  97894. * @returns The serialized JSON object
  97895. */
  97896. serialize(): any;
  97897. /**
  97898. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  97899. * @param parsedShadowGenerator The JSON object to parse
  97900. * @param scene The scene to create the shadow map for
  97901. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  97902. * @returns The parsed shadow generator
  97903. */
  97904. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  97905. }
  97906. }
  97907. declare module BABYLON {
  97908. /**
  97909. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  97910. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  97911. * 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.
  97912. */
  97913. export abstract class Light extends Node {
  97914. /**
  97915. * Falloff Default: light is falling off following the material specification:
  97916. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  97917. */
  97918. static readonly FALLOFF_DEFAULT: number;
  97919. /**
  97920. * Falloff Physical: light is falling off following the inverse squared distance law.
  97921. */
  97922. static readonly FALLOFF_PHYSICAL: number;
  97923. /**
  97924. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  97925. * to enhance interoperability with other engines.
  97926. */
  97927. static readonly FALLOFF_GLTF: number;
  97928. /**
  97929. * Falloff Standard: light is falling off like in the standard material
  97930. * to enhance interoperability with other materials.
  97931. */
  97932. static readonly FALLOFF_STANDARD: number;
  97933. /**
  97934. * If every light affecting the material is in this lightmapMode,
  97935. * material.lightmapTexture adds or multiplies
  97936. * (depends on material.useLightmapAsShadowmap)
  97937. * after every other light calculations.
  97938. */
  97939. static readonly LIGHTMAP_DEFAULT: number;
  97940. /**
  97941. * material.lightmapTexture as only diffuse lighting from this light
  97942. * adds only specular lighting from this light
  97943. * adds dynamic shadows
  97944. */
  97945. static readonly LIGHTMAP_SPECULAR: number;
  97946. /**
  97947. * material.lightmapTexture as only lighting
  97948. * no light calculation from this light
  97949. * only adds dynamic shadows from this light
  97950. */
  97951. static readonly LIGHTMAP_SHADOWSONLY: number;
  97952. /**
  97953. * Each light type uses the default quantity according to its type:
  97954. * point/spot lights use luminous intensity
  97955. * directional lights use illuminance
  97956. */
  97957. static readonly INTENSITYMODE_AUTOMATIC: number;
  97958. /**
  97959. * lumen (lm)
  97960. */
  97961. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97962. /**
  97963. * candela (lm/sr)
  97964. */
  97965. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97966. /**
  97967. * lux (lm/m^2)
  97968. */
  97969. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97970. /**
  97971. * nit (cd/m^2)
  97972. */
  97973. static readonly INTENSITYMODE_LUMINANCE: number;
  97974. /**
  97975. * Light type const id of the point light.
  97976. */
  97977. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97978. /**
  97979. * Light type const id of the directional light.
  97980. */
  97981. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97982. /**
  97983. * Light type const id of the spot light.
  97984. */
  97985. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97986. /**
  97987. * Light type const id of the hemispheric light.
  97988. */
  97989. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97990. /**
  97991. * Diffuse gives the basic color to an object.
  97992. */
  97993. diffuse: Color3;
  97994. /**
  97995. * Specular produces a highlight color on an object.
  97996. * Note: This is note affecting PBR materials.
  97997. */
  97998. specular: Color3;
  97999. /**
  98000. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98001. * falling off base on range or angle.
  98002. * This can be set to any values in Light.FALLOFF_x.
  98003. *
  98004. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98005. * other types of materials.
  98006. */
  98007. falloffType: number;
  98008. /**
  98009. * Strength of the light.
  98010. * Note: By default it is define in the framework own unit.
  98011. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98012. */
  98013. intensity: number;
  98014. private _range;
  98015. protected _inverseSquaredRange: number;
  98016. /**
  98017. * Defines how far from the source the light is impacting in scene units.
  98018. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98019. */
  98020. get range(): number;
  98021. /**
  98022. * Defines how far from the source the light is impacting in scene units.
  98023. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98024. */
  98025. set range(value: number);
  98026. /**
  98027. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98028. * of light.
  98029. */
  98030. private _photometricScale;
  98031. private _intensityMode;
  98032. /**
  98033. * Gets the photometric scale used to interpret the intensity.
  98034. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98035. */
  98036. get intensityMode(): number;
  98037. /**
  98038. * Sets the photometric scale used to interpret the intensity.
  98039. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98040. */
  98041. set intensityMode(value: number);
  98042. private _radius;
  98043. /**
  98044. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98045. */
  98046. get radius(): number;
  98047. /**
  98048. * sets the light radius used by PBR Materials to simulate soft area lights.
  98049. */
  98050. set radius(value: number);
  98051. private _renderPriority;
  98052. /**
  98053. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98054. * exceeding the number allowed of the materials.
  98055. */
  98056. renderPriority: number;
  98057. private _shadowEnabled;
  98058. /**
  98059. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98060. * the current shadow generator.
  98061. */
  98062. get shadowEnabled(): boolean;
  98063. /**
  98064. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98065. * the current shadow generator.
  98066. */
  98067. set shadowEnabled(value: boolean);
  98068. private _includedOnlyMeshes;
  98069. /**
  98070. * Gets the only meshes impacted by this light.
  98071. */
  98072. get includedOnlyMeshes(): AbstractMesh[];
  98073. /**
  98074. * Sets the only meshes impacted by this light.
  98075. */
  98076. set includedOnlyMeshes(value: AbstractMesh[]);
  98077. private _excludedMeshes;
  98078. /**
  98079. * Gets the meshes not impacted by this light.
  98080. */
  98081. get excludedMeshes(): AbstractMesh[];
  98082. /**
  98083. * Sets the meshes not impacted by this light.
  98084. */
  98085. set excludedMeshes(value: AbstractMesh[]);
  98086. private _excludeWithLayerMask;
  98087. /**
  98088. * Gets the layer id use to find what meshes are not impacted by the light.
  98089. * Inactive if 0
  98090. */
  98091. get excludeWithLayerMask(): number;
  98092. /**
  98093. * Sets the layer id use to find what meshes are not impacted by the light.
  98094. * Inactive if 0
  98095. */
  98096. set excludeWithLayerMask(value: number);
  98097. private _includeOnlyWithLayerMask;
  98098. /**
  98099. * Gets the layer id use to find what meshes are impacted by the light.
  98100. * Inactive if 0
  98101. */
  98102. get includeOnlyWithLayerMask(): number;
  98103. /**
  98104. * Sets the layer id use to find what meshes are impacted by the light.
  98105. * Inactive if 0
  98106. */
  98107. set includeOnlyWithLayerMask(value: number);
  98108. private _lightmapMode;
  98109. /**
  98110. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98111. */
  98112. get lightmapMode(): number;
  98113. /**
  98114. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98115. */
  98116. set lightmapMode(value: number);
  98117. /**
  98118. * Shadow generator associted to the light.
  98119. * @hidden Internal use only.
  98120. */
  98121. _shadowGenerator: Nullable<IShadowGenerator>;
  98122. /**
  98123. * @hidden Internal use only.
  98124. */
  98125. _excludedMeshesIds: string[];
  98126. /**
  98127. * @hidden Internal use only.
  98128. */
  98129. _includedOnlyMeshesIds: string[];
  98130. /**
  98131. * The current light unifom buffer.
  98132. * @hidden Internal use only.
  98133. */
  98134. _uniformBuffer: UniformBuffer;
  98135. /** @hidden */
  98136. _renderId: number;
  98137. /**
  98138. * Creates a Light object in the scene.
  98139. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98140. * @param name The firendly name of the light
  98141. * @param scene The scene the light belongs too
  98142. */
  98143. constructor(name: string, scene: Scene);
  98144. protected abstract _buildUniformLayout(): void;
  98145. /**
  98146. * Sets the passed Effect "effect" with the Light information.
  98147. * @param effect The effect to update
  98148. * @param lightIndex The index of the light in the effect to update
  98149. * @returns The light
  98150. */
  98151. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98152. /**
  98153. * Sets the passed Effect "effect" with the Light textures.
  98154. * @param effect The effect to update
  98155. * @param lightIndex The index of the light in the effect to update
  98156. * @returns The light
  98157. */
  98158. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98159. /**
  98160. * Binds the lights information from the scene to the effect for the given mesh.
  98161. * @param lightIndex Light index
  98162. * @param scene The scene where the light belongs to
  98163. * @param effect The effect we are binding the data to
  98164. * @param useSpecular Defines if specular is supported
  98165. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98166. */
  98167. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98168. /**
  98169. * Sets the passed Effect "effect" with the Light information.
  98170. * @param effect The effect to update
  98171. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98172. * @returns The light
  98173. */
  98174. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98175. /**
  98176. * Returns the string "Light".
  98177. * @returns the class name
  98178. */
  98179. getClassName(): string;
  98180. /** @hidden */
  98181. readonly _isLight: boolean;
  98182. /**
  98183. * Converts the light information to a readable string for debug purpose.
  98184. * @param fullDetails Supports for multiple levels of logging within scene loading
  98185. * @returns the human readable light info
  98186. */
  98187. toString(fullDetails?: boolean): string;
  98188. /** @hidden */
  98189. protected _syncParentEnabledState(): void;
  98190. /**
  98191. * Set the enabled state of this node.
  98192. * @param value - the new enabled state
  98193. */
  98194. setEnabled(value: boolean): void;
  98195. /**
  98196. * Returns the Light associated shadow generator if any.
  98197. * @return the associated shadow generator.
  98198. */
  98199. getShadowGenerator(): Nullable<IShadowGenerator>;
  98200. /**
  98201. * Returns a Vector3, the absolute light position in the World.
  98202. * @returns the world space position of the light
  98203. */
  98204. getAbsolutePosition(): Vector3;
  98205. /**
  98206. * Specifies if the light will affect the passed mesh.
  98207. * @param mesh The mesh to test against the light
  98208. * @return true the mesh is affected otherwise, false.
  98209. */
  98210. canAffectMesh(mesh: AbstractMesh): boolean;
  98211. /**
  98212. * Sort function to order lights for rendering.
  98213. * @param a First Light object to compare to second.
  98214. * @param b Second Light object to compare first.
  98215. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98216. */
  98217. static CompareLightsPriority(a: Light, b: Light): number;
  98218. /**
  98219. * Releases resources associated with this node.
  98220. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98221. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98222. */
  98223. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98224. /**
  98225. * Returns the light type ID (integer).
  98226. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98227. */
  98228. getTypeID(): number;
  98229. /**
  98230. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98231. * @returns the scaled intensity in intensity mode unit
  98232. */
  98233. getScaledIntensity(): number;
  98234. /**
  98235. * Returns a new Light object, named "name", from the current one.
  98236. * @param name The name of the cloned light
  98237. * @param newParent The parent of this light, if it has one
  98238. * @returns the new created light
  98239. */
  98240. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98241. /**
  98242. * Serializes the current light into a Serialization object.
  98243. * @returns the serialized object.
  98244. */
  98245. serialize(): any;
  98246. /**
  98247. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98248. * This new light is named "name" and added to the passed scene.
  98249. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98250. * @param name The friendly name of the light
  98251. * @param scene The scene the new light will belong to
  98252. * @returns the constructor function
  98253. */
  98254. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98255. /**
  98256. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98257. * @param parsedLight The JSON representation of the light
  98258. * @param scene The scene to create the parsed light in
  98259. * @returns the created light after parsing
  98260. */
  98261. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98262. private _hookArrayForExcluded;
  98263. private _hookArrayForIncludedOnly;
  98264. private _resyncMeshes;
  98265. /**
  98266. * Forces the meshes to update their light related information in their rendering used effects
  98267. * @hidden Internal Use Only
  98268. */
  98269. _markMeshesAsLightDirty(): void;
  98270. /**
  98271. * Recomputes the cached photometric scale if needed.
  98272. */
  98273. private _computePhotometricScale;
  98274. /**
  98275. * Returns the Photometric Scale according to the light type and intensity mode.
  98276. */
  98277. private _getPhotometricScale;
  98278. /**
  98279. * Reorder the light in the scene according to their defined priority.
  98280. * @hidden Internal Use Only
  98281. */
  98282. _reorderLightsInScene(): void;
  98283. /**
  98284. * Prepares the list of defines specific to the light type.
  98285. * @param defines the list of defines
  98286. * @param lightIndex defines the index of the light for the effect
  98287. */
  98288. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98289. }
  98290. }
  98291. declare module BABYLON {
  98292. /**
  98293. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98294. * This is the base of the follow, arc rotate cameras and Free camera
  98295. * @see https://doc.babylonjs.com/features/cameras
  98296. */
  98297. export class TargetCamera extends Camera {
  98298. private static _RigCamTransformMatrix;
  98299. private static _TargetTransformMatrix;
  98300. private static _TargetFocalPoint;
  98301. private _tmpUpVector;
  98302. private _tmpTargetVector;
  98303. /**
  98304. * Define the current direction the camera is moving to
  98305. */
  98306. cameraDirection: Vector3;
  98307. /**
  98308. * Define the current rotation the camera is rotating to
  98309. */
  98310. cameraRotation: Vector2;
  98311. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98312. ignoreParentScaling: boolean;
  98313. /**
  98314. * When set, the up vector of the camera will be updated by the rotation of the camera
  98315. */
  98316. updateUpVectorFromRotation: boolean;
  98317. private _tmpQuaternion;
  98318. /**
  98319. * Define the current rotation of the camera
  98320. */
  98321. rotation: Vector3;
  98322. /**
  98323. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98324. */
  98325. rotationQuaternion: Quaternion;
  98326. /**
  98327. * Define the current speed of the camera
  98328. */
  98329. speed: number;
  98330. /**
  98331. * Add constraint to the camera to prevent it to move freely in all directions and
  98332. * around all axis.
  98333. */
  98334. noRotationConstraint: boolean;
  98335. /**
  98336. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98337. * panning
  98338. */
  98339. invertRotation: boolean;
  98340. /**
  98341. * Speed multiplier for inverse camera panning
  98342. */
  98343. inverseRotationSpeed: number;
  98344. /**
  98345. * Define the current target of the camera as an object or a position.
  98346. */
  98347. lockedTarget: any;
  98348. /** @hidden */
  98349. _currentTarget: Vector3;
  98350. /** @hidden */
  98351. _initialFocalDistance: number;
  98352. /** @hidden */
  98353. _viewMatrix: Matrix;
  98354. /** @hidden */
  98355. _camMatrix: Matrix;
  98356. /** @hidden */
  98357. _cameraTransformMatrix: Matrix;
  98358. /** @hidden */
  98359. _cameraRotationMatrix: Matrix;
  98360. /** @hidden */
  98361. _referencePoint: Vector3;
  98362. /** @hidden */
  98363. _transformedReferencePoint: Vector3;
  98364. /** @hidden */
  98365. _reset: () => void;
  98366. private _defaultUp;
  98367. /**
  98368. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98369. * This is the base of the follow, arc rotate cameras and Free camera
  98370. * @see https://doc.babylonjs.com/features/cameras
  98371. * @param name Defines the name of the camera in the scene
  98372. * @param position Defines the start position of the camera in the scene
  98373. * @param scene Defines the scene the camera belongs to
  98374. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98375. */
  98376. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98377. /**
  98378. * Gets the position in front of the camera at a given distance.
  98379. * @param distance The distance from the camera we want the position to be
  98380. * @returns the position
  98381. */
  98382. getFrontPosition(distance: number): Vector3;
  98383. /** @hidden */
  98384. _getLockedTargetPosition(): Nullable<Vector3>;
  98385. private _storedPosition;
  98386. private _storedRotation;
  98387. private _storedRotationQuaternion;
  98388. /**
  98389. * Store current camera state of the camera (fov, position, rotation, etc..)
  98390. * @returns the camera
  98391. */
  98392. storeState(): Camera;
  98393. /**
  98394. * Restored camera state. You must call storeState() first
  98395. * @returns whether it was successful or not
  98396. * @hidden
  98397. */
  98398. _restoreStateValues(): boolean;
  98399. /** @hidden */
  98400. _initCache(): void;
  98401. /** @hidden */
  98402. _updateCache(ignoreParentClass?: boolean): void;
  98403. /** @hidden */
  98404. _isSynchronizedViewMatrix(): boolean;
  98405. /** @hidden */
  98406. _computeLocalCameraSpeed(): number;
  98407. /**
  98408. * Defines the target the camera should look at.
  98409. * @param target Defines the new target as a Vector or a mesh
  98410. */
  98411. setTarget(target: Vector3): void;
  98412. /**
  98413. * Defines the target point of the camera.
  98414. * The camera looks towards it form the radius distance.
  98415. */
  98416. get target(): Vector3;
  98417. set target(value: Vector3);
  98418. /**
  98419. * Return the current target position of the camera. This value is expressed in local space.
  98420. * @returns the target position
  98421. */
  98422. getTarget(): Vector3;
  98423. /** @hidden */
  98424. _decideIfNeedsToMove(): boolean;
  98425. /** @hidden */
  98426. _updatePosition(): void;
  98427. /** @hidden */
  98428. _checkInputs(): void;
  98429. protected _updateCameraRotationMatrix(): void;
  98430. /**
  98431. * 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)
  98432. * @returns the current camera
  98433. */
  98434. private _rotateUpVectorWithCameraRotationMatrix;
  98435. private _cachedRotationZ;
  98436. private _cachedQuaternionRotationZ;
  98437. /** @hidden */
  98438. _getViewMatrix(): Matrix;
  98439. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98440. /**
  98441. * @hidden
  98442. */
  98443. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98444. /**
  98445. * @hidden
  98446. */
  98447. _updateRigCameras(): void;
  98448. private _getRigCamPositionAndTarget;
  98449. /**
  98450. * Gets the current object class name.
  98451. * @return the class name
  98452. */
  98453. getClassName(): string;
  98454. }
  98455. }
  98456. declare module BABYLON {
  98457. /**
  98458. * Gather the list of keyboard event types as constants.
  98459. */
  98460. export class KeyboardEventTypes {
  98461. /**
  98462. * The keydown event is fired when a key becomes active (pressed).
  98463. */
  98464. static readonly KEYDOWN: number;
  98465. /**
  98466. * The keyup event is fired when a key has been released.
  98467. */
  98468. static readonly KEYUP: number;
  98469. }
  98470. /**
  98471. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98472. */
  98473. export class KeyboardInfo {
  98474. /**
  98475. * Defines the type of event (KeyboardEventTypes)
  98476. */
  98477. type: number;
  98478. /**
  98479. * Defines the related dom event
  98480. */
  98481. event: KeyboardEvent;
  98482. /**
  98483. * Instantiates a new keyboard info.
  98484. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98485. * @param type Defines the type of event (KeyboardEventTypes)
  98486. * @param event Defines the related dom event
  98487. */
  98488. constructor(
  98489. /**
  98490. * Defines the type of event (KeyboardEventTypes)
  98491. */
  98492. type: number,
  98493. /**
  98494. * Defines the related dom event
  98495. */
  98496. event: KeyboardEvent);
  98497. }
  98498. /**
  98499. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98500. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98501. */
  98502. export class KeyboardInfoPre extends KeyboardInfo {
  98503. /**
  98504. * Defines the type of event (KeyboardEventTypes)
  98505. */
  98506. type: number;
  98507. /**
  98508. * Defines the related dom event
  98509. */
  98510. event: KeyboardEvent;
  98511. /**
  98512. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98513. */
  98514. skipOnPointerObservable: boolean;
  98515. /**
  98516. * Instantiates a new keyboard pre info.
  98517. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98518. * @param type Defines the type of event (KeyboardEventTypes)
  98519. * @param event Defines the related dom event
  98520. */
  98521. constructor(
  98522. /**
  98523. * Defines the type of event (KeyboardEventTypes)
  98524. */
  98525. type: number,
  98526. /**
  98527. * Defines the related dom event
  98528. */
  98529. event: KeyboardEvent);
  98530. }
  98531. }
  98532. declare module BABYLON {
  98533. /**
  98534. * Manage the keyboard inputs to control the movement of a free camera.
  98535. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98536. */
  98537. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98538. /**
  98539. * Defines the camera the input is attached to.
  98540. */
  98541. camera: FreeCamera;
  98542. /**
  98543. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98544. */
  98545. keysUp: number[];
  98546. /**
  98547. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98548. */
  98549. keysUpward: number[];
  98550. /**
  98551. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98552. */
  98553. keysDown: number[];
  98554. /**
  98555. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98556. */
  98557. keysDownward: number[];
  98558. /**
  98559. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98560. */
  98561. keysLeft: number[];
  98562. /**
  98563. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98564. */
  98565. keysRight: number[];
  98566. private _keys;
  98567. private _onCanvasBlurObserver;
  98568. private _onKeyboardObserver;
  98569. private _engine;
  98570. private _scene;
  98571. /**
  98572. * Attach the input controls to a specific dom element to get the input from.
  98573. * @param element Defines the element the controls should be listened from
  98574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98575. */
  98576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98577. /**
  98578. * Detach the current controls from the specified dom element.
  98579. * @param element Defines the element to stop listening the inputs from
  98580. */
  98581. detachControl(element: Nullable<HTMLElement>): void;
  98582. /**
  98583. * Update the current camera state depending on the inputs that have been used this frame.
  98584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98585. */
  98586. checkInputs(): void;
  98587. /**
  98588. * Gets the class name of the current intput.
  98589. * @returns the class name
  98590. */
  98591. getClassName(): string;
  98592. /** @hidden */
  98593. _onLostFocus(): void;
  98594. /**
  98595. * Get the friendly name associated with the input class.
  98596. * @returns the input friendly name
  98597. */
  98598. getSimpleName(): string;
  98599. }
  98600. }
  98601. declare module BABYLON {
  98602. /**
  98603. * Gather the list of pointer event types as constants.
  98604. */
  98605. export class PointerEventTypes {
  98606. /**
  98607. * 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.
  98608. */
  98609. static readonly POINTERDOWN: number;
  98610. /**
  98611. * The pointerup event is fired when a pointer is no longer active.
  98612. */
  98613. static readonly POINTERUP: number;
  98614. /**
  98615. * The pointermove event is fired when a pointer changes coordinates.
  98616. */
  98617. static readonly POINTERMOVE: number;
  98618. /**
  98619. * The pointerwheel event is fired when a mouse wheel has been rotated.
  98620. */
  98621. static readonly POINTERWHEEL: number;
  98622. /**
  98623. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  98624. */
  98625. static readonly POINTERPICK: number;
  98626. /**
  98627. * The pointertap event is fired when a the object has been touched and released without drag.
  98628. */
  98629. static readonly POINTERTAP: number;
  98630. /**
  98631. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  98632. */
  98633. static readonly POINTERDOUBLETAP: number;
  98634. }
  98635. /**
  98636. * Base class of pointer info types.
  98637. */
  98638. export class PointerInfoBase {
  98639. /**
  98640. * Defines the type of event (PointerEventTypes)
  98641. */
  98642. type: number;
  98643. /**
  98644. * Defines the related dom event
  98645. */
  98646. event: PointerEvent | MouseWheelEvent;
  98647. /**
  98648. * Instantiates the base class of pointers info.
  98649. * @param type Defines the type of event (PointerEventTypes)
  98650. * @param event Defines the related dom event
  98651. */
  98652. constructor(
  98653. /**
  98654. * Defines the type of event (PointerEventTypes)
  98655. */
  98656. type: number,
  98657. /**
  98658. * Defines the related dom event
  98659. */
  98660. event: PointerEvent | MouseWheelEvent);
  98661. }
  98662. /**
  98663. * This class is used to store pointer related info for the onPrePointerObservable event.
  98664. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  98665. */
  98666. export class PointerInfoPre extends PointerInfoBase {
  98667. /**
  98668. * Ray from a pointer if availible (eg. 6dof controller)
  98669. */
  98670. ray: Nullable<Ray>;
  98671. /**
  98672. * Defines the local position of the pointer on the canvas.
  98673. */
  98674. localPosition: Vector2;
  98675. /**
  98676. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  98677. */
  98678. skipOnPointerObservable: boolean;
  98679. /**
  98680. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  98681. * @param type Defines the type of event (PointerEventTypes)
  98682. * @param event Defines the related dom event
  98683. * @param localX Defines the local x coordinates of the pointer when the event occured
  98684. * @param localY Defines the local y coordinates of the pointer when the event occured
  98685. */
  98686. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  98687. }
  98688. /**
  98689. * This type contains all the data related to a pointer event in Babylon.js.
  98690. * 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.
  98691. */
  98692. export class PointerInfo extends PointerInfoBase {
  98693. /**
  98694. * Defines the picking info associated to the info (if any)\
  98695. */
  98696. pickInfo: Nullable<PickingInfo>;
  98697. /**
  98698. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  98699. * @param type Defines the type of event (PointerEventTypes)
  98700. * @param event Defines the related dom event
  98701. * @param pickInfo Defines the picking info associated to the info (if any)\
  98702. */
  98703. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  98704. /**
  98705. * Defines the picking info associated to the info (if any)\
  98706. */
  98707. pickInfo: Nullable<PickingInfo>);
  98708. }
  98709. /**
  98710. * Data relating to a touch event on the screen.
  98711. */
  98712. export interface PointerTouch {
  98713. /**
  98714. * X coordinate of touch.
  98715. */
  98716. x: number;
  98717. /**
  98718. * Y coordinate of touch.
  98719. */
  98720. y: number;
  98721. /**
  98722. * Id of touch. Unique for each finger.
  98723. */
  98724. pointerId: number;
  98725. /**
  98726. * Event type passed from DOM.
  98727. */
  98728. type: any;
  98729. }
  98730. }
  98731. declare module BABYLON {
  98732. /**
  98733. * Manage the mouse inputs to control the movement of a free camera.
  98734. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98735. */
  98736. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  98737. /**
  98738. * Define if touch is enabled in the mouse input
  98739. */
  98740. touchEnabled: boolean;
  98741. /**
  98742. * Defines the camera the input is attached to.
  98743. */
  98744. camera: FreeCamera;
  98745. /**
  98746. * Defines the buttons associated with the input to handle camera move.
  98747. */
  98748. buttons: number[];
  98749. /**
  98750. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  98751. */
  98752. angularSensibility: number;
  98753. private _pointerInput;
  98754. private _onMouseMove;
  98755. private _observer;
  98756. private previousPosition;
  98757. /**
  98758. * Observable for when a pointer move event occurs containing the move offset
  98759. */
  98760. onPointerMovedObservable: Observable<{
  98761. offsetX: number;
  98762. offsetY: number;
  98763. }>;
  98764. /**
  98765. * @hidden
  98766. * If the camera should be rotated automatically based on pointer movement
  98767. */
  98768. _allowCameraRotation: boolean;
  98769. /**
  98770. * Manage the mouse inputs to control the movement of a free camera.
  98771. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98772. * @param touchEnabled Defines if touch is enabled or not
  98773. */
  98774. constructor(
  98775. /**
  98776. * Define if touch is enabled in the mouse input
  98777. */
  98778. touchEnabled?: boolean);
  98779. /**
  98780. * Attach the input controls to a specific dom element to get the input from.
  98781. * @param element Defines the element the controls should be listened from
  98782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98783. */
  98784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98785. /**
  98786. * Called on JS contextmenu event.
  98787. * Override this method to provide functionality.
  98788. */
  98789. protected onContextMenu(evt: PointerEvent): void;
  98790. /**
  98791. * Detach the current controls from the specified dom element.
  98792. * @param element Defines the element to stop listening the inputs from
  98793. */
  98794. detachControl(element: Nullable<HTMLElement>): void;
  98795. /**
  98796. * Gets the class name of the current intput.
  98797. * @returns the class name
  98798. */
  98799. getClassName(): string;
  98800. /**
  98801. * Get the friendly name associated with the input class.
  98802. * @returns the input friendly name
  98803. */
  98804. getSimpleName(): string;
  98805. }
  98806. }
  98807. declare module BABYLON {
  98808. /**
  98809. * Manage the touch inputs to control the movement of a free camera.
  98810. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98811. */
  98812. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  98813. /**
  98814. * Define if mouse events can be treated as touch events
  98815. */
  98816. allowMouse: boolean;
  98817. /**
  98818. * Defines the camera the input is attached to.
  98819. */
  98820. camera: FreeCamera;
  98821. /**
  98822. * Defines the touch sensibility for rotation.
  98823. * The higher the faster.
  98824. */
  98825. touchAngularSensibility: number;
  98826. /**
  98827. * Defines the touch sensibility for move.
  98828. * The higher the faster.
  98829. */
  98830. touchMoveSensibility: number;
  98831. private _offsetX;
  98832. private _offsetY;
  98833. private _pointerPressed;
  98834. private _pointerInput;
  98835. private _observer;
  98836. private _onLostFocus;
  98837. /**
  98838. * Manage the touch inputs to control the movement of a free camera.
  98839. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98840. * @param allowMouse Defines if mouse events can be treated as touch events
  98841. */
  98842. constructor(
  98843. /**
  98844. * Define if mouse events can be treated as touch events
  98845. */
  98846. allowMouse?: boolean);
  98847. /**
  98848. * Attach the input controls to a specific dom element to get the input from.
  98849. * @param element Defines the element the controls should be listened from
  98850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98851. */
  98852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98853. /**
  98854. * Detach the current controls from the specified dom element.
  98855. * @param element Defines the element to stop listening the inputs from
  98856. */
  98857. detachControl(element: Nullable<HTMLElement>): void;
  98858. /**
  98859. * Update the current camera state depending on the inputs that have been used this frame.
  98860. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98861. */
  98862. checkInputs(): void;
  98863. /**
  98864. * Gets the class name of the current intput.
  98865. * @returns the class name
  98866. */
  98867. getClassName(): string;
  98868. /**
  98869. * Get the friendly name associated with the input class.
  98870. * @returns the input friendly name
  98871. */
  98872. getSimpleName(): string;
  98873. }
  98874. }
  98875. declare module BABYLON {
  98876. /**
  98877. * Default Inputs manager for the FreeCamera.
  98878. * It groups all the default supported inputs for ease of use.
  98879. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98880. */
  98881. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  98882. /**
  98883. * @hidden
  98884. */
  98885. _mouseInput: Nullable<FreeCameraMouseInput>;
  98886. /**
  98887. * Instantiates a new FreeCameraInputsManager.
  98888. * @param camera Defines the camera the inputs belong to
  98889. */
  98890. constructor(camera: FreeCamera);
  98891. /**
  98892. * Add keyboard input support to the input manager.
  98893. * @returns the current input manager
  98894. */
  98895. addKeyboard(): FreeCameraInputsManager;
  98896. /**
  98897. * Add mouse input support to the input manager.
  98898. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  98899. * @returns the current input manager
  98900. */
  98901. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  98902. /**
  98903. * Removes the mouse input support from the manager
  98904. * @returns the current input manager
  98905. */
  98906. removeMouse(): FreeCameraInputsManager;
  98907. /**
  98908. * Add touch input support to the input manager.
  98909. * @returns the current input manager
  98910. */
  98911. addTouch(): FreeCameraInputsManager;
  98912. /**
  98913. * Remove all attached input methods from a camera
  98914. */
  98915. clear(): void;
  98916. }
  98917. }
  98918. declare module BABYLON {
  98919. /**
  98920. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98921. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  98922. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98923. */
  98924. export class FreeCamera extends TargetCamera {
  98925. /**
  98926. * Define the collision ellipsoid of the camera.
  98927. * This is helpful to simulate a camera body like the player body around the camera
  98928. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98929. */
  98930. ellipsoid: Vector3;
  98931. /**
  98932. * Define an offset for the position of the ellipsoid around the camera.
  98933. * This can be helpful to determine the center of the body near the gravity center of the body
  98934. * instead of its head.
  98935. */
  98936. ellipsoidOffset: Vector3;
  98937. /**
  98938. * Enable or disable collisions of the camera with the rest of the scene objects.
  98939. */
  98940. checkCollisions: boolean;
  98941. /**
  98942. * Enable or disable gravity on the camera.
  98943. */
  98944. applyGravity: boolean;
  98945. /**
  98946. * Define the input manager associated to the camera.
  98947. */
  98948. inputs: FreeCameraInputsManager;
  98949. /**
  98950. * Gets the input sensibility for a mouse input. (default is 2000.0)
  98951. * Higher values reduce sensitivity.
  98952. */
  98953. get angularSensibility(): number;
  98954. /**
  98955. * Sets the input sensibility for a mouse input. (default is 2000.0)
  98956. * Higher values reduce sensitivity.
  98957. */
  98958. set angularSensibility(value: number);
  98959. /**
  98960. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98961. */
  98962. get keysUp(): number[];
  98963. set keysUp(value: number[]);
  98964. /**
  98965. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98966. */
  98967. get keysUpward(): number[];
  98968. set keysUpward(value: number[]);
  98969. /**
  98970. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98971. */
  98972. get keysDown(): number[];
  98973. set keysDown(value: number[]);
  98974. /**
  98975. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98976. */
  98977. get keysDownward(): number[];
  98978. set keysDownward(value: number[]);
  98979. /**
  98980. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98981. */
  98982. get keysLeft(): number[];
  98983. set keysLeft(value: number[]);
  98984. /**
  98985. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98986. */
  98987. get keysRight(): number[];
  98988. set keysRight(value: number[]);
  98989. /**
  98990. * Event raised when the camera collide with a mesh in the scene.
  98991. */
  98992. onCollide: (collidedMesh: AbstractMesh) => void;
  98993. private _collider;
  98994. private _needMoveForGravity;
  98995. private _oldPosition;
  98996. private _diffPosition;
  98997. private _newPosition;
  98998. /** @hidden */
  98999. _localDirection: Vector3;
  99000. /** @hidden */
  99001. _transformedDirection: Vector3;
  99002. /**
  99003. * Instantiates a Free Camera.
  99004. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99005. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99006. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99007. * @param name Define the name of the camera in the scene
  99008. * @param position Define the start position of the camera in the scene
  99009. * @param scene Define the scene the camera belongs to
  99010. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99011. */
  99012. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99013. /**
  99014. * Attached controls to the current camera.
  99015. * @param element Defines the element the controls should be listened from
  99016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99017. */
  99018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99019. /**
  99020. * Detach the current controls from the camera.
  99021. * The camera will stop reacting to inputs.
  99022. * @param element Defines the element to stop listening the inputs from
  99023. */
  99024. detachControl(element: HTMLElement): void;
  99025. private _collisionMask;
  99026. /**
  99027. * Define a collision mask to limit the list of object the camera can collide with
  99028. */
  99029. get collisionMask(): number;
  99030. set collisionMask(mask: number);
  99031. /** @hidden */
  99032. _collideWithWorld(displacement: Vector3): void;
  99033. private _onCollisionPositionChange;
  99034. /** @hidden */
  99035. _checkInputs(): void;
  99036. /** @hidden */
  99037. _decideIfNeedsToMove(): boolean;
  99038. /** @hidden */
  99039. _updatePosition(): void;
  99040. /**
  99041. * Destroy the camera and release the current resources hold by it.
  99042. */
  99043. dispose(): void;
  99044. /**
  99045. * Gets the current object class name.
  99046. * @return the class name
  99047. */
  99048. getClassName(): string;
  99049. }
  99050. }
  99051. declare module BABYLON {
  99052. /**
  99053. * Represents a gamepad control stick position
  99054. */
  99055. export class StickValues {
  99056. /**
  99057. * The x component of the control stick
  99058. */
  99059. x: number;
  99060. /**
  99061. * The y component of the control stick
  99062. */
  99063. y: number;
  99064. /**
  99065. * Initializes the gamepad x and y control stick values
  99066. * @param x The x component of the gamepad control stick value
  99067. * @param y The y component of the gamepad control stick value
  99068. */
  99069. constructor(
  99070. /**
  99071. * The x component of the control stick
  99072. */
  99073. x: number,
  99074. /**
  99075. * The y component of the control stick
  99076. */
  99077. y: number);
  99078. }
  99079. /**
  99080. * An interface which manages callbacks for gamepad button changes
  99081. */
  99082. export interface GamepadButtonChanges {
  99083. /**
  99084. * Called when a gamepad has been changed
  99085. */
  99086. changed: boolean;
  99087. /**
  99088. * Called when a gamepad press event has been triggered
  99089. */
  99090. pressChanged: boolean;
  99091. /**
  99092. * Called when a touch event has been triggered
  99093. */
  99094. touchChanged: boolean;
  99095. /**
  99096. * Called when a value has changed
  99097. */
  99098. valueChanged: boolean;
  99099. }
  99100. /**
  99101. * Represents a gamepad
  99102. */
  99103. export class Gamepad {
  99104. /**
  99105. * The id of the gamepad
  99106. */
  99107. id: string;
  99108. /**
  99109. * The index of the gamepad
  99110. */
  99111. index: number;
  99112. /**
  99113. * The browser gamepad
  99114. */
  99115. browserGamepad: any;
  99116. /**
  99117. * Specifies what type of gamepad this represents
  99118. */
  99119. type: number;
  99120. private _leftStick;
  99121. private _rightStick;
  99122. /** @hidden */
  99123. _isConnected: boolean;
  99124. private _leftStickAxisX;
  99125. private _leftStickAxisY;
  99126. private _rightStickAxisX;
  99127. private _rightStickAxisY;
  99128. /**
  99129. * Triggered when the left control stick has been changed
  99130. */
  99131. private _onleftstickchanged;
  99132. /**
  99133. * Triggered when the right control stick has been changed
  99134. */
  99135. private _onrightstickchanged;
  99136. /**
  99137. * Represents a gamepad controller
  99138. */
  99139. static GAMEPAD: number;
  99140. /**
  99141. * Represents a generic controller
  99142. */
  99143. static GENERIC: number;
  99144. /**
  99145. * Represents an XBox controller
  99146. */
  99147. static XBOX: number;
  99148. /**
  99149. * Represents a pose-enabled controller
  99150. */
  99151. static POSE_ENABLED: number;
  99152. /**
  99153. * Represents an Dual Shock controller
  99154. */
  99155. static DUALSHOCK: number;
  99156. /**
  99157. * Specifies whether the left control stick should be Y-inverted
  99158. */
  99159. protected _invertLeftStickY: boolean;
  99160. /**
  99161. * Specifies if the gamepad has been connected
  99162. */
  99163. get isConnected(): boolean;
  99164. /**
  99165. * Initializes the gamepad
  99166. * @param id The id of the gamepad
  99167. * @param index The index of the gamepad
  99168. * @param browserGamepad The browser gamepad
  99169. * @param leftStickX The x component of the left joystick
  99170. * @param leftStickY The y component of the left joystick
  99171. * @param rightStickX The x component of the right joystick
  99172. * @param rightStickY The y component of the right joystick
  99173. */
  99174. constructor(
  99175. /**
  99176. * The id of the gamepad
  99177. */
  99178. id: string,
  99179. /**
  99180. * The index of the gamepad
  99181. */
  99182. index: number,
  99183. /**
  99184. * The browser gamepad
  99185. */
  99186. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99187. /**
  99188. * Callback triggered when the left joystick has changed
  99189. * @param callback
  99190. */
  99191. onleftstickchanged(callback: (values: StickValues) => void): void;
  99192. /**
  99193. * Callback triggered when the right joystick has changed
  99194. * @param callback
  99195. */
  99196. onrightstickchanged(callback: (values: StickValues) => void): void;
  99197. /**
  99198. * Gets the left joystick
  99199. */
  99200. get leftStick(): StickValues;
  99201. /**
  99202. * Sets the left joystick values
  99203. */
  99204. set leftStick(newValues: StickValues);
  99205. /**
  99206. * Gets the right joystick
  99207. */
  99208. get rightStick(): StickValues;
  99209. /**
  99210. * Sets the right joystick value
  99211. */
  99212. set rightStick(newValues: StickValues);
  99213. /**
  99214. * Updates the gamepad joystick positions
  99215. */
  99216. update(): void;
  99217. /**
  99218. * Disposes the gamepad
  99219. */
  99220. dispose(): void;
  99221. }
  99222. /**
  99223. * Represents a generic gamepad
  99224. */
  99225. export class GenericPad extends Gamepad {
  99226. private _buttons;
  99227. private _onbuttondown;
  99228. private _onbuttonup;
  99229. /**
  99230. * Observable triggered when a button has been pressed
  99231. */
  99232. onButtonDownObservable: Observable<number>;
  99233. /**
  99234. * Observable triggered when a button has been released
  99235. */
  99236. onButtonUpObservable: Observable<number>;
  99237. /**
  99238. * Callback triggered when a button has been pressed
  99239. * @param callback Called when a button has been pressed
  99240. */
  99241. onbuttondown(callback: (buttonPressed: number) => void): void;
  99242. /**
  99243. * Callback triggered when a button has been released
  99244. * @param callback Called when a button has been released
  99245. */
  99246. onbuttonup(callback: (buttonReleased: number) => void): void;
  99247. /**
  99248. * Initializes the generic gamepad
  99249. * @param id The id of the generic gamepad
  99250. * @param index The index of the generic gamepad
  99251. * @param browserGamepad The browser gamepad
  99252. */
  99253. constructor(id: string, index: number, browserGamepad: any);
  99254. private _setButtonValue;
  99255. /**
  99256. * Updates the generic gamepad
  99257. */
  99258. update(): void;
  99259. /**
  99260. * Disposes the generic gamepad
  99261. */
  99262. dispose(): void;
  99263. }
  99264. }
  99265. declare module BABYLON {
  99266. /**
  99267. * Defines the types of pose enabled controllers that are supported
  99268. */
  99269. export enum PoseEnabledControllerType {
  99270. /**
  99271. * HTC Vive
  99272. */
  99273. VIVE = 0,
  99274. /**
  99275. * Oculus Rift
  99276. */
  99277. OCULUS = 1,
  99278. /**
  99279. * Windows mixed reality
  99280. */
  99281. WINDOWS = 2,
  99282. /**
  99283. * Samsung gear VR
  99284. */
  99285. GEAR_VR = 3,
  99286. /**
  99287. * Google Daydream
  99288. */
  99289. DAYDREAM = 4,
  99290. /**
  99291. * Generic
  99292. */
  99293. GENERIC = 5
  99294. }
  99295. /**
  99296. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99297. */
  99298. export interface MutableGamepadButton {
  99299. /**
  99300. * Value of the button/trigger
  99301. */
  99302. value: number;
  99303. /**
  99304. * If the button/trigger is currently touched
  99305. */
  99306. touched: boolean;
  99307. /**
  99308. * If the button/trigger is currently pressed
  99309. */
  99310. pressed: boolean;
  99311. }
  99312. /**
  99313. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99314. * @hidden
  99315. */
  99316. export interface ExtendedGamepadButton extends GamepadButton {
  99317. /**
  99318. * If the button/trigger is currently pressed
  99319. */
  99320. readonly pressed: boolean;
  99321. /**
  99322. * If the button/trigger is currently touched
  99323. */
  99324. readonly touched: boolean;
  99325. /**
  99326. * Value of the button/trigger
  99327. */
  99328. readonly value: number;
  99329. }
  99330. /** @hidden */
  99331. export interface _GamePadFactory {
  99332. /**
  99333. * Returns whether or not the current gamepad can be created for this type of controller.
  99334. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99335. * @returns true if it can be created, otherwise false
  99336. */
  99337. canCreate(gamepadInfo: any): boolean;
  99338. /**
  99339. * Creates a new instance of the Gamepad.
  99340. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99341. * @returns the new gamepad instance
  99342. */
  99343. create(gamepadInfo: any): Gamepad;
  99344. }
  99345. /**
  99346. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99347. */
  99348. export class PoseEnabledControllerHelper {
  99349. /** @hidden */
  99350. static _ControllerFactories: _GamePadFactory[];
  99351. /** @hidden */
  99352. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99353. /**
  99354. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99355. * @param vrGamepad the gamepad to initialized
  99356. * @returns a vr controller of the type the gamepad identified as
  99357. */
  99358. static InitiateController(vrGamepad: any): Gamepad;
  99359. }
  99360. /**
  99361. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99362. */
  99363. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99364. /**
  99365. * If the controller is used in a webXR session
  99366. */
  99367. isXR: boolean;
  99368. private _deviceRoomPosition;
  99369. private _deviceRoomRotationQuaternion;
  99370. /**
  99371. * The device position in babylon space
  99372. */
  99373. devicePosition: Vector3;
  99374. /**
  99375. * The device rotation in babylon space
  99376. */
  99377. deviceRotationQuaternion: Quaternion;
  99378. /**
  99379. * The scale factor of the device in babylon space
  99380. */
  99381. deviceScaleFactor: number;
  99382. /**
  99383. * (Likely devicePosition should be used instead) The device position in its room space
  99384. */
  99385. position: Vector3;
  99386. /**
  99387. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99388. */
  99389. rotationQuaternion: Quaternion;
  99390. /**
  99391. * The type of controller (Eg. Windows mixed reality)
  99392. */
  99393. controllerType: PoseEnabledControllerType;
  99394. protected _calculatedPosition: Vector3;
  99395. private _calculatedRotation;
  99396. /**
  99397. * The raw pose from the device
  99398. */
  99399. rawPose: DevicePose;
  99400. private _trackPosition;
  99401. private _maxRotationDistFromHeadset;
  99402. private _draggedRoomRotation;
  99403. /**
  99404. * @hidden
  99405. */
  99406. _disableTrackPosition(fixedPosition: Vector3): void;
  99407. /**
  99408. * Internal, the mesh attached to the controller
  99409. * @hidden
  99410. */
  99411. _mesh: Nullable<AbstractMesh>;
  99412. private _poseControlledCamera;
  99413. private _leftHandSystemQuaternion;
  99414. /**
  99415. * Internal, matrix used to convert room space to babylon space
  99416. * @hidden
  99417. */
  99418. _deviceToWorld: Matrix;
  99419. /**
  99420. * Node to be used when casting a ray from the controller
  99421. * @hidden
  99422. */
  99423. _pointingPoseNode: Nullable<TransformNode>;
  99424. /**
  99425. * Name of the child mesh that can be used to cast a ray from the controller
  99426. */
  99427. static readonly POINTING_POSE: string;
  99428. /**
  99429. * Creates a new PoseEnabledController from a gamepad
  99430. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99431. */
  99432. constructor(browserGamepad: any);
  99433. private _workingMatrix;
  99434. /**
  99435. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99436. */
  99437. update(): void;
  99438. /**
  99439. * Updates only the pose device and mesh without doing any button event checking
  99440. */
  99441. protected _updatePoseAndMesh(): void;
  99442. /**
  99443. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99444. * @param poseData raw pose fromthe device
  99445. */
  99446. updateFromDevice(poseData: DevicePose): void;
  99447. /**
  99448. * @hidden
  99449. */
  99450. _meshAttachedObservable: Observable<AbstractMesh>;
  99451. /**
  99452. * Attaches a mesh to the controller
  99453. * @param mesh the mesh to be attached
  99454. */
  99455. attachToMesh(mesh: AbstractMesh): void;
  99456. /**
  99457. * Attaches the controllers mesh to a camera
  99458. * @param camera the camera the mesh should be attached to
  99459. */
  99460. attachToPoseControlledCamera(camera: TargetCamera): void;
  99461. /**
  99462. * Disposes of the controller
  99463. */
  99464. dispose(): void;
  99465. /**
  99466. * The mesh that is attached to the controller
  99467. */
  99468. get mesh(): Nullable<AbstractMesh>;
  99469. /**
  99470. * Gets the ray of the controller in the direction the controller is pointing
  99471. * @param length the length the resulting ray should be
  99472. * @returns a ray in the direction the controller is pointing
  99473. */
  99474. getForwardRay(length?: number): Ray;
  99475. }
  99476. }
  99477. declare module BABYLON {
  99478. /**
  99479. * Defines the WebVRController object that represents controllers tracked in 3D space
  99480. */
  99481. export abstract class WebVRController extends PoseEnabledController {
  99482. /**
  99483. * Internal, the default controller model for the controller
  99484. */
  99485. protected _defaultModel: Nullable<AbstractMesh>;
  99486. /**
  99487. * Fired when the trigger state has changed
  99488. */
  99489. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99490. /**
  99491. * Fired when the main button state has changed
  99492. */
  99493. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99494. /**
  99495. * Fired when the secondary button state has changed
  99496. */
  99497. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99498. /**
  99499. * Fired when the pad state has changed
  99500. */
  99501. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99502. /**
  99503. * Fired when controllers stick values have changed
  99504. */
  99505. onPadValuesChangedObservable: Observable<StickValues>;
  99506. /**
  99507. * Array of button availible on the controller
  99508. */
  99509. protected _buttons: Array<MutableGamepadButton>;
  99510. private _onButtonStateChange;
  99511. /**
  99512. * Fired when a controller button's state has changed
  99513. * @param callback the callback containing the button that was modified
  99514. */
  99515. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99516. /**
  99517. * X and Y axis corresponding to the controllers joystick
  99518. */
  99519. pad: StickValues;
  99520. /**
  99521. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99522. */
  99523. hand: string;
  99524. /**
  99525. * The default controller model for the controller
  99526. */
  99527. get defaultModel(): Nullable<AbstractMesh>;
  99528. /**
  99529. * Creates a new WebVRController from a gamepad
  99530. * @param vrGamepad the gamepad that the WebVRController should be created from
  99531. */
  99532. constructor(vrGamepad: any);
  99533. /**
  99534. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99535. */
  99536. update(): void;
  99537. /**
  99538. * Function to be called when a button is modified
  99539. */
  99540. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99541. /**
  99542. * Loads a mesh and attaches it to the controller
  99543. * @param scene the scene the mesh should be added to
  99544. * @param meshLoaded callback for when the mesh has been loaded
  99545. */
  99546. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99547. private _setButtonValue;
  99548. private _changes;
  99549. private _checkChanges;
  99550. /**
  99551. * Disposes of th webVRCOntroller
  99552. */
  99553. dispose(): void;
  99554. }
  99555. }
  99556. declare module BABYLON {
  99557. /**
  99558. * The HemisphericLight simulates the ambient environment light,
  99559. * so the passed direction is the light reflection direction, not the incoming direction.
  99560. */
  99561. export class HemisphericLight extends Light {
  99562. /**
  99563. * The groundColor is the light in the opposite direction to the one specified during creation.
  99564. * 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.
  99565. */
  99566. groundColor: Color3;
  99567. /**
  99568. * The light reflection direction, not the incoming direction.
  99569. */
  99570. direction: Vector3;
  99571. /**
  99572. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99573. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99574. * The HemisphericLight can't cast shadows.
  99575. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99576. * @param name The friendly name of the light
  99577. * @param direction The direction of the light reflection
  99578. * @param scene The scene the light belongs to
  99579. */
  99580. constructor(name: string, direction: Vector3, scene: Scene);
  99581. protected _buildUniformLayout(): void;
  99582. /**
  99583. * Returns the string "HemisphericLight".
  99584. * @return The class name
  99585. */
  99586. getClassName(): string;
  99587. /**
  99588. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99589. * Returns the updated direction.
  99590. * @param target The target the direction should point to
  99591. * @return The computed direction
  99592. */
  99593. setDirectionToTarget(target: Vector3): Vector3;
  99594. /**
  99595. * Returns the shadow generator associated to the light.
  99596. * @returns Always null for hemispheric lights because it does not support shadows.
  99597. */
  99598. getShadowGenerator(): Nullable<IShadowGenerator>;
  99599. /**
  99600. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  99601. * @param effect The effect to update
  99602. * @param lightIndex The index of the light in the effect to update
  99603. * @returns The hemispheric light
  99604. */
  99605. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  99606. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  99607. /**
  99608. * Computes the world matrix of the node
  99609. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99610. * @param useWasUpdatedFlag defines a reserved property
  99611. * @returns the world matrix
  99612. */
  99613. computeWorldMatrix(): Matrix;
  99614. /**
  99615. * Returns the integer 3.
  99616. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99617. */
  99618. getTypeID(): number;
  99619. /**
  99620. * Prepares the list of defines specific to the light type.
  99621. * @param defines the list of defines
  99622. * @param lightIndex defines the index of the light for the effect
  99623. */
  99624. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99625. }
  99626. }
  99627. declare module BABYLON {
  99628. /** @hidden */
  99629. export var vrMultiviewToSingleviewPixelShader: {
  99630. name: string;
  99631. shader: string;
  99632. };
  99633. }
  99634. declare module BABYLON {
  99635. /**
  99636. * Renders to multiple views with a single draw call
  99637. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  99638. */
  99639. export class MultiviewRenderTarget extends RenderTargetTexture {
  99640. /**
  99641. * Creates a multiview render target
  99642. * @param scene scene used with the render target
  99643. * @param size the size of the render target (used for each view)
  99644. */
  99645. constructor(scene: Scene, size?: number | {
  99646. width: number;
  99647. height: number;
  99648. } | {
  99649. ratio: number;
  99650. });
  99651. /**
  99652. * @hidden
  99653. * @param faceIndex the face index, if its a cube texture
  99654. */
  99655. _bindFrameBuffer(faceIndex?: number): void;
  99656. /**
  99657. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  99658. * @returns the view count
  99659. */
  99660. getViewCount(): number;
  99661. }
  99662. }
  99663. declare module BABYLON {
  99664. interface Engine {
  99665. /**
  99666. * Creates a new multiview render target
  99667. * @param width defines the width of the texture
  99668. * @param height defines the height of the texture
  99669. * @returns the created multiview texture
  99670. */
  99671. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  99672. /**
  99673. * Binds a multiview framebuffer to be drawn to
  99674. * @param multiviewTexture texture to bind
  99675. */
  99676. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  99677. }
  99678. interface Camera {
  99679. /**
  99680. * @hidden
  99681. * 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)
  99682. */
  99683. _useMultiviewToSingleView: boolean;
  99684. /**
  99685. * @hidden
  99686. * 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)
  99687. */
  99688. _multiviewTexture: Nullable<RenderTargetTexture>;
  99689. /**
  99690. * @hidden
  99691. * ensures the multiview texture of the camera exists and has the specified width/height
  99692. * @param width height to set on the multiview texture
  99693. * @param height width to set on the multiview texture
  99694. */
  99695. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  99696. }
  99697. interface Scene {
  99698. /** @hidden */
  99699. _transformMatrixR: Matrix;
  99700. /** @hidden */
  99701. _multiviewSceneUbo: Nullable<UniformBuffer>;
  99702. /** @hidden */
  99703. _createMultiviewUbo(): void;
  99704. /** @hidden */
  99705. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  99706. /** @hidden */
  99707. _renderMultiviewToSingleView(camera: Camera): void;
  99708. }
  99709. }
  99710. declare module BABYLON {
  99711. /**
  99712. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  99713. * This will not be used for webXR as it supports displaying texture arrays directly
  99714. */
  99715. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  99716. /**
  99717. * Gets a string identifying the name of the class
  99718. * @returns "VRMultiviewToSingleviewPostProcess" string
  99719. */
  99720. getClassName(): string;
  99721. /**
  99722. * Initializes a VRMultiviewToSingleview
  99723. * @param name name of the post process
  99724. * @param camera camera to be applied to
  99725. * @param scaleFactor scaling factor to the size of the output texture
  99726. */
  99727. constructor(name: string, camera: Camera, scaleFactor: number);
  99728. }
  99729. }
  99730. declare module BABYLON {
  99731. /**
  99732. * Interface used to define additional presentation attributes
  99733. */
  99734. export interface IVRPresentationAttributes {
  99735. /**
  99736. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  99737. */
  99738. highRefreshRate: boolean;
  99739. /**
  99740. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  99741. */
  99742. foveationLevel: number;
  99743. }
  99744. interface Engine {
  99745. /** @hidden */
  99746. _vrDisplay: any;
  99747. /** @hidden */
  99748. _vrSupported: boolean;
  99749. /** @hidden */
  99750. _oldSize: Size;
  99751. /** @hidden */
  99752. _oldHardwareScaleFactor: number;
  99753. /** @hidden */
  99754. _vrExclusivePointerMode: boolean;
  99755. /** @hidden */
  99756. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  99757. /** @hidden */
  99758. _onVRDisplayPointerRestricted: () => void;
  99759. /** @hidden */
  99760. _onVRDisplayPointerUnrestricted: () => void;
  99761. /** @hidden */
  99762. _onVrDisplayConnect: Nullable<(display: any) => void>;
  99763. /** @hidden */
  99764. _onVrDisplayDisconnect: Nullable<() => void>;
  99765. /** @hidden */
  99766. _onVrDisplayPresentChange: Nullable<() => void>;
  99767. /**
  99768. * Observable signaled when VR display mode changes
  99769. */
  99770. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  99771. /**
  99772. * Observable signaled when VR request present is complete
  99773. */
  99774. onVRRequestPresentComplete: Observable<boolean>;
  99775. /**
  99776. * Observable signaled when VR request present starts
  99777. */
  99778. onVRRequestPresentStart: Observable<Engine>;
  99779. /**
  99780. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  99781. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  99782. */
  99783. isInVRExclusivePointerMode: boolean;
  99784. /**
  99785. * Gets a boolean indicating if a webVR device was detected
  99786. * @returns true if a webVR device was detected
  99787. */
  99788. isVRDevicePresent(): boolean;
  99789. /**
  99790. * Gets the current webVR device
  99791. * @returns the current webVR device (or null)
  99792. */
  99793. getVRDevice(): any;
  99794. /**
  99795. * Initializes a webVR display and starts listening to display change events
  99796. * The onVRDisplayChangedObservable will be notified upon these changes
  99797. * @returns A promise containing a VRDisplay and if vr is supported
  99798. */
  99799. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  99800. /** @hidden */
  99801. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  99802. /**
  99803. * Gets or sets the presentation attributes used to configure VR rendering
  99804. */
  99805. vrPresentationAttributes?: IVRPresentationAttributes;
  99806. /**
  99807. * Call this function to switch to webVR mode
  99808. * Will do nothing if webVR is not supported or if there is no webVR device
  99809. * @param options the webvr options provided to the camera. mainly used for multiview
  99810. * @see https://doc.babylonjs.com/how_to/webvr_camera
  99811. */
  99812. enableVR(options: WebVROptions): void;
  99813. /** @hidden */
  99814. _onVRFullScreenTriggered(): void;
  99815. }
  99816. }
  99817. declare module BABYLON {
  99818. /**
  99819. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  99820. * IMPORTANT!! The data is right-hand data.
  99821. * @export
  99822. * @interface DevicePose
  99823. */
  99824. export interface DevicePose {
  99825. /**
  99826. * The position of the device, values in array are [x,y,z].
  99827. */
  99828. readonly position: Nullable<Float32Array>;
  99829. /**
  99830. * The linearVelocity of the device, values in array are [x,y,z].
  99831. */
  99832. readonly linearVelocity: Nullable<Float32Array>;
  99833. /**
  99834. * The linearAcceleration of the device, values in array are [x,y,z].
  99835. */
  99836. readonly linearAcceleration: Nullable<Float32Array>;
  99837. /**
  99838. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  99839. */
  99840. readonly orientation: Nullable<Float32Array>;
  99841. /**
  99842. * The angularVelocity of the device, values in array are [x,y,z].
  99843. */
  99844. readonly angularVelocity: Nullable<Float32Array>;
  99845. /**
  99846. * The angularAcceleration of the device, values in array are [x,y,z].
  99847. */
  99848. readonly angularAcceleration: Nullable<Float32Array>;
  99849. }
  99850. /**
  99851. * Interface representing a pose controlled object in Babylon.
  99852. * A pose controlled object has both regular pose values as well as pose values
  99853. * from an external device such as a VR head mounted display
  99854. */
  99855. export interface PoseControlled {
  99856. /**
  99857. * The position of the object in babylon space.
  99858. */
  99859. position: Vector3;
  99860. /**
  99861. * The rotation quaternion of the object in babylon space.
  99862. */
  99863. rotationQuaternion: Quaternion;
  99864. /**
  99865. * The position of the device in babylon space.
  99866. */
  99867. devicePosition?: Vector3;
  99868. /**
  99869. * The rotation quaternion of the device in babylon space.
  99870. */
  99871. deviceRotationQuaternion: Quaternion;
  99872. /**
  99873. * The raw pose coming from the device.
  99874. */
  99875. rawPose: Nullable<DevicePose>;
  99876. /**
  99877. * The scale of the device to be used when translating from device space to babylon space.
  99878. */
  99879. deviceScaleFactor: number;
  99880. /**
  99881. * Updates the poseControlled values based on the input device pose.
  99882. * @param poseData the pose data to update the object with
  99883. */
  99884. updateFromDevice(poseData: DevicePose): void;
  99885. }
  99886. /**
  99887. * Set of options to customize the webVRCamera
  99888. */
  99889. export interface WebVROptions {
  99890. /**
  99891. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  99892. */
  99893. trackPosition?: boolean;
  99894. /**
  99895. * Sets the scale of the vrDevice in babylon space. (default: 1)
  99896. */
  99897. positionScale?: number;
  99898. /**
  99899. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  99900. */
  99901. displayName?: string;
  99902. /**
  99903. * Should the native controller meshes be initialized. (default: true)
  99904. */
  99905. controllerMeshes?: boolean;
  99906. /**
  99907. * Creating a default HemiLight only on controllers. (default: true)
  99908. */
  99909. defaultLightingOnControllers?: boolean;
  99910. /**
  99911. * If you don't want to use the default VR button of the helper. (default: false)
  99912. */
  99913. useCustomVRButton?: boolean;
  99914. /**
  99915. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  99916. */
  99917. customVRButton?: HTMLButtonElement;
  99918. /**
  99919. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  99920. */
  99921. rayLength?: number;
  99922. /**
  99923. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  99924. */
  99925. defaultHeight?: number;
  99926. /**
  99927. * If multiview should be used if availible (default: false)
  99928. */
  99929. useMultiview?: boolean;
  99930. }
  99931. /**
  99932. * This represents a WebVR camera.
  99933. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  99934. * @example https://doc.babylonjs.com/how_to/webvr_camera
  99935. */
  99936. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  99937. private webVROptions;
  99938. /**
  99939. * @hidden
  99940. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  99941. */
  99942. _vrDevice: any;
  99943. /**
  99944. * The rawPose of the vrDevice.
  99945. */
  99946. rawPose: Nullable<DevicePose>;
  99947. private _onVREnabled;
  99948. private _specsVersion;
  99949. private _attached;
  99950. private _frameData;
  99951. protected _descendants: Array<Node>;
  99952. private _deviceRoomPosition;
  99953. /** @hidden */
  99954. _deviceRoomRotationQuaternion: Quaternion;
  99955. private _standingMatrix;
  99956. /**
  99957. * Represents device position in babylon space.
  99958. */
  99959. devicePosition: Vector3;
  99960. /**
  99961. * Represents device rotation in babylon space.
  99962. */
  99963. deviceRotationQuaternion: Quaternion;
  99964. /**
  99965. * The scale of the device to be used when translating from device space to babylon space.
  99966. */
  99967. deviceScaleFactor: number;
  99968. private _deviceToWorld;
  99969. private _worldToDevice;
  99970. /**
  99971. * References to the webVR controllers for the vrDevice.
  99972. */
  99973. controllers: Array<WebVRController>;
  99974. /**
  99975. * Emits an event when a controller is attached.
  99976. */
  99977. onControllersAttachedObservable: Observable<WebVRController[]>;
  99978. /**
  99979. * Emits an event when a controller's mesh has been loaded;
  99980. */
  99981. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99982. /**
  99983. * Emits an event when the HMD's pose has been updated.
  99984. */
  99985. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99986. private _poseSet;
  99987. /**
  99988. * If the rig cameras be used as parent instead of this camera.
  99989. */
  99990. rigParenting: boolean;
  99991. private _lightOnControllers;
  99992. private _defaultHeight?;
  99993. /**
  99994. * Instantiates a WebVRFreeCamera.
  99995. * @param name The name of the WebVRFreeCamera
  99996. * @param position The starting anchor position for the camera
  99997. * @param scene The scene the camera belongs to
  99998. * @param webVROptions a set of customizable options for the webVRCamera
  99999. */
  100000. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100001. /**
  100002. * Gets the device distance from the ground in meters.
  100003. * @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.
  100004. */
  100005. deviceDistanceToRoomGround(): number;
  100006. /**
  100007. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100008. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100009. */
  100010. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100011. /**
  100012. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100013. * @returns A promise with a boolean set to if the standing matrix is supported.
  100014. */
  100015. useStandingMatrixAsync(): Promise<boolean>;
  100016. /**
  100017. * Disposes the camera
  100018. */
  100019. dispose(): void;
  100020. /**
  100021. * Gets a vrController by name.
  100022. * @param name The name of the controller to retreive
  100023. * @returns the controller matching the name specified or null if not found
  100024. */
  100025. getControllerByName(name: string): Nullable<WebVRController>;
  100026. private _leftController;
  100027. /**
  100028. * The controller corresponding to the users left hand.
  100029. */
  100030. get leftController(): Nullable<WebVRController>;
  100031. private _rightController;
  100032. /**
  100033. * The controller corresponding to the users right hand.
  100034. */
  100035. get rightController(): Nullable<WebVRController>;
  100036. /**
  100037. * Casts a ray forward from the vrCamera's gaze.
  100038. * @param length Length of the ray (default: 100)
  100039. * @returns the ray corresponding to the gaze
  100040. */
  100041. getForwardRay(length?: number): Ray;
  100042. /**
  100043. * @hidden
  100044. * Updates the camera based on device's frame data
  100045. */
  100046. _checkInputs(): void;
  100047. /**
  100048. * Updates the poseControlled values based on the input device pose.
  100049. * @param poseData Pose coming from the device
  100050. */
  100051. updateFromDevice(poseData: DevicePose): void;
  100052. private _htmlElementAttached;
  100053. private _detachIfAttached;
  100054. /**
  100055. * WebVR's attach control will start broadcasting frames to the device.
  100056. * Note that in certain browsers (chrome for example) this function must be called
  100057. * within a user-interaction callback. Example:
  100058. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100059. *
  100060. * @param element html element to attach the vrDevice to
  100061. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100062. */
  100063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100064. /**
  100065. * Detaches the camera from the html element and disables VR
  100066. *
  100067. * @param element html element to detach from
  100068. */
  100069. detachControl(element: HTMLElement): void;
  100070. /**
  100071. * @returns the name of this class
  100072. */
  100073. getClassName(): string;
  100074. /**
  100075. * Calls resetPose on the vrDisplay
  100076. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100077. */
  100078. resetToCurrentRotation(): void;
  100079. /**
  100080. * @hidden
  100081. * Updates the rig cameras (left and right eye)
  100082. */
  100083. _updateRigCameras(): void;
  100084. private _workingVector;
  100085. private _oneVector;
  100086. private _workingMatrix;
  100087. private updateCacheCalled;
  100088. private _correctPositionIfNotTrackPosition;
  100089. /**
  100090. * @hidden
  100091. * Updates the cached values of the camera
  100092. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100093. */
  100094. _updateCache(ignoreParentClass?: boolean): void;
  100095. /**
  100096. * @hidden
  100097. * Get current device position in babylon world
  100098. */
  100099. _computeDevicePosition(): void;
  100100. /**
  100101. * Updates the current device position and rotation in the babylon world
  100102. */
  100103. update(): void;
  100104. /**
  100105. * @hidden
  100106. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100107. * @returns an identity matrix
  100108. */
  100109. _getViewMatrix(): Matrix;
  100110. private _tmpMatrix;
  100111. /**
  100112. * This function is called by the two RIG cameras.
  100113. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100114. * @hidden
  100115. */
  100116. _getWebVRViewMatrix(): Matrix;
  100117. /** @hidden */
  100118. _getWebVRProjectionMatrix(): Matrix;
  100119. private _onGamepadConnectedObserver;
  100120. private _onGamepadDisconnectedObserver;
  100121. private _updateCacheWhenTrackingDisabledObserver;
  100122. /**
  100123. * Initializes the controllers and their meshes
  100124. */
  100125. initControllers(): void;
  100126. }
  100127. }
  100128. declare module BABYLON {
  100129. /**
  100130. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100131. *
  100132. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100133. *
  100134. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100135. */
  100136. export class MaterialHelper {
  100137. /**
  100138. * Bind the current view position to an effect.
  100139. * @param effect The effect to be bound
  100140. * @param scene The scene the eyes position is used from
  100141. * @param variableName name of the shader variable that will hold the eye position
  100142. */
  100143. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100144. /**
  100145. * Helps preparing the defines values about the UVs in used in the effect.
  100146. * UVs are shared as much as we can accross channels in the shaders.
  100147. * @param texture The texture we are preparing the UVs for
  100148. * @param defines The defines to update
  100149. * @param key The channel key "diffuse", "specular"... used in the shader
  100150. */
  100151. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100152. /**
  100153. * Binds a texture matrix value to its corrsponding uniform
  100154. * @param texture The texture to bind the matrix for
  100155. * @param uniformBuffer The uniform buffer receivin the data
  100156. * @param key The channel key "diffuse", "specular"... used in the shader
  100157. */
  100158. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100159. /**
  100160. * Gets the current status of the fog (should it be enabled?)
  100161. * @param mesh defines the mesh to evaluate for fog support
  100162. * @param scene defines the hosting scene
  100163. * @returns true if fog must be enabled
  100164. */
  100165. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100166. /**
  100167. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100168. * @param mesh defines the current mesh
  100169. * @param scene defines the current scene
  100170. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100171. * @param pointsCloud defines if point cloud rendering has to be turned on
  100172. * @param fogEnabled defines if fog has to be turned on
  100173. * @param alphaTest defines if alpha testing has to be turned on
  100174. * @param defines defines the current list of defines
  100175. */
  100176. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100177. /**
  100178. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100179. * @param scene defines the current scene
  100180. * @param engine defines the current engine
  100181. * @param defines specifies the list of active defines
  100182. * @param useInstances defines if instances have to be turned on
  100183. * @param useClipPlane defines if clip plane have to be turned on
  100184. * @param useInstances defines if instances have to be turned on
  100185. * @param useThinInstances defines if thin instances have to be turned on
  100186. */
  100187. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100188. /**
  100189. * Prepares the defines for bones
  100190. * @param mesh The mesh containing the geometry data we will draw
  100191. * @param defines The defines to update
  100192. */
  100193. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100194. /**
  100195. * Prepares the defines for morph targets
  100196. * @param mesh The mesh containing the geometry data we will draw
  100197. * @param defines The defines to update
  100198. */
  100199. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100200. /**
  100201. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100202. * @param mesh The mesh containing the geometry data we will draw
  100203. * @param defines The defines to update
  100204. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100205. * @param useBones Precise whether bones should be used or not (override mesh info)
  100206. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100207. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100208. * @returns false if defines are considered not dirty and have not been checked
  100209. */
  100210. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100211. /**
  100212. * Prepares the defines related to multiview
  100213. * @param scene The scene we are intending to draw
  100214. * @param defines The defines to update
  100215. */
  100216. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100217. /**
  100218. * Prepares the defines related to the prepass
  100219. * @param scene The scene we are intending to draw
  100220. * @param defines The defines to update
  100221. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100222. */
  100223. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100224. /**
  100225. * Prepares the defines related to the light information passed in parameter
  100226. * @param scene The scene we are intending to draw
  100227. * @param mesh The mesh the effect is compiling for
  100228. * @param light The light the effect is compiling for
  100229. * @param lightIndex The index of the light
  100230. * @param defines The defines to update
  100231. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100232. * @param state Defines the current state regarding what is needed (normals, etc...)
  100233. */
  100234. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100235. needNormals: boolean;
  100236. needRebuild: boolean;
  100237. shadowEnabled: boolean;
  100238. specularEnabled: boolean;
  100239. lightmapMode: boolean;
  100240. }): void;
  100241. /**
  100242. * Prepares the defines related to the light information passed in parameter
  100243. * @param scene The scene we are intending to draw
  100244. * @param mesh The mesh the effect is compiling for
  100245. * @param defines The defines to update
  100246. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100247. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100248. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100249. * @returns true if normals will be required for the rest of the effect
  100250. */
  100251. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100252. /**
  100253. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100254. * @param lightIndex defines the light index
  100255. * @param uniformsList The uniform list
  100256. * @param samplersList The sampler list
  100257. * @param projectedLightTexture defines if projected texture must be used
  100258. * @param uniformBuffersList defines an optional list of uniform buffers
  100259. */
  100260. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100261. /**
  100262. * Prepares the uniforms and samplers list to be used in the effect
  100263. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100264. * @param samplersList The sampler list
  100265. * @param defines The defines helping in the list generation
  100266. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100267. */
  100268. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100269. /**
  100270. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100271. * @param defines The defines to update while falling back
  100272. * @param fallbacks The authorized effect fallbacks
  100273. * @param maxSimultaneousLights The maximum number of lights allowed
  100274. * @param rank the current rank of the Effect
  100275. * @returns The newly affected rank
  100276. */
  100277. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100278. private static _TmpMorphInfluencers;
  100279. /**
  100280. * Prepares the list of attributes required for morph targets according to the effect defines.
  100281. * @param attribs The current list of supported attribs
  100282. * @param mesh The mesh to prepare the morph targets attributes for
  100283. * @param influencers The number of influencers
  100284. */
  100285. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100286. /**
  100287. * Prepares the list of attributes required for morph targets according to the effect defines.
  100288. * @param attribs The current list of supported attribs
  100289. * @param mesh The mesh to prepare the morph targets attributes for
  100290. * @param defines The current Defines of the effect
  100291. */
  100292. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100293. /**
  100294. * Prepares the list of attributes required for bones according to the effect defines.
  100295. * @param attribs The current list of supported attribs
  100296. * @param mesh The mesh to prepare the bones attributes for
  100297. * @param defines The current Defines of the effect
  100298. * @param fallbacks The current efffect fallback strategy
  100299. */
  100300. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100301. /**
  100302. * Check and prepare the list of attributes required for instances according to the effect defines.
  100303. * @param attribs The current list of supported attribs
  100304. * @param defines The current MaterialDefines of the effect
  100305. */
  100306. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100307. /**
  100308. * Add the list of attributes required for instances to the attribs array.
  100309. * @param attribs The current list of supported attribs
  100310. */
  100311. static PushAttributesForInstances(attribs: string[]): void;
  100312. /**
  100313. * Binds the light information to the effect.
  100314. * @param light The light containing the generator
  100315. * @param effect The effect we are binding the data to
  100316. * @param lightIndex The light index in the effect used to render
  100317. */
  100318. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100319. /**
  100320. * Binds the lights information from the scene to the effect for the given mesh.
  100321. * @param light Light to bind
  100322. * @param lightIndex Light index
  100323. * @param scene The scene where the light belongs to
  100324. * @param effect The effect we are binding the data to
  100325. * @param useSpecular Defines if specular is supported
  100326. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100327. */
  100328. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100329. /**
  100330. * Binds the lights information from the scene to the effect for the given mesh.
  100331. * @param scene The scene the lights belongs to
  100332. * @param mesh The mesh we are binding the information to render
  100333. * @param effect The effect we are binding the data to
  100334. * @param defines The generated defines for the effect
  100335. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100336. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100337. */
  100338. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100339. private static _tempFogColor;
  100340. /**
  100341. * Binds the fog information from the scene to the effect for the given mesh.
  100342. * @param scene The scene the lights belongs to
  100343. * @param mesh The mesh we are binding the information to render
  100344. * @param effect The effect we are binding the data to
  100345. * @param linearSpace Defines if the fog effect is applied in linear space
  100346. */
  100347. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100348. /**
  100349. * Binds the bones information from the mesh to the effect.
  100350. * @param mesh The mesh we are binding the information to render
  100351. * @param effect The effect we are binding the data to
  100352. */
  100353. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100354. /**
  100355. * Binds the morph targets information from the mesh to the effect.
  100356. * @param abstractMesh The mesh we are binding the information to render
  100357. * @param effect The effect we are binding the data to
  100358. */
  100359. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100360. /**
  100361. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100362. * @param defines The generated defines used in the effect
  100363. * @param effect The effect we are binding the data to
  100364. * @param scene The scene we are willing to render with logarithmic scale for
  100365. */
  100366. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100367. /**
  100368. * Binds the clip plane information from the scene to the effect.
  100369. * @param scene The scene the clip plane information are extracted from
  100370. * @param effect The effect we are binding the data to
  100371. */
  100372. static BindClipPlane(effect: Effect, scene: Scene): void;
  100373. }
  100374. }
  100375. declare module BABYLON {
  100376. /**
  100377. * Block used to expose an input value
  100378. */
  100379. export class InputBlock extends NodeMaterialBlock {
  100380. private _mode;
  100381. private _associatedVariableName;
  100382. private _storedValue;
  100383. private _valueCallback;
  100384. private _type;
  100385. private _animationType;
  100386. /** Gets or set a value used to limit the range of float values */
  100387. min: number;
  100388. /** Gets or set a value used to limit the range of float values */
  100389. max: number;
  100390. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100391. isBoolean: boolean;
  100392. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100393. matrixMode: number;
  100394. /** @hidden */
  100395. _systemValue: Nullable<NodeMaterialSystemValues>;
  100396. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100397. isConstant: boolean;
  100398. /** Gets or sets the group to use to display this block in the Inspector */
  100399. groupInInspector: string;
  100400. /** Gets an observable raised when the value is changed */
  100401. onValueChangedObservable: Observable<InputBlock>;
  100402. /**
  100403. * Gets or sets the connection point type (default is float)
  100404. */
  100405. get type(): NodeMaterialBlockConnectionPointTypes;
  100406. /**
  100407. * Creates a new InputBlock
  100408. * @param name defines the block name
  100409. * @param target defines the target of that block (Vertex by default)
  100410. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100411. */
  100412. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100413. /**
  100414. * Validates if a name is a reserve word.
  100415. * @param newName the new name to be given to the node.
  100416. * @returns false if the name is a reserve word, else true.
  100417. */
  100418. validateBlockName(newName: string): boolean;
  100419. /**
  100420. * Gets the output component
  100421. */
  100422. get output(): NodeMaterialConnectionPoint;
  100423. /**
  100424. * Set the source of this connection point to a vertex attribute
  100425. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100426. * @returns the current connection point
  100427. */
  100428. setAsAttribute(attributeName?: string): InputBlock;
  100429. /**
  100430. * Set the source of this connection point to a system value
  100431. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100432. * @returns the current connection point
  100433. */
  100434. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100435. /**
  100436. * Gets or sets the value of that point.
  100437. * Please note that this value will be ignored if valueCallback is defined
  100438. */
  100439. get value(): any;
  100440. set value(value: any);
  100441. /**
  100442. * Gets or sets a callback used to get the value of that point.
  100443. * Please note that setting this value will force the connection point to ignore the value property
  100444. */
  100445. get valueCallback(): () => any;
  100446. set valueCallback(value: () => any);
  100447. /**
  100448. * Gets or sets the associated variable name in the shader
  100449. */
  100450. get associatedVariableName(): string;
  100451. set associatedVariableName(value: string);
  100452. /** Gets or sets the type of animation applied to the input */
  100453. get animationType(): AnimatedInputBlockTypes;
  100454. set animationType(value: AnimatedInputBlockTypes);
  100455. /**
  100456. * Gets a boolean indicating that this connection point not defined yet
  100457. */
  100458. get isUndefined(): boolean;
  100459. /**
  100460. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100461. * In this case the connection point name must be the name of the uniform to use.
  100462. * Can only be set on inputs
  100463. */
  100464. get isUniform(): boolean;
  100465. set isUniform(value: boolean);
  100466. /**
  100467. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100468. * In this case the connection point name must be the name of the attribute to use
  100469. * Can only be set on inputs
  100470. */
  100471. get isAttribute(): boolean;
  100472. set isAttribute(value: boolean);
  100473. /**
  100474. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100475. * Can only be set on exit points
  100476. */
  100477. get isVarying(): boolean;
  100478. set isVarying(value: boolean);
  100479. /**
  100480. * Gets a boolean indicating that the current connection point is a system value
  100481. */
  100482. get isSystemValue(): boolean;
  100483. /**
  100484. * Gets or sets the current well known value or null if not defined as a system value
  100485. */
  100486. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100487. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100488. /**
  100489. * Gets the current class name
  100490. * @returns the class name
  100491. */
  100492. getClassName(): string;
  100493. /**
  100494. * Animate the input if animationType !== None
  100495. * @param scene defines the rendering scene
  100496. */
  100497. animate(scene: Scene): void;
  100498. private _emitDefine;
  100499. initialize(state: NodeMaterialBuildState): void;
  100500. /**
  100501. * Set the input block to its default value (based on its type)
  100502. */
  100503. setDefaultValue(): void;
  100504. private _emitConstant;
  100505. /** @hidden */
  100506. get _noContextSwitch(): boolean;
  100507. private _emit;
  100508. /** @hidden */
  100509. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100510. /** @hidden */
  100511. _transmit(effect: Effect, scene: Scene): void;
  100512. protected _buildBlock(state: NodeMaterialBuildState): void;
  100513. protected _dumpPropertiesCode(): string;
  100514. dispose(): void;
  100515. serialize(): any;
  100516. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100517. }
  100518. }
  100519. declare module BABYLON {
  100520. /**
  100521. * Enum used to define the compatibility state between two connection points
  100522. */
  100523. export enum NodeMaterialConnectionPointCompatibilityStates {
  100524. /** Points are compatibles */
  100525. Compatible = 0,
  100526. /** Points are incompatible because of their types */
  100527. TypeIncompatible = 1,
  100528. /** Points are incompatible because of their targets (vertex vs fragment) */
  100529. TargetIncompatible = 2
  100530. }
  100531. /**
  100532. * Defines the direction of a connection point
  100533. */
  100534. export enum NodeMaterialConnectionPointDirection {
  100535. /** Input */
  100536. Input = 0,
  100537. /** Output */
  100538. Output = 1
  100539. }
  100540. /**
  100541. * Defines a connection point for a block
  100542. */
  100543. export class NodeMaterialConnectionPoint {
  100544. /** @hidden */
  100545. _ownerBlock: NodeMaterialBlock;
  100546. /** @hidden */
  100547. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100548. private _endpoints;
  100549. private _associatedVariableName;
  100550. private _direction;
  100551. /** @hidden */
  100552. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100553. /** @hidden */
  100554. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100555. private _type;
  100556. /** @hidden */
  100557. _enforceAssociatedVariableName: boolean;
  100558. /** Gets the direction of the point */
  100559. get direction(): NodeMaterialConnectionPointDirection;
  100560. /** Indicates that this connection point needs dual validation before being connected to another point */
  100561. needDualDirectionValidation: boolean;
  100562. /**
  100563. * Gets or sets the additional types supported by this connection point
  100564. */
  100565. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100566. /**
  100567. * Gets or sets the additional types excluded by this connection point
  100568. */
  100569. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100570. /**
  100571. * Observable triggered when this point is connected
  100572. */
  100573. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100574. /**
  100575. * Gets or sets the associated variable name in the shader
  100576. */
  100577. get associatedVariableName(): string;
  100578. set associatedVariableName(value: string);
  100579. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100580. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100581. /**
  100582. * Gets or sets the connection point type (default is float)
  100583. */
  100584. get type(): NodeMaterialBlockConnectionPointTypes;
  100585. set type(value: NodeMaterialBlockConnectionPointTypes);
  100586. /**
  100587. * Gets or sets the connection point name
  100588. */
  100589. name: string;
  100590. /**
  100591. * Gets or sets the connection point name
  100592. */
  100593. displayName: string;
  100594. /**
  100595. * Gets or sets a boolean indicating that this connection point can be omitted
  100596. */
  100597. isOptional: boolean;
  100598. /**
  100599. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  100600. */
  100601. isExposedOnFrame: boolean;
  100602. /**
  100603. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  100604. */
  100605. define: string;
  100606. /** @hidden */
  100607. _prioritizeVertex: boolean;
  100608. private _target;
  100609. /** Gets or sets the target of that connection point */
  100610. get target(): NodeMaterialBlockTargets;
  100611. set target(value: NodeMaterialBlockTargets);
  100612. /**
  100613. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  100614. */
  100615. get isConnected(): boolean;
  100616. /**
  100617. * Gets a boolean indicating that the current point is connected to an input block
  100618. */
  100619. get isConnectedToInputBlock(): boolean;
  100620. /**
  100621. * Gets a the connected input block (if any)
  100622. */
  100623. get connectInputBlock(): Nullable<InputBlock>;
  100624. /** Get the other side of the connection (if any) */
  100625. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  100626. /** Get the block that owns this connection point */
  100627. get ownerBlock(): NodeMaterialBlock;
  100628. /** Get the block connected on the other side of this connection (if any) */
  100629. get sourceBlock(): Nullable<NodeMaterialBlock>;
  100630. /** Get the block connected on the endpoints of this connection (if any) */
  100631. get connectedBlocks(): Array<NodeMaterialBlock>;
  100632. /** Gets the list of connected endpoints */
  100633. get endpoints(): NodeMaterialConnectionPoint[];
  100634. /** Gets a boolean indicating if that output point is connected to at least one input */
  100635. get hasEndpoints(): boolean;
  100636. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  100637. get isConnectedInVertexShader(): boolean;
  100638. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  100639. get isConnectedInFragmentShader(): boolean;
  100640. /**
  100641. * Creates a block suitable to be used as an input for this input point.
  100642. * If null is returned, a block based on the point type will be created.
  100643. * @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
  100644. */
  100645. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100646. /**
  100647. * Creates a new connection point
  100648. * @param name defines the connection point name
  100649. * @param ownerBlock defines the block hosting this connection point
  100650. * @param direction defines the direction of the connection point
  100651. */
  100652. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  100653. /**
  100654. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  100655. * @returns the class name
  100656. */
  100657. getClassName(): string;
  100658. /**
  100659. * Gets a boolean indicating if the current point can be connected to another point
  100660. * @param connectionPoint defines the other connection point
  100661. * @returns a boolean
  100662. */
  100663. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  100664. /**
  100665. * Gets a number indicating if the current point can be connected to another point
  100666. * @param connectionPoint defines the other connection point
  100667. * @returns a number defining the compatibility state
  100668. */
  100669. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100670. /**
  100671. * Connect this point to another connection point
  100672. * @param connectionPoint defines the other connection point
  100673. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  100674. * @returns the current connection point
  100675. */
  100676. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  100677. /**
  100678. * Disconnect this point from one of his endpoint
  100679. * @param endpoint defines the other connection point
  100680. * @returns the current connection point
  100681. */
  100682. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  100683. /**
  100684. * Serializes this point in a JSON representation
  100685. * @param isInput defines if the connection point is an input (default is true)
  100686. * @returns the serialized point object
  100687. */
  100688. serialize(isInput?: boolean): any;
  100689. /**
  100690. * Release resources
  100691. */
  100692. dispose(): void;
  100693. }
  100694. }
  100695. declare module BABYLON {
  100696. /**
  100697. * Enum used to define the material modes
  100698. */
  100699. export enum NodeMaterialModes {
  100700. /** Regular material */
  100701. Material = 0,
  100702. /** For post process */
  100703. PostProcess = 1,
  100704. /** For particle system */
  100705. Particle = 2,
  100706. /** For procedural texture */
  100707. ProceduralTexture = 3
  100708. }
  100709. }
  100710. declare module BABYLON {
  100711. /**
  100712. * Block used to read a texture from a sampler
  100713. */
  100714. export class TextureBlock extends NodeMaterialBlock {
  100715. private _defineName;
  100716. private _linearDefineName;
  100717. private _gammaDefineName;
  100718. private _tempTextureRead;
  100719. private _samplerName;
  100720. private _transformedUVName;
  100721. private _textureTransformName;
  100722. private _textureInfoName;
  100723. private _mainUVName;
  100724. private _mainUVDefineName;
  100725. private _fragmentOnly;
  100726. /**
  100727. * Gets or sets the texture associated with the node
  100728. */
  100729. texture: Nullable<Texture>;
  100730. /**
  100731. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100732. */
  100733. convertToGammaSpace: boolean;
  100734. /**
  100735. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100736. */
  100737. convertToLinearSpace: boolean;
  100738. /**
  100739. * Create a new TextureBlock
  100740. * @param name defines the block name
  100741. */
  100742. constructor(name: string, fragmentOnly?: boolean);
  100743. /**
  100744. * Gets the current class name
  100745. * @returns the class name
  100746. */
  100747. getClassName(): string;
  100748. /**
  100749. * Gets the uv input component
  100750. */
  100751. get uv(): NodeMaterialConnectionPoint;
  100752. /**
  100753. * Gets the rgba output component
  100754. */
  100755. get rgba(): NodeMaterialConnectionPoint;
  100756. /**
  100757. * Gets the rgb output component
  100758. */
  100759. get rgb(): NodeMaterialConnectionPoint;
  100760. /**
  100761. * Gets the r output component
  100762. */
  100763. get r(): NodeMaterialConnectionPoint;
  100764. /**
  100765. * Gets the g output component
  100766. */
  100767. get g(): NodeMaterialConnectionPoint;
  100768. /**
  100769. * Gets the b output component
  100770. */
  100771. get b(): NodeMaterialConnectionPoint;
  100772. /**
  100773. * Gets the a output component
  100774. */
  100775. get a(): NodeMaterialConnectionPoint;
  100776. get target(): NodeMaterialBlockTargets;
  100777. autoConfigure(material: NodeMaterial): void;
  100778. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100779. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100780. isReady(): boolean;
  100781. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100782. private get _isMixed();
  100783. private _injectVertexCode;
  100784. private _writeTextureRead;
  100785. private _writeOutput;
  100786. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100787. protected _dumpPropertiesCode(): string;
  100788. serialize(): any;
  100789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100790. }
  100791. }
  100792. declare module BABYLON {
  100793. /** @hidden */
  100794. export var reflectionFunction: {
  100795. name: string;
  100796. shader: string;
  100797. };
  100798. }
  100799. declare module BABYLON {
  100800. /**
  100801. * Base block used to read a reflection texture from a sampler
  100802. */
  100803. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  100804. /** @hidden */
  100805. _define3DName: string;
  100806. /** @hidden */
  100807. _defineCubicName: string;
  100808. /** @hidden */
  100809. _defineExplicitName: string;
  100810. /** @hidden */
  100811. _defineProjectionName: string;
  100812. /** @hidden */
  100813. _defineLocalCubicName: string;
  100814. /** @hidden */
  100815. _defineSphericalName: string;
  100816. /** @hidden */
  100817. _definePlanarName: string;
  100818. /** @hidden */
  100819. _defineEquirectangularName: string;
  100820. /** @hidden */
  100821. _defineMirroredEquirectangularFixedName: string;
  100822. /** @hidden */
  100823. _defineEquirectangularFixedName: string;
  100824. /** @hidden */
  100825. _defineSkyboxName: string;
  100826. /** @hidden */
  100827. _defineOppositeZ: string;
  100828. /** @hidden */
  100829. _cubeSamplerName: string;
  100830. /** @hidden */
  100831. _2DSamplerName: string;
  100832. protected _positionUVWName: string;
  100833. protected _directionWName: string;
  100834. protected _reflectionVectorName: string;
  100835. /** @hidden */
  100836. _reflectionCoordsName: string;
  100837. /** @hidden */
  100838. _reflectionMatrixName: string;
  100839. protected _reflectionColorName: string;
  100840. /**
  100841. * Gets or sets the texture associated with the node
  100842. */
  100843. texture: Nullable<BaseTexture>;
  100844. /**
  100845. * Create a new ReflectionTextureBaseBlock
  100846. * @param name defines the block name
  100847. */
  100848. constructor(name: string);
  100849. /**
  100850. * Gets the current class name
  100851. * @returns the class name
  100852. */
  100853. getClassName(): string;
  100854. /**
  100855. * Gets the world position input component
  100856. */
  100857. abstract get position(): NodeMaterialConnectionPoint;
  100858. /**
  100859. * Gets the world position input component
  100860. */
  100861. abstract get worldPosition(): NodeMaterialConnectionPoint;
  100862. /**
  100863. * Gets the world normal input component
  100864. */
  100865. abstract get worldNormal(): NodeMaterialConnectionPoint;
  100866. /**
  100867. * Gets the world input component
  100868. */
  100869. abstract get world(): NodeMaterialConnectionPoint;
  100870. /**
  100871. * Gets the camera (or eye) position component
  100872. */
  100873. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  100874. /**
  100875. * Gets the view input component
  100876. */
  100877. abstract get view(): NodeMaterialConnectionPoint;
  100878. protected _getTexture(): Nullable<BaseTexture>;
  100879. autoConfigure(material: NodeMaterial): void;
  100880. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100881. isReady(): boolean;
  100882. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100883. /**
  100884. * Gets the code to inject in the vertex shader
  100885. * @param state current state of the node material building
  100886. * @returns the shader code
  100887. */
  100888. handleVertexSide(state: NodeMaterialBuildState): string;
  100889. /**
  100890. * Handles the inits for the fragment code path
  100891. * @param state node material build state
  100892. */
  100893. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  100894. /**
  100895. * Generates the reflection coords code for the fragment code path
  100896. * @param worldNormalVarName name of the world normal variable
  100897. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  100898. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  100899. * @returns the shader code
  100900. */
  100901. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  100902. /**
  100903. * Generates the reflection color code for the fragment code path
  100904. * @param lodVarName name of the lod variable
  100905. * @param swizzleLookupTexture swizzle to use for the final color variable
  100906. * @returns the shader code
  100907. */
  100908. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  100909. /**
  100910. * Generates the code corresponding to the connected output points
  100911. * @param state node material build state
  100912. * @param varName name of the variable to output
  100913. * @returns the shader code
  100914. */
  100915. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  100916. protected _buildBlock(state: NodeMaterialBuildState): this;
  100917. protected _dumpPropertiesCode(): string;
  100918. serialize(): any;
  100919. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100920. }
  100921. }
  100922. declare module BABYLON {
  100923. /**
  100924. * Defines a connection point to be used for points with a custom object type
  100925. */
  100926. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  100927. private _blockType;
  100928. private _blockName;
  100929. private _nameForCheking?;
  100930. /**
  100931. * Creates a new connection point
  100932. * @param name defines the connection point name
  100933. * @param ownerBlock defines the block hosting this connection point
  100934. * @param direction defines the direction of the connection point
  100935. */
  100936. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  100937. /**
  100938. * Gets a number indicating if the current point can be connected to another point
  100939. * @param connectionPoint defines the other connection point
  100940. * @returns a number defining the compatibility state
  100941. */
  100942. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100943. /**
  100944. * Creates a block suitable to be used as an input for this input point.
  100945. * If null is returned, a block based on the point type will be created.
  100946. * @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
  100947. */
  100948. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100949. }
  100950. }
  100951. declare module BABYLON {
  100952. /**
  100953. * Enum defining the type of properties that can be edited in the property pages in the NME
  100954. */
  100955. export enum PropertyTypeForEdition {
  100956. /** property is a boolean */
  100957. Boolean = 0,
  100958. /** property is a float */
  100959. Float = 1,
  100960. /** property is a Vector2 */
  100961. Vector2 = 2,
  100962. /** property is a list of values */
  100963. List = 3
  100964. }
  100965. /**
  100966. * Interface that defines an option in a variable of type list
  100967. */
  100968. export interface IEditablePropertyListOption {
  100969. /** label of the option */
  100970. "label": string;
  100971. /** value of the option */
  100972. "value": number;
  100973. }
  100974. /**
  100975. * Interface that defines the options available for an editable property
  100976. */
  100977. export interface IEditablePropertyOption {
  100978. /** min value */
  100979. "min"?: number;
  100980. /** max value */
  100981. "max"?: number;
  100982. /** notifiers: indicates which actions to take when the property is changed */
  100983. "notifiers"?: {
  100984. /** the material should be rebuilt */
  100985. "rebuild"?: boolean;
  100986. /** the preview should be updated */
  100987. "update"?: boolean;
  100988. };
  100989. /** list of the options for a variable of type list */
  100990. "options"?: IEditablePropertyListOption[];
  100991. }
  100992. /**
  100993. * Interface that describes an editable property
  100994. */
  100995. export interface IPropertyDescriptionForEdition {
  100996. /** name of the property */
  100997. "propertyName": string;
  100998. /** display name of the property */
  100999. "displayName": string;
  101000. /** type of the property */
  101001. "type": PropertyTypeForEdition;
  101002. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101003. "groupName": string;
  101004. /** options for the property */
  101005. "options": IEditablePropertyOption;
  101006. }
  101007. /**
  101008. * Decorator that flags a property in a node material block as being editable
  101009. */
  101010. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101011. }
  101012. declare module BABYLON {
  101013. /**
  101014. * Block used to implement the refraction part of the sub surface module of the PBR material
  101015. */
  101016. export class RefractionBlock extends NodeMaterialBlock {
  101017. /** @hidden */
  101018. _define3DName: string;
  101019. /** @hidden */
  101020. _refractionMatrixName: string;
  101021. /** @hidden */
  101022. _defineLODRefractionAlpha: string;
  101023. /** @hidden */
  101024. _defineLinearSpecularRefraction: string;
  101025. /** @hidden */
  101026. _defineOppositeZ: string;
  101027. /** @hidden */
  101028. _cubeSamplerName: string;
  101029. /** @hidden */
  101030. _2DSamplerName: string;
  101031. /** @hidden */
  101032. _vRefractionMicrosurfaceInfosName: string;
  101033. /** @hidden */
  101034. _vRefractionInfosName: string;
  101035. private _scene;
  101036. /**
  101037. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101038. * Materials half opaque for instance using refraction could benefit from this control.
  101039. */
  101040. linkRefractionWithTransparency: boolean;
  101041. /**
  101042. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101043. */
  101044. invertRefractionY: boolean;
  101045. /**
  101046. * Gets or sets the texture associated with the node
  101047. */
  101048. texture: Nullable<BaseTexture>;
  101049. /**
  101050. * Create a new RefractionBlock
  101051. * @param name defines the block name
  101052. */
  101053. constructor(name: string);
  101054. /**
  101055. * Gets the current class name
  101056. * @returns the class name
  101057. */
  101058. getClassName(): string;
  101059. /**
  101060. * Gets the intensity input component
  101061. */
  101062. get intensity(): NodeMaterialConnectionPoint;
  101063. /**
  101064. * Gets the index of refraction input component
  101065. */
  101066. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101067. /**
  101068. * Gets the tint at distance input component
  101069. */
  101070. get tintAtDistance(): NodeMaterialConnectionPoint;
  101071. /**
  101072. * Gets the view input component
  101073. */
  101074. get view(): NodeMaterialConnectionPoint;
  101075. /**
  101076. * Gets the refraction object output component
  101077. */
  101078. get refraction(): NodeMaterialConnectionPoint;
  101079. /**
  101080. * Returns true if the block has a texture
  101081. */
  101082. get hasTexture(): boolean;
  101083. protected _getTexture(): Nullable<BaseTexture>;
  101084. autoConfigure(material: NodeMaterial): void;
  101085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101086. isReady(): boolean;
  101087. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101088. /**
  101089. * Gets the main code of the block (fragment side)
  101090. * @param state current state of the node material building
  101091. * @returns the shader code
  101092. */
  101093. getCode(state: NodeMaterialBuildState): string;
  101094. protected _buildBlock(state: NodeMaterialBuildState): this;
  101095. protected _dumpPropertiesCode(): string;
  101096. serialize(): any;
  101097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101098. }
  101099. }
  101100. declare module BABYLON {
  101101. /**
  101102. * Base block used as input for post process
  101103. */
  101104. export class CurrentScreenBlock extends NodeMaterialBlock {
  101105. private _samplerName;
  101106. private _linearDefineName;
  101107. private _gammaDefineName;
  101108. private _mainUVName;
  101109. private _tempTextureRead;
  101110. /**
  101111. * Gets or sets the texture associated with the node
  101112. */
  101113. texture: Nullable<BaseTexture>;
  101114. /**
  101115. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101116. */
  101117. convertToGammaSpace: boolean;
  101118. /**
  101119. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101120. */
  101121. convertToLinearSpace: boolean;
  101122. /**
  101123. * Create a new CurrentScreenBlock
  101124. * @param name defines the block name
  101125. */
  101126. constructor(name: string);
  101127. /**
  101128. * Gets the current class name
  101129. * @returns the class name
  101130. */
  101131. getClassName(): string;
  101132. /**
  101133. * Gets the uv input component
  101134. */
  101135. get uv(): NodeMaterialConnectionPoint;
  101136. /**
  101137. * Gets the rgba output component
  101138. */
  101139. get rgba(): NodeMaterialConnectionPoint;
  101140. /**
  101141. * Gets the rgb output component
  101142. */
  101143. get rgb(): NodeMaterialConnectionPoint;
  101144. /**
  101145. * Gets the r output component
  101146. */
  101147. get r(): NodeMaterialConnectionPoint;
  101148. /**
  101149. * Gets the g output component
  101150. */
  101151. get g(): NodeMaterialConnectionPoint;
  101152. /**
  101153. * Gets the b output component
  101154. */
  101155. get b(): NodeMaterialConnectionPoint;
  101156. /**
  101157. * Gets the a output component
  101158. */
  101159. get a(): NodeMaterialConnectionPoint;
  101160. /**
  101161. * Initialize the block and prepare the context for build
  101162. * @param state defines the state that will be used for the build
  101163. */
  101164. initialize(state: NodeMaterialBuildState): void;
  101165. get target(): NodeMaterialBlockTargets;
  101166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101167. isReady(): boolean;
  101168. private _injectVertexCode;
  101169. private _writeTextureRead;
  101170. private _writeOutput;
  101171. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101172. serialize(): any;
  101173. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101174. }
  101175. }
  101176. declare module BABYLON {
  101177. /**
  101178. * Base block used for the particle texture
  101179. */
  101180. export class ParticleTextureBlock extends NodeMaterialBlock {
  101181. private _samplerName;
  101182. private _linearDefineName;
  101183. private _gammaDefineName;
  101184. private _tempTextureRead;
  101185. /**
  101186. * Gets or sets the texture associated with the node
  101187. */
  101188. texture: Nullable<BaseTexture>;
  101189. /**
  101190. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101191. */
  101192. convertToGammaSpace: boolean;
  101193. /**
  101194. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101195. */
  101196. convertToLinearSpace: boolean;
  101197. /**
  101198. * Create a new ParticleTextureBlock
  101199. * @param name defines the block name
  101200. */
  101201. constructor(name: string);
  101202. /**
  101203. * Gets the current class name
  101204. * @returns the class name
  101205. */
  101206. getClassName(): string;
  101207. /**
  101208. * Gets the uv input component
  101209. */
  101210. get uv(): NodeMaterialConnectionPoint;
  101211. /**
  101212. * Gets the rgba output component
  101213. */
  101214. get rgba(): NodeMaterialConnectionPoint;
  101215. /**
  101216. * Gets the rgb output component
  101217. */
  101218. get rgb(): NodeMaterialConnectionPoint;
  101219. /**
  101220. * Gets the r output component
  101221. */
  101222. get r(): NodeMaterialConnectionPoint;
  101223. /**
  101224. * Gets the g output component
  101225. */
  101226. get g(): NodeMaterialConnectionPoint;
  101227. /**
  101228. * Gets the b output component
  101229. */
  101230. get b(): NodeMaterialConnectionPoint;
  101231. /**
  101232. * Gets the a output component
  101233. */
  101234. get a(): NodeMaterialConnectionPoint;
  101235. /**
  101236. * Initialize the block and prepare the context for build
  101237. * @param state defines the state that will be used for the build
  101238. */
  101239. initialize(state: NodeMaterialBuildState): void;
  101240. autoConfigure(material: NodeMaterial): void;
  101241. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101242. isReady(): boolean;
  101243. private _writeOutput;
  101244. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101245. serialize(): any;
  101246. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101247. }
  101248. }
  101249. declare module BABYLON {
  101250. /**
  101251. * Class used to store shared data between 2 NodeMaterialBuildState
  101252. */
  101253. export class NodeMaterialBuildStateSharedData {
  101254. /**
  101255. * Gets the list of emitted varyings
  101256. */
  101257. temps: string[];
  101258. /**
  101259. * Gets the list of emitted varyings
  101260. */
  101261. varyings: string[];
  101262. /**
  101263. * Gets the varying declaration string
  101264. */
  101265. varyingDeclaration: string;
  101266. /**
  101267. * Input blocks
  101268. */
  101269. inputBlocks: InputBlock[];
  101270. /**
  101271. * Input blocks
  101272. */
  101273. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101274. /**
  101275. * Bindable blocks (Blocks that need to set data to the effect)
  101276. */
  101277. bindableBlocks: NodeMaterialBlock[];
  101278. /**
  101279. * List of blocks that can provide a compilation fallback
  101280. */
  101281. blocksWithFallbacks: NodeMaterialBlock[];
  101282. /**
  101283. * List of blocks that can provide a define update
  101284. */
  101285. blocksWithDefines: NodeMaterialBlock[];
  101286. /**
  101287. * List of blocks that can provide a repeatable content
  101288. */
  101289. repeatableContentBlocks: NodeMaterialBlock[];
  101290. /**
  101291. * List of blocks that can provide a dynamic list of uniforms
  101292. */
  101293. dynamicUniformBlocks: NodeMaterialBlock[];
  101294. /**
  101295. * List of blocks that can block the isReady function for the material
  101296. */
  101297. blockingBlocks: NodeMaterialBlock[];
  101298. /**
  101299. * Gets the list of animated inputs
  101300. */
  101301. animatedInputs: InputBlock[];
  101302. /**
  101303. * Build Id used to avoid multiple recompilations
  101304. */
  101305. buildId: number;
  101306. /** List of emitted variables */
  101307. variableNames: {
  101308. [key: string]: number;
  101309. };
  101310. /** List of emitted defines */
  101311. defineNames: {
  101312. [key: string]: number;
  101313. };
  101314. /** Should emit comments? */
  101315. emitComments: boolean;
  101316. /** Emit build activity */
  101317. verbose: boolean;
  101318. /** Gets or sets the hosting scene */
  101319. scene: Scene;
  101320. /**
  101321. * Gets the compilation hints emitted at compilation time
  101322. */
  101323. hints: {
  101324. needWorldViewMatrix: boolean;
  101325. needWorldViewProjectionMatrix: boolean;
  101326. needAlphaBlending: boolean;
  101327. needAlphaTesting: boolean;
  101328. };
  101329. /**
  101330. * List of compilation checks
  101331. */
  101332. checks: {
  101333. emitVertex: boolean;
  101334. emitFragment: boolean;
  101335. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101336. };
  101337. /**
  101338. * Is vertex program allowed to be empty?
  101339. */
  101340. allowEmptyVertexProgram: boolean;
  101341. /** Creates a new shared data */
  101342. constructor();
  101343. /**
  101344. * Emits console errors and exceptions if there is a failing check
  101345. */
  101346. emitErrors(): void;
  101347. }
  101348. }
  101349. declare module BABYLON {
  101350. /**
  101351. * Class used to store node based material build state
  101352. */
  101353. export class NodeMaterialBuildState {
  101354. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101355. supportUniformBuffers: boolean;
  101356. /**
  101357. * Gets the list of emitted attributes
  101358. */
  101359. attributes: string[];
  101360. /**
  101361. * Gets the list of emitted uniforms
  101362. */
  101363. uniforms: string[];
  101364. /**
  101365. * Gets the list of emitted constants
  101366. */
  101367. constants: string[];
  101368. /**
  101369. * Gets the list of emitted samplers
  101370. */
  101371. samplers: string[];
  101372. /**
  101373. * Gets the list of emitted functions
  101374. */
  101375. functions: {
  101376. [key: string]: string;
  101377. };
  101378. /**
  101379. * Gets the list of emitted extensions
  101380. */
  101381. extensions: {
  101382. [key: string]: string;
  101383. };
  101384. /**
  101385. * Gets the target of the compilation state
  101386. */
  101387. target: NodeMaterialBlockTargets;
  101388. /**
  101389. * Gets the list of emitted counters
  101390. */
  101391. counters: {
  101392. [key: string]: number;
  101393. };
  101394. /**
  101395. * Shared data between multiple NodeMaterialBuildState instances
  101396. */
  101397. sharedData: NodeMaterialBuildStateSharedData;
  101398. /** @hidden */
  101399. _vertexState: NodeMaterialBuildState;
  101400. /** @hidden */
  101401. _attributeDeclaration: string;
  101402. /** @hidden */
  101403. _uniformDeclaration: string;
  101404. /** @hidden */
  101405. _constantDeclaration: string;
  101406. /** @hidden */
  101407. _samplerDeclaration: string;
  101408. /** @hidden */
  101409. _varyingTransfer: string;
  101410. /** @hidden */
  101411. _injectAtEnd: string;
  101412. private _repeatableContentAnchorIndex;
  101413. /** @hidden */
  101414. _builtCompilationString: string;
  101415. /**
  101416. * Gets the emitted compilation strings
  101417. */
  101418. compilationString: string;
  101419. /**
  101420. * Finalize the compilation strings
  101421. * @param state defines the current compilation state
  101422. */
  101423. finalize(state: NodeMaterialBuildState): void;
  101424. /** @hidden */
  101425. get _repeatableContentAnchor(): string;
  101426. /** @hidden */
  101427. _getFreeVariableName(prefix: string): string;
  101428. /** @hidden */
  101429. _getFreeDefineName(prefix: string): string;
  101430. /** @hidden */
  101431. _excludeVariableName(name: string): void;
  101432. /** @hidden */
  101433. _emit2DSampler(name: string): void;
  101434. /** @hidden */
  101435. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101436. /** @hidden */
  101437. _emitExtension(name: string, extension: string, define?: string): void;
  101438. /** @hidden */
  101439. _emitFunction(name: string, code: string, comments: string): void;
  101440. /** @hidden */
  101441. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101442. replaceStrings?: {
  101443. search: RegExp;
  101444. replace: string;
  101445. }[];
  101446. repeatKey?: string;
  101447. }): string;
  101448. /** @hidden */
  101449. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101450. repeatKey?: string;
  101451. removeAttributes?: boolean;
  101452. removeUniforms?: boolean;
  101453. removeVaryings?: boolean;
  101454. removeIfDef?: boolean;
  101455. replaceStrings?: {
  101456. search: RegExp;
  101457. replace: string;
  101458. }[];
  101459. }, storeKey?: string): void;
  101460. /** @hidden */
  101461. _registerTempVariable(name: string): boolean;
  101462. /** @hidden */
  101463. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101464. /** @hidden */
  101465. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101466. /** @hidden */
  101467. _emitFloat(value: number): string;
  101468. }
  101469. }
  101470. declare module BABYLON {
  101471. /**
  101472. * Helper class used to generate session unique ID
  101473. */
  101474. export class UniqueIdGenerator {
  101475. private static _UniqueIdCounter;
  101476. /**
  101477. * Gets an unique (relatively to the current scene) Id
  101478. */
  101479. static get UniqueId(): number;
  101480. }
  101481. }
  101482. declare module BABYLON {
  101483. /**
  101484. * Defines a block that can be used inside a node based material
  101485. */
  101486. export class NodeMaterialBlock {
  101487. private _buildId;
  101488. private _buildTarget;
  101489. private _target;
  101490. private _isFinalMerger;
  101491. private _isInput;
  101492. private _name;
  101493. protected _isUnique: boolean;
  101494. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101495. inputsAreExclusive: boolean;
  101496. /** @hidden */
  101497. _codeVariableName: string;
  101498. /** @hidden */
  101499. _inputs: NodeMaterialConnectionPoint[];
  101500. /** @hidden */
  101501. _outputs: NodeMaterialConnectionPoint[];
  101502. /** @hidden */
  101503. _preparationId: number;
  101504. /**
  101505. * Gets the name of the block
  101506. */
  101507. get name(): string;
  101508. /**
  101509. * Sets the name of the block. Will check if the name is valid.
  101510. */
  101511. set name(newName: string);
  101512. /**
  101513. * Gets or sets the unique id of the node
  101514. */
  101515. uniqueId: number;
  101516. /**
  101517. * Gets or sets the comments associated with this block
  101518. */
  101519. comments: string;
  101520. /**
  101521. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101522. */
  101523. get isUnique(): boolean;
  101524. /**
  101525. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101526. */
  101527. get isFinalMerger(): boolean;
  101528. /**
  101529. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101530. */
  101531. get isInput(): boolean;
  101532. /**
  101533. * Gets or sets the build Id
  101534. */
  101535. get buildId(): number;
  101536. set buildId(value: number);
  101537. /**
  101538. * Gets or sets the target of the block
  101539. */
  101540. get target(): NodeMaterialBlockTargets;
  101541. set target(value: NodeMaterialBlockTargets);
  101542. /**
  101543. * Gets the list of input points
  101544. */
  101545. get inputs(): NodeMaterialConnectionPoint[];
  101546. /** Gets the list of output points */
  101547. get outputs(): NodeMaterialConnectionPoint[];
  101548. /**
  101549. * Find an input by its name
  101550. * @param name defines the name of the input to look for
  101551. * @returns the input or null if not found
  101552. */
  101553. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101554. /**
  101555. * Find an output by its name
  101556. * @param name defines the name of the outputto look for
  101557. * @returns the output or null if not found
  101558. */
  101559. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101560. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101561. visibleInInspector: boolean;
  101562. /**
  101563. * Creates a new NodeMaterialBlock
  101564. * @param name defines the block name
  101565. * @param target defines the target of that block (Vertex by default)
  101566. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101567. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101568. */
  101569. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101570. /**
  101571. * Initialize the block and prepare the context for build
  101572. * @param state defines the state that will be used for the build
  101573. */
  101574. initialize(state: NodeMaterialBuildState): void;
  101575. /**
  101576. * Bind data to effect. Will only be called for blocks with isBindable === true
  101577. * @param effect defines the effect to bind data to
  101578. * @param nodeMaterial defines the hosting NodeMaterial
  101579. * @param mesh defines the mesh that will be rendered
  101580. * @param subMesh defines the submesh that will be rendered
  101581. */
  101582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101583. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101584. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101585. protected _writeFloat(value: number): string;
  101586. /**
  101587. * Gets the current class name e.g. "NodeMaterialBlock"
  101588. * @returns the class name
  101589. */
  101590. getClassName(): string;
  101591. /**
  101592. * Register a new input. Must be called inside a block constructor
  101593. * @param name defines the connection point name
  101594. * @param type defines the connection point type
  101595. * @param isOptional defines a boolean indicating that this input can be omitted
  101596. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101597. * @param point an already created connection point. If not provided, create a new one
  101598. * @returns the current block
  101599. */
  101600. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101601. /**
  101602. * Register a new output. Must be called inside a block constructor
  101603. * @param name defines the connection point name
  101604. * @param type defines the connection point type
  101605. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101606. * @param point an already created connection point. If not provided, create a new one
  101607. * @returns the current block
  101608. */
  101609. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101610. /**
  101611. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  101612. * @param forOutput defines an optional connection point to check compatibility with
  101613. * @returns the first available input or null
  101614. */
  101615. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  101616. /**
  101617. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  101618. * @param forBlock defines an optional block to check compatibility with
  101619. * @returns the first available input or null
  101620. */
  101621. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  101622. /**
  101623. * Gets the sibling of the given output
  101624. * @param current defines the current output
  101625. * @returns the next output in the list or null
  101626. */
  101627. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  101628. /**
  101629. * Connect current block with another block
  101630. * @param other defines the block to connect with
  101631. * @param options define the various options to help pick the right connections
  101632. * @returns the current block
  101633. */
  101634. connectTo(other: NodeMaterialBlock, options?: {
  101635. input?: string;
  101636. output?: string;
  101637. outputSwizzle?: string;
  101638. }): this | undefined;
  101639. protected _buildBlock(state: NodeMaterialBuildState): void;
  101640. /**
  101641. * Add uniforms, samplers and uniform buffers at compilation time
  101642. * @param state defines the state to update
  101643. * @param nodeMaterial defines the node material requesting the update
  101644. * @param defines defines the material defines to update
  101645. * @param uniformBuffers defines the list of uniform buffer names
  101646. */
  101647. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  101648. /**
  101649. * Add potential fallbacks if shader compilation fails
  101650. * @param mesh defines the mesh to be rendered
  101651. * @param fallbacks defines the current prioritized list of fallbacks
  101652. */
  101653. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  101654. /**
  101655. * Initialize defines for shader compilation
  101656. * @param mesh defines the mesh to be rendered
  101657. * @param nodeMaterial defines the node material requesting the update
  101658. * @param defines defines the material defines to update
  101659. * @param useInstances specifies that instances should be used
  101660. */
  101661. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101662. /**
  101663. * Update defines for shader compilation
  101664. * @param mesh defines the mesh to be rendered
  101665. * @param nodeMaterial defines the node material requesting the update
  101666. * @param defines defines the material defines to update
  101667. * @param useInstances specifies that instances should be used
  101668. * @param subMesh defines which submesh to render
  101669. */
  101670. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101671. /**
  101672. * Lets the block try to connect some inputs automatically
  101673. * @param material defines the hosting NodeMaterial
  101674. */
  101675. autoConfigure(material: NodeMaterial): void;
  101676. /**
  101677. * Function called when a block is declared as repeatable content generator
  101678. * @param vertexShaderState defines the current compilation state for the vertex shader
  101679. * @param fragmentShaderState defines the current compilation state for the fragment shader
  101680. * @param mesh defines the mesh to be rendered
  101681. * @param defines defines the material defines to update
  101682. */
  101683. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  101684. /**
  101685. * Checks if the block is ready
  101686. * @param mesh defines the mesh to be rendered
  101687. * @param nodeMaterial defines the node material requesting the update
  101688. * @param defines defines the material defines to update
  101689. * @param useInstances specifies that instances should be used
  101690. * @returns true if the block is ready
  101691. */
  101692. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  101693. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  101694. private _processBuild;
  101695. /**
  101696. * Validates the new name for the block node.
  101697. * @param newName the new name to be given to the node.
  101698. * @returns false if the name is a reserve word, else true.
  101699. */
  101700. validateBlockName(newName: string): boolean;
  101701. /**
  101702. * Compile the current node and generate the shader code
  101703. * @param state defines the current compilation state (uniforms, samplers, current string)
  101704. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  101705. * @returns true if already built
  101706. */
  101707. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  101708. protected _inputRename(name: string): string;
  101709. protected _outputRename(name: string): string;
  101710. protected _dumpPropertiesCode(): string;
  101711. /** @hidden */
  101712. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  101713. /** @hidden */
  101714. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  101715. /**
  101716. * Clone the current block to a new identical block
  101717. * @param scene defines the hosting scene
  101718. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101719. * @returns a copy of the current block
  101720. */
  101721. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  101722. /**
  101723. * Serializes this block in a JSON representation
  101724. * @returns the serialized block object
  101725. */
  101726. serialize(): any;
  101727. /** @hidden */
  101728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101729. private _deserializePortDisplayNamesAndExposedOnFrame;
  101730. /**
  101731. * Release resources
  101732. */
  101733. dispose(): void;
  101734. }
  101735. }
  101736. declare module BABYLON {
  101737. /**
  101738. * Base class of materials working in push mode in babylon JS
  101739. * @hidden
  101740. */
  101741. export class PushMaterial extends Material {
  101742. protected _activeEffect: Effect;
  101743. protected _normalMatrix: Matrix;
  101744. constructor(name: string, scene: Scene);
  101745. getEffect(): Effect;
  101746. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101747. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101748. /**
  101749. * Binds the given world matrix to the active effect
  101750. *
  101751. * @param world the matrix to bind
  101752. */
  101753. bindOnlyWorldMatrix(world: Matrix): void;
  101754. /**
  101755. * Binds the given normal matrix to the active effect
  101756. *
  101757. * @param normalMatrix the matrix to bind
  101758. */
  101759. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101760. bind(world: Matrix, mesh?: Mesh): void;
  101761. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101762. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101763. }
  101764. }
  101765. declare module BABYLON {
  101766. /**
  101767. * Root class for all node material optimizers
  101768. */
  101769. export class NodeMaterialOptimizer {
  101770. /**
  101771. * Function used to optimize a NodeMaterial graph
  101772. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  101773. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  101774. */
  101775. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  101776. }
  101777. }
  101778. declare module BABYLON {
  101779. /**
  101780. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  101781. */
  101782. export class TransformBlock extends NodeMaterialBlock {
  101783. /**
  101784. * Defines the value to use to complement W value to transform it to a Vector4
  101785. */
  101786. complementW: number;
  101787. /**
  101788. * Defines the value to use to complement z value to transform it to a Vector4
  101789. */
  101790. complementZ: number;
  101791. /**
  101792. * Creates a new TransformBlock
  101793. * @param name defines the block name
  101794. */
  101795. constructor(name: string);
  101796. /**
  101797. * Gets the current class name
  101798. * @returns the class name
  101799. */
  101800. getClassName(): string;
  101801. /**
  101802. * Gets the vector input
  101803. */
  101804. get vector(): NodeMaterialConnectionPoint;
  101805. /**
  101806. * Gets the output component
  101807. */
  101808. get output(): NodeMaterialConnectionPoint;
  101809. /**
  101810. * Gets the xyz output component
  101811. */
  101812. get xyz(): NodeMaterialConnectionPoint;
  101813. /**
  101814. * Gets the matrix transform input
  101815. */
  101816. get transform(): NodeMaterialConnectionPoint;
  101817. protected _buildBlock(state: NodeMaterialBuildState): this;
  101818. /**
  101819. * Update defines for shader compilation
  101820. * @param mesh defines the mesh to be rendered
  101821. * @param nodeMaterial defines the node material requesting the update
  101822. * @param defines defines the material defines to update
  101823. * @param useInstances specifies that instances should be used
  101824. * @param subMesh defines which submesh to render
  101825. */
  101826. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101827. serialize(): any;
  101828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101829. protected _dumpPropertiesCode(): string;
  101830. }
  101831. }
  101832. declare module BABYLON {
  101833. /**
  101834. * Block used to output the vertex position
  101835. */
  101836. export class VertexOutputBlock extends NodeMaterialBlock {
  101837. /**
  101838. * Creates a new VertexOutputBlock
  101839. * @param name defines the block name
  101840. */
  101841. constructor(name: string);
  101842. /**
  101843. * Gets the current class name
  101844. * @returns the class name
  101845. */
  101846. getClassName(): string;
  101847. /**
  101848. * Gets the vector input component
  101849. */
  101850. get vector(): NodeMaterialConnectionPoint;
  101851. protected _buildBlock(state: NodeMaterialBuildState): this;
  101852. }
  101853. }
  101854. declare module BABYLON {
  101855. /**
  101856. * Block used to output the final color
  101857. */
  101858. export class FragmentOutputBlock extends NodeMaterialBlock {
  101859. /**
  101860. * Create a new FragmentOutputBlock
  101861. * @param name defines the block name
  101862. */
  101863. constructor(name: string);
  101864. /**
  101865. * Gets the current class name
  101866. * @returns the class name
  101867. */
  101868. getClassName(): string;
  101869. /**
  101870. * Gets the rgba input component
  101871. */
  101872. get rgba(): NodeMaterialConnectionPoint;
  101873. /**
  101874. * Gets the rgb input component
  101875. */
  101876. get rgb(): NodeMaterialConnectionPoint;
  101877. /**
  101878. * Gets the a input component
  101879. */
  101880. get a(): NodeMaterialConnectionPoint;
  101881. protected _buildBlock(state: NodeMaterialBuildState): this;
  101882. }
  101883. }
  101884. declare module BABYLON {
  101885. /**
  101886. * Block used for the particle ramp gradient section
  101887. */
  101888. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  101889. /**
  101890. * Create a new ParticleRampGradientBlock
  101891. * @param name defines the block name
  101892. */
  101893. constructor(name: string);
  101894. /**
  101895. * Gets the current class name
  101896. * @returns the class name
  101897. */
  101898. getClassName(): string;
  101899. /**
  101900. * Gets the color input component
  101901. */
  101902. get color(): NodeMaterialConnectionPoint;
  101903. /**
  101904. * Gets the rampColor output component
  101905. */
  101906. get rampColor(): NodeMaterialConnectionPoint;
  101907. /**
  101908. * Initialize the block and prepare the context for build
  101909. * @param state defines the state that will be used for the build
  101910. */
  101911. initialize(state: NodeMaterialBuildState): void;
  101912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101913. }
  101914. }
  101915. declare module BABYLON {
  101916. /**
  101917. * Block used for the particle blend multiply section
  101918. */
  101919. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  101920. /**
  101921. * Create a new ParticleBlendMultiplyBlock
  101922. * @param name defines the block name
  101923. */
  101924. constructor(name: string);
  101925. /**
  101926. * Gets the current class name
  101927. * @returns the class name
  101928. */
  101929. getClassName(): string;
  101930. /**
  101931. * Gets the color input component
  101932. */
  101933. get color(): NodeMaterialConnectionPoint;
  101934. /**
  101935. * Gets the alphaTexture input component
  101936. */
  101937. get alphaTexture(): NodeMaterialConnectionPoint;
  101938. /**
  101939. * Gets the alphaColor input component
  101940. */
  101941. get alphaColor(): NodeMaterialConnectionPoint;
  101942. /**
  101943. * Gets the blendColor output component
  101944. */
  101945. get blendColor(): NodeMaterialConnectionPoint;
  101946. /**
  101947. * Initialize the block and prepare the context for build
  101948. * @param state defines the state that will be used for the build
  101949. */
  101950. initialize(state: NodeMaterialBuildState): void;
  101951. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101952. }
  101953. }
  101954. declare module BABYLON {
  101955. /**
  101956. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  101957. */
  101958. export class VectorMergerBlock extends NodeMaterialBlock {
  101959. /**
  101960. * Create a new VectorMergerBlock
  101961. * @param name defines the block name
  101962. */
  101963. constructor(name: string);
  101964. /**
  101965. * Gets the current class name
  101966. * @returns the class name
  101967. */
  101968. getClassName(): string;
  101969. /**
  101970. * Gets the xyz component (input)
  101971. */
  101972. get xyzIn(): NodeMaterialConnectionPoint;
  101973. /**
  101974. * Gets the xy component (input)
  101975. */
  101976. get xyIn(): NodeMaterialConnectionPoint;
  101977. /**
  101978. * Gets the x component (input)
  101979. */
  101980. get x(): NodeMaterialConnectionPoint;
  101981. /**
  101982. * Gets the y component (input)
  101983. */
  101984. get y(): NodeMaterialConnectionPoint;
  101985. /**
  101986. * Gets the z component (input)
  101987. */
  101988. get z(): NodeMaterialConnectionPoint;
  101989. /**
  101990. * Gets the w component (input)
  101991. */
  101992. get w(): NodeMaterialConnectionPoint;
  101993. /**
  101994. * Gets the xyzw component (output)
  101995. */
  101996. get xyzw(): NodeMaterialConnectionPoint;
  101997. /**
  101998. * Gets the xyz component (output)
  101999. */
  102000. get xyzOut(): NodeMaterialConnectionPoint;
  102001. /**
  102002. * Gets the xy component (output)
  102003. */
  102004. get xyOut(): NodeMaterialConnectionPoint;
  102005. /**
  102006. * Gets the xy component (output)
  102007. * @deprecated Please use xyOut instead.
  102008. */
  102009. get xy(): NodeMaterialConnectionPoint;
  102010. /**
  102011. * Gets the xyz component (output)
  102012. * @deprecated Please use xyzOut instead.
  102013. */
  102014. get xyz(): NodeMaterialConnectionPoint;
  102015. protected _buildBlock(state: NodeMaterialBuildState): this;
  102016. }
  102017. }
  102018. declare module BABYLON {
  102019. /**
  102020. * Block used to remap a float from a range to a new one
  102021. */
  102022. export class RemapBlock extends NodeMaterialBlock {
  102023. /**
  102024. * Gets or sets the source range
  102025. */
  102026. sourceRange: Vector2;
  102027. /**
  102028. * Gets or sets the target range
  102029. */
  102030. targetRange: Vector2;
  102031. /**
  102032. * Creates a new RemapBlock
  102033. * @param name defines the block name
  102034. */
  102035. constructor(name: string);
  102036. /**
  102037. * Gets the current class name
  102038. * @returns the class name
  102039. */
  102040. getClassName(): string;
  102041. /**
  102042. * Gets the input component
  102043. */
  102044. get input(): NodeMaterialConnectionPoint;
  102045. /**
  102046. * Gets the source min input component
  102047. */
  102048. get sourceMin(): NodeMaterialConnectionPoint;
  102049. /**
  102050. * Gets the source max input component
  102051. */
  102052. get sourceMax(): NodeMaterialConnectionPoint;
  102053. /**
  102054. * Gets the target min input component
  102055. */
  102056. get targetMin(): NodeMaterialConnectionPoint;
  102057. /**
  102058. * Gets the target max input component
  102059. */
  102060. get targetMax(): NodeMaterialConnectionPoint;
  102061. /**
  102062. * Gets the output component
  102063. */
  102064. get output(): NodeMaterialConnectionPoint;
  102065. protected _buildBlock(state: NodeMaterialBuildState): this;
  102066. protected _dumpPropertiesCode(): string;
  102067. serialize(): any;
  102068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102069. }
  102070. }
  102071. declare module BABYLON {
  102072. /**
  102073. * Block used to multiply 2 values
  102074. */
  102075. export class MultiplyBlock extends NodeMaterialBlock {
  102076. /**
  102077. * Creates a new MultiplyBlock
  102078. * @param name defines the block name
  102079. */
  102080. constructor(name: string);
  102081. /**
  102082. * Gets the current class name
  102083. * @returns the class name
  102084. */
  102085. getClassName(): string;
  102086. /**
  102087. * Gets the left operand input component
  102088. */
  102089. get left(): NodeMaterialConnectionPoint;
  102090. /**
  102091. * Gets the right operand input component
  102092. */
  102093. get right(): NodeMaterialConnectionPoint;
  102094. /**
  102095. * Gets the output component
  102096. */
  102097. get output(): NodeMaterialConnectionPoint;
  102098. protected _buildBlock(state: NodeMaterialBuildState): this;
  102099. }
  102100. }
  102101. declare module BABYLON {
  102102. /**
  102103. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102104. */
  102105. export class ColorSplitterBlock extends NodeMaterialBlock {
  102106. /**
  102107. * Create a new ColorSplitterBlock
  102108. * @param name defines the block name
  102109. */
  102110. constructor(name: string);
  102111. /**
  102112. * Gets the current class name
  102113. * @returns the class name
  102114. */
  102115. getClassName(): string;
  102116. /**
  102117. * Gets the rgba component (input)
  102118. */
  102119. get rgba(): NodeMaterialConnectionPoint;
  102120. /**
  102121. * Gets the rgb component (input)
  102122. */
  102123. get rgbIn(): NodeMaterialConnectionPoint;
  102124. /**
  102125. * Gets the rgb component (output)
  102126. */
  102127. get rgbOut(): NodeMaterialConnectionPoint;
  102128. /**
  102129. * Gets the r component (output)
  102130. */
  102131. get r(): NodeMaterialConnectionPoint;
  102132. /**
  102133. * Gets the g component (output)
  102134. */
  102135. get g(): NodeMaterialConnectionPoint;
  102136. /**
  102137. * Gets the b component (output)
  102138. */
  102139. get b(): NodeMaterialConnectionPoint;
  102140. /**
  102141. * Gets the a component (output)
  102142. */
  102143. get a(): NodeMaterialConnectionPoint;
  102144. protected _inputRename(name: string): string;
  102145. protected _outputRename(name: string): string;
  102146. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102147. }
  102148. }
  102149. declare module BABYLON {
  102150. /**
  102151. * Operations supported by the Trigonometry block
  102152. */
  102153. export enum TrigonometryBlockOperations {
  102154. /** Cos */
  102155. Cos = 0,
  102156. /** Sin */
  102157. Sin = 1,
  102158. /** Abs */
  102159. Abs = 2,
  102160. /** Exp */
  102161. Exp = 3,
  102162. /** Exp2 */
  102163. Exp2 = 4,
  102164. /** Round */
  102165. Round = 5,
  102166. /** Floor */
  102167. Floor = 6,
  102168. /** Ceiling */
  102169. Ceiling = 7,
  102170. /** Square root */
  102171. Sqrt = 8,
  102172. /** Log */
  102173. Log = 9,
  102174. /** Tangent */
  102175. Tan = 10,
  102176. /** Arc tangent */
  102177. ArcTan = 11,
  102178. /** Arc cosinus */
  102179. ArcCos = 12,
  102180. /** Arc sinus */
  102181. ArcSin = 13,
  102182. /** Fraction */
  102183. Fract = 14,
  102184. /** Sign */
  102185. Sign = 15,
  102186. /** To radians (from degrees) */
  102187. Radians = 16,
  102188. /** To degrees (from radians) */
  102189. Degrees = 17
  102190. }
  102191. /**
  102192. * Block used to apply trigonometry operation to floats
  102193. */
  102194. export class TrigonometryBlock extends NodeMaterialBlock {
  102195. /**
  102196. * Gets or sets the operation applied by the block
  102197. */
  102198. operation: TrigonometryBlockOperations;
  102199. /**
  102200. * Creates a new TrigonometryBlock
  102201. * @param name defines the block name
  102202. */
  102203. constructor(name: string);
  102204. /**
  102205. * Gets the current class name
  102206. * @returns the class name
  102207. */
  102208. getClassName(): string;
  102209. /**
  102210. * Gets the input component
  102211. */
  102212. get input(): NodeMaterialConnectionPoint;
  102213. /**
  102214. * Gets the output component
  102215. */
  102216. get output(): NodeMaterialConnectionPoint;
  102217. protected _buildBlock(state: NodeMaterialBuildState): this;
  102218. serialize(): any;
  102219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102220. protected _dumpPropertiesCode(): string;
  102221. }
  102222. }
  102223. declare module BABYLON {
  102224. /**
  102225. * Interface used to configure the node material editor
  102226. */
  102227. export interface INodeMaterialEditorOptions {
  102228. /** Define the URl to load node editor script */
  102229. editorURL?: string;
  102230. }
  102231. /** @hidden */
  102232. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102233. NORMAL: boolean;
  102234. TANGENT: boolean;
  102235. UV1: boolean;
  102236. /** BONES */
  102237. NUM_BONE_INFLUENCERS: number;
  102238. BonesPerMesh: number;
  102239. BONETEXTURE: boolean;
  102240. /** MORPH TARGETS */
  102241. MORPHTARGETS: boolean;
  102242. MORPHTARGETS_NORMAL: boolean;
  102243. MORPHTARGETS_TANGENT: boolean;
  102244. MORPHTARGETS_UV: boolean;
  102245. NUM_MORPH_INFLUENCERS: number;
  102246. /** IMAGE PROCESSING */
  102247. IMAGEPROCESSING: boolean;
  102248. VIGNETTE: boolean;
  102249. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102250. VIGNETTEBLENDMODEOPAQUE: boolean;
  102251. TONEMAPPING: boolean;
  102252. TONEMAPPING_ACES: boolean;
  102253. CONTRAST: boolean;
  102254. EXPOSURE: boolean;
  102255. COLORCURVES: boolean;
  102256. COLORGRADING: boolean;
  102257. COLORGRADING3D: boolean;
  102258. SAMPLER3DGREENDEPTH: boolean;
  102259. SAMPLER3DBGRMAP: boolean;
  102260. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102261. /** MISC. */
  102262. BUMPDIRECTUV: number;
  102263. constructor();
  102264. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102265. }
  102266. /**
  102267. * Class used to configure NodeMaterial
  102268. */
  102269. export interface INodeMaterialOptions {
  102270. /**
  102271. * Defines if blocks should emit comments
  102272. */
  102273. emitComments: boolean;
  102274. }
  102275. /**
  102276. * Class used to create a node based material built by assembling shader blocks
  102277. */
  102278. export class NodeMaterial extends PushMaterial {
  102279. private static _BuildIdGenerator;
  102280. private _options;
  102281. private _vertexCompilationState;
  102282. private _fragmentCompilationState;
  102283. private _sharedData;
  102284. private _buildId;
  102285. private _buildWasSuccessful;
  102286. private _cachedWorldViewMatrix;
  102287. private _cachedWorldViewProjectionMatrix;
  102288. private _optimizers;
  102289. private _animationFrame;
  102290. /** Define the Url to load node editor script */
  102291. static EditorURL: string;
  102292. /** Define the Url to load snippets */
  102293. static SnippetUrl: string;
  102294. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102295. static IgnoreTexturesAtLoadTime: boolean;
  102296. private BJSNODEMATERIALEDITOR;
  102297. /** Get the inspector from bundle or global */
  102298. private _getGlobalNodeMaterialEditor;
  102299. /**
  102300. * Snippet ID if the material was created from the snippet server
  102301. */
  102302. snippetId: string;
  102303. /**
  102304. * Gets or sets data used by visual editor
  102305. * @see https://nme.babylonjs.com
  102306. */
  102307. editorData: any;
  102308. /**
  102309. * 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)
  102310. */
  102311. ignoreAlpha: boolean;
  102312. /**
  102313. * Defines the maximum number of lights that can be used in the material
  102314. */
  102315. maxSimultaneousLights: number;
  102316. /**
  102317. * Observable raised when the material is built
  102318. */
  102319. onBuildObservable: Observable<NodeMaterial>;
  102320. /**
  102321. * Gets or sets the root nodes of the material vertex shader
  102322. */
  102323. _vertexOutputNodes: NodeMaterialBlock[];
  102324. /**
  102325. * Gets or sets the root nodes of the material fragment (pixel) shader
  102326. */
  102327. _fragmentOutputNodes: NodeMaterialBlock[];
  102328. /** Gets or sets options to control the node material overall behavior */
  102329. get options(): INodeMaterialOptions;
  102330. set options(options: INodeMaterialOptions);
  102331. /**
  102332. * Default configuration related to image processing available in the standard Material.
  102333. */
  102334. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102335. /**
  102336. * Gets the image processing configuration used either in this material.
  102337. */
  102338. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102339. /**
  102340. * Sets the Default image processing configuration used either in the this material.
  102341. *
  102342. * If sets to null, the scene one is in use.
  102343. */
  102344. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102345. /**
  102346. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102347. */
  102348. attachedBlocks: NodeMaterialBlock[];
  102349. /**
  102350. * Specifies the mode of the node material
  102351. * @hidden
  102352. */
  102353. _mode: NodeMaterialModes;
  102354. /**
  102355. * Gets the mode property
  102356. */
  102357. get mode(): NodeMaterialModes;
  102358. /**
  102359. * Create a new node based material
  102360. * @param name defines the material name
  102361. * @param scene defines the hosting scene
  102362. * @param options defines creation option
  102363. */
  102364. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102365. /**
  102366. * Gets the current class name of the material e.g. "NodeMaterial"
  102367. * @returns the class name
  102368. */
  102369. getClassName(): string;
  102370. /**
  102371. * Keep track of the image processing observer to allow dispose and replace.
  102372. */
  102373. private _imageProcessingObserver;
  102374. /**
  102375. * Attaches a new image processing configuration to the Standard Material.
  102376. * @param configuration
  102377. */
  102378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102379. /**
  102380. * Get a block by its name
  102381. * @param name defines the name of the block to retrieve
  102382. * @returns the required block or null if not found
  102383. */
  102384. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102385. /**
  102386. * Get a block by its name
  102387. * @param predicate defines the predicate used to find the good candidate
  102388. * @returns the required block or null if not found
  102389. */
  102390. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102391. /**
  102392. * Get an input block by its name
  102393. * @param predicate defines the predicate used to find the good candidate
  102394. * @returns the required input block or null if not found
  102395. */
  102396. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102397. /**
  102398. * Gets the list of input blocks attached to this material
  102399. * @returns an array of InputBlocks
  102400. */
  102401. getInputBlocks(): InputBlock[];
  102402. /**
  102403. * Adds a new optimizer to the list of optimizers
  102404. * @param optimizer defines the optimizers to add
  102405. * @returns the current material
  102406. */
  102407. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102408. /**
  102409. * Remove an optimizer from the list of optimizers
  102410. * @param optimizer defines the optimizers to remove
  102411. * @returns the current material
  102412. */
  102413. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102414. /**
  102415. * Add a new block to the list of output nodes
  102416. * @param node defines the node to add
  102417. * @returns the current material
  102418. */
  102419. addOutputNode(node: NodeMaterialBlock): this;
  102420. /**
  102421. * Remove a block from the list of root nodes
  102422. * @param node defines the node to remove
  102423. * @returns the current material
  102424. */
  102425. removeOutputNode(node: NodeMaterialBlock): this;
  102426. private _addVertexOutputNode;
  102427. private _removeVertexOutputNode;
  102428. private _addFragmentOutputNode;
  102429. private _removeFragmentOutputNode;
  102430. /**
  102431. * Specifies if the material will require alpha blending
  102432. * @returns a boolean specifying if alpha blending is needed
  102433. */
  102434. needAlphaBlending(): boolean;
  102435. /**
  102436. * Specifies if this material should be rendered in alpha test mode
  102437. * @returns a boolean specifying if an alpha test is needed.
  102438. */
  102439. needAlphaTesting(): boolean;
  102440. private _initializeBlock;
  102441. private _resetDualBlocks;
  102442. /**
  102443. * Remove a block from the current node material
  102444. * @param block defines the block to remove
  102445. */
  102446. removeBlock(block: NodeMaterialBlock): void;
  102447. /**
  102448. * Build the material and generates the inner effect
  102449. * @param verbose defines if the build should log activity
  102450. */
  102451. build(verbose?: boolean): void;
  102452. /**
  102453. * Runs an otpimization phase to try to improve the shader code
  102454. */
  102455. optimize(): void;
  102456. private _prepareDefinesForAttributes;
  102457. /**
  102458. * Create a post process from the material
  102459. * @param camera The camera to apply the render pass to.
  102460. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102461. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102462. * @param engine The engine which the post process will be applied. (default: current engine)
  102463. * @param reusable If the post process can be reused on the same frame. (default: false)
  102464. * @param textureType Type of textures used when performing the post process. (default: 0)
  102465. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102466. * @returns the post process created
  102467. */
  102468. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102469. /**
  102470. * Create the post process effect from the material
  102471. * @param postProcess The post process to create the effect for
  102472. */
  102473. createEffectForPostProcess(postProcess: PostProcess): void;
  102474. private _createEffectForPostProcess;
  102475. /**
  102476. * Create a new procedural texture based on this node material
  102477. * @param size defines the size of the texture
  102478. * @param scene defines the hosting scene
  102479. * @returns the new procedural texture attached to this node material
  102480. */
  102481. createProceduralTexture(size: number | {
  102482. width: number;
  102483. height: number;
  102484. layers?: number;
  102485. }, scene: Scene): Nullable<ProceduralTexture>;
  102486. private _createEffectForParticles;
  102487. private _checkInternals;
  102488. /**
  102489. * Create the effect to be used as the custom effect for a particle system
  102490. * @param particleSystem Particle system to create the effect for
  102491. * @param onCompiled defines a function to call when the effect creation is successful
  102492. * @param onError defines a function to call when the effect creation has failed
  102493. */
  102494. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102495. private _processDefines;
  102496. /**
  102497. * Get if the submesh is ready to be used and all its information available.
  102498. * Child classes can use it to update shaders
  102499. * @param mesh defines the mesh to check
  102500. * @param subMesh defines which submesh to check
  102501. * @param useInstances specifies that instances should be used
  102502. * @returns a boolean indicating that the submesh is ready or not
  102503. */
  102504. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102505. /**
  102506. * Get a string representing the shaders built by the current node graph
  102507. */
  102508. get compiledShaders(): string;
  102509. /**
  102510. * Binds the world matrix to the material
  102511. * @param world defines the world transformation matrix
  102512. */
  102513. bindOnlyWorldMatrix(world: Matrix): void;
  102514. /**
  102515. * Binds the submesh to this material by preparing the effect and shader to draw
  102516. * @param world defines the world transformation matrix
  102517. * @param mesh defines the mesh containing the submesh
  102518. * @param subMesh defines the submesh to bind the material to
  102519. */
  102520. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102521. /**
  102522. * Gets the active textures from the material
  102523. * @returns an array of textures
  102524. */
  102525. getActiveTextures(): BaseTexture[];
  102526. /**
  102527. * Gets the list of texture blocks
  102528. * @returns an array of texture blocks
  102529. */
  102530. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102531. /**
  102532. * Specifies if the material uses a texture
  102533. * @param texture defines the texture to check against the material
  102534. * @returns a boolean specifying if the material uses the texture
  102535. */
  102536. hasTexture(texture: BaseTexture): boolean;
  102537. /**
  102538. * Disposes the material
  102539. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102540. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102541. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102542. */
  102543. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102544. /** Creates the node editor window. */
  102545. private _createNodeEditor;
  102546. /**
  102547. * Launch the node material editor
  102548. * @param config Define the configuration of the editor
  102549. * @return a promise fulfilled when the node editor is visible
  102550. */
  102551. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102552. /**
  102553. * Clear the current material
  102554. */
  102555. clear(): void;
  102556. /**
  102557. * Clear the current material and set it to a default state
  102558. */
  102559. setToDefault(): void;
  102560. /**
  102561. * Clear the current material and set it to a default state for post process
  102562. */
  102563. setToDefaultPostProcess(): void;
  102564. /**
  102565. * Clear the current material and set it to a default state for procedural texture
  102566. */
  102567. setToDefaultProceduralTexture(): void;
  102568. /**
  102569. * Clear the current material and set it to a default state for particle
  102570. */
  102571. setToDefaultParticle(): void;
  102572. /**
  102573. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102574. * @param url defines the url to load from
  102575. * @returns a promise that will fullfil when the material is fully loaded
  102576. */
  102577. loadAsync(url: string): Promise<void>;
  102578. private _gatherBlocks;
  102579. /**
  102580. * Generate a string containing the code declaration required to create an equivalent of this material
  102581. * @returns a string
  102582. */
  102583. generateCode(): string;
  102584. /**
  102585. * Serializes this material in a JSON representation
  102586. * @returns the serialized material object
  102587. */
  102588. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102589. private _restoreConnections;
  102590. /**
  102591. * Clear the current graph and load a new one from a serialization object
  102592. * @param source defines the JSON representation of the material
  102593. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102594. * @param merge defines whether or not the source must be merged or replace the current content
  102595. */
  102596. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102597. /**
  102598. * Makes a duplicate of the current material.
  102599. * @param name - name to use for the new material.
  102600. */
  102601. clone(name: string): NodeMaterial;
  102602. /**
  102603. * Creates a node material from parsed material data
  102604. * @param source defines the JSON representation of the material
  102605. * @param scene defines the hosting scene
  102606. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102607. * @returns a new node material
  102608. */
  102609. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102610. /**
  102611. * Creates a node material from a snippet saved in a remote file
  102612. * @param name defines the name of the material to create
  102613. * @param url defines the url to load from
  102614. * @param scene defines the hosting scene
  102615. * @returns a promise that will resolve to the new node material
  102616. */
  102617. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102618. /**
  102619. * Creates a node material from a snippet saved by the node material editor
  102620. * @param snippetId defines the snippet to load
  102621. * @param scene defines the hosting scene
  102622. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102623. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102624. * @returns a promise that will resolve to the new node material
  102625. */
  102626. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102627. /**
  102628. * Creates a new node material set to default basic configuration
  102629. * @param name defines the name of the material
  102630. * @param scene defines the hosting scene
  102631. * @returns a new NodeMaterial
  102632. */
  102633. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102634. }
  102635. }
  102636. declare module BABYLON {
  102637. /**
  102638. * Size options for a post process
  102639. */
  102640. export type PostProcessOptions = {
  102641. width: number;
  102642. height: number;
  102643. };
  102644. /**
  102645. * PostProcess can be used to apply a shader to a texture after it has been rendered
  102646. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102647. */
  102648. export class PostProcess {
  102649. /**
  102650. * Gets or sets the unique id of the post process
  102651. */
  102652. uniqueId: number;
  102653. /** Name of the PostProcess. */
  102654. name: string;
  102655. /**
  102656. * Width of the texture to apply the post process on
  102657. */
  102658. width: number;
  102659. /**
  102660. * Height of the texture to apply the post process on
  102661. */
  102662. height: number;
  102663. /**
  102664. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  102665. */
  102666. nodeMaterialSource: Nullable<NodeMaterial>;
  102667. /**
  102668. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  102669. * @hidden
  102670. */
  102671. _outputTexture: Nullable<InternalTexture>;
  102672. /**
  102673. * Sampling mode used by the shader
  102674. * See https://doc.babylonjs.com/classes/3.1/texture
  102675. */
  102676. renderTargetSamplingMode: number;
  102677. /**
  102678. * Clear color to use when screen clearing
  102679. */
  102680. clearColor: Color4;
  102681. /**
  102682. * If the buffer needs to be cleared before applying the post process. (default: true)
  102683. * Should be set to false if shader will overwrite all previous pixels.
  102684. */
  102685. autoClear: boolean;
  102686. /**
  102687. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  102688. */
  102689. alphaMode: number;
  102690. /**
  102691. * Sets the setAlphaBlendConstants of the babylon engine
  102692. */
  102693. alphaConstants: Color4;
  102694. /**
  102695. * Animations to be used for the post processing
  102696. */
  102697. animations: Animation[];
  102698. /**
  102699. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  102700. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  102701. */
  102702. enablePixelPerfectMode: boolean;
  102703. /**
  102704. * Force the postprocess to be applied without taking in account viewport
  102705. */
  102706. forceFullscreenViewport: boolean;
  102707. /**
  102708. * List of inspectable custom properties (used by the Inspector)
  102709. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102710. */
  102711. inspectableCustomProperties: IInspectable[];
  102712. /**
  102713. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  102714. *
  102715. * | Value | Type | Description |
  102716. * | ----- | ----------------------------------- | ----------- |
  102717. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  102718. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  102719. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  102720. *
  102721. */
  102722. scaleMode: number;
  102723. /**
  102724. * Force textures to be a power of two (default: false)
  102725. */
  102726. alwaysForcePOT: boolean;
  102727. private _samples;
  102728. /**
  102729. * Number of sample textures (default: 1)
  102730. */
  102731. get samples(): number;
  102732. set samples(n: number);
  102733. /**
  102734. * Modify the scale of the post process to be the same as the viewport (default: false)
  102735. */
  102736. adaptScaleToCurrentViewport: boolean;
  102737. private _camera;
  102738. protected _scene: Scene;
  102739. private _engine;
  102740. private _options;
  102741. private _reusable;
  102742. private _textureType;
  102743. private _textureFormat;
  102744. /**
  102745. * Smart array of input and output textures for the post process.
  102746. * @hidden
  102747. */
  102748. _textures: SmartArray<InternalTexture>;
  102749. /**
  102750. * The index in _textures that corresponds to the output texture.
  102751. * @hidden
  102752. */
  102753. _currentRenderTextureInd: number;
  102754. private _effect;
  102755. private _samplers;
  102756. private _fragmentUrl;
  102757. private _vertexUrl;
  102758. private _parameters;
  102759. private _scaleRatio;
  102760. protected _indexParameters: any;
  102761. private _shareOutputWithPostProcess;
  102762. private _texelSize;
  102763. private _forcedOutputTexture;
  102764. /**
  102765. * Returns the fragment url or shader name used in the post process.
  102766. * @returns the fragment url or name in the shader store.
  102767. */
  102768. getEffectName(): string;
  102769. /**
  102770. * An event triggered when the postprocess is activated.
  102771. */
  102772. onActivateObservable: Observable<Camera>;
  102773. private _onActivateObserver;
  102774. /**
  102775. * A function that is added to the onActivateObservable
  102776. */
  102777. set onActivate(callback: Nullable<(camera: Camera) => void>);
  102778. /**
  102779. * An event triggered when the postprocess changes its size.
  102780. */
  102781. onSizeChangedObservable: Observable<PostProcess>;
  102782. private _onSizeChangedObserver;
  102783. /**
  102784. * A function that is added to the onSizeChangedObservable
  102785. */
  102786. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  102787. /**
  102788. * An event triggered when the postprocess applies its effect.
  102789. */
  102790. onApplyObservable: Observable<Effect>;
  102791. private _onApplyObserver;
  102792. /**
  102793. * A function that is added to the onApplyObservable
  102794. */
  102795. set onApply(callback: (effect: Effect) => void);
  102796. /**
  102797. * An event triggered before rendering the postprocess
  102798. */
  102799. onBeforeRenderObservable: Observable<Effect>;
  102800. private _onBeforeRenderObserver;
  102801. /**
  102802. * A function that is added to the onBeforeRenderObservable
  102803. */
  102804. set onBeforeRender(callback: (effect: Effect) => void);
  102805. /**
  102806. * An event triggered after rendering the postprocess
  102807. */
  102808. onAfterRenderObservable: Observable<Effect>;
  102809. private _onAfterRenderObserver;
  102810. /**
  102811. * A function that is added to the onAfterRenderObservable
  102812. */
  102813. set onAfterRender(callback: (efect: Effect) => void);
  102814. /**
  102815. * 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
  102816. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  102817. */
  102818. get inputTexture(): InternalTexture;
  102819. set inputTexture(value: InternalTexture);
  102820. /**
  102821. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  102822. * the only way to unset it is to use this function to restore its internal state
  102823. */
  102824. restoreDefaultInputTexture(): void;
  102825. /**
  102826. * Gets the camera which post process is applied to.
  102827. * @returns The camera the post process is applied to.
  102828. */
  102829. getCamera(): Camera;
  102830. /**
  102831. * Gets the texel size of the postprocess.
  102832. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  102833. */
  102834. get texelSize(): Vector2;
  102835. /**
  102836. * Creates a new instance PostProcess
  102837. * @param name The name of the PostProcess.
  102838. * @param fragmentUrl The url of the fragment shader to be used.
  102839. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  102840. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  102841. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102842. * @param camera The camera to apply the render pass to.
  102843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102844. * @param engine The engine which the post process will be applied. (default: current engine)
  102845. * @param reusable If the post process can be reused on the same frame. (default: false)
  102846. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  102847. * @param textureType Type of textures used when performing the post process. (default: 0)
  102848. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  102849. * @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
  102850. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  102851. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102852. */
  102853. 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);
  102854. /**
  102855. * Gets a string identifying the name of the class
  102856. * @returns "PostProcess" string
  102857. */
  102858. getClassName(): string;
  102859. /**
  102860. * Gets the engine which this post process belongs to.
  102861. * @returns The engine the post process was enabled with.
  102862. */
  102863. getEngine(): Engine;
  102864. /**
  102865. * The effect that is created when initializing the post process.
  102866. * @returns The created effect corresponding the the postprocess.
  102867. */
  102868. getEffect(): Effect;
  102869. /**
  102870. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  102871. * @param postProcess The post process to share the output with.
  102872. * @returns This post process.
  102873. */
  102874. shareOutputWith(postProcess: PostProcess): PostProcess;
  102875. /**
  102876. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  102877. * This should be called if the post process that shares output with this post process is disabled/disposed.
  102878. */
  102879. useOwnOutput(): void;
  102880. /**
  102881. * Updates the effect with the current post process compile time values and recompiles the shader.
  102882. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102883. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102884. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102885. * @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
  102886. * @param onCompiled Called when the shader has been compiled.
  102887. * @param onError Called if there is an error when compiling a shader.
  102888. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  102889. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  102890. */
  102891. 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;
  102892. /**
  102893. * The post process is reusable if it can be used multiple times within one frame.
  102894. * @returns If the post process is reusable
  102895. */
  102896. isReusable(): boolean;
  102897. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  102898. markTextureDirty(): void;
  102899. /**
  102900. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  102901. * 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.
  102902. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  102903. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  102904. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  102905. * @returns The target texture that was bound to be written to.
  102906. */
  102907. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  102908. /**
  102909. * If the post process is supported.
  102910. */
  102911. get isSupported(): boolean;
  102912. /**
  102913. * The aspect ratio of the output texture.
  102914. */
  102915. get aspectRatio(): number;
  102916. /**
  102917. * Get a value indicating if the post-process is ready to be used
  102918. * @returns true if the post-process is ready (shader is compiled)
  102919. */
  102920. isReady(): boolean;
  102921. /**
  102922. * Binds all textures and uniforms to the shader, this will be run on every pass.
  102923. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  102924. */
  102925. apply(): Nullable<Effect>;
  102926. private _disposeTextures;
  102927. /**
  102928. * Disposes the post process.
  102929. * @param camera The camera to dispose the post process on.
  102930. */
  102931. dispose(camera?: Camera): void;
  102932. /**
  102933. * Serializes the particle system to a JSON object
  102934. * @returns the JSON object
  102935. */
  102936. serialize(): any;
  102937. /**
  102938. * Creates a material from parsed material data
  102939. * @param parsedPostProcess defines parsed post process data
  102940. * @param scene defines the hosting scene
  102941. * @param rootUrl defines the root URL to use to load textures
  102942. * @returns a new post process
  102943. */
  102944. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  102945. }
  102946. }
  102947. declare module BABYLON {
  102948. /** @hidden */
  102949. export var kernelBlurVaryingDeclaration: {
  102950. name: string;
  102951. shader: string;
  102952. };
  102953. }
  102954. declare module BABYLON {
  102955. /** @hidden */
  102956. export var kernelBlurFragment: {
  102957. name: string;
  102958. shader: string;
  102959. };
  102960. }
  102961. declare module BABYLON {
  102962. /** @hidden */
  102963. export var kernelBlurFragment2: {
  102964. name: string;
  102965. shader: string;
  102966. };
  102967. }
  102968. declare module BABYLON {
  102969. /** @hidden */
  102970. export var kernelBlurPixelShader: {
  102971. name: string;
  102972. shader: string;
  102973. };
  102974. }
  102975. declare module BABYLON {
  102976. /** @hidden */
  102977. export var kernelBlurVertex: {
  102978. name: string;
  102979. shader: string;
  102980. };
  102981. }
  102982. declare module BABYLON {
  102983. /** @hidden */
  102984. export var kernelBlurVertexShader: {
  102985. name: string;
  102986. shader: string;
  102987. };
  102988. }
  102989. declare module BABYLON {
  102990. /**
  102991. * The Blur Post Process which blurs an image based on a kernel and direction.
  102992. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  102993. */
  102994. export class BlurPostProcess extends PostProcess {
  102995. private blockCompilation;
  102996. protected _kernel: number;
  102997. protected _idealKernel: number;
  102998. protected _packedFloat: boolean;
  102999. private _staticDefines;
  103000. /** The direction in which to blur the image. */
  103001. direction: Vector2;
  103002. /**
  103003. * Sets the length in pixels of the blur sample region
  103004. */
  103005. set kernel(v: number);
  103006. /**
  103007. * Gets the length in pixels of the blur sample region
  103008. */
  103009. get kernel(): number;
  103010. /**
  103011. * Sets wether or not the blur needs to unpack/repack floats
  103012. */
  103013. set packedFloat(v: boolean);
  103014. /**
  103015. * Gets wether or not the blur is unpacking/repacking floats
  103016. */
  103017. get packedFloat(): boolean;
  103018. /**
  103019. * Gets a string identifying the name of the class
  103020. * @returns "BlurPostProcess" string
  103021. */
  103022. getClassName(): string;
  103023. /**
  103024. * Creates a new instance BlurPostProcess
  103025. * @param name The name of the effect.
  103026. * @param direction The direction in which to blur the image.
  103027. * @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.
  103028. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103029. * @param camera The camera to apply the render pass to.
  103030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103031. * @param engine The engine which the post process will be applied. (default: current engine)
  103032. * @param reusable If the post process can be reused on the same frame. (default: false)
  103033. * @param textureType Type of textures used when performing the post process. (default: 0)
  103034. * @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)
  103035. */
  103036. 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);
  103037. /**
  103038. * Updates the effect with the current post process compile time values and recompiles the shader.
  103039. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103040. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103041. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103042. * @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
  103043. * @param onCompiled Called when the shader has been compiled.
  103044. * @param onError Called if there is an error when compiling a shader.
  103045. */
  103046. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103047. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103048. /**
  103049. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  103050. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  103051. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  103052. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  103053. * The gaps between physical kernels are compensated for in the weighting of the samples
  103054. * @param idealKernel Ideal blur kernel.
  103055. * @return Nearest best kernel.
  103056. */
  103057. protected _nearestBestKernel(idealKernel: number): number;
  103058. /**
  103059. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  103060. * @param x The point on the Gaussian distribution to sample.
  103061. * @return the value of the Gaussian function at x.
  103062. */
  103063. protected _gaussianWeight(x: number): number;
  103064. /**
  103065. * Generates a string that can be used as a floating point number in GLSL.
  103066. * @param x Value to print.
  103067. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  103068. * @return GLSL float string.
  103069. */
  103070. protected _glslFloat(x: number, decimalFigures?: number): string;
  103071. /** @hidden */
  103072. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  103073. }
  103074. }
  103075. declare module BABYLON {
  103076. /**
  103077. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103078. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103079. * You can then easily use it as a reflectionTexture on a flat surface.
  103080. * In case the surface is not a plane, please consider relying on reflection probes.
  103081. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103082. */
  103083. export class MirrorTexture extends RenderTargetTexture {
  103084. private scene;
  103085. /**
  103086. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  103087. * 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.
  103088. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103089. */
  103090. mirrorPlane: Plane;
  103091. /**
  103092. * Define the blur ratio used to blur the reflection if needed.
  103093. */
  103094. set blurRatio(value: number);
  103095. get blurRatio(): number;
  103096. /**
  103097. * Define the adaptive blur kernel used to blur the reflection if needed.
  103098. * This will autocompute the closest best match for the `blurKernel`
  103099. */
  103100. set adaptiveBlurKernel(value: number);
  103101. /**
  103102. * Define the blur kernel used to blur the reflection if needed.
  103103. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103104. */
  103105. set blurKernel(value: number);
  103106. /**
  103107. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  103108. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103109. */
  103110. set blurKernelX(value: number);
  103111. get blurKernelX(): number;
  103112. /**
  103113. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  103114. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103115. */
  103116. set blurKernelY(value: number);
  103117. get blurKernelY(): number;
  103118. private _autoComputeBlurKernel;
  103119. protected _onRatioRescale(): void;
  103120. private _updateGammaSpace;
  103121. private _imageProcessingConfigChangeObserver;
  103122. private _transformMatrix;
  103123. private _mirrorMatrix;
  103124. private _savedViewMatrix;
  103125. private _blurX;
  103126. private _blurY;
  103127. private _adaptiveBlurKernel;
  103128. private _blurKernelX;
  103129. private _blurKernelY;
  103130. private _blurRatio;
  103131. /**
  103132. * Instantiates a Mirror Texture.
  103133. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103134. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103135. * You can then easily use it as a reflectionTexture on a flat surface.
  103136. * In case the surface is not a plane, please consider relying on reflection probes.
  103137. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103138. * @param name
  103139. * @param size
  103140. * @param scene
  103141. * @param generateMipMaps
  103142. * @param type
  103143. * @param samplingMode
  103144. * @param generateDepthBuffer
  103145. */
  103146. constructor(name: string, size: number | {
  103147. width: number;
  103148. height: number;
  103149. } | {
  103150. ratio: number;
  103151. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103152. private _preparePostProcesses;
  103153. /**
  103154. * Clone the mirror texture.
  103155. * @returns the cloned texture
  103156. */
  103157. clone(): MirrorTexture;
  103158. /**
  103159. * Serialize the texture to a JSON representation you could use in Parse later on
  103160. * @returns the serialized JSON representation
  103161. */
  103162. serialize(): any;
  103163. /**
  103164. * Dispose the texture and release its associated resources.
  103165. */
  103166. dispose(): void;
  103167. }
  103168. }
  103169. declare module BABYLON {
  103170. /**
  103171. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103172. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103173. */
  103174. export class Texture extends BaseTexture {
  103175. /**
  103176. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103177. */
  103178. static SerializeBuffers: boolean;
  103179. /** @hidden */
  103180. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103181. /** @hidden */
  103182. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103183. /** @hidden */
  103184. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103185. /** nearest is mag = nearest and min = nearest and mip = linear */
  103186. static readonly NEAREST_SAMPLINGMODE: number;
  103187. /** nearest is mag = nearest and min = nearest and mip = linear */
  103188. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103189. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103190. static readonly BILINEAR_SAMPLINGMODE: number;
  103191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103192. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103193. /** Trilinear is mag = linear and min = linear and mip = linear */
  103194. static readonly TRILINEAR_SAMPLINGMODE: number;
  103195. /** Trilinear is mag = linear and min = linear and mip = linear */
  103196. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103197. /** mag = nearest and min = nearest and mip = nearest */
  103198. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103199. /** mag = nearest and min = linear and mip = nearest */
  103200. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103201. /** mag = nearest and min = linear and mip = linear */
  103202. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103203. /** mag = nearest and min = linear and mip = none */
  103204. static readonly NEAREST_LINEAR: number;
  103205. /** mag = nearest and min = nearest and mip = none */
  103206. static readonly NEAREST_NEAREST: number;
  103207. /** mag = linear and min = nearest and mip = nearest */
  103208. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103209. /** mag = linear and min = nearest and mip = linear */
  103210. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103211. /** mag = linear and min = linear and mip = none */
  103212. static readonly LINEAR_LINEAR: number;
  103213. /** mag = linear and min = nearest and mip = none */
  103214. static readonly LINEAR_NEAREST: number;
  103215. /** Explicit coordinates mode */
  103216. static readonly EXPLICIT_MODE: number;
  103217. /** Spherical coordinates mode */
  103218. static readonly SPHERICAL_MODE: number;
  103219. /** Planar coordinates mode */
  103220. static readonly PLANAR_MODE: number;
  103221. /** Cubic coordinates mode */
  103222. static readonly CUBIC_MODE: number;
  103223. /** Projection coordinates mode */
  103224. static readonly PROJECTION_MODE: number;
  103225. /** Inverse Cubic coordinates mode */
  103226. static readonly SKYBOX_MODE: number;
  103227. /** Inverse Cubic coordinates mode */
  103228. static readonly INVCUBIC_MODE: number;
  103229. /** Equirectangular coordinates mode */
  103230. static readonly EQUIRECTANGULAR_MODE: number;
  103231. /** Equirectangular Fixed coordinates mode */
  103232. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103233. /** Equirectangular Fixed Mirrored coordinates mode */
  103234. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103235. /** Texture is not repeating outside of 0..1 UVs */
  103236. static readonly CLAMP_ADDRESSMODE: number;
  103237. /** Texture is repeating outside of 0..1 UVs */
  103238. static readonly WRAP_ADDRESSMODE: number;
  103239. /** Texture is repeating and mirrored */
  103240. static readonly MIRROR_ADDRESSMODE: number;
  103241. /**
  103242. * 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
  103243. */
  103244. static UseSerializedUrlIfAny: boolean;
  103245. /**
  103246. * Define the url of the texture.
  103247. */
  103248. url: Nullable<string>;
  103249. /**
  103250. * Define an offset on the texture to offset the u coordinates of the UVs
  103251. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103252. */
  103253. uOffset: number;
  103254. /**
  103255. * Define an offset on the texture to offset the v coordinates of the UVs
  103256. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103257. */
  103258. vOffset: number;
  103259. /**
  103260. * Define an offset on the texture to scale the u coordinates of the UVs
  103261. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103262. */
  103263. uScale: number;
  103264. /**
  103265. * Define an offset on the texture to scale the v coordinates of the UVs
  103266. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103267. */
  103268. vScale: number;
  103269. /**
  103270. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103271. * @see https://doc.babylonjs.com/how_to/more_materials
  103272. */
  103273. uAng: number;
  103274. /**
  103275. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103276. * @see https://doc.babylonjs.com/how_to/more_materials
  103277. */
  103278. vAng: number;
  103279. /**
  103280. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103281. * @see https://doc.babylonjs.com/how_to/more_materials
  103282. */
  103283. wAng: number;
  103284. /**
  103285. * Defines the center of rotation (U)
  103286. */
  103287. uRotationCenter: number;
  103288. /**
  103289. * Defines the center of rotation (V)
  103290. */
  103291. vRotationCenter: number;
  103292. /**
  103293. * Defines the center of rotation (W)
  103294. */
  103295. wRotationCenter: number;
  103296. /**
  103297. * Are mip maps generated for this texture or not.
  103298. */
  103299. get noMipmap(): boolean;
  103300. /**
  103301. * List of inspectable custom properties (used by the Inspector)
  103302. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103303. */
  103304. inspectableCustomProperties: Nullable<IInspectable[]>;
  103305. private _noMipmap;
  103306. /** @hidden */
  103307. _invertY: boolean;
  103308. private _rowGenerationMatrix;
  103309. private _cachedTextureMatrix;
  103310. private _projectionModeMatrix;
  103311. private _t0;
  103312. private _t1;
  103313. private _t2;
  103314. private _cachedUOffset;
  103315. private _cachedVOffset;
  103316. private _cachedUScale;
  103317. private _cachedVScale;
  103318. private _cachedUAng;
  103319. private _cachedVAng;
  103320. private _cachedWAng;
  103321. private _cachedProjectionMatrixId;
  103322. private _cachedCoordinatesMode;
  103323. /** @hidden */
  103324. protected _initialSamplingMode: number;
  103325. /** @hidden */
  103326. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103327. private _deleteBuffer;
  103328. protected _format: Nullable<number>;
  103329. private _delayedOnLoad;
  103330. private _delayedOnError;
  103331. private _mimeType?;
  103332. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103333. get mimeType(): string | undefined;
  103334. /**
  103335. * Observable triggered once the texture has been loaded.
  103336. */
  103337. onLoadObservable: Observable<Texture>;
  103338. protected _isBlocking: boolean;
  103339. /**
  103340. * Is the texture preventing material to render while loading.
  103341. * If false, a default texture will be used instead of the loading one during the preparation step.
  103342. */
  103343. set isBlocking(value: boolean);
  103344. get isBlocking(): boolean;
  103345. /**
  103346. * Get the current sampling mode associated with the texture.
  103347. */
  103348. get samplingMode(): number;
  103349. /**
  103350. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103351. */
  103352. get invertY(): boolean;
  103353. /**
  103354. * Instantiates a new texture.
  103355. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103356. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103357. * @param url defines the url of the picture to load as a texture
  103358. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103359. * @param noMipmap defines if the texture will require mip maps or not
  103360. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103361. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103362. * @param onLoad defines a callback triggered when the texture has been loaded
  103363. * @param onError defines a callback triggered when an error occurred during the loading session
  103364. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103365. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103366. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103367. * @param mimeType defines an optional mime type information
  103368. */
  103369. 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);
  103370. /**
  103371. * Update the url (and optional buffer) of this texture if url was null during construction.
  103372. * @param url the url of the texture
  103373. * @param buffer the buffer of the texture (defaults to null)
  103374. * @param onLoad callback called when the texture is loaded (defaults to null)
  103375. */
  103376. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103377. /**
  103378. * Finish the loading sequence of a texture flagged as delayed load.
  103379. * @hidden
  103380. */
  103381. delayLoad(): void;
  103382. private _prepareRowForTextureGeneration;
  103383. /**
  103384. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103385. * @returns the transform matrix of the texture.
  103386. */
  103387. getTextureMatrix(uBase?: number): Matrix;
  103388. /**
  103389. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103390. * @returns The reflection texture transform
  103391. */
  103392. getReflectionTextureMatrix(): Matrix;
  103393. /**
  103394. * Clones the texture.
  103395. * @returns the cloned texture
  103396. */
  103397. clone(): Texture;
  103398. /**
  103399. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103400. * @returns The JSON representation of the texture
  103401. */
  103402. serialize(): any;
  103403. /**
  103404. * Get the current class name of the texture useful for serialization or dynamic coding.
  103405. * @returns "Texture"
  103406. */
  103407. getClassName(): string;
  103408. /**
  103409. * Dispose the texture and release its associated resources.
  103410. */
  103411. dispose(): void;
  103412. /**
  103413. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103414. * @param parsedTexture Define the JSON representation of the texture
  103415. * @param scene Define the scene the parsed texture should be instantiated in
  103416. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103417. * @returns The parsed texture if successful
  103418. */
  103419. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103420. /**
  103421. * Creates a texture from its base 64 representation.
  103422. * @param data Define the base64 payload without the data: prefix
  103423. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103424. * @param scene Define the scene the texture should belong to
  103425. * @param noMipmap Forces the texture to not create mip map information if true
  103426. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103427. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103428. * @param onLoad define a callback triggered when the texture has been loaded
  103429. * @param onError define a callback triggered when an error occurred during the loading session
  103430. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103431. * @returns the created texture
  103432. */
  103433. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103434. /**
  103435. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103436. * @param data Define the base64 payload without the data: prefix
  103437. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103438. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103439. * @param scene Define the scene the texture should belong to
  103440. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103441. * @param noMipmap Forces the texture to not create mip map information if true
  103442. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103443. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103444. * @param onLoad define a callback triggered when the texture has been loaded
  103445. * @param onError define a callback triggered when an error occurred during the loading session
  103446. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103447. * @returns the created texture
  103448. */
  103449. 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;
  103450. }
  103451. }
  103452. declare module BABYLON {
  103453. /**
  103454. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103455. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103456. */
  103457. export class PostProcessManager {
  103458. private _scene;
  103459. private _indexBuffer;
  103460. private _vertexBuffers;
  103461. /**
  103462. * Creates a new instance PostProcess
  103463. * @param scene The scene that the post process is associated with.
  103464. */
  103465. constructor(scene: Scene);
  103466. private _prepareBuffers;
  103467. private _buildIndexBuffer;
  103468. /**
  103469. * Rebuilds the vertex buffers of the manager.
  103470. * @hidden
  103471. */
  103472. _rebuild(): void;
  103473. /**
  103474. * Prepares a frame to be run through a post process.
  103475. * @param sourceTexture The input texture to the post procesess. (default: null)
  103476. * @param postProcesses An array of post processes to be run. (default: null)
  103477. * @returns True if the post processes were able to be run.
  103478. * @hidden
  103479. */
  103480. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103481. /**
  103482. * Manually render a set of post processes to a texture.
  103483. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103484. * @param postProcesses An array of post processes to be run.
  103485. * @param targetTexture The target texture to render to.
  103486. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103487. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103488. * @param lodLevel defines which lod of the texture to render to
  103489. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103490. */
  103491. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103492. /**
  103493. * Finalize the result of the output of the postprocesses.
  103494. * @param doNotPresent If true the result will not be displayed to the screen.
  103495. * @param targetTexture The target texture to render to.
  103496. * @param faceIndex The index of the face to bind the target texture to.
  103497. * @param postProcesses The array of post processes to render.
  103498. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103499. * @hidden
  103500. */
  103501. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103502. /**
  103503. * Disposes of the post process manager.
  103504. */
  103505. dispose(): void;
  103506. }
  103507. }
  103508. declare module BABYLON {
  103509. /**
  103510. * This Helps creating a texture that will be created from a camera in your scene.
  103511. * It is basically a dynamic texture that could be used to create special effects for instance.
  103512. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103513. */
  103514. export class RenderTargetTexture extends Texture {
  103515. /**
  103516. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103517. */
  103518. static readonly REFRESHRATE_RENDER_ONCE: number;
  103519. /**
  103520. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103521. */
  103522. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103523. /**
  103524. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103525. * the central point of your effect and can save a lot of performances.
  103526. */
  103527. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103528. /**
  103529. * Use this predicate to dynamically define the list of mesh you want to render.
  103530. * If set, the renderList property will be overwritten.
  103531. */
  103532. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103533. private _renderList;
  103534. /**
  103535. * Use this list to define the list of mesh you want to render.
  103536. */
  103537. get renderList(): Nullable<Array<AbstractMesh>>;
  103538. set renderList(value: Nullable<Array<AbstractMesh>>);
  103539. /**
  103540. * Use this function to overload the renderList array at rendering time.
  103541. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103542. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103543. * the cube (if the RTT is a cube, else layerOrFace=0).
  103544. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103545. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103546. * hold dummy elements!
  103547. */
  103548. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103549. private _hookArray;
  103550. /**
  103551. * Define if particles should be rendered in your texture.
  103552. */
  103553. renderParticles: boolean;
  103554. /**
  103555. * Define if sprites should be rendered in your texture.
  103556. */
  103557. renderSprites: boolean;
  103558. /**
  103559. * Define the camera used to render the texture.
  103560. */
  103561. activeCamera: Nullable<Camera>;
  103562. /**
  103563. * Override the mesh isReady function with your own one.
  103564. */
  103565. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103566. /**
  103567. * Override the render function of the texture with your own one.
  103568. */
  103569. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103570. /**
  103571. * Define if camera post processes should be use while rendering the texture.
  103572. */
  103573. useCameraPostProcesses: boolean;
  103574. /**
  103575. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103576. */
  103577. ignoreCameraViewport: boolean;
  103578. private _postProcessManager;
  103579. private _postProcesses;
  103580. private _resizeObserver;
  103581. /**
  103582. * An event triggered when the texture is unbind.
  103583. */
  103584. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103585. /**
  103586. * An event triggered when the texture is unbind.
  103587. */
  103588. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103589. private _onAfterUnbindObserver;
  103590. /**
  103591. * Set a after unbind callback in the texture.
  103592. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103593. */
  103594. set onAfterUnbind(callback: () => void);
  103595. /**
  103596. * An event triggered before rendering the texture
  103597. */
  103598. onBeforeRenderObservable: Observable<number>;
  103599. private _onBeforeRenderObserver;
  103600. /**
  103601. * Set a before render callback in the texture.
  103602. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  103603. */
  103604. set onBeforeRender(callback: (faceIndex: number) => void);
  103605. /**
  103606. * An event triggered after rendering the texture
  103607. */
  103608. onAfterRenderObservable: Observable<number>;
  103609. private _onAfterRenderObserver;
  103610. /**
  103611. * Set a after render callback in the texture.
  103612. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  103613. */
  103614. set onAfterRender(callback: (faceIndex: number) => void);
  103615. /**
  103616. * An event triggered after the texture clear
  103617. */
  103618. onClearObservable: Observable<Engine>;
  103619. private _onClearObserver;
  103620. /**
  103621. * Set a clear callback in the texture.
  103622. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  103623. */
  103624. set onClear(callback: (Engine: Engine) => void);
  103625. /**
  103626. * An event triggered when the texture is resized.
  103627. */
  103628. onResizeObservable: Observable<RenderTargetTexture>;
  103629. /**
  103630. * Define the clear color of the Render Target if it should be different from the scene.
  103631. */
  103632. clearColor: Color4;
  103633. protected _size: number | {
  103634. width: number;
  103635. height: number;
  103636. layers?: number;
  103637. };
  103638. protected _initialSizeParameter: number | {
  103639. width: number;
  103640. height: number;
  103641. } | {
  103642. ratio: number;
  103643. };
  103644. protected _sizeRatio: Nullable<number>;
  103645. /** @hidden */
  103646. _generateMipMaps: boolean;
  103647. protected _renderingManager: RenderingManager;
  103648. /** @hidden */
  103649. _waitingRenderList?: string[];
  103650. protected _doNotChangeAspectRatio: boolean;
  103651. protected _currentRefreshId: number;
  103652. protected _refreshRate: number;
  103653. protected _textureMatrix: Matrix;
  103654. protected _samples: number;
  103655. protected _renderTargetOptions: RenderTargetCreationOptions;
  103656. /**
  103657. * Gets render target creation options that were used.
  103658. */
  103659. get renderTargetOptions(): RenderTargetCreationOptions;
  103660. protected _onRatioRescale(): void;
  103661. /**
  103662. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  103663. * It must define where the camera used to render the texture is set
  103664. */
  103665. boundingBoxPosition: Vector3;
  103666. private _boundingBoxSize;
  103667. /**
  103668. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  103669. * When defined, the cubemap will switch to local mode
  103670. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103671. * @example https://www.babylonjs-playground.com/#RNASML
  103672. */
  103673. set boundingBoxSize(value: Vector3);
  103674. get boundingBoxSize(): Vector3;
  103675. /**
  103676. * In case the RTT has been created with a depth texture, get the associated
  103677. * depth texture.
  103678. * Otherwise, return null.
  103679. */
  103680. get depthStencilTexture(): Nullable<InternalTexture>;
  103681. /**
  103682. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  103683. * or used a shadow, depth texture...
  103684. * @param name The friendly name of the texture
  103685. * @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)
  103686. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  103687. * @param generateMipMaps True if mip maps need to be generated after render.
  103688. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  103689. * @param type The type of the buffer in the RTT (int, half float, float...)
  103690. * @param isCube True if a cube texture needs to be created
  103691. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  103692. * @param generateDepthBuffer True to generate a depth buffer
  103693. * @param generateStencilBuffer True to generate a stencil buffer
  103694. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  103695. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  103696. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103697. */
  103698. constructor(name: string, size: number | {
  103699. width: number;
  103700. height: number;
  103701. layers?: number;
  103702. } | {
  103703. ratio: number;
  103704. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  103705. /**
  103706. * Creates a depth stencil texture.
  103707. * This is only available in WebGL 2 or with the depth texture extension available.
  103708. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  103709. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  103710. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  103711. */
  103712. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  103713. private _processSizeParameter;
  103714. /**
  103715. * Define the number of samples to use in case of MSAA.
  103716. * It defaults to one meaning no MSAA has been enabled.
  103717. */
  103718. get samples(): number;
  103719. set samples(value: number);
  103720. /**
  103721. * Resets the refresh counter of the texture and start bak from scratch.
  103722. * Could be useful to regenerate the texture if it is setup to render only once.
  103723. */
  103724. resetRefreshCounter(): void;
  103725. /**
  103726. * Define the refresh rate of the texture or the rendering frequency.
  103727. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  103728. */
  103729. get refreshRate(): number;
  103730. set refreshRate(value: number);
  103731. /**
  103732. * Adds a post process to the render target rendering passes.
  103733. * @param postProcess define the post process to add
  103734. */
  103735. addPostProcess(postProcess: PostProcess): void;
  103736. /**
  103737. * Clear all the post processes attached to the render target
  103738. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  103739. */
  103740. clearPostProcesses(dispose?: boolean): void;
  103741. /**
  103742. * Remove one of the post process from the list of attached post processes to the texture
  103743. * @param postProcess define the post process to remove from the list
  103744. */
  103745. removePostProcess(postProcess: PostProcess): void;
  103746. /** @hidden */
  103747. _shouldRender(): boolean;
  103748. /**
  103749. * Gets the actual render size of the texture.
  103750. * @returns the width of the render size
  103751. */
  103752. getRenderSize(): number;
  103753. /**
  103754. * Gets the actual render width of the texture.
  103755. * @returns the width of the render size
  103756. */
  103757. getRenderWidth(): number;
  103758. /**
  103759. * Gets the actual render height of the texture.
  103760. * @returns the height of the render size
  103761. */
  103762. getRenderHeight(): number;
  103763. /**
  103764. * Gets the actual number of layers of the texture.
  103765. * @returns the number of layers
  103766. */
  103767. getRenderLayers(): number;
  103768. /**
  103769. * Get if the texture can be rescaled or not.
  103770. */
  103771. get canRescale(): boolean;
  103772. /**
  103773. * Resize the texture using a ratio.
  103774. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  103775. */
  103776. scale(ratio: number): void;
  103777. /**
  103778. * Get the texture reflection matrix used to rotate/transform the reflection.
  103779. * @returns the reflection matrix
  103780. */
  103781. getReflectionTextureMatrix(): Matrix;
  103782. /**
  103783. * Resize the texture to a new desired size.
  103784. * Be carrefull as it will recreate all the data in the new texture.
  103785. * @param size Define the new size. It can be:
  103786. * - a number for squared texture,
  103787. * - an object containing { width: number, height: number }
  103788. * - or an object containing a ratio { ratio: number }
  103789. */
  103790. resize(size: number | {
  103791. width: number;
  103792. height: number;
  103793. } | {
  103794. ratio: number;
  103795. }): void;
  103796. private _defaultRenderListPrepared;
  103797. /**
  103798. * Renders all the objects from the render list into the texture.
  103799. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  103800. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  103801. */
  103802. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  103803. private _bestReflectionRenderTargetDimension;
  103804. private _prepareRenderingManager;
  103805. /**
  103806. * @hidden
  103807. * @param faceIndex face index to bind to if this is a cubetexture
  103808. * @param layer defines the index of the texture to bind in the array
  103809. */
  103810. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  103811. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103812. private renderToTarget;
  103813. /**
  103814. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103815. * This allowed control for front to back rendering or reversly depending of the special needs.
  103816. *
  103817. * @param renderingGroupId The rendering group id corresponding to its index
  103818. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103819. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103820. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103821. */
  103822. 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;
  103823. /**
  103824. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103825. *
  103826. * @param renderingGroupId The rendering group id corresponding to its index
  103827. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103828. */
  103829. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103830. /**
  103831. * Clones the texture.
  103832. * @returns the cloned texture
  103833. */
  103834. clone(): RenderTargetTexture;
  103835. /**
  103836. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103837. * @returns The JSON representation of the texture
  103838. */
  103839. serialize(): any;
  103840. /**
  103841. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  103842. */
  103843. disposeFramebufferObjects(): void;
  103844. /**
  103845. * Dispose the texture and release its associated resources.
  103846. */
  103847. dispose(): void;
  103848. /** @hidden */
  103849. _rebuild(): void;
  103850. /**
  103851. * Clear the info related to rendering groups preventing retention point in material dispose.
  103852. */
  103853. freeRenderingGroups(): void;
  103854. /**
  103855. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  103856. * @returns the view count
  103857. */
  103858. getViewCount(): number;
  103859. }
  103860. }
  103861. declare module BABYLON {
  103862. /**
  103863. * Class used to manipulate GUIDs
  103864. */
  103865. export class GUID {
  103866. /**
  103867. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103868. * Be aware Math.random() could cause collisions, but:
  103869. * "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"
  103870. * @returns a pseudo random id
  103871. */
  103872. static RandomId(): string;
  103873. }
  103874. }
  103875. declare module BABYLON {
  103876. /**
  103877. * Options to be used when creating a shadow depth material
  103878. */
  103879. export interface IIOptionShadowDepthMaterial {
  103880. /** Variables in the vertex shader code that need to have their names remapped.
  103881. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  103882. * "var_name" should be either: worldPos or vNormalW
  103883. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  103884. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  103885. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  103886. */
  103887. remappedVariables?: string[];
  103888. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  103889. standalone?: boolean;
  103890. }
  103891. /**
  103892. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  103893. */
  103894. export class ShadowDepthWrapper {
  103895. private _scene;
  103896. private _options?;
  103897. private _baseMaterial;
  103898. private _onEffectCreatedObserver;
  103899. private _subMeshToEffect;
  103900. private _subMeshToDepthEffect;
  103901. private _meshes;
  103902. /** @hidden */
  103903. _matriceNames: any;
  103904. /** Gets the standalone status of the wrapper */
  103905. get standalone(): boolean;
  103906. /** Gets the base material the wrapper is built upon */
  103907. get baseMaterial(): Material;
  103908. /**
  103909. * Instantiate a new shadow depth wrapper.
  103910. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  103911. * generate the shadow depth map. For more information, please refer to the documentation:
  103912. * https://doc.babylonjs.com/babylon101/shadows
  103913. * @param baseMaterial Material to wrap
  103914. * @param scene Define the scene the material belongs to
  103915. * @param options Options used to create the wrapper
  103916. */
  103917. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  103918. /**
  103919. * Gets the effect to use to generate the depth map
  103920. * @param subMesh subMesh to get the effect for
  103921. * @param shadowGenerator shadow generator to get the effect for
  103922. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  103923. */
  103924. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  103925. /**
  103926. * Specifies that the submesh is ready to be used for depth rendering
  103927. * @param subMesh submesh to check
  103928. * @param defines the list of defines to take into account when checking the effect
  103929. * @param shadowGenerator combined with subMesh, it defines the effect to check
  103930. * @param useInstances specifies that instances should be used
  103931. * @returns a boolean indicating that the submesh is ready or not
  103932. */
  103933. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  103934. /**
  103935. * Disposes the resources
  103936. */
  103937. dispose(): void;
  103938. private _makeEffect;
  103939. }
  103940. }
  103941. declare module BABYLON {
  103942. interface ThinEngine {
  103943. /**
  103944. * Unbind a list of render target textures from the webGL context
  103945. * This is used only when drawBuffer extension or webGL2 are active
  103946. * @param textures defines the render target textures to unbind
  103947. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103948. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103949. */
  103950. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103951. /**
  103952. * Create a multi render target texture
  103953. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103954. * @param size defines the size of the texture
  103955. * @param options defines the creation options
  103956. * @returns the cube texture as an InternalTexture
  103957. */
  103958. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103959. /**
  103960. * Update the sample count for a given multiple render target texture
  103961. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103962. * @param textures defines the textures to update
  103963. * @param samples defines the sample count to set
  103964. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103965. */
  103966. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103967. /**
  103968. * Select a subsets of attachments to draw to.
  103969. * @param attachments gl attachments
  103970. */
  103971. bindAttachments(attachments: number[]): void;
  103972. }
  103973. }
  103974. declare module BABYLON {
  103975. /**
  103976. * Creation options of the multi render target texture.
  103977. */
  103978. export interface IMultiRenderTargetOptions {
  103979. /**
  103980. * Define if the texture needs to create mip maps after render.
  103981. */
  103982. generateMipMaps?: boolean;
  103983. /**
  103984. * Define the types of all the draw buffers we want to create
  103985. */
  103986. types?: number[];
  103987. /**
  103988. * Define the sampling modes of all the draw buffers we want to create
  103989. */
  103990. samplingModes?: number[];
  103991. /**
  103992. * Define if a depth buffer is required
  103993. */
  103994. generateDepthBuffer?: boolean;
  103995. /**
  103996. * Define if a stencil buffer is required
  103997. */
  103998. generateStencilBuffer?: boolean;
  103999. /**
  104000. * Define if a depth texture is required instead of a depth buffer
  104001. */
  104002. generateDepthTexture?: boolean;
  104003. /**
  104004. * Define the number of desired draw buffers
  104005. */
  104006. textureCount?: number;
  104007. /**
  104008. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104009. */
  104010. doNotChangeAspectRatio?: boolean;
  104011. /**
  104012. * Define the default type of the buffers we are creating
  104013. */
  104014. defaultType?: number;
  104015. }
  104016. /**
  104017. * A multi render target, like a render target provides the ability to render to a texture.
  104018. * Unlike the render target, it can render to several draw buffers in one draw.
  104019. * This is specially interesting in deferred rendering or for any effects requiring more than
  104020. * just one color from a single pass.
  104021. */
  104022. export class MultiRenderTarget extends RenderTargetTexture {
  104023. private _internalTextures;
  104024. private _textures;
  104025. private _multiRenderTargetOptions;
  104026. private _count;
  104027. /**
  104028. * Get if draw buffers are currently supported by the used hardware and browser.
  104029. */
  104030. get isSupported(): boolean;
  104031. /**
  104032. * Get the list of textures generated by the multi render target.
  104033. */
  104034. get textures(): Texture[];
  104035. /**
  104036. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104037. */
  104038. get count(): number;
  104039. /**
  104040. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104041. */
  104042. get depthTexture(): Texture;
  104043. /**
  104044. * Set the wrapping mode on U of all the textures we are rendering to.
  104045. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104046. */
  104047. set wrapU(wrap: number);
  104048. /**
  104049. * Set the wrapping mode on V of all the textures we are rendering to.
  104050. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104051. */
  104052. set wrapV(wrap: number);
  104053. /**
  104054. * Instantiate a new multi render target texture.
  104055. * A multi render target, like a render target provides the ability to render to a texture.
  104056. * Unlike the render target, it can render to several draw buffers in one draw.
  104057. * This is specially interesting in deferred rendering or for any effects requiring more than
  104058. * just one color from a single pass.
  104059. * @param name Define the name of the texture
  104060. * @param size Define the size of the buffers to render to
  104061. * @param count Define the number of target we are rendering into
  104062. * @param scene Define the scene the texture belongs to
  104063. * @param options Define the options used to create the multi render target
  104064. */
  104065. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104066. /** @hidden */
  104067. _rebuild(): void;
  104068. private _createInternalTextures;
  104069. private _createTextures;
  104070. /**
  104071. * Define the number of samples used if MSAA is enabled.
  104072. */
  104073. get samples(): number;
  104074. set samples(value: number);
  104075. /**
  104076. * Resize all the textures in the multi render target.
  104077. * Be carrefull as it will recreate all the data in the new texture.
  104078. * @param size Define the new size
  104079. */
  104080. resize(size: any): void;
  104081. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104082. /**
  104083. * Dispose the render targets and their associated resources
  104084. */
  104085. dispose(): void;
  104086. /**
  104087. * Release all the underlying texture used as draw buffers.
  104088. */
  104089. releaseInternalTextures(): void;
  104090. }
  104091. }
  104092. declare module BABYLON {
  104093. /** @hidden */
  104094. export var imageProcessingPixelShader: {
  104095. name: string;
  104096. shader: string;
  104097. };
  104098. }
  104099. declare module BABYLON {
  104100. /**
  104101. * ImageProcessingPostProcess
  104102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104103. */
  104104. export class ImageProcessingPostProcess extends PostProcess {
  104105. /**
  104106. * Default configuration related to image processing available in the PBR Material.
  104107. */
  104108. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104109. /**
  104110. * Gets the image processing configuration used either in this material.
  104111. */
  104112. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104113. /**
  104114. * Sets the Default image processing configuration used either in the this material.
  104115. *
  104116. * If sets to null, the scene one is in use.
  104117. */
  104118. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104119. /**
  104120. * Keep track of the image processing observer to allow dispose and replace.
  104121. */
  104122. private _imageProcessingObserver;
  104123. /**
  104124. * Attaches a new image processing configuration to the PBR Material.
  104125. * @param configuration
  104126. */
  104127. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104128. /**
  104129. * If the post process is supported.
  104130. */
  104131. get isSupported(): boolean;
  104132. /**
  104133. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104134. */
  104135. get colorCurves(): Nullable<ColorCurves>;
  104136. /**
  104137. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104138. */
  104139. set colorCurves(value: Nullable<ColorCurves>);
  104140. /**
  104141. * Gets wether the color curves effect is enabled.
  104142. */
  104143. get colorCurvesEnabled(): boolean;
  104144. /**
  104145. * Sets wether the color curves effect is enabled.
  104146. */
  104147. set colorCurvesEnabled(value: boolean);
  104148. /**
  104149. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104150. */
  104151. get colorGradingTexture(): Nullable<BaseTexture>;
  104152. /**
  104153. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104154. */
  104155. set colorGradingTexture(value: Nullable<BaseTexture>);
  104156. /**
  104157. * Gets wether the color grading effect is enabled.
  104158. */
  104159. get colorGradingEnabled(): boolean;
  104160. /**
  104161. * Gets wether the color grading effect is enabled.
  104162. */
  104163. set colorGradingEnabled(value: boolean);
  104164. /**
  104165. * Gets exposure used in the effect.
  104166. */
  104167. get exposure(): number;
  104168. /**
  104169. * Sets exposure used in the effect.
  104170. */
  104171. set exposure(value: number);
  104172. /**
  104173. * Gets wether tonemapping is enabled or not.
  104174. */
  104175. get toneMappingEnabled(): boolean;
  104176. /**
  104177. * Sets wether tonemapping is enabled or not
  104178. */
  104179. set toneMappingEnabled(value: boolean);
  104180. /**
  104181. * Gets the type of tone mapping effect.
  104182. */
  104183. get toneMappingType(): number;
  104184. /**
  104185. * Sets the type of tone mapping effect.
  104186. */
  104187. set toneMappingType(value: number);
  104188. /**
  104189. * Gets contrast used in the effect.
  104190. */
  104191. get contrast(): number;
  104192. /**
  104193. * Sets contrast used in the effect.
  104194. */
  104195. set contrast(value: number);
  104196. /**
  104197. * Gets Vignette stretch size.
  104198. */
  104199. get vignetteStretch(): number;
  104200. /**
  104201. * Sets Vignette stretch size.
  104202. */
  104203. set vignetteStretch(value: number);
  104204. /**
  104205. * Gets Vignette centre X Offset.
  104206. */
  104207. get vignetteCentreX(): number;
  104208. /**
  104209. * Sets Vignette centre X Offset.
  104210. */
  104211. set vignetteCentreX(value: number);
  104212. /**
  104213. * Gets Vignette centre Y Offset.
  104214. */
  104215. get vignetteCentreY(): number;
  104216. /**
  104217. * Sets Vignette centre Y Offset.
  104218. */
  104219. set vignetteCentreY(value: number);
  104220. /**
  104221. * Gets Vignette weight or intensity of the vignette effect.
  104222. */
  104223. get vignetteWeight(): number;
  104224. /**
  104225. * Sets Vignette weight or intensity of the vignette effect.
  104226. */
  104227. set vignetteWeight(value: number);
  104228. /**
  104229. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104230. * if vignetteEnabled is set to true.
  104231. */
  104232. get vignetteColor(): Color4;
  104233. /**
  104234. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104235. * if vignetteEnabled is set to true.
  104236. */
  104237. set vignetteColor(value: Color4);
  104238. /**
  104239. * Gets Camera field of view used by the Vignette effect.
  104240. */
  104241. get vignetteCameraFov(): number;
  104242. /**
  104243. * Sets Camera field of view used by the Vignette effect.
  104244. */
  104245. set vignetteCameraFov(value: number);
  104246. /**
  104247. * Gets the vignette blend mode allowing different kind of effect.
  104248. */
  104249. get vignetteBlendMode(): number;
  104250. /**
  104251. * Sets the vignette blend mode allowing different kind of effect.
  104252. */
  104253. set vignetteBlendMode(value: number);
  104254. /**
  104255. * Gets wether the vignette effect is enabled.
  104256. */
  104257. get vignetteEnabled(): boolean;
  104258. /**
  104259. * Sets wether the vignette effect is enabled.
  104260. */
  104261. set vignetteEnabled(value: boolean);
  104262. private _fromLinearSpace;
  104263. /**
  104264. * Gets wether the input of the processing is in Gamma or Linear Space.
  104265. */
  104266. get fromLinearSpace(): boolean;
  104267. /**
  104268. * Sets wether the input of the processing is in Gamma or Linear Space.
  104269. */
  104270. set fromLinearSpace(value: boolean);
  104271. /**
  104272. * Defines cache preventing GC.
  104273. */
  104274. private _defines;
  104275. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104276. /**
  104277. * "ImageProcessingPostProcess"
  104278. * @returns "ImageProcessingPostProcess"
  104279. */
  104280. getClassName(): string;
  104281. /**
  104282. * @hidden
  104283. */
  104284. _updateParameters(): void;
  104285. dispose(camera?: Camera): void;
  104286. }
  104287. }
  104288. declare module BABYLON {
  104289. /** @hidden */
  104290. export var fibonacci: {
  104291. name: string;
  104292. shader: string;
  104293. };
  104294. }
  104295. declare module BABYLON {
  104296. /** @hidden */
  104297. export var subSurfaceScatteringFunctions: {
  104298. name: string;
  104299. shader: string;
  104300. };
  104301. }
  104302. declare module BABYLON {
  104303. /** @hidden */
  104304. export var diffusionProfile: {
  104305. name: string;
  104306. shader: string;
  104307. };
  104308. }
  104309. declare module BABYLON {
  104310. /** @hidden */
  104311. export var subSurfaceScatteringPixelShader: {
  104312. name: string;
  104313. shader: string;
  104314. };
  104315. }
  104316. declare module BABYLON {
  104317. /**
  104318. * Sub surface scattering post process
  104319. */
  104320. export class SubSurfaceScatteringPostProcess extends PostProcess {
  104321. /**
  104322. * Gets a string identifying the name of the class
  104323. * @returns "SubSurfaceScatteringPostProcess" string
  104324. */
  104325. getClassName(): string;
  104326. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  104327. }
  104328. }
  104329. declare module BABYLON {
  104330. /**
  104331. * Interface for defining prepass effects in the prepass post-process pipeline
  104332. */
  104333. export interface PrePassEffectConfiguration {
  104334. /**
  104335. * Post process to attach for this effect
  104336. */
  104337. postProcess: PostProcess;
  104338. /**
  104339. * Is the effect enabled
  104340. */
  104341. enabled: boolean;
  104342. /**
  104343. * Disposes the effect configuration
  104344. */
  104345. dispose(): void;
  104346. /**
  104347. * Disposes the effect configuration
  104348. */
  104349. createPostProcess: () => PostProcess;
  104350. }
  104351. }
  104352. declare module BABYLON {
  104353. /**
  104354. * Contains all parameters needed for the prepass to perform
  104355. * screen space subsurface scattering
  104356. */
  104357. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  104358. private _ssDiffusionS;
  104359. private _ssFilterRadii;
  104360. private _ssDiffusionD;
  104361. /**
  104362. * Post process to attach for screen space subsurface scattering
  104363. */
  104364. postProcess: SubSurfaceScatteringPostProcess;
  104365. /**
  104366. * Diffusion profile color for subsurface scattering
  104367. */
  104368. get ssDiffusionS(): number[];
  104369. /**
  104370. * Diffusion profile max color channel value for subsurface scattering
  104371. */
  104372. get ssDiffusionD(): number[];
  104373. /**
  104374. * Diffusion profile filter radius for subsurface scattering
  104375. */
  104376. get ssFilterRadii(): number[];
  104377. /**
  104378. * Is subsurface enabled
  104379. */
  104380. enabled: boolean;
  104381. /**
  104382. * Diffusion profile colors for subsurface scattering
  104383. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  104384. * See ...
  104385. * Note that you can only store up to 5 of them
  104386. */
  104387. ssDiffusionProfileColors: Color3[];
  104388. /**
  104389. * Defines the ratio real world => scene units.
  104390. * Used for subsurface scattering
  104391. */
  104392. metersPerUnit: number;
  104393. private _scene;
  104394. /**
  104395. * Builds a subsurface configuration object
  104396. * @param scene The scene
  104397. */
  104398. constructor(scene: Scene);
  104399. /**
  104400. * Adds a new diffusion profile.
  104401. * Useful for more realistic subsurface scattering on diverse materials.
  104402. * @param color The color of the diffusion profile. Should be the average color of the material.
  104403. * @return The index of the diffusion profile for the material subsurface configuration
  104404. */
  104405. addDiffusionProfile(color: Color3): number;
  104406. /**
  104407. * Creates the sss post process
  104408. * @return The created post process
  104409. */
  104410. createPostProcess(): SubSurfaceScatteringPostProcess;
  104411. /**
  104412. * Deletes all diffusion profiles.
  104413. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  104414. */
  104415. clearAllDiffusionProfiles(): void;
  104416. /**
  104417. * Disposes this object
  104418. */
  104419. dispose(): void;
  104420. /**
  104421. * @hidden
  104422. * https://zero-radiance.github.io/post/sampling-diffusion/
  104423. *
  104424. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  104425. * ------------------------------------------------------------------------------------
  104426. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  104427. * PDF[r, phi, s] = r * R[r, phi, s]
  104428. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  104429. * ------------------------------------------------------------------------------------
  104430. * We importance sample the color channel with the widest scattering distance.
  104431. */
  104432. getDiffusionProfileParameters(color: Color3): number;
  104433. /**
  104434. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  104435. * 'u' is the random number (the value of the CDF): [0, 1).
  104436. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  104437. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  104438. */
  104439. private _sampleBurleyDiffusionProfile;
  104440. }
  104441. }
  104442. declare module BABYLON {
  104443. /**
  104444. * Renders a pre pass of the scene
  104445. * This means every mesh in the scene will be rendered to a render target texture
  104446. * And then this texture will be composited to the rendering canvas with post processes
  104447. * It is necessary for effects like subsurface scattering or deferred shading
  104448. */
  104449. export class PrePassRenderer {
  104450. /** @hidden */
  104451. static _SceneComponentInitialization: (scene: Scene) => void;
  104452. private _scene;
  104453. private _engine;
  104454. private _isDirty;
  104455. /**
  104456. * Number of textures in the multi render target texture where the scene is directly rendered
  104457. */
  104458. readonly mrtCount: number;
  104459. /**
  104460. * The render target where the scene is directly rendered
  104461. */
  104462. prePassRT: MultiRenderTarget;
  104463. private _mrtTypes;
  104464. private _multiRenderAttachments;
  104465. private _defaultAttachments;
  104466. private _clearAttachments;
  104467. private _postProcesses;
  104468. private readonly _clearColor;
  104469. /**
  104470. * Image processing post process for composition
  104471. */
  104472. imageProcessingPostProcess: ImageProcessingPostProcess;
  104473. /**
  104474. * Configuration for sub surface scattering post process
  104475. */
  104476. subSurfaceConfiguration: SubSurfaceConfiguration;
  104477. /**
  104478. * Should materials render their geometry on the MRT
  104479. */
  104480. materialsShouldRenderGeometry: boolean;
  104481. /**
  104482. * Should materials render the irradiance information on the MRT
  104483. */
  104484. materialsShouldRenderIrradiance: boolean;
  104485. private _enabled;
  104486. /**
  104487. * Indicates if the prepass is enabled
  104488. */
  104489. get enabled(): boolean;
  104490. /**
  104491. * How many samples are used for MSAA of the scene render target
  104492. */
  104493. get samples(): number;
  104494. set samples(n: number);
  104495. /**
  104496. * Instanciates a prepass renderer
  104497. * @param scene The scene
  104498. */
  104499. constructor(scene: Scene);
  104500. private _initializeAttachments;
  104501. private _createCompositionEffect;
  104502. /**
  104503. * Indicates if rendering a prepass is supported
  104504. */
  104505. get isSupported(): boolean;
  104506. /**
  104507. * Sets the proper output textures to draw in the engine.
  104508. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104509. */
  104510. bindAttachmentsForEffect(effect: Effect): void;
  104511. /**
  104512. * @hidden
  104513. */
  104514. _beforeCameraDraw(): void;
  104515. /**
  104516. * @hidden
  104517. */
  104518. _afterCameraDraw(): void;
  104519. private _checkRTSize;
  104520. private _bindFrameBuffer;
  104521. /**
  104522. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104523. */
  104524. clear(): void;
  104525. private _setState;
  104526. private _enable;
  104527. private _disable;
  104528. private _resetPostProcessChain;
  104529. private _bindPostProcessChain;
  104530. /**
  104531. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104532. */
  104533. markAsDirty(): void;
  104534. private _update;
  104535. /**
  104536. * Disposes the prepass renderer.
  104537. */
  104538. dispose(): void;
  104539. }
  104540. }
  104541. declare module BABYLON {
  104542. /**
  104543. * Options for compiling materials.
  104544. */
  104545. export interface IMaterialCompilationOptions {
  104546. /**
  104547. * Defines whether clip planes are enabled.
  104548. */
  104549. clipPlane: boolean;
  104550. /**
  104551. * Defines whether instances are enabled.
  104552. */
  104553. useInstances: boolean;
  104554. }
  104555. /**
  104556. * Options passed when calling customShaderNameResolve
  104557. */
  104558. export interface ICustomShaderNameResolveOptions {
  104559. /**
  104560. * 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
  104561. */
  104562. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104563. }
  104564. /**
  104565. * Base class for the main features of a material in Babylon.js
  104566. */
  104567. export class Material implements IAnimatable {
  104568. /**
  104569. * Returns the triangle fill mode
  104570. */
  104571. static readonly TriangleFillMode: number;
  104572. /**
  104573. * Returns the wireframe mode
  104574. */
  104575. static readonly WireFrameFillMode: number;
  104576. /**
  104577. * Returns the point fill mode
  104578. */
  104579. static readonly PointFillMode: number;
  104580. /**
  104581. * Returns the point list draw mode
  104582. */
  104583. static readonly PointListDrawMode: number;
  104584. /**
  104585. * Returns the line list draw mode
  104586. */
  104587. static readonly LineListDrawMode: number;
  104588. /**
  104589. * Returns the line loop draw mode
  104590. */
  104591. static readonly LineLoopDrawMode: number;
  104592. /**
  104593. * Returns the line strip draw mode
  104594. */
  104595. static readonly LineStripDrawMode: number;
  104596. /**
  104597. * Returns the triangle strip draw mode
  104598. */
  104599. static readonly TriangleStripDrawMode: number;
  104600. /**
  104601. * Returns the triangle fan draw mode
  104602. */
  104603. static readonly TriangleFanDrawMode: number;
  104604. /**
  104605. * Stores the clock-wise side orientation
  104606. */
  104607. static readonly ClockWiseSideOrientation: number;
  104608. /**
  104609. * Stores the counter clock-wise side orientation
  104610. */
  104611. static readonly CounterClockWiseSideOrientation: number;
  104612. /**
  104613. * The dirty texture flag value
  104614. */
  104615. static readonly TextureDirtyFlag: number;
  104616. /**
  104617. * The dirty light flag value
  104618. */
  104619. static readonly LightDirtyFlag: number;
  104620. /**
  104621. * The dirty fresnel flag value
  104622. */
  104623. static readonly FresnelDirtyFlag: number;
  104624. /**
  104625. * The dirty attribute flag value
  104626. */
  104627. static readonly AttributesDirtyFlag: number;
  104628. /**
  104629. * The dirty misc flag value
  104630. */
  104631. static readonly MiscDirtyFlag: number;
  104632. /**
  104633. * The all dirty flag value
  104634. */
  104635. static readonly AllDirtyFlag: number;
  104636. /**
  104637. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104638. */
  104639. static readonly MATERIAL_OPAQUE: number;
  104640. /**
  104641. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104642. */
  104643. static readonly MATERIAL_ALPHATEST: number;
  104644. /**
  104645. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104646. */
  104647. static readonly MATERIAL_ALPHABLEND: number;
  104648. /**
  104649. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104650. * They are also discarded below the alpha cutoff threshold to improve performances.
  104651. */
  104652. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104653. /**
  104654. * The Whiteout method is used to blend normals.
  104655. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104656. */
  104657. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104658. /**
  104659. * The Reoriented Normal Mapping method is used to blend normals.
  104660. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104661. */
  104662. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104663. /**
  104664. * Custom callback helping to override the default shader used in the material.
  104665. */
  104666. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104667. /**
  104668. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104669. */
  104670. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104671. /**
  104672. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104673. * This means that the material can keep using a previous shader while a new one is being compiled.
  104674. * This is mostly used when shader parallel compilation is supported (true by default)
  104675. */
  104676. allowShaderHotSwapping: boolean;
  104677. /**
  104678. * The ID of the material
  104679. */
  104680. id: string;
  104681. /**
  104682. * Gets or sets the unique id of the material
  104683. */
  104684. uniqueId: number;
  104685. /**
  104686. * The name of the material
  104687. */
  104688. name: string;
  104689. /**
  104690. * Gets or sets user defined metadata
  104691. */
  104692. metadata: any;
  104693. /**
  104694. * For internal use only. Please do not use.
  104695. */
  104696. reservedDataStore: any;
  104697. /**
  104698. * Specifies if the ready state should be checked on each call
  104699. */
  104700. checkReadyOnEveryCall: boolean;
  104701. /**
  104702. * Specifies if the ready state should be checked once
  104703. */
  104704. checkReadyOnlyOnce: boolean;
  104705. /**
  104706. * The state of the material
  104707. */
  104708. state: string;
  104709. /**
  104710. * If the material can be rendered to several textures with MRT extension
  104711. */
  104712. get canRenderToMRT(): boolean;
  104713. /**
  104714. * The alpha value of the material
  104715. */
  104716. protected _alpha: number;
  104717. /**
  104718. * List of inspectable custom properties (used by the Inspector)
  104719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104720. */
  104721. inspectableCustomProperties: IInspectable[];
  104722. /**
  104723. * Sets the alpha value of the material
  104724. */
  104725. set alpha(value: number);
  104726. /**
  104727. * Gets the alpha value of the material
  104728. */
  104729. get alpha(): number;
  104730. /**
  104731. * Specifies if back face culling is enabled
  104732. */
  104733. protected _backFaceCulling: boolean;
  104734. /**
  104735. * Sets the back-face culling state
  104736. */
  104737. set backFaceCulling(value: boolean);
  104738. /**
  104739. * Gets the back-face culling state
  104740. */
  104741. get backFaceCulling(): boolean;
  104742. /**
  104743. * Stores the value for side orientation
  104744. */
  104745. sideOrientation: number;
  104746. /**
  104747. * Callback triggered when the material is compiled
  104748. */
  104749. onCompiled: Nullable<(effect: Effect) => void>;
  104750. /**
  104751. * Callback triggered when an error occurs
  104752. */
  104753. onError: Nullable<(effect: Effect, errors: string) => void>;
  104754. /**
  104755. * Callback triggered to get the render target textures
  104756. */
  104757. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  104758. /**
  104759. * Gets a boolean indicating that current material needs to register RTT
  104760. */
  104761. get hasRenderTargetTextures(): boolean;
  104762. /**
  104763. * Specifies if the material should be serialized
  104764. */
  104765. doNotSerialize: boolean;
  104766. /**
  104767. * @hidden
  104768. */
  104769. _storeEffectOnSubMeshes: boolean;
  104770. /**
  104771. * Stores the animations for the material
  104772. */
  104773. animations: Nullable<Array<Animation>>;
  104774. /**
  104775. * An event triggered when the material is disposed
  104776. */
  104777. onDisposeObservable: Observable<Material>;
  104778. /**
  104779. * An observer which watches for dispose events
  104780. */
  104781. private _onDisposeObserver;
  104782. private _onUnBindObservable;
  104783. /**
  104784. * Called during a dispose event
  104785. */
  104786. set onDispose(callback: () => void);
  104787. private _onBindObservable;
  104788. /**
  104789. * An event triggered when the material is bound
  104790. */
  104791. get onBindObservable(): Observable<AbstractMesh>;
  104792. /**
  104793. * An observer which watches for bind events
  104794. */
  104795. private _onBindObserver;
  104796. /**
  104797. * Called during a bind event
  104798. */
  104799. set onBind(callback: (Mesh: AbstractMesh) => void);
  104800. /**
  104801. * An event triggered when the material is unbound
  104802. */
  104803. get onUnBindObservable(): Observable<Material>;
  104804. protected _onEffectCreatedObservable: Nullable<Observable<{
  104805. effect: Effect;
  104806. subMesh: Nullable<SubMesh>;
  104807. }>>;
  104808. /**
  104809. * An event triggered when the effect is (re)created
  104810. */
  104811. get onEffectCreatedObservable(): Observable<{
  104812. effect: Effect;
  104813. subMesh: Nullable<SubMesh>;
  104814. }>;
  104815. /**
  104816. * Stores the value of the alpha mode
  104817. */
  104818. private _alphaMode;
  104819. /**
  104820. * Sets the value of the alpha mode.
  104821. *
  104822. * | Value | Type | Description |
  104823. * | --- | --- | --- |
  104824. * | 0 | ALPHA_DISABLE | |
  104825. * | 1 | ALPHA_ADD | |
  104826. * | 2 | ALPHA_COMBINE | |
  104827. * | 3 | ALPHA_SUBTRACT | |
  104828. * | 4 | ALPHA_MULTIPLY | |
  104829. * | 5 | ALPHA_MAXIMIZED | |
  104830. * | 6 | ALPHA_ONEONE | |
  104831. * | 7 | ALPHA_PREMULTIPLIED | |
  104832. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  104833. * | 9 | ALPHA_INTERPOLATE | |
  104834. * | 10 | ALPHA_SCREENMODE | |
  104835. *
  104836. */
  104837. set alphaMode(value: number);
  104838. /**
  104839. * Gets the value of the alpha mode
  104840. */
  104841. get alphaMode(): number;
  104842. /**
  104843. * Stores the state of the need depth pre-pass value
  104844. */
  104845. private _needDepthPrePass;
  104846. /**
  104847. * Sets the need depth pre-pass value
  104848. */
  104849. set needDepthPrePass(value: boolean);
  104850. /**
  104851. * Gets the depth pre-pass value
  104852. */
  104853. get needDepthPrePass(): boolean;
  104854. /**
  104855. * Specifies if depth writing should be disabled
  104856. */
  104857. disableDepthWrite: boolean;
  104858. /**
  104859. * Specifies if color writing should be disabled
  104860. */
  104861. disableColorWrite: boolean;
  104862. /**
  104863. * Specifies if depth writing should be forced
  104864. */
  104865. forceDepthWrite: boolean;
  104866. /**
  104867. * Specifies the depth function that should be used. 0 means the default engine function
  104868. */
  104869. depthFunction: number;
  104870. /**
  104871. * Specifies if there should be a separate pass for culling
  104872. */
  104873. separateCullingPass: boolean;
  104874. /**
  104875. * Stores the state specifing if fog should be enabled
  104876. */
  104877. private _fogEnabled;
  104878. /**
  104879. * Sets the state for enabling fog
  104880. */
  104881. set fogEnabled(value: boolean);
  104882. /**
  104883. * Gets the value of the fog enabled state
  104884. */
  104885. get fogEnabled(): boolean;
  104886. /**
  104887. * Stores the size of points
  104888. */
  104889. pointSize: number;
  104890. /**
  104891. * Stores the z offset value
  104892. */
  104893. zOffset: number;
  104894. get wireframe(): boolean;
  104895. /**
  104896. * Sets the state of wireframe mode
  104897. */
  104898. set wireframe(value: boolean);
  104899. /**
  104900. * Gets the value specifying if point clouds are enabled
  104901. */
  104902. get pointsCloud(): boolean;
  104903. /**
  104904. * Sets the state of point cloud mode
  104905. */
  104906. set pointsCloud(value: boolean);
  104907. /**
  104908. * Gets the material fill mode
  104909. */
  104910. get fillMode(): number;
  104911. /**
  104912. * Sets the material fill mode
  104913. */
  104914. set fillMode(value: number);
  104915. /**
  104916. * @hidden
  104917. * Stores the effects for the material
  104918. */
  104919. _effect: Nullable<Effect>;
  104920. /**
  104921. * Specifies if uniform buffers should be used
  104922. */
  104923. private _useUBO;
  104924. /**
  104925. * Stores a reference to the scene
  104926. */
  104927. private _scene;
  104928. /**
  104929. * Stores the fill mode state
  104930. */
  104931. private _fillMode;
  104932. /**
  104933. * Specifies if the depth write state should be cached
  104934. */
  104935. private _cachedDepthWriteState;
  104936. /**
  104937. * Specifies if the color write state should be cached
  104938. */
  104939. private _cachedColorWriteState;
  104940. /**
  104941. * Specifies if the depth function state should be cached
  104942. */
  104943. private _cachedDepthFunctionState;
  104944. /**
  104945. * Stores the uniform buffer
  104946. */
  104947. protected _uniformBuffer: UniformBuffer;
  104948. /** @hidden */
  104949. _indexInSceneMaterialArray: number;
  104950. /** @hidden */
  104951. meshMap: Nullable<{
  104952. [id: string]: AbstractMesh | undefined;
  104953. }>;
  104954. /**
  104955. * Creates a material instance
  104956. * @param name defines the name of the material
  104957. * @param scene defines the scene to reference
  104958. * @param doNotAdd specifies if the material should be added to the scene
  104959. */
  104960. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  104961. /**
  104962. * Returns a string representation of the current material
  104963. * @param fullDetails defines a boolean indicating which levels of logging is desired
  104964. * @returns a string with material information
  104965. */
  104966. toString(fullDetails?: boolean): string;
  104967. /**
  104968. * Gets the class name of the material
  104969. * @returns a string with the class name of the material
  104970. */
  104971. getClassName(): string;
  104972. /**
  104973. * Specifies if updates for the material been locked
  104974. */
  104975. get isFrozen(): boolean;
  104976. /**
  104977. * Locks updates for the material
  104978. */
  104979. freeze(): void;
  104980. /**
  104981. * Unlocks updates for the material
  104982. */
  104983. unfreeze(): void;
  104984. /**
  104985. * Specifies if the material is ready to be used
  104986. * @param mesh defines the mesh to check
  104987. * @param useInstances specifies if instances should be used
  104988. * @returns a boolean indicating if the material is ready to be used
  104989. */
  104990. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104991. /**
  104992. * Specifies that the submesh is ready to be used
  104993. * @param mesh defines the mesh to check
  104994. * @param subMesh defines which submesh to check
  104995. * @param useInstances specifies that instances should be used
  104996. * @returns a boolean indicating that the submesh is ready or not
  104997. */
  104998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104999. /**
  105000. * Returns the material effect
  105001. * @returns the effect associated with the material
  105002. */
  105003. getEffect(): Nullable<Effect>;
  105004. /**
  105005. * Returns the current scene
  105006. * @returns a Scene
  105007. */
  105008. getScene(): Scene;
  105009. /**
  105010. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105011. */
  105012. protected _forceAlphaTest: boolean;
  105013. /**
  105014. * The transparency mode of the material.
  105015. */
  105016. protected _transparencyMode: Nullable<number>;
  105017. /**
  105018. * Gets the current transparency mode.
  105019. */
  105020. get transparencyMode(): Nullable<number>;
  105021. /**
  105022. * Sets the transparency mode of the material.
  105023. *
  105024. * | Value | Type | Description |
  105025. * | ----- | ----------------------------------- | ----------- |
  105026. * | 0 | OPAQUE | |
  105027. * | 1 | ALPHATEST | |
  105028. * | 2 | ALPHABLEND | |
  105029. * | 3 | ALPHATESTANDBLEND | |
  105030. *
  105031. */
  105032. set transparencyMode(value: Nullable<number>);
  105033. /**
  105034. * Returns true if alpha blending should be disabled.
  105035. */
  105036. protected get _disableAlphaBlending(): boolean;
  105037. /**
  105038. * Specifies whether or not this material should be rendered in alpha blend mode.
  105039. * @returns a boolean specifying if alpha blending is needed
  105040. */
  105041. needAlphaBlending(): boolean;
  105042. /**
  105043. * Specifies if the mesh will require alpha blending
  105044. * @param mesh defines the mesh to check
  105045. * @returns a boolean specifying if alpha blending is needed for the mesh
  105046. */
  105047. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105048. /**
  105049. * Specifies whether or not this material should be rendered in alpha test mode.
  105050. * @returns a boolean specifying if an alpha test is needed.
  105051. */
  105052. needAlphaTesting(): boolean;
  105053. /**
  105054. * Specifies if material alpha testing should be turned on for the mesh
  105055. * @param mesh defines the mesh to check
  105056. */
  105057. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105058. /**
  105059. * Gets the texture used for the alpha test
  105060. * @returns the texture to use for alpha testing
  105061. */
  105062. getAlphaTestTexture(): Nullable<BaseTexture>;
  105063. /**
  105064. * Marks the material to indicate that it needs to be re-calculated
  105065. */
  105066. markDirty(): void;
  105067. /** @hidden */
  105068. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105069. /**
  105070. * Binds the material to the mesh
  105071. * @param world defines the world transformation matrix
  105072. * @param mesh defines the mesh to bind the material to
  105073. */
  105074. bind(world: Matrix, mesh?: Mesh): void;
  105075. /**
  105076. * Binds the submesh to the material
  105077. * @param world defines the world transformation matrix
  105078. * @param mesh defines the mesh containing the submesh
  105079. * @param subMesh defines the submesh to bind the material to
  105080. */
  105081. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105082. /**
  105083. * Binds the world matrix to the material
  105084. * @param world defines the world transformation matrix
  105085. */
  105086. bindOnlyWorldMatrix(world: Matrix): void;
  105087. /**
  105088. * Binds the scene's uniform buffer to the effect.
  105089. * @param effect defines the effect to bind to the scene uniform buffer
  105090. * @param sceneUbo defines the uniform buffer storing scene data
  105091. */
  105092. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105093. /**
  105094. * Binds the view matrix to the effect
  105095. * @param effect defines the effect to bind the view matrix to
  105096. */
  105097. bindView(effect: Effect): void;
  105098. /**
  105099. * Binds the view projection matrix to the effect
  105100. * @param effect defines the effect to bind the view projection matrix to
  105101. */
  105102. bindViewProjection(effect: Effect): void;
  105103. /**
  105104. * Processes to execute after binding the material to a mesh
  105105. * @param mesh defines the rendered mesh
  105106. */
  105107. protected _afterBind(mesh?: Mesh): void;
  105108. /**
  105109. * Unbinds the material from the mesh
  105110. */
  105111. unbind(): void;
  105112. /**
  105113. * Gets the active textures from the material
  105114. * @returns an array of textures
  105115. */
  105116. getActiveTextures(): BaseTexture[];
  105117. /**
  105118. * Specifies if the material uses a texture
  105119. * @param texture defines the texture to check against the material
  105120. * @returns a boolean specifying if the material uses the texture
  105121. */
  105122. hasTexture(texture: BaseTexture): boolean;
  105123. /**
  105124. * Makes a duplicate of the material, and gives it a new name
  105125. * @param name defines the new name for the duplicated material
  105126. * @returns the cloned material
  105127. */
  105128. clone(name: string): Nullable<Material>;
  105129. /**
  105130. * Gets the meshes bound to the material
  105131. * @returns an array of meshes bound to the material
  105132. */
  105133. getBindedMeshes(): AbstractMesh[];
  105134. /**
  105135. * Force shader compilation
  105136. * @param mesh defines the mesh associated with this material
  105137. * @param onCompiled defines a function to execute once the material is compiled
  105138. * @param options defines the options to configure the compilation
  105139. * @param onError defines a function to execute if the material fails compiling
  105140. */
  105141. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105142. /**
  105143. * Force shader compilation
  105144. * @param mesh defines the mesh that will use this material
  105145. * @param options defines additional options for compiling the shaders
  105146. * @returns a promise that resolves when the compilation completes
  105147. */
  105148. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105149. private static readonly _AllDirtyCallBack;
  105150. private static readonly _ImageProcessingDirtyCallBack;
  105151. private static readonly _TextureDirtyCallBack;
  105152. private static readonly _FresnelDirtyCallBack;
  105153. private static readonly _MiscDirtyCallBack;
  105154. private static readonly _LightsDirtyCallBack;
  105155. private static readonly _AttributeDirtyCallBack;
  105156. private static _FresnelAndMiscDirtyCallBack;
  105157. private static _TextureAndMiscDirtyCallBack;
  105158. private static readonly _DirtyCallbackArray;
  105159. private static readonly _RunDirtyCallBacks;
  105160. /**
  105161. * Marks a define in the material to indicate that it needs to be re-computed
  105162. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105163. */
  105164. markAsDirty(flag: number): void;
  105165. /**
  105166. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105167. * @param func defines a function which checks material defines against the submeshes
  105168. */
  105169. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105170. /**
  105171. * Indicates that the scene should check if the rendering now needs a prepass
  105172. */
  105173. protected _markScenePrePassDirty(): void;
  105174. /**
  105175. * Indicates that we need to re-calculated for all submeshes
  105176. */
  105177. protected _markAllSubMeshesAsAllDirty(): void;
  105178. /**
  105179. * Indicates that image processing needs to be re-calculated for all submeshes
  105180. */
  105181. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105182. /**
  105183. * Indicates that textures need to be re-calculated for all submeshes
  105184. */
  105185. protected _markAllSubMeshesAsTexturesDirty(): void;
  105186. /**
  105187. * Indicates that fresnel needs to be re-calculated for all submeshes
  105188. */
  105189. protected _markAllSubMeshesAsFresnelDirty(): void;
  105190. /**
  105191. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105192. */
  105193. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105194. /**
  105195. * Indicates that lights need to be re-calculated for all submeshes
  105196. */
  105197. protected _markAllSubMeshesAsLightsDirty(): void;
  105198. /**
  105199. * Indicates that attributes need to be re-calculated for all submeshes
  105200. */
  105201. protected _markAllSubMeshesAsAttributesDirty(): void;
  105202. /**
  105203. * Indicates that misc needs to be re-calculated for all submeshes
  105204. */
  105205. protected _markAllSubMeshesAsMiscDirty(): void;
  105206. /**
  105207. * Indicates that textures and misc need to be re-calculated for all submeshes
  105208. */
  105209. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105210. /**
  105211. * Sets the required values to the prepass renderer.
  105212. * @param prePassRenderer defines the prepass renderer to setup.
  105213. * @returns true if the pre pass is needed.
  105214. */
  105215. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105216. /**
  105217. * Disposes the material
  105218. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105219. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105220. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105221. */
  105222. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105223. /** @hidden */
  105224. private releaseVertexArrayObject;
  105225. /**
  105226. * Serializes this material
  105227. * @returns the serialized material object
  105228. */
  105229. serialize(): any;
  105230. /**
  105231. * Creates a material from parsed material data
  105232. * @param parsedMaterial defines parsed material data
  105233. * @param scene defines the hosting scene
  105234. * @param rootUrl defines the root URL to use to load textures
  105235. * @returns a new material
  105236. */
  105237. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105238. }
  105239. }
  105240. declare module BABYLON {
  105241. /**
  105242. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105243. * separate meshes. This can be use to improve performances.
  105244. * @see https://doc.babylonjs.com/how_to/multi_materials
  105245. */
  105246. export class MultiMaterial extends Material {
  105247. private _subMaterials;
  105248. /**
  105249. * Gets or Sets the list of Materials used within the multi material.
  105250. * They need to be ordered according to the submeshes order in the associated mesh
  105251. */
  105252. get subMaterials(): Nullable<Material>[];
  105253. set subMaterials(value: Nullable<Material>[]);
  105254. /**
  105255. * Function used to align with Node.getChildren()
  105256. * @returns the list of Materials used within the multi material
  105257. */
  105258. getChildren(): Nullable<Material>[];
  105259. /**
  105260. * Instantiates a new Multi Material
  105261. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105262. * separate meshes. This can be use to improve performances.
  105263. * @see https://doc.babylonjs.com/how_to/multi_materials
  105264. * @param name Define the name in the scene
  105265. * @param scene Define the scene the material belongs to
  105266. */
  105267. constructor(name: string, scene: Scene);
  105268. private _hookArray;
  105269. /**
  105270. * Get one of the submaterial by its index in the submaterials array
  105271. * @param index The index to look the sub material at
  105272. * @returns The Material if the index has been defined
  105273. */
  105274. getSubMaterial(index: number): Nullable<Material>;
  105275. /**
  105276. * Get the list of active textures for the whole sub materials list.
  105277. * @returns All the textures that will be used during the rendering
  105278. */
  105279. getActiveTextures(): BaseTexture[];
  105280. /**
  105281. * Gets the current class name of the material e.g. "MultiMaterial"
  105282. * Mainly use in serialization.
  105283. * @returns the class name
  105284. */
  105285. getClassName(): string;
  105286. /**
  105287. * Checks if the material is ready to render the requested sub mesh
  105288. * @param mesh Define the mesh the submesh belongs to
  105289. * @param subMesh Define the sub mesh to look readyness for
  105290. * @param useInstances Define whether or not the material is used with instances
  105291. * @returns true if ready, otherwise false
  105292. */
  105293. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105294. /**
  105295. * Clones the current material and its related sub materials
  105296. * @param name Define the name of the newly cloned material
  105297. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105298. * @returns the cloned material
  105299. */
  105300. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105301. /**
  105302. * Serializes the materials into a JSON representation.
  105303. * @returns the JSON representation
  105304. */
  105305. serialize(): any;
  105306. /**
  105307. * Dispose the material and release its associated resources
  105308. * @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)
  105309. * @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)
  105310. * @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)
  105311. */
  105312. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105313. /**
  105314. * Creates a MultiMaterial from parsed MultiMaterial data.
  105315. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105316. * @param scene defines the hosting scene
  105317. * @returns a new MultiMaterial
  105318. */
  105319. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105320. }
  105321. }
  105322. declare module BABYLON {
  105323. /**
  105324. * Defines a subdivision inside a mesh
  105325. */
  105326. export class SubMesh implements ICullable {
  105327. /** the material index to use */
  105328. materialIndex: number;
  105329. /** vertex index start */
  105330. verticesStart: number;
  105331. /** vertices count */
  105332. verticesCount: number;
  105333. /** index start */
  105334. indexStart: number;
  105335. /** indices count */
  105336. indexCount: number;
  105337. /** @hidden */
  105338. _materialDefines: Nullable<MaterialDefines>;
  105339. /** @hidden */
  105340. _materialEffect: Nullable<Effect>;
  105341. /** @hidden */
  105342. _effectOverride: Nullable<Effect>;
  105343. /**
  105344. * Gets material defines used by the effect associated to the sub mesh
  105345. */
  105346. get materialDefines(): Nullable<MaterialDefines>;
  105347. /**
  105348. * Sets material defines used by the effect associated to the sub mesh
  105349. */
  105350. set materialDefines(defines: Nullable<MaterialDefines>);
  105351. /**
  105352. * Gets associated effect
  105353. */
  105354. get effect(): Nullable<Effect>;
  105355. /**
  105356. * Sets associated effect (effect used to render this submesh)
  105357. * @param effect defines the effect to associate with
  105358. * @param defines defines the set of defines used to compile this effect
  105359. */
  105360. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105361. /** @hidden */
  105362. _linesIndexCount: number;
  105363. private _mesh;
  105364. private _renderingMesh;
  105365. private _boundingInfo;
  105366. private _linesIndexBuffer;
  105367. /** @hidden */
  105368. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105369. /** @hidden */
  105370. _trianglePlanes: Plane[];
  105371. /** @hidden */
  105372. _lastColliderTransformMatrix: Nullable<Matrix>;
  105373. /** @hidden */
  105374. _renderId: number;
  105375. /** @hidden */
  105376. _alphaIndex: number;
  105377. /** @hidden */
  105378. _distanceToCamera: number;
  105379. /** @hidden */
  105380. _id: number;
  105381. private _currentMaterial;
  105382. /**
  105383. * Add a new submesh to a mesh
  105384. * @param materialIndex defines the material index to use
  105385. * @param verticesStart defines vertex index start
  105386. * @param verticesCount defines vertices count
  105387. * @param indexStart defines index start
  105388. * @param indexCount defines indices count
  105389. * @param mesh defines the parent mesh
  105390. * @param renderingMesh defines an optional rendering mesh
  105391. * @param createBoundingBox defines if bounding box should be created for this submesh
  105392. * @returns the new submesh
  105393. */
  105394. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105395. /**
  105396. * Creates a new submesh
  105397. * @param materialIndex defines the material index to use
  105398. * @param verticesStart defines vertex index start
  105399. * @param verticesCount defines vertices count
  105400. * @param indexStart defines index start
  105401. * @param indexCount defines indices count
  105402. * @param mesh defines the parent mesh
  105403. * @param renderingMesh defines an optional rendering mesh
  105404. * @param createBoundingBox defines if bounding box should be created for this submesh
  105405. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105406. */
  105407. constructor(
  105408. /** the material index to use */
  105409. materialIndex: number,
  105410. /** vertex index start */
  105411. verticesStart: number,
  105412. /** vertices count */
  105413. verticesCount: number,
  105414. /** index start */
  105415. indexStart: number,
  105416. /** indices count */
  105417. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105418. /**
  105419. * Returns true if this submesh covers the entire parent mesh
  105420. * @ignorenaming
  105421. */
  105422. get IsGlobal(): boolean;
  105423. /**
  105424. * Returns the submesh BoudingInfo object
  105425. * @returns current bounding info (or mesh's one if the submesh is global)
  105426. */
  105427. getBoundingInfo(): BoundingInfo;
  105428. /**
  105429. * Sets the submesh BoundingInfo
  105430. * @param boundingInfo defines the new bounding info to use
  105431. * @returns the SubMesh
  105432. */
  105433. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105434. /**
  105435. * Returns the mesh of the current submesh
  105436. * @return the parent mesh
  105437. */
  105438. getMesh(): AbstractMesh;
  105439. /**
  105440. * Returns the rendering mesh of the submesh
  105441. * @returns the rendering mesh (could be different from parent mesh)
  105442. */
  105443. getRenderingMesh(): Mesh;
  105444. /**
  105445. * Returns the replacement mesh of the submesh
  105446. * @returns the replacement mesh (could be different from parent mesh)
  105447. */
  105448. getReplacementMesh(): Nullable<AbstractMesh>;
  105449. /**
  105450. * Returns the effective mesh of the submesh
  105451. * @returns the effective mesh (could be different from parent mesh)
  105452. */
  105453. getEffectiveMesh(): AbstractMesh;
  105454. /**
  105455. * Returns the submesh material
  105456. * @returns null or the current material
  105457. */
  105458. getMaterial(): Nullable<Material>;
  105459. private _IsMultiMaterial;
  105460. /**
  105461. * Sets a new updated BoundingInfo object to the submesh
  105462. * @param data defines an optional position array to use to determine the bounding info
  105463. * @returns the SubMesh
  105464. */
  105465. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105466. /** @hidden */
  105467. _checkCollision(collider: Collider): boolean;
  105468. /**
  105469. * Updates the submesh BoundingInfo
  105470. * @param world defines the world matrix to use to update the bounding info
  105471. * @returns the submesh
  105472. */
  105473. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105474. /**
  105475. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105476. * @param frustumPlanes defines the frustum planes
  105477. * @returns true if the submesh is intersecting with the frustum
  105478. */
  105479. isInFrustum(frustumPlanes: Plane[]): boolean;
  105480. /**
  105481. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105482. * @param frustumPlanes defines the frustum planes
  105483. * @returns true if the submesh is inside the frustum
  105484. */
  105485. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105486. /**
  105487. * Renders the submesh
  105488. * @param enableAlphaMode defines if alpha needs to be used
  105489. * @returns the submesh
  105490. */
  105491. render(enableAlphaMode: boolean): SubMesh;
  105492. /**
  105493. * @hidden
  105494. */
  105495. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105496. /**
  105497. * Checks if the submesh intersects with a ray
  105498. * @param ray defines the ray to test
  105499. * @returns true is the passed ray intersects the submesh bounding box
  105500. */
  105501. canIntersects(ray: Ray): boolean;
  105502. /**
  105503. * Intersects current submesh with a ray
  105504. * @param ray defines the ray to test
  105505. * @param positions defines mesh's positions array
  105506. * @param indices defines mesh's indices array
  105507. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105508. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105509. * @returns intersection info or null if no intersection
  105510. */
  105511. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105512. /** @hidden */
  105513. private _intersectLines;
  105514. /** @hidden */
  105515. private _intersectUnIndexedLines;
  105516. /** @hidden */
  105517. private _intersectTriangles;
  105518. /** @hidden */
  105519. private _intersectUnIndexedTriangles;
  105520. /** @hidden */
  105521. _rebuild(): void;
  105522. /**
  105523. * Creates a new submesh from the passed mesh
  105524. * @param newMesh defines the new hosting mesh
  105525. * @param newRenderingMesh defines an optional rendering mesh
  105526. * @returns the new submesh
  105527. */
  105528. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105529. /**
  105530. * Release associated resources
  105531. */
  105532. dispose(): void;
  105533. /**
  105534. * Gets the class name
  105535. * @returns the string "SubMesh".
  105536. */
  105537. getClassName(): string;
  105538. /**
  105539. * Creates a new submesh from indices data
  105540. * @param materialIndex the index of the main mesh material
  105541. * @param startIndex the index where to start the copy in the mesh indices array
  105542. * @param indexCount the number of indices to copy then from the startIndex
  105543. * @param mesh the main mesh to create the submesh from
  105544. * @param renderingMesh the optional rendering mesh
  105545. * @returns a new submesh
  105546. */
  105547. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105548. }
  105549. }
  105550. declare module BABYLON {
  105551. /**
  105552. * Class used to represent data loading progression
  105553. */
  105554. export class SceneLoaderFlags {
  105555. private static _ForceFullSceneLoadingForIncremental;
  105556. private static _ShowLoadingScreen;
  105557. private static _CleanBoneMatrixWeights;
  105558. private static _loggingLevel;
  105559. /**
  105560. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105561. */
  105562. static get ForceFullSceneLoadingForIncremental(): boolean;
  105563. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105564. /**
  105565. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105566. */
  105567. static get ShowLoadingScreen(): boolean;
  105568. static set ShowLoadingScreen(value: boolean);
  105569. /**
  105570. * Defines the current logging level (while loading the scene)
  105571. * @ignorenaming
  105572. */
  105573. static get loggingLevel(): number;
  105574. static set loggingLevel(value: number);
  105575. /**
  105576. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105577. */
  105578. static get CleanBoneMatrixWeights(): boolean;
  105579. static set CleanBoneMatrixWeights(value: boolean);
  105580. }
  105581. }
  105582. declare module BABYLON {
  105583. /**
  105584. * Class used to store geometry data (vertex buffers + index buffer)
  105585. */
  105586. export class Geometry implements IGetSetVerticesData {
  105587. /**
  105588. * Gets or sets the ID of the geometry
  105589. */
  105590. id: string;
  105591. /**
  105592. * Gets or sets the unique ID of the geometry
  105593. */
  105594. uniqueId: number;
  105595. /**
  105596. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105597. */
  105598. delayLoadState: number;
  105599. /**
  105600. * Gets the file containing the data to load when running in delay load state
  105601. */
  105602. delayLoadingFile: Nullable<string>;
  105603. /**
  105604. * Callback called when the geometry is updated
  105605. */
  105606. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105607. private _scene;
  105608. private _engine;
  105609. private _meshes;
  105610. private _totalVertices;
  105611. /** @hidden */
  105612. _indices: IndicesArray;
  105613. /** @hidden */
  105614. _vertexBuffers: {
  105615. [key: string]: VertexBuffer;
  105616. };
  105617. private _isDisposed;
  105618. private _extend;
  105619. private _boundingBias;
  105620. /** @hidden */
  105621. _delayInfo: Array<string>;
  105622. private _indexBuffer;
  105623. private _indexBufferIsUpdatable;
  105624. /** @hidden */
  105625. _boundingInfo: Nullable<BoundingInfo>;
  105626. /** @hidden */
  105627. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105628. /** @hidden */
  105629. _softwareSkinningFrameId: number;
  105630. private _vertexArrayObjects;
  105631. private _updatable;
  105632. /** @hidden */
  105633. _positions: Nullable<Vector3[]>;
  105634. /**
  105635. * 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
  105636. */
  105637. get boundingBias(): Vector2;
  105638. /**
  105639. * 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
  105640. */
  105641. set boundingBias(value: Vector2);
  105642. /**
  105643. * Static function used to attach a new empty geometry to a mesh
  105644. * @param mesh defines the mesh to attach the geometry to
  105645. * @returns the new Geometry
  105646. */
  105647. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105648. /** Get the list of meshes using this geometry */
  105649. get meshes(): Mesh[];
  105650. /**
  105651. * 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
  105652. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105653. */
  105654. useBoundingInfoFromGeometry: boolean;
  105655. /**
  105656. * Creates a new geometry
  105657. * @param id defines the unique ID
  105658. * @param scene defines the hosting scene
  105659. * @param vertexData defines the VertexData used to get geometry data
  105660. * @param updatable defines if geometry must be updatable (false by default)
  105661. * @param mesh defines the mesh that will be associated with the geometry
  105662. */
  105663. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105664. /**
  105665. * Gets the current extend of the geometry
  105666. */
  105667. get extend(): {
  105668. minimum: Vector3;
  105669. maximum: Vector3;
  105670. };
  105671. /**
  105672. * Gets the hosting scene
  105673. * @returns the hosting Scene
  105674. */
  105675. getScene(): Scene;
  105676. /**
  105677. * Gets the hosting engine
  105678. * @returns the hosting Engine
  105679. */
  105680. getEngine(): Engine;
  105681. /**
  105682. * Defines if the geometry is ready to use
  105683. * @returns true if the geometry is ready to be used
  105684. */
  105685. isReady(): boolean;
  105686. /**
  105687. * Gets a value indicating that the geometry should not be serialized
  105688. */
  105689. get doNotSerialize(): boolean;
  105690. /** @hidden */
  105691. _rebuild(): void;
  105692. /**
  105693. * Affects all geometry data in one call
  105694. * @param vertexData defines the geometry data
  105695. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  105696. */
  105697. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  105698. /**
  105699. * Set specific vertex data
  105700. * @param kind defines the data kind (Position, normal, etc...)
  105701. * @param data defines the vertex data to use
  105702. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105703. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105704. */
  105705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  105706. /**
  105707. * Removes a specific vertex data
  105708. * @param kind defines the data kind (Position, normal, etc...)
  105709. */
  105710. removeVerticesData(kind: string): void;
  105711. /**
  105712. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  105713. * @param buffer defines the vertex buffer to use
  105714. * @param totalVertices defines the total number of vertices for position kind (could be null)
  105715. */
  105716. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  105717. /**
  105718. * Update a specific vertex buffer
  105719. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  105720. * It will do nothing if the buffer is not updatable
  105721. * @param kind defines the data kind (Position, normal, etc...)
  105722. * @param data defines the data to use
  105723. * @param offset defines the offset in the target buffer where to store the data
  105724. * @param useBytes set to true if the offset is in bytes
  105725. */
  105726. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  105727. /**
  105728. * Update a specific vertex buffer
  105729. * This function will create a new buffer if the current one is not updatable
  105730. * @param kind defines the data kind (Position, normal, etc...)
  105731. * @param data defines the data to use
  105732. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  105733. */
  105734. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  105735. private _updateBoundingInfo;
  105736. /** @hidden */
  105737. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  105738. /**
  105739. * Gets total number of vertices
  105740. * @returns the total number of vertices
  105741. */
  105742. getTotalVertices(): number;
  105743. /**
  105744. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105745. * @param kind defines the data kind (Position, normal, etc...)
  105746. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105748. * @returns a float array containing vertex data
  105749. */
  105750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105751. /**
  105752. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  105753. * @param kind defines the data kind (Position, normal, etc...)
  105754. * @returns true if the vertex buffer with the specified kind is updatable
  105755. */
  105756. isVertexBufferUpdatable(kind: string): boolean;
  105757. /**
  105758. * Gets a specific vertex buffer
  105759. * @param kind defines the data kind (Position, normal, etc...)
  105760. * @returns a VertexBuffer
  105761. */
  105762. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105763. /**
  105764. * Returns all vertex buffers
  105765. * @return an object holding all vertex buffers indexed by kind
  105766. */
  105767. getVertexBuffers(): Nullable<{
  105768. [key: string]: VertexBuffer;
  105769. }>;
  105770. /**
  105771. * Gets a boolean indicating if specific vertex buffer is present
  105772. * @param kind defines the data kind (Position, normal, etc...)
  105773. * @returns true if data is present
  105774. */
  105775. isVerticesDataPresent(kind: string): boolean;
  105776. /**
  105777. * Gets a list of all attached data kinds (Position, normal, etc...)
  105778. * @returns a list of string containing all kinds
  105779. */
  105780. getVerticesDataKinds(): string[];
  105781. /**
  105782. * Update index buffer
  105783. * @param indices defines the indices to store in the index buffer
  105784. * @param offset defines the offset in the target buffer where to store the data
  105785. * @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)
  105786. */
  105787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  105788. /**
  105789. * Creates a new index buffer
  105790. * @param indices defines the indices to store in the index buffer
  105791. * @param totalVertices defines the total number of vertices (could be null)
  105792. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105793. */
  105794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  105795. /**
  105796. * Return the total number of indices
  105797. * @returns the total number of indices
  105798. */
  105799. getTotalIndices(): number;
  105800. /**
  105801. * Gets the index buffer array
  105802. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105803. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105804. * @returns the index buffer array
  105805. */
  105806. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105807. /**
  105808. * Gets the index buffer
  105809. * @return the index buffer
  105810. */
  105811. getIndexBuffer(): Nullable<DataBuffer>;
  105812. /** @hidden */
  105813. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  105814. /**
  105815. * Release the associated resources for a specific mesh
  105816. * @param mesh defines the source mesh
  105817. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  105818. */
  105819. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  105820. /**
  105821. * Apply current geometry to a given mesh
  105822. * @param mesh defines the mesh to apply geometry to
  105823. */
  105824. applyToMesh(mesh: Mesh): void;
  105825. private _updateExtend;
  105826. private _applyToMesh;
  105827. private notifyUpdate;
  105828. /**
  105829. * Load the geometry if it was flagged as delay loaded
  105830. * @param scene defines the hosting scene
  105831. * @param onLoaded defines a callback called when the geometry is loaded
  105832. */
  105833. load(scene: Scene, onLoaded?: () => void): void;
  105834. private _queueLoad;
  105835. /**
  105836. * Invert the geometry to move from a right handed system to a left handed one.
  105837. */
  105838. toLeftHanded(): void;
  105839. /** @hidden */
  105840. _resetPointsArrayCache(): void;
  105841. /** @hidden */
  105842. _generatePointsArray(): boolean;
  105843. /**
  105844. * Gets a value indicating if the geometry is disposed
  105845. * @returns true if the geometry was disposed
  105846. */
  105847. isDisposed(): boolean;
  105848. private _disposeVertexArrayObjects;
  105849. /**
  105850. * Free all associated resources
  105851. */
  105852. dispose(): void;
  105853. /**
  105854. * Clone the current geometry into a new geometry
  105855. * @param id defines the unique ID of the new geometry
  105856. * @returns a new geometry object
  105857. */
  105858. copy(id: string): Geometry;
  105859. /**
  105860. * Serialize the current geometry info (and not the vertices data) into a JSON object
  105861. * @return a JSON representation of the current geometry data (without the vertices data)
  105862. */
  105863. serialize(): any;
  105864. private toNumberArray;
  105865. /**
  105866. * Serialize all vertices data into a JSON oject
  105867. * @returns a JSON representation of the current geometry data
  105868. */
  105869. serializeVerticeData(): any;
  105870. /**
  105871. * Extracts a clone of a mesh geometry
  105872. * @param mesh defines the source mesh
  105873. * @param id defines the unique ID of the new geometry object
  105874. * @returns the new geometry object
  105875. */
  105876. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  105877. /**
  105878. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  105879. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105880. * Be aware Math.random() could cause collisions, but:
  105881. * "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"
  105882. * @returns a string containing a new GUID
  105883. */
  105884. static RandomId(): string;
  105885. /** @hidden */
  105886. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  105887. private static _CleanMatricesWeights;
  105888. /**
  105889. * Create a new geometry from persisted data (Using .babylon file format)
  105890. * @param parsedVertexData defines the persisted data
  105891. * @param scene defines the hosting scene
  105892. * @param rootUrl defines the root url to use to load assets (like delayed data)
  105893. * @returns the new geometry object
  105894. */
  105895. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  105896. }
  105897. }
  105898. declare module BABYLON {
  105899. /**
  105900. * Define an interface for all classes that will get and set the data on vertices
  105901. */
  105902. export interface IGetSetVerticesData {
  105903. /**
  105904. * Gets a boolean indicating if specific vertex data is present
  105905. * @param kind defines the vertex data kind to use
  105906. * @returns true is data kind is present
  105907. */
  105908. isVerticesDataPresent(kind: string): boolean;
  105909. /**
  105910. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105911. * @param kind defines the data kind (Position, normal, etc...)
  105912. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105913. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105914. * @returns a float array containing vertex data
  105915. */
  105916. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105917. /**
  105918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105919. * @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.
  105920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105921. * @returns the indices array or an empty array if the mesh has no geometry
  105922. */
  105923. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105924. /**
  105925. * Set specific vertex data
  105926. * @param kind defines the data kind (Position, normal, etc...)
  105927. * @param data defines the vertex data to use
  105928. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105929. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105930. */
  105931. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  105932. /**
  105933. * Update a specific associated vertex buffer
  105934. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105935. * - VertexBuffer.PositionKind
  105936. * - VertexBuffer.UVKind
  105937. * - VertexBuffer.UV2Kind
  105938. * - VertexBuffer.UV3Kind
  105939. * - VertexBuffer.UV4Kind
  105940. * - VertexBuffer.UV5Kind
  105941. * - VertexBuffer.UV6Kind
  105942. * - VertexBuffer.ColorKind
  105943. * - VertexBuffer.MatricesIndicesKind
  105944. * - VertexBuffer.MatricesIndicesExtraKind
  105945. * - VertexBuffer.MatricesWeightsKind
  105946. * - VertexBuffer.MatricesWeightsExtraKind
  105947. * @param data defines the data source
  105948. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105949. * @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)
  105950. */
  105951. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  105952. /**
  105953. * Creates a new index buffer
  105954. * @param indices defines the indices to store in the index buffer
  105955. * @param totalVertices defines the total number of vertices (could be null)
  105956. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105957. */
  105958. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  105959. }
  105960. /**
  105961. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  105962. */
  105963. export class VertexData {
  105964. /**
  105965. * Mesh side orientation : usually the external or front surface
  105966. */
  105967. static readonly FRONTSIDE: number;
  105968. /**
  105969. * Mesh side orientation : usually the internal or back surface
  105970. */
  105971. static readonly BACKSIDE: number;
  105972. /**
  105973. * Mesh side orientation : both internal and external or front and back surfaces
  105974. */
  105975. static readonly DOUBLESIDE: number;
  105976. /**
  105977. * Mesh side orientation : by default, `FRONTSIDE`
  105978. */
  105979. static readonly DEFAULTSIDE: number;
  105980. /**
  105981. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  105982. */
  105983. positions: Nullable<FloatArray>;
  105984. /**
  105985. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  105986. */
  105987. normals: Nullable<FloatArray>;
  105988. /**
  105989. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  105990. */
  105991. tangents: Nullable<FloatArray>;
  105992. /**
  105993. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105994. */
  105995. uvs: Nullable<FloatArray>;
  105996. /**
  105997. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105998. */
  105999. uvs2: Nullable<FloatArray>;
  106000. /**
  106001. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106002. */
  106003. uvs3: Nullable<FloatArray>;
  106004. /**
  106005. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106006. */
  106007. uvs4: Nullable<FloatArray>;
  106008. /**
  106009. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106010. */
  106011. uvs5: Nullable<FloatArray>;
  106012. /**
  106013. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106014. */
  106015. uvs6: Nullable<FloatArray>;
  106016. /**
  106017. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106018. */
  106019. colors: Nullable<FloatArray>;
  106020. /**
  106021. * 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).
  106022. */
  106023. matricesIndices: Nullable<FloatArray>;
  106024. /**
  106025. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106026. */
  106027. matricesWeights: Nullable<FloatArray>;
  106028. /**
  106029. * An array extending the number of possible indices
  106030. */
  106031. matricesIndicesExtra: Nullable<FloatArray>;
  106032. /**
  106033. * An array extending the number of possible weights when the number of indices is extended
  106034. */
  106035. matricesWeightsExtra: Nullable<FloatArray>;
  106036. /**
  106037. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106038. */
  106039. indices: Nullable<IndicesArray>;
  106040. /**
  106041. * Uses the passed data array to set the set the values for the specified kind of data
  106042. * @param data a linear array of floating numbers
  106043. * @param kind the type of data that is being set, eg positions, colors etc
  106044. */
  106045. set(data: FloatArray, kind: string): void;
  106046. /**
  106047. * Associates the vertexData to the passed Mesh.
  106048. * Sets it as updatable or not (default `false`)
  106049. * @param mesh the mesh the vertexData is applied to
  106050. * @param updatable when used and having the value true allows new data to update the vertexData
  106051. * @returns the VertexData
  106052. */
  106053. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106054. /**
  106055. * Associates the vertexData to the passed Geometry.
  106056. * Sets it as updatable or not (default `false`)
  106057. * @param geometry the geometry the vertexData is applied to
  106058. * @param updatable when used and having the value true allows new data to update the vertexData
  106059. * @returns VertexData
  106060. */
  106061. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106062. /**
  106063. * Updates the associated mesh
  106064. * @param mesh the mesh to be updated
  106065. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106066. * @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
  106067. * @returns VertexData
  106068. */
  106069. updateMesh(mesh: Mesh): VertexData;
  106070. /**
  106071. * Updates the associated geometry
  106072. * @param geometry the geometry to be updated
  106073. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106074. * @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
  106075. * @returns VertexData.
  106076. */
  106077. updateGeometry(geometry: Geometry): VertexData;
  106078. private _applyTo;
  106079. private _update;
  106080. /**
  106081. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106082. * @param matrix the transforming matrix
  106083. * @returns the VertexData
  106084. */
  106085. transform(matrix: Matrix): VertexData;
  106086. /**
  106087. * Merges the passed VertexData into the current one
  106088. * @param other the VertexData to be merged into the current one
  106089. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106090. * @returns the modified VertexData
  106091. */
  106092. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106093. private _mergeElement;
  106094. private _validate;
  106095. /**
  106096. * Serializes the VertexData
  106097. * @returns a serialized object
  106098. */
  106099. serialize(): any;
  106100. /**
  106101. * Extracts the vertexData from a mesh
  106102. * @param mesh the mesh from which to extract the VertexData
  106103. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106104. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106105. * @returns the object VertexData associated to the passed mesh
  106106. */
  106107. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106108. /**
  106109. * Extracts the vertexData from the geometry
  106110. * @param geometry the geometry from which to extract the VertexData
  106111. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106112. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106113. * @returns the object VertexData associated to the passed mesh
  106114. */
  106115. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106116. private static _ExtractFrom;
  106117. /**
  106118. * Creates the VertexData for a Ribbon
  106119. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106120. * * pathArray array of paths, each of which an array of successive Vector3
  106121. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106122. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106123. * * 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
  106124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106125. * * 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)
  106126. * * 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)
  106127. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106128. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106129. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106130. * @returns the VertexData of the ribbon
  106131. */
  106132. static CreateRibbon(options: {
  106133. pathArray: Vector3[][];
  106134. closeArray?: boolean;
  106135. closePath?: boolean;
  106136. offset?: number;
  106137. sideOrientation?: number;
  106138. frontUVs?: Vector4;
  106139. backUVs?: Vector4;
  106140. invertUV?: boolean;
  106141. uvs?: Vector2[];
  106142. colors?: Color4[];
  106143. }): VertexData;
  106144. /**
  106145. * Creates the VertexData for a box
  106146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106147. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106148. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106149. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106150. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106151. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106152. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106154. * * 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)
  106155. * * 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)
  106156. * @returns the VertexData of the box
  106157. */
  106158. static CreateBox(options: {
  106159. size?: number;
  106160. width?: number;
  106161. height?: number;
  106162. depth?: number;
  106163. faceUV?: Vector4[];
  106164. faceColors?: Color4[];
  106165. sideOrientation?: number;
  106166. frontUVs?: Vector4;
  106167. backUVs?: Vector4;
  106168. }): VertexData;
  106169. /**
  106170. * Creates the VertexData for a tiled box
  106171. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106172. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106173. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106174. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106176. * @returns the VertexData of the box
  106177. */
  106178. static CreateTiledBox(options: {
  106179. pattern?: number;
  106180. width?: number;
  106181. height?: number;
  106182. depth?: number;
  106183. tileSize?: number;
  106184. tileWidth?: number;
  106185. tileHeight?: number;
  106186. alignHorizontal?: number;
  106187. alignVertical?: number;
  106188. faceUV?: Vector4[];
  106189. faceColors?: Color4[];
  106190. sideOrientation?: number;
  106191. }): VertexData;
  106192. /**
  106193. * Creates the VertexData for a tiled plane
  106194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106195. * * pattern a limited pattern arrangement depending on the number
  106196. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106197. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106198. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106200. * * 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)
  106201. * * 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)
  106202. * @returns the VertexData of the tiled plane
  106203. */
  106204. static CreateTiledPlane(options: {
  106205. pattern?: number;
  106206. tileSize?: number;
  106207. tileWidth?: number;
  106208. tileHeight?: number;
  106209. size?: number;
  106210. width?: number;
  106211. height?: number;
  106212. alignHorizontal?: number;
  106213. alignVertical?: number;
  106214. sideOrientation?: number;
  106215. frontUVs?: Vector4;
  106216. backUVs?: Vector4;
  106217. }): VertexData;
  106218. /**
  106219. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106221. * * segments sets the number of horizontal strips optional, default 32
  106222. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106223. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106224. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106225. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106226. * * 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
  106227. * * 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
  106228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106229. * * 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)
  106230. * * 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)
  106231. * @returns the VertexData of the ellipsoid
  106232. */
  106233. static CreateSphere(options: {
  106234. segments?: number;
  106235. diameter?: number;
  106236. diameterX?: number;
  106237. diameterY?: number;
  106238. diameterZ?: number;
  106239. arc?: number;
  106240. slice?: number;
  106241. sideOrientation?: number;
  106242. frontUVs?: Vector4;
  106243. backUVs?: Vector4;
  106244. }): VertexData;
  106245. /**
  106246. * Creates the VertexData for a cylinder, cone or prism
  106247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106248. * * height sets the height (y direction) of the cylinder, optional, default 2
  106249. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106250. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106251. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106252. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106253. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106254. * * 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
  106255. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106256. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106257. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106258. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106260. * * 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)
  106261. * * 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)
  106262. * @returns the VertexData of the cylinder, cone or prism
  106263. */
  106264. static CreateCylinder(options: {
  106265. height?: number;
  106266. diameterTop?: number;
  106267. diameterBottom?: number;
  106268. diameter?: number;
  106269. tessellation?: number;
  106270. subdivisions?: number;
  106271. arc?: number;
  106272. faceColors?: Color4[];
  106273. faceUV?: Vector4[];
  106274. hasRings?: boolean;
  106275. enclose?: boolean;
  106276. sideOrientation?: number;
  106277. frontUVs?: Vector4;
  106278. backUVs?: Vector4;
  106279. }): VertexData;
  106280. /**
  106281. * Creates the VertexData for a torus
  106282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106283. * * diameter the diameter of the torus, optional default 1
  106284. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106285. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106287. * * 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)
  106288. * * 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)
  106289. * @returns the VertexData of the torus
  106290. */
  106291. static CreateTorus(options: {
  106292. diameter?: number;
  106293. thickness?: number;
  106294. tessellation?: number;
  106295. sideOrientation?: number;
  106296. frontUVs?: Vector4;
  106297. backUVs?: Vector4;
  106298. }): VertexData;
  106299. /**
  106300. * Creates the VertexData of the LineSystem
  106301. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106302. * - lines an array of lines, each line being an array of successive Vector3
  106303. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106304. * @returns the VertexData of the LineSystem
  106305. */
  106306. static CreateLineSystem(options: {
  106307. lines: Vector3[][];
  106308. colors?: Nullable<Color4[][]>;
  106309. }): VertexData;
  106310. /**
  106311. * Create the VertexData for a DashedLines
  106312. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106313. * - points an array successive Vector3
  106314. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106315. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106316. * - dashNb the intended total number of dashes, optional, default 200
  106317. * @returns the VertexData for the DashedLines
  106318. */
  106319. static CreateDashedLines(options: {
  106320. points: Vector3[];
  106321. dashSize?: number;
  106322. gapSize?: number;
  106323. dashNb?: number;
  106324. }): VertexData;
  106325. /**
  106326. * Creates the VertexData for a Ground
  106327. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106328. * - width the width (x direction) of the ground, optional, default 1
  106329. * - height the height (z direction) of the ground, optional, default 1
  106330. * - subdivisions the number of subdivisions per side, optional, default 1
  106331. * @returns the VertexData of the Ground
  106332. */
  106333. static CreateGround(options: {
  106334. width?: number;
  106335. height?: number;
  106336. subdivisions?: number;
  106337. subdivisionsX?: number;
  106338. subdivisionsY?: number;
  106339. }): VertexData;
  106340. /**
  106341. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106343. * * xmin the ground minimum X coordinate, optional, default -1
  106344. * * zmin the ground minimum Z coordinate, optional, default -1
  106345. * * xmax the ground maximum X coordinate, optional, default 1
  106346. * * zmax the ground maximum Z coordinate, optional, default 1
  106347. * * 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}
  106348. * * 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}
  106349. * @returns the VertexData of the TiledGround
  106350. */
  106351. static CreateTiledGround(options: {
  106352. xmin: number;
  106353. zmin: number;
  106354. xmax: number;
  106355. zmax: number;
  106356. subdivisions?: {
  106357. w: number;
  106358. h: number;
  106359. };
  106360. precision?: {
  106361. w: number;
  106362. h: number;
  106363. };
  106364. }): VertexData;
  106365. /**
  106366. * Creates the VertexData of the Ground designed from a heightmap
  106367. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106368. * * width the width (x direction) of the ground
  106369. * * height the height (z direction) of the ground
  106370. * * subdivisions the number of subdivisions per side
  106371. * * minHeight the minimum altitude on the ground, optional, default 0
  106372. * * maxHeight the maximum altitude on the ground, optional default 1
  106373. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106374. * * buffer the array holding the image color data
  106375. * * bufferWidth the width of image
  106376. * * bufferHeight the height of image
  106377. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106378. * @returns the VertexData of the Ground designed from a heightmap
  106379. */
  106380. static CreateGroundFromHeightMap(options: {
  106381. width: number;
  106382. height: number;
  106383. subdivisions: number;
  106384. minHeight: number;
  106385. maxHeight: number;
  106386. colorFilter: Color3;
  106387. buffer: Uint8Array;
  106388. bufferWidth: number;
  106389. bufferHeight: number;
  106390. alphaFilter: number;
  106391. }): VertexData;
  106392. /**
  106393. * Creates the VertexData for a Plane
  106394. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106395. * * size sets the width and height of the plane to the value of size, optional default 1
  106396. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106397. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106399. * * 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)
  106400. * * 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)
  106401. * @returns the VertexData of the box
  106402. */
  106403. static CreatePlane(options: {
  106404. size?: number;
  106405. width?: number;
  106406. height?: number;
  106407. sideOrientation?: number;
  106408. frontUVs?: Vector4;
  106409. backUVs?: Vector4;
  106410. }): VertexData;
  106411. /**
  106412. * Creates the VertexData of the Disc or regular Polygon
  106413. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106414. * * radius the radius of the disc, optional default 0.5
  106415. * * tessellation the number of polygon sides, optional, default 64
  106416. * * 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
  106417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106418. * * 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)
  106419. * * 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)
  106420. * @returns the VertexData of the box
  106421. */
  106422. static CreateDisc(options: {
  106423. radius?: number;
  106424. tessellation?: number;
  106425. arc?: number;
  106426. sideOrientation?: number;
  106427. frontUVs?: Vector4;
  106428. backUVs?: Vector4;
  106429. }): VertexData;
  106430. /**
  106431. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106432. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106433. * @param polygon a mesh built from polygonTriangulation.build()
  106434. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106435. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106436. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106437. * @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)
  106438. * @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)
  106439. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106440. * @returns the VertexData of the Polygon
  106441. */
  106442. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106443. /**
  106444. * Creates the VertexData of the IcoSphere
  106445. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106446. * * radius the radius of the IcoSphere, optional default 1
  106447. * * radiusX allows stretching in the x direction, optional, default radius
  106448. * * radiusY allows stretching in the y direction, optional, default radius
  106449. * * radiusZ allows stretching in the z direction, optional, default radius
  106450. * * flat when true creates a flat shaded mesh, optional, default true
  106451. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106453. * * 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)
  106454. * * 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)
  106455. * @returns the VertexData of the IcoSphere
  106456. */
  106457. static CreateIcoSphere(options: {
  106458. radius?: number;
  106459. radiusX?: number;
  106460. radiusY?: number;
  106461. radiusZ?: number;
  106462. flat?: boolean;
  106463. subdivisions?: number;
  106464. sideOrientation?: number;
  106465. frontUVs?: Vector4;
  106466. backUVs?: Vector4;
  106467. }): VertexData;
  106468. /**
  106469. * Creates the VertexData for a Polyhedron
  106470. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106471. * * type provided types are:
  106472. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106473. * * 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)
  106474. * * size the size of the IcoSphere, optional default 1
  106475. * * sizeX allows stretching in the x direction, optional, default size
  106476. * * sizeY allows stretching in the y direction, optional, default size
  106477. * * sizeZ allows stretching in the z direction, optional, default size
  106478. * * 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
  106479. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106480. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106481. * * flat when true creates a flat shaded mesh, optional, default true
  106482. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106484. * * 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)
  106485. * * 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)
  106486. * @returns the VertexData of the Polyhedron
  106487. */
  106488. static CreatePolyhedron(options: {
  106489. type?: number;
  106490. size?: number;
  106491. sizeX?: number;
  106492. sizeY?: number;
  106493. sizeZ?: number;
  106494. custom?: any;
  106495. faceUV?: Vector4[];
  106496. faceColors?: Color4[];
  106497. flat?: boolean;
  106498. sideOrientation?: number;
  106499. frontUVs?: Vector4;
  106500. backUVs?: Vector4;
  106501. }): VertexData;
  106502. /**
  106503. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106504. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106505. * @returns the VertexData of the Capsule
  106506. */
  106507. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106508. /**
  106509. * Creates the VertexData for a TorusKnot
  106510. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106511. * * radius the radius of the torus knot, optional, default 2
  106512. * * tube the thickness of the tube, optional, default 0.5
  106513. * * radialSegments the number of sides on each tube segments, optional, default 32
  106514. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106515. * * p the number of windings around the z axis, optional, default 2
  106516. * * q the number of windings around the x axis, optional, default 3
  106517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106518. * * 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)
  106519. * * 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)
  106520. * @returns the VertexData of the Torus Knot
  106521. */
  106522. static CreateTorusKnot(options: {
  106523. radius?: number;
  106524. tube?: number;
  106525. radialSegments?: number;
  106526. tubularSegments?: number;
  106527. p?: number;
  106528. q?: number;
  106529. sideOrientation?: number;
  106530. frontUVs?: Vector4;
  106531. backUVs?: Vector4;
  106532. }): VertexData;
  106533. /**
  106534. * Compute normals for given positions and indices
  106535. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106536. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106537. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106538. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106539. * * facetNormals : optional array of facet normals (vector3)
  106540. * * facetPositions : optional array of facet positions (vector3)
  106541. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106542. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106543. * * bInfo : optional bounding info, required for facetPartitioning computation
  106544. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106545. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106546. * * useRightHandedSystem: optional boolean to for right handed system computation
  106547. * * depthSort : optional boolean to enable the facet depth sort computation
  106548. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106549. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106550. */
  106551. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106552. facetNormals?: any;
  106553. facetPositions?: any;
  106554. facetPartitioning?: any;
  106555. ratio?: number;
  106556. bInfo?: any;
  106557. bbSize?: Vector3;
  106558. subDiv?: any;
  106559. useRightHandedSystem?: boolean;
  106560. depthSort?: boolean;
  106561. distanceTo?: Vector3;
  106562. depthSortedFacets?: any;
  106563. }): void;
  106564. /** @hidden */
  106565. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106566. /**
  106567. * Applies VertexData created from the imported parameters to the geometry
  106568. * @param parsedVertexData the parsed data from an imported file
  106569. * @param geometry the geometry to apply the VertexData to
  106570. */
  106571. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106572. }
  106573. }
  106574. declare module BABYLON {
  106575. /**
  106576. * Defines a target to use with MorphTargetManager
  106577. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106578. */
  106579. export class MorphTarget implements IAnimatable {
  106580. /** defines the name of the target */
  106581. name: string;
  106582. /**
  106583. * Gets or sets the list of animations
  106584. */
  106585. animations: Animation[];
  106586. private _scene;
  106587. private _positions;
  106588. private _normals;
  106589. private _tangents;
  106590. private _uvs;
  106591. private _influence;
  106592. private _uniqueId;
  106593. /**
  106594. * Observable raised when the influence changes
  106595. */
  106596. onInfluenceChanged: Observable<boolean>;
  106597. /** @hidden */
  106598. _onDataLayoutChanged: Observable<void>;
  106599. /**
  106600. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106601. */
  106602. get influence(): number;
  106603. set influence(influence: number);
  106604. /**
  106605. * Gets or sets the id of the morph Target
  106606. */
  106607. id: string;
  106608. private _animationPropertiesOverride;
  106609. /**
  106610. * Gets or sets the animation properties override
  106611. */
  106612. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106613. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106614. /**
  106615. * Creates a new MorphTarget
  106616. * @param name defines the name of the target
  106617. * @param influence defines the influence to use
  106618. * @param scene defines the scene the morphtarget belongs to
  106619. */
  106620. constructor(
  106621. /** defines the name of the target */
  106622. name: string, influence?: number, scene?: Nullable<Scene>);
  106623. /**
  106624. * Gets the unique ID of this manager
  106625. */
  106626. get uniqueId(): number;
  106627. /**
  106628. * Gets a boolean defining if the target contains position data
  106629. */
  106630. get hasPositions(): boolean;
  106631. /**
  106632. * Gets a boolean defining if the target contains normal data
  106633. */
  106634. get hasNormals(): boolean;
  106635. /**
  106636. * Gets a boolean defining if the target contains tangent data
  106637. */
  106638. get hasTangents(): boolean;
  106639. /**
  106640. * Gets a boolean defining if the target contains texture coordinates data
  106641. */
  106642. get hasUVs(): boolean;
  106643. /**
  106644. * Affects position data to this target
  106645. * @param data defines the position data to use
  106646. */
  106647. setPositions(data: Nullable<FloatArray>): void;
  106648. /**
  106649. * Gets the position data stored in this target
  106650. * @returns a FloatArray containing the position data (or null if not present)
  106651. */
  106652. getPositions(): Nullable<FloatArray>;
  106653. /**
  106654. * Affects normal data to this target
  106655. * @param data defines the normal data to use
  106656. */
  106657. setNormals(data: Nullable<FloatArray>): void;
  106658. /**
  106659. * Gets the normal data stored in this target
  106660. * @returns a FloatArray containing the normal data (or null if not present)
  106661. */
  106662. getNormals(): Nullable<FloatArray>;
  106663. /**
  106664. * Affects tangent data to this target
  106665. * @param data defines the tangent data to use
  106666. */
  106667. setTangents(data: Nullable<FloatArray>): void;
  106668. /**
  106669. * Gets the tangent data stored in this target
  106670. * @returns a FloatArray containing the tangent data (or null if not present)
  106671. */
  106672. getTangents(): Nullable<FloatArray>;
  106673. /**
  106674. * Affects texture coordinates data to this target
  106675. * @param data defines the texture coordinates data to use
  106676. */
  106677. setUVs(data: Nullable<FloatArray>): void;
  106678. /**
  106679. * Gets the texture coordinates data stored in this target
  106680. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106681. */
  106682. getUVs(): Nullable<FloatArray>;
  106683. /**
  106684. * Clone the current target
  106685. * @returns a new MorphTarget
  106686. */
  106687. clone(): MorphTarget;
  106688. /**
  106689. * Serializes the current target into a Serialization object
  106690. * @returns the serialized object
  106691. */
  106692. serialize(): any;
  106693. /**
  106694. * Returns the string "MorphTarget"
  106695. * @returns "MorphTarget"
  106696. */
  106697. getClassName(): string;
  106698. /**
  106699. * Creates a new target from serialized data
  106700. * @param serializationObject defines the serialized data to use
  106701. * @returns a new MorphTarget
  106702. */
  106703. static Parse(serializationObject: any): MorphTarget;
  106704. /**
  106705. * Creates a MorphTarget from mesh data
  106706. * @param mesh defines the source mesh
  106707. * @param name defines the name to use for the new target
  106708. * @param influence defines the influence to attach to the target
  106709. * @returns a new MorphTarget
  106710. */
  106711. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  106712. }
  106713. }
  106714. declare module BABYLON {
  106715. /**
  106716. * This class is used to deform meshes using morphing between different targets
  106717. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106718. */
  106719. export class MorphTargetManager {
  106720. private _targets;
  106721. private _targetInfluenceChangedObservers;
  106722. private _targetDataLayoutChangedObservers;
  106723. private _activeTargets;
  106724. private _scene;
  106725. private _influences;
  106726. private _supportsNormals;
  106727. private _supportsTangents;
  106728. private _supportsUVs;
  106729. private _vertexCount;
  106730. private _uniqueId;
  106731. private _tempInfluences;
  106732. /**
  106733. * Gets or sets a boolean indicating if normals must be morphed
  106734. */
  106735. enableNormalMorphing: boolean;
  106736. /**
  106737. * Gets or sets a boolean indicating if tangents must be morphed
  106738. */
  106739. enableTangentMorphing: boolean;
  106740. /**
  106741. * Gets or sets a boolean indicating if UV must be morphed
  106742. */
  106743. enableUVMorphing: boolean;
  106744. /**
  106745. * Creates a new MorphTargetManager
  106746. * @param scene defines the current scene
  106747. */
  106748. constructor(scene?: Nullable<Scene>);
  106749. /**
  106750. * Gets the unique ID of this manager
  106751. */
  106752. get uniqueId(): number;
  106753. /**
  106754. * Gets the number of vertices handled by this manager
  106755. */
  106756. get vertexCount(): number;
  106757. /**
  106758. * Gets a boolean indicating if this manager supports morphing of normals
  106759. */
  106760. get supportsNormals(): boolean;
  106761. /**
  106762. * Gets a boolean indicating if this manager supports morphing of tangents
  106763. */
  106764. get supportsTangents(): boolean;
  106765. /**
  106766. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  106767. */
  106768. get supportsUVs(): boolean;
  106769. /**
  106770. * Gets the number of targets stored in this manager
  106771. */
  106772. get numTargets(): number;
  106773. /**
  106774. * Gets the number of influencers (ie. the number of targets with influences > 0)
  106775. */
  106776. get numInfluencers(): number;
  106777. /**
  106778. * Gets the list of influences (one per target)
  106779. */
  106780. get influences(): Float32Array;
  106781. /**
  106782. * Gets the active target at specified index. An active target is a target with an influence > 0
  106783. * @param index defines the index to check
  106784. * @returns the requested target
  106785. */
  106786. getActiveTarget(index: number): MorphTarget;
  106787. /**
  106788. * Gets the target at specified index
  106789. * @param index defines the index to check
  106790. * @returns the requested target
  106791. */
  106792. getTarget(index: number): MorphTarget;
  106793. /**
  106794. * Add a new target to this manager
  106795. * @param target defines the target to add
  106796. */
  106797. addTarget(target: MorphTarget): void;
  106798. /**
  106799. * Removes a target from the manager
  106800. * @param target defines the target to remove
  106801. */
  106802. removeTarget(target: MorphTarget): void;
  106803. /**
  106804. * Clone the current manager
  106805. * @returns a new MorphTargetManager
  106806. */
  106807. clone(): MorphTargetManager;
  106808. /**
  106809. * Serializes the current manager into a Serialization object
  106810. * @returns the serialized object
  106811. */
  106812. serialize(): any;
  106813. private _syncActiveTargets;
  106814. /**
  106815. * Syncrhonize the targets with all the meshes using this morph target manager
  106816. */
  106817. synchronize(): void;
  106818. /**
  106819. * Creates a new MorphTargetManager from serialized data
  106820. * @param serializationObject defines the serialized data
  106821. * @param scene defines the hosting scene
  106822. * @returns the new MorphTargetManager
  106823. */
  106824. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  106825. }
  106826. }
  106827. declare module BABYLON {
  106828. /**
  106829. * Class used to represent a specific level of detail of a mesh
  106830. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106831. */
  106832. export class MeshLODLevel {
  106833. /** Defines the distance where this level should start being displayed */
  106834. distance: number;
  106835. /** Defines the mesh to use to render this level */
  106836. mesh: Nullable<Mesh>;
  106837. /**
  106838. * Creates a new LOD level
  106839. * @param distance defines the distance where this level should star being displayed
  106840. * @param mesh defines the mesh to use to render this level
  106841. */
  106842. constructor(
  106843. /** Defines the distance where this level should start being displayed */
  106844. distance: number,
  106845. /** Defines the mesh to use to render this level */
  106846. mesh: Nullable<Mesh>);
  106847. }
  106848. }
  106849. declare module BABYLON {
  106850. /**
  106851. * Helper class used to generate a canvas to manipulate images
  106852. */
  106853. export class CanvasGenerator {
  106854. /**
  106855. * Create a new canvas (or offscreen canvas depending on the context)
  106856. * @param width defines the expected width
  106857. * @param height defines the expected height
  106858. * @return a new canvas or offscreen canvas
  106859. */
  106860. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  106861. }
  106862. }
  106863. declare module BABYLON {
  106864. /**
  106865. * Mesh representing the gorund
  106866. */
  106867. export class GroundMesh extends Mesh {
  106868. /** If octree should be generated */
  106869. generateOctree: boolean;
  106870. private _heightQuads;
  106871. /** @hidden */
  106872. _subdivisionsX: number;
  106873. /** @hidden */
  106874. _subdivisionsY: number;
  106875. /** @hidden */
  106876. _width: number;
  106877. /** @hidden */
  106878. _height: number;
  106879. /** @hidden */
  106880. _minX: number;
  106881. /** @hidden */
  106882. _maxX: number;
  106883. /** @hidden */
  106884. _minZ: number;
  106885. /** @hidden */
  106886. _maxZ: number;
  106887. constructor(name: string, scene: Scene);
  106888. /**
  106889. * "GroundMesh"
  106890. * @returns "GroundMesh"
  106891. */
  106892. getClassName(): string;
  106893. /**
  106894. * The minimum of x and y subdivisions
  106895. */
  106896. get subdivisions(): number;
  106897. /**
  106898. * X subdivisions
  106899. */
  106900. get subdivisionsX(): number;
  106901. /**
  106902. * Y subdivisions
  106903. */
  106904. get subdivisionsY(): number;
  106905. /**
  106906. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  106907. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106908. * @param chunksCount the number of subdivisions for x and y
  106909. * @param octreeBlocksSize (Default: 32)
  106910. */
  106911. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  106912. /**
  106913. * Returns a height (y) value in the Worl system :
  106914. * the ground altitude at the coordinates (x, z) expressed in the World system.
  106915. * @param x x coordinate
  106916. * @param z z coordinate
  106917. * @returns the ground y position if (x, z) are outside the ground surface.
  106918. */
  106919. getHeightAtCoordinates(x: number, z: number): number;
  106920. /**
  106921. * Returns a normalized vector (Vector3) orthogonal to the ground
  106922. * at the ground coordinates (x, z) expressed in the World system.
  106923. * @param x x coordinate
  106924. * @param z z coordinate
  106925. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  106926. */
  106927. getNormalAtCoordinates(x: number, z: number): Vector3;
  106928. /**
  106929. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  106930. * at the ground coordinates (x, z) expressed in the World system.
  106931. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  106932. * @param x x coordinate
  106933. * @param z z coordinate
  106934. * @param ref vector to store the result
  106935. * @returns the GroundMesh.
  106936. */
  106937. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  106938. /**
  106939. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  106940. * if the ground has been updated.
  106941. * This can be used in the render loop.
  106942. * @returns the GroundMesh.
  106943. */
  106944. updateCoordinateHeights(): GroundMesh;
  106945. private _getFacetAt;
  106946. private _initHeightQuads;
  106947. private _computeHeightQuads;
  106948. /**
  106949. * Serializes this ground mesh
  106950. * @param serializationObject object to write serialization to
  106951. */
  106952. serialize(serializationObject: any): void;
  106953. /**
  106954. * Parses a serialized ground mesh
  106955. * @param parsedMesh the serialized mesh
  106956. * @param scene the scene to create the ground mesh in
  106957. * @returns the created ground mesh
  106958. */
  106959. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  106960. }
  106961. }
  106962. declare module BABYLON {
  106963. /**
  106964. * Interface for Physics-Joint data
  106965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106966. */
  106967. export interface PhysicsJointData {
  106968. /**
  106969. * The main pivot of the joint
  106970. */
  106971. mainPivot?: Vector3;
  106972. /**
  106973. * The connected pivot of the joint
  106974. */
  106975. connectedPivot?: Vector3;
  106976. /**
  106977. * The main axis of the joint
  106978. */
  106979. mainAxis?: Vector3;
  106980. /**
  106981. * The connected axis of the joint
  106982. */
  106983. connectedAxis?: Vector3;
  106984. /**
  106985. * The collision of the joint
  106986. */
  106987. collision?: boolean;
  106988. /**
  106989. * Native Oimo/Cannon/Energy data
  106990. */
  106991. nativeParams?: any;
  106992. }
  106993. /**
  106994. * This is a holder class for the physics joint created by the physics plugin
  106995. * It holds a set of functions to control the underlying joint
  106996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106997. */
  106998. export class PhysicsJoint {
  106999. /**
  107000. * The type of the physics joint
  107001. */
  107002. type: number;
  107003. /**
  107004. * The data for the physics joint
  107005. */
  107006. jointData: PhysicsJointData;
  107007. private _physicsJoint;
  107008. protected _physicsPlugin: IPhysicsEnginePlugin;
  107009. /**
  107010. * Initializes the physics joint
  107011. * @param type The type of the physics joint
  107012. * @param jointData The data for the physics joint
  107013. */
  107014. constructor(
  107015. /**
  107016. * The type of the physics joint
  107017. */
  107018. type: number,
  107019. /**
  107020. * The data for the physics joint
  107021. */
  107022. jointData: PhysicsJointData);
  107023. /**
  107024. * Gets the physics joint
  107025. */
  107026. get physicsJoint(): any;
  107027. /**
  107028. * Sets the physics joint
  107029. */
  107030. set physicsJoint(newJoint: any);
  107031. /**
  107032. * Sets the physics plugin
  107033. */
  107034. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107035. /**
  107036. * Execute a function that is physics-plugin specific.
  107037. * @param {Function} func the function that will be executed.
  107038. * It accepts two parameters: the physics world and the physics joint
  107039. */
  107040. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107041. /**
  107042. * Distance-Joint type
  107043. */
  107044. static DistanceJoint: number;
  107045. /**
  107046. * Hinge-Joint type
  107047. */
  107048. static HingeJoint: number;
  107049. /**
  107050. * Ball-and-Socket joint type
  107051. */
  107052. static BallAndSocketJoint: number;
  107053. /**
  107054. * Wheel-Joint type
  107055. */
  107056. static WheelJoint: number;
  107057. /**
  107058. * Slider-Joint type
  107059. */
  107060. static SliderJoint: number;
  107061. /**
  107062. * Prismatic-Joint type
  107063. */
  107064. static PrismaticJoint: number;
  107065. /**
  107066. * Universal-Joint type
  107067. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107068. */
  107069. static UniversalJoint: number;
  107070. /**
  107071. * Hinge-Joint 2 type
  107072. */
  107073. static Hinge2Joint: number;
  107074. /**
  107075. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107076. */
  107077. static PointToPointJoint: number;
  107078. /**
  107079. * Spring-Joint type
  107080. */
  107081. static SpringJoint: number;
  107082. /**
  107083. * Lock-Joint type
  107084. */
  107085. static LockJoint: number;
  107086. }
  107087. /**
  107088. * A class representing a physics distance joint
  107089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107090. */
  107091. export class DistanceJoint extends PhysicsJoint {
  107092. /**
  107093. *
  107094. * @param jointData The data for the Distance-Joint
  107095. */
  107096. constructor(jointData: DistanceJointData);
  107097. /**
  107098. * Update the predefined distance.
  107099. * @param maxDistance The maximum preferred distance
  107100. * @param minDistance The minimum preferred distance
  107101. */
  107102. updateDistance(maxDistance: number, minDistance?: number): void;
  107103. }
  107104. /**
  107105. * Represents a Motor-Enabled Joint
  107106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107107. */
  107108. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107109. /**
  107110. * Initializes the Motor-Enabled Joint
  107111. * @param type The type of the joint
  107112. * @param jointData The physica joint data for the joint
  107113. */
  107114. constructor(type: number, jointData: PhysicsJointData);
  107115. /**
  107116. * Set the motor values.
  107117. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107118. * @param force the force to apply
  107119. * @param maxForce max force for this motor.
  107120. */
  107121. setMotor(force?: number, maxForce?: number): void;
  107122. /**
  107123. * Set the motor's limits.
  107124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107125. * @param upperLimit The upper limit of the motor
  107126. * @param lowerLimit The lower limit of the motor
  107127. */
  107128. setLimit(upperLimit: number, lowerLimit?: number): void;
  107129. }
  107130. /**
  107131. * This class represents a single physics Hinge-Joint
  107132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107133. */
  107134. export class HingeJoint extends MotorEnabledJoint {
  107135. /**
  107136. * Initializes the Hinge-Joint
  107137. * @param jointData The joint data for the Hinge-Joint
  107138. */
  107139. constructor(jointData: PhysicsJointData);
  107140. /**
  107141. * Set the motor values.
  107142. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107143. * @param {number} force the force to apply
  107144. * @param {number} maxForce max force for this motor.
  107145. */
  107146. setMotor(force?: number, maxForce?: number): void;
  107147. /**
  107148. * Set the motor's limits.
  107149. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107150. * @param upperLimit The upper limit of the motor
  107151. * @param lowerLimit The lower limit of the motor
  107152. */
  107153. setLimit(upperLimit: number, lowerLimit?: number): void;
  107154. }
  107155. /**
  107156. * This class represents a dual hinge physics joint (same as wheel joint)
  107157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107158. */
  107159. export class Hinge2Joint extends MotorEnabledJoint {
  107160. /**
  107161. * Initializes the Hinge2-Joint
  107162. * @param jointData The joint data for the Hinge2-Joint
  107163. */
  107164. constructor(jointData: PhysicsJointData);
  107165. /**
  107166. * Set the motor values.
  107167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107168. * @param {number} targetSpeed the speed the motor is to reach
  107169. * @param {number} maxForce max force for this motor.
  107170. * @param {motorIndex} the motor's index, 0 or 1.
  107171. */
  107172. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107173. /**
  107174. * Set the motor limits.
  107175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107176. * @param {number} upperLimit the upper limit
  107177. * @param {number} lowerLimit lower limit
  107178. * @param {motorIndex} the motor's index, 0 or 1.
  107179. */
  107180. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107181. }
  107182. /**
  107183. * Interface for a motor enabled joint
  107184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107185. */
  107186. export interface IMotorEnabledJoint {
  107187. /**
  107188. * Physics joint
  107189. */
  107190. physicsJoint: any;
  107191. /**
  107192. * Sets the motor of the motor-enabled joint
  107193. * @param force The force of the motor
  107194. * @param maxForce The maximum force of the motor
  107195. * @param motorIndex The index of the motor
  107196. */
  107197. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107198. /**
  107199. * Sets the limit of the motor
  107200. * @param upperLimit The upper limit of the motor
  107201. * @param lowerLimit The lower limit of the motor
  107202. * @param motorIndex The index of the motor
  107203. */
  107204. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107205. }
  107206. /**
  107207. * Joint data for a Distance-Joint
  107208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107209. */
  107210. export interface DistanceJointData extends PhysicsJointData {
  107211. /**
  107212. * Max distance the 2 joint objects can be apart
  107213. */
  107214. maxDistance: number;
  107215. }
  107216. /**
  107217. * Joint data from a spring joint
  107218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107219. */
  107220. export interface SpringJointData extends PhysicsJointData {
  107221. /**
  107222. * Length of the spring
  107223. */
  107224. length: number;
  107225. /**
  107226. * Stiffness of the spring
  107227. */
  107228. stiffness: number;
  107229. /**
  107230. * Damping of the spring
  107231. */
  107232. damping: number;
  107233. /** this callback will be called when applying the force to the impostors. */
  107234. forceApplicationCallback: () => void;
  107235. }
  107236. }
  107237. declare module BABYLON {
  107238. /**
  107239. * Holds the data for the raycast result
  107240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107241. */
  107242. export class PhysicsRaycastResult {
  107243. private _hasHit;
  107244. private _hitDistance;
  107245. private _hitNormalWorld;
  107246. private _hitPointWorld;
  107247. private _rayFromWorld;
  107248. private _rayToWorld;
  107249. /**
  107250. * Gets if there was a hit
  107251. */
  107252. get hasHit(): boolean;
  107253. /**
  107254. * Gets the distance from the hit
  107255. */
  107256. get hitDistance(): number;
  107257. /**
  107258. * Gets the hit normal/direction in the world
  107259. */
  107260. get hitNormalWorld(): Vector3;
  107261. /**
  107262. * Gets the hit point in the world
  107263. */
  107264. get hitPointWorld(): Vector3;
  107265. /**
  107266. * Gets the ray "start point" of the ray in the world
  107267. */
  107268. get rayFromWorld(): Vector3;
  107269. /**
  107270. * Gets the ray "end point" of the ray in the world
  107271. */
  107272. get rayToWorld(): Vector3;
  107273. /**
  107274. * Sets the hit data (normal & point in world space)
  107275. * @param hitNormalWorld defines the normal in world space
  107276. * @param hitPointWorld defines the point in world space
  107277. */
  107278. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107279. /**
  107280. * Sets the distance from the start point to the hit point
  107281. * @param distance
  107282. */
  107283. setHitDistance(distance: number): void;
  107284. /**
  107285. * Calculates the distance manually
  107286. */
  107287. calculateHitDistance(): void;
  107288. /**
  107289. * Resets all the values to default
  107290. * @param from The from point on world space
  107291. * @param to The to point on world space
  107292. */
  107293. reset(from?: Vector3, to?: Vector3): void;
  107294. }
  107295. /**
  107296. * Interface for the size containing width and height
  107297. */
  107298. interface IXYZ {
  107299. /**
  107300. * X
  107301. */
  107302. x: number;
  107303. /**
  107304. * Y
  107305. */
  107306. y: number;
  107307. /**
  107308. * Z
  107309. */
  107310. z: number;
  107311. }
  107312. }
  107313. declare module BABYLON {
  107314. /**
  107315. * Interface used to describe a physics joint
  107316. */
  107317. export interface PhysicsImpostorJoint {
  107318. /** Defines the main impostor to which the joint is linked */
  107319. mainImpostor: PhysicsImpostor;
  107320. /** Defines the impostor that is connected to the main impostor using this joint */
  107321. connectedImpostor: PhysicsImpostor;
  107322. /** Defines the joint itself */
  107323. joint: PhysicsJoint;
  107324. }
  107325. /** @hidden */
  107326. export interface IPhysicsEnginePlugin {
  107327. world: any;
  107328. name: string;
  107329. setGravity(gravity: Vector3): void;
  107330. setTimeStep(timeStep: number): void;
  107331. getTimeStep(): number;
  107332. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107333. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107334. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107335. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107336. removePhysicsBody(impostor: PhysicsImpostor): void;
  107337. generateJoint(joint: PhysicsImpostorJoint): void;
  107338. removeJoint(joint: PhysicsImpostorJoint): void;
  107339. isSupported(): boolean;
  107340. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107341. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107342. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107343. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107344. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107345. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107346. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107347. getBodyMass(impostor: PhysicsImpostor): number;
  107348. getBodyFriction(impostor: PhysicsImpostor): number;
  107349. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107350. getBodyRestitution(impostor: PhysicsImpostor): number;
  107351. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107352. getBodyPressure?(impostor: PhysicsImpostor): number;
  107353. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107354. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107355. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107356. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107357. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107358. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107359. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107360. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107361. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107362. sleepBody(impostor: PhysicsImpostor): void;
  107363. wakeUpBody(impostor: PhysicsImpostor): void;
  107364. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107365. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107366. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107367. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107368. getRadius(impostor: PhysicsImpostor): number;
  107369. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107370. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107371. dispose(): void;
  107372. }
  107373. /**
  107374. * Interface used to define a physics engine
  107375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107376. */
  107377. export interface IPhysicsEngine {
  107378. /**
  107379. * Gets the gravity vector used by the simulation
  107380. */
  107381. gravity: Vector3;
  107382. /**
  107383. * Sets the gravity vector used by the simulation
  107384. * @param gravity defines the gravity vector to use
  107385. */
  107386. setGravity(gravity: Vector3): void;
  107387. /**
  107388. * Set the time step of the physics engine.
  107389. * Default is 1/60.
  107390. * To slow it down, enter 1/600 for example.
  107391. * To speed it up, 1/30
  107392. * @param newTimeStep the new timestep to apply to this world.
  107393. */
  107394. setTimeStep(newTimeStep: number): void;
  107395. /**
  107396. * Get the time step of the physics engine.
  107397. * @returns the current time step
  107398. */
  107399. getTimeStep(): number;
  107400. /**
  107401. * Set the sub time step of the physics engine.
  107402. * Default is 0 meaning there is no sub steps
  107403. * To increase physics resolution precision, set a small value (like 1 ms)
  107404. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107405. */
  107406. setSubTimeStep(subTimeStep: number): void;
  107407. /**
  107408. * Get the sub time step of the physics engine.
  107409. * @returns the current sub time step
  107410. */
  107411. getSubTimeStep(): number;
  107412. /**
  107413. * Release all resources
  107414. */
  107415. dispose(): void;
  107416. /**
  107417. * Gets the name of the current physics plugin
  107418. * @returns the name of the plugin
  107419. */
  107420. getPhysicsPluginName(): string;
  107421. /**
  107422. * Adding a new impostor for the impostor tracking.
  107423. * This will be done by the impostor itself.
  107424. * @param impostor the impostor to add
  107425. */
  107426. addImpostor(impostor: PhysicsImpostor): void;
  107427. /**
  107428. * Remove an impostor from the engine.
  107429. * This impostor and its mesh will not longer be updated by the physics engine.
  107430. * @param impostor the impostor to remove
  107431. */
  107432. removeImpostor(impostor: PhysicsImpostor): void;
  107433. /**
  107434. * Add a joint to the physics engine
  107435. * @param mainImpostor defines the main impostor to which the joint is added.
  107436. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107437. * @param joint defines the joint that will connect both impostors.
  107438. */
  107439. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107440. /**
  107441. * Removes a joint from the simulation
  107442. * @param mainImpostor defines the impostor used with the joint
  107443. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107444. * @param joint defines the joint to remove
  107445. */
  107446. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107447. /**
  107448. * Gets the current plugin used to run the simulation
  107449. * @returns current plugin
  107450. */
  107451. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107452. /**
  107453. * Gets the list of physic impostors
  107454. * @returns an array of PhysicsImpostor
  107455. */
  107456. getImpostors(): Array<PhysicsImpostor>;
  107457. /**
  107458. * Gets the impostor for a physics enabled object
  107459. * @param object defines the object impersonated by the impostor
  107460. * @returns the PhysicsImpostor or null if not found
  107461. */
  107462. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107463. /**
  107464. * Gets the impostor for a physics body object
  107465. * @param body defines physics body used by the impostor
  107466. * @returns the PhysicsImpostor or null if not found
  107467. */
  107468. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107469. /**
  107470. * Does a raycast in the physics world
  107471. * @param from when should the ray start?
  107472. * @param to when should the ray end?
  107473. * @returns PhysicsRaycastResult
  107474. */
  107475. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107476. /**
  107477. * Called by the scene. No need to call it.
  107478. * @param delta defines the timespam between frames
  107479. */
  107480. _step(delta: number): void;
  107481. }
  107482. }
  107483. declare module BABYLON {
  107484. /**
  107485. * The interface for the physics imposter parameters
  107486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107487. */
  107488. export interface PhysicsImpostorParameters {
  107489. /**
  107490. * The mass of the physics imposter
  107491. */
  107492. mass: number;
  107493. /**
  107494. * The friction of the physics imposter
  107495. */
  107496. friction?: number;
  107497. /**
  107498. * The coefficient of restitution of the physics imposter
  107499. */
  107500. restitution?: number;
  107501. /**
  107502. * The native options of the physics imposter
  107503. */
  107504. nativeOptions?: any;
  107505. /**
  107506. * Specifies if the parent should be ignored
  107507. */
  107508. ignoreParent?: boolean;
  107509. /**
  107510. * Specifies if bi-directional transformations should be disabled
  107511. */
  107512. disableBidirectionalTransformation?: boolean;
  107513. /**
  107514. * The pressure inside the physics imposter, soft object only
  107515. */
  107516. pressure?: number;
  107517. /**
  107518. * The stiffness the physics imposter, soft object only
  107519. */
  107520. stiffness?: number;
  107521. /**
  107522. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107523. */
  107524. velocityIterations?: number;
  107525. /**
  107526. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107527. */
  107528. positionIterations?: number;
  107529. /**
  107530. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107531. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107532. * Add to fix multiple points
  107533. */
  107534. fixedPoints?: number;
  107535. /**
  107536. * The collision margin around a soft object
  107537. */
  107538. margin?: number;
  107539. /**
  107540. * The collision margin around a soft object
  107541. */
  107542. damping?: number;
  107543. /**
  107544. * The path for a rope based on an extrusion
  107545. */
  107546. path?: any;
  107547. /**
  107548. * The shape of an extrusion used for a rope based on an extrusion
  107549. */
  107550. shape?: any;
  107551. }
  107552. /**
  107553. * Interface for a physics-enabled object
  107554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107555. */
  107556. export interface IPhysicsEnabledObject {
  107557. /**
  107558. * The position of the physics-enabled object
  107559. */
  107560. position: Vector3;
  107561. /**
  107562. * The rotation of the physics-enabled object
  107563. */
  107564. rotationQuaternion: Nullable<Quaternion>;
  107565. /**
  107566. * The scale of the physics-enabled object
  107567. */
  107568. scaling: Vector3;
  107569. /**
  107570. * The rotation of the physics-enabled object
  107571. */
  107572. rotation?: Vector3;
  107573. /**
  107574. * The parent of the physics-enabled object
  107575. */
  107576. parent?: any;
  107577. /**
  107578. * The bounding info of the physics-enabled object
  107579. * @returns The bounding info of the physics-enabled object
  107580. */
  107581. getBoundingInfo(): BoundingInfo;
  107582. /**
  107583. * Computes the world matrix
  107584. * @param force Specifies if the world matrix should be computed by force
  107585. * @returns A world matrix
  107586. */
  107587. computeWorldMatrix(force: boolean): Matrix;
  107588. /**
  107589. * Gets the world matrix
  107590. * @returns A world matrix
  107591. */
  107592. getWorldMatrix?(): Matrix;
  107593. /**
  107594. * Gets the child meshes
  107595. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107596. * @returns An array of abstract meshes
  107597. */
  107598. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107599. /**
  107600. * Gets the vertex data
  107601. * @param kind The type of vertex data
  107602. * @returns A nullable array of numbers, or a float32 array
  107603. */
  107604. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107605. /**
  107606. * Gets the indices from the mesh
  107607. * @returns A nullable array of index arrays
  107608. */
  107609. getIndices?(): Nullable<IndicesArray>;
  107610. /**
  107611. * Gets the scene from the mesh
  107612. * @returns the indices array or null
  107613. */
  107614. getScene?(): Scene;
  107615. /**
  107616. * Gets the absolute position from the mesh
  107617. * @returns the absolute position
  107618. */
  107619. getAbsolutePosition(): Vector3;
  107620. /**
  107621. * Gets the absolute pivot point from the mesh
  107622. * @returns the absolute pivot point
  107623. */
  107624. getAbsolutePivotPoint(): Vector3;
  107625. /**
  107626. * Rotates the mesh
  107627. * @param axis The axis of rotation
  107628. * @param amount The amount of rotation
  107629. * @param space The space of the rotation
  107630. * @returns The rotation transform node
  107631. */
  107632. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107633. /**
  107634. * Translates the mesh
  107635. * @param axis The axis of translation
  107636. * @param distance The distance of translation
  107637. * @param space The space of the translation
  107638. * @returns The transform node
  107639. */
  107640. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107641. /**
  107642. * Sets the absolute position of the mesh
  107643. * @param absolutePosition The absolute position of the mesh
  107644. * @returns The transform node
  107645. */
  107646. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107647. /**
  107648. * Gets the class name of the mesh
  107649. * @returns The class name
  107650. */
  107651. getClassName(): string;
  107652. }
  107653. /**
  107654. * Represents a physics imposter
  107655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107656. */
  107657. export class PhysicsImpostor {
  107658. /**
  107659. * The physics-enabled object used as the physics imposter
  107660. */
  107661. object: IPhysicsEnabledObject;
  107662. /**
  107663. * The type of the physics imposter
  107664. */
  107665. type: number;
  107666. private _options;
  107667. private _scene?;
  107668. /**
  107669. * The default object size of the imposter
  107670. */
  107671. static DEFAULT_OBJECT_SIZE: Vector3;
  107672. /**
  107673. * The identity quaternion of the imposter
  107674. */
  107675. static IDENTITY_QUATERNION: Quaternion;
  107676. /** @hidden */
  107677. _pluginData: any;
  107678. private _physicsEngine;
  107679. private _physicsBody;
  107680. private _bodyUpdateRequired;
  107681. private _onBeforePhysicsStepCallbacks;
  107682. private _onAfterPhysicsStepCallbacks;
  107683. /** @hidden */
  107684. _onPhysicsCollideCallbacks: Array<{
  107685. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107686. otherImpostors: Array<PhysicsImpostor>;
  107687. }>;
  107688. private _deltaPosition;
  107689. private _deltaRotation;
  107690. private _deltaRotationConjugated;
  107691. /** @hidden */
  107692. _isFromLine: boolean;
  107693. private _parent;
  107694. private _isDisposed;
  107695. private static _tmpVecs;
  107696. private static _tmpQuat;
  107697. /**
  107698. * Specifies if the physics imposter is disposed
  107699. */
  107700. get isDisposed(): boolean;
  107701. /**
  107702. * Gets the mass of the physics imposter
  107703. */
  107704. get mass(): number;
  107705. set mass(value: number);
  107706. /**
  107707. * Gets the coefficient of friction
  107708. */
  107709. get friction(): number;
  107710. /**
  107711. * Sets the coefficient of friction
  107712. */
  107713. set friction(value: number);
  107714. /**
  107715. * Gets the coefficient of restitution
  107716. */
  107717. get restitution(): number;
  107718. /**
  107719. * Sets the coefficient of restitution
  107720. */
  107721. set restitution(value: number);
  107722. /**
  107723. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  107724. */
  107725. get pressure(): number;
  107726. /**
  107727. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  107728. */
  107729. set pressure(value: number);
  107730. /**
  107731. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107732. */
  107733. get stiffness(): number;
  107734. /**
  107735. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107736. */
  107737. set stiffness(value: number);
  107738. /**
  107739. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107740. */
  107741. get velocityIterations(): number;
  107742. /**
  107743. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107744. */
  107745. set velocityIterations(value: number);
  107746. /**
  107747. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107748. */
  107749. get positionIterations(): number;
  107750. /**
  107751. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107752. */
  107753. set positionIterations(value: number);
  107754. /**
  107755. * The unique id of the physics imposter
  107756. * set by the physics engine when adding this impostor to the array
  107757. */
  107758. uniqueId: number;
  107759. /**
  107760. * @hidden
  107761. */
  107762. soft: boolean;
  107763. /**
  107764. * @hidden
  107765. */
  107766. segments: number;
  107767. private _joints;
  107768. /**
  107769. * Initializes the physics imposter
  107770. * @param object The physics-enabled object used as the physics imposter
  107771. * @param type The type of the physics imposter
  107772. * @param _options The options for the physics imposter
  107773. * @param _scene The Babylon scene
  107774. */
  107775. constructor(
  107776. /**
  107777. * The physics-enabled object used as the physics imposter
  107778. */
  107779. object: IPhysicsEnabledObject,
  107780. /**
  107781. * The type of the physics imposter
  107782. */
  107783. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  107784. /**
  107785. * This function will completly initialize this impostor.
  107786. * It will create a new body - but only if this mesh has no parent.
  107787. * If it has, this impostor will not be used other than to define the impostor
  107788. * of the child mesh.
  107789. * @hidden
  107790. */
  107791. _init(): void;
  107792. private _getPhysicsParent;
  107793. /**
  107794. * Should a new body be generated.
  107795. * @returns boolean specifying if body initialization is required
  107796. */
  107797. isBodyInitRequired(): boolean;
  107798. /**
  107799. * Sets the updated scaling
  107800. * @param updated Specifies if the scaling is updated
  107801. */
  107802. setScalingUpdated(): void;
  107803. /**
  107804. * Force a regeneration of this or the parent's impostor's body.
  107805. * Use under cautious - This will remove all joints already implemented.
  107806. */
  107807. forceUpdate(): void;
  107808. /**
  107809. * Gets the body that holds this impostor. Either its own, or its parent.
  107810. */
  107811. get physicsBody(): any;
  107812. /**
  107813. * Get the parent of the physics imposter
  107814. * @returns Physics imposter or null
  107815. */
  107816. get parent(): Nullable<PhysicsImpostor>;
  107817. /**
  107818. * Sets the parent of the physics imposter
  107819. */
  107820. set parent(value: Nullable<PhysicsImpostor>);
  107821. /**
  107822. * Set the physics body. Used mainly by the physics engine/plugin
  107823. */
  107824. set physicsBody(physicsBody: any);
  107825. /**
  107826. * Resets the update flags
  107827. */
  107828. resetUpdateFlags(): void;
  107829. /**
  107830. * Gets the object extend size
  107831. * @returns the object extend size
  107832. */
  107833. getObjectExtendSize(): Vector3;
  107834. /**
  107835. * Gets the object center
  107836. * @returns The object center
  107837. */
  107838. getObjectCenter(): Vector3;
  107839. /**
  107840. * Get a specific parameter from the options parameters
  107841. * @param paramName The object parameter name
  107842. * @returns The object parameter
  107843. */
  107844. getParam(paramName: string): any;
  107845. /**
  107846. * Sets a specific parameter in the options given to the physics plugin
  107847. * @param paramName The parameter name
  107848. * @param value The value of the parameter
  107849. */
  107850. setParam(paramName: string, value: number): void;
  107851. /**
  107852. * Specifically change the body's mass option. Won't recreate the physics body object
  107853. * @param mass The mass of the physics imposter
  107854. */
  107855. setMass(mass: number): void;
  107856. /**
  107857. * Gets the linear velocity
  107858. * @returns linear velocity or null
  107859. */
  107860. getLinearVelocity(): Nullable<Vector3>;
  107861. /**
  107862. * Sets the linear velocity
  107863. * @param velocity linear velocity or null
  107864. */
  107865. setLinearVelocity(velocity: Nullable<Vector3>): void;
  107866. /**
  107867. * Gets the angular velocity
  107868. * @returns angular velocity or null
  107869. */
  107870. getAngularVelocity(): Nullable<Vector3>;
  107871. /**
  107872. * Sets the angular velocity
  107873. * @param velocity The velocity or null
  107874. */
  107875. setAngularVelocity(velocity: Nullable<Vector3>): void;
  107876. /**
  107877. * Execute a function with the physics plugin native code
  107878. * Provide a function the will have two variables - the world object and the physics body object
  107879. * @param func The function to execute with the physics plugin native code
  107880. */
  107881. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  107882. /**
  107883. * Register a function that will be executed before the physics world is stepping forward
  107884. * @param func The function to execute before the physics world is stepped forward
  107885. */
  107886. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107887. /**
  107888. * Unregister a function that will be executed before the physics world is stepping forward
  107889. * @param func The function to execute before the physics world is stepped forward
  107890. */
  107891. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107892. /**
  107893. * Register a function that will be executed after the physics step
  107894. * @param func The function to execute after physics step
  107895. */
  107896. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107897. /**
  107898. * Unregisters a function that will be executed after the physics step
  107899. * @param func The function to execute after physics step
  107900. */
  107901. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107902. /**
  107903. * register a function that will be executed when this impostor collides against a different body
  107904. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  107905. * @param func Callback that is executed on collision
  107906. */
  107907. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  107908. /**
  107909. * Unregisters the physics imposter on contact
  107910. * @param collideAgainst The physics object to collide against
  107911. * @param func Callback to execute on collision
  107912. */
  107913. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  107914. private _tmpQuat;
  107915. private _tmpQuat2;
  107916. /**
  107917. * Get the parent rotation
  107918. * @returns The parent rotation
  107919. */
  107920. getParentsRotation(): Quaternion;
  107921. /**
  107922. * this function is executed by the physics engine.
  107923. */
  107924. beforeStep: () => void;
  107925. /**
  107926. * this function is executed by the physics engine
  107927. */
  107928. afterStep: () => void;
  107929. /**
  107930. * Legacy collision detection event support
  107931. */
  107932. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  107933. /**
  107934. * event and body object due to cannon's event-based architecture.
  107935. */
  107936. onCollide: (e: {
  107937. body: any;
  107938. }) => void;
  107939. /**
  107940. * Apply a force
  107941. * @param force The force to apply
  107942. * @param contactPoint The contact point for the force
  107943. * @returns The physics imposter
  107944. */
  107945. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107946. /**
  107947. * Apply an impulse
  107948. * @param force The impulse force
  107949. * @param contactPoint The contact point for the impulse force
  107950. * @returns The physics imposter
  107951. */
  107952. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107953. /**
  107954. * A help function to create a joint
  107955. * @param otherImpostor A physics imposter used to create a joint
  107956. * @param jointType The type of joint
  107957. * @param jointData The data for the joint
  107958. * @returns The physics imposter
  107959. */
  107960. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  107961. /**
  107962. * Add a joint to this impostor with a different impostor
  107963. * @param otherImpostor A physics imposter used to add a joint
  107964. * @param joint The joint to add
  107965. * @returns The physics imposter
  107966. */
  107967. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  107968. /**
  107969. * Add an anchor to a cloth impostor
  107970. * @param otherImpostor rigid impostor to anchor to
  107971. * @param width ratio across width from 0 to 1
  107972. * @param height ratio up height from 0 to 1
  107973. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107974. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  107975. * @returns impostor the soft imposter
  107976. */
  107977. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107978. /**
  107979. * Add a hook to a rope impostor
  107980. * @param otherImpostor rigid impostor to anchor to
  107981. * @param length ratio across rope from 0 to 1
  107982. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  107983. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107984. * @returns impostor the rope imposter
  107985. */
  107986. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107987. /**
  107988. * Will keep this body still, in a sleep mode.
  107989. * @returns the physics imposter
  107990. */
  107991. sleep(): PhysicsImpostor;
  107992. /**
  107993. * Wake the body up.
  107994. * @returns The physics imposter
  107995. */
  107996. wakeUp(): PhysicsImpostor;
  107997. /**
  107998. * Clones the physics imposter
  107999. * @param newObject The physics imposter clones to this physics-enabled object
  108000. * @returns A nullable physics imposter
  108001. */
  108002. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108003. /**
  108004. * Disposes the physics imposter
  108005. */
  108006. dispose(): void;
  108007. /**
  108008. * Sets the delta position
  108009. * @param position The delta position amount
  108010. */
  108011. setDeltaPosition(position: Vector3): void;
  108012. /**
  108013. * Sets the delta rotation
  108014. * @param rotation The delta rotation amount
  108015. */
  108016. setDeltaRotation(rotation: Quaternion): void;
  108017. /**
  108018. * Gets the box size of the physics imposter and stores the result in the input parameter
  108019. * @param result Stores the box size
  108020. * @returns The physics imposter
  108021. */
  108022. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108023. /**
  108024. * Gets the radius of the physics imposter
  108025. * @returns Radius of the physics imposter
  108026. */
  108027. getRadius(): number;
  108028. /**
  108029. * Sync a bone with this impostor
  108030. * @param bone The bone to sync to the impostor.
  108031. * @param boneMesh The mesh that the bone is influencing.
  108032. * @param jointPivot The pivot of the joint / bone in local space.
  108033. * @param distToJoint Optional distance from the impostor to the joint.
  108034. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108035. */
  108036. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108037. /**
  108038. * Sync impostor to a bone
  108039. * @param bone The bone that the impostor will be synced to.
  108040. * @param boneMesh The mesh that the bone is influencing.
  108041. * @param jointPivot The pivot of the joint / bone in local space.
  108042. * @param distToJoint Optional distance from the impostor to the joint.
  108043. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108044. * @param boneAxis Optional vector3 axis the bone is aligned with
  108045. */
  108046. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108047. /**
  108048. * No-Imposter type
  108049. */
  108050. static NoImpostor: number;
  108051. /**
  108052. * Sphere-Imposter type
  108053. */
  108054. static SphereImpostor: number;
  108055. /**
  108056. * Box-Imposter type
  108057. */
  108058. static BoxImpostor: number;
  108059. /**
  108060. * Plane-Imposter type
  108061. */
  108062. static PlaneImpostor: number;
  108063. /**
  108064. * Mesh-imposter type
  108065. */
  108066. static MeshImpostor: number;
  108067. /**
  108068. * Capsule-Impostor type (Ammo.js plugin only)
  108069. */
  108070. static CapsuleImpostor: number;
  108071. /**
  108072. * Cylinder-Imposter type
  108073. */
  108074. static CylinderImpostor: number;
  108075. /**
  108076. * Particle-Imposter type
  108077. */
  108078. static ParticleImpostor: number;
  108079. /**
  108080. * Heightmap-Imposter type
  108081. */
  108082. static HeightmapImpostor: number;
  108083. /**
  108084. * ConvexHull-Impostor type (Ammo.js plugin only)
  108085. */
  108086. static ConvexHullImpostor: number;
  108087. /**
  108088. * Custom-Imposter type (Ammo.js plugin only)
  108089. */
  108090. static CustomImpostor: number;
  108091. /**
  108092. * Rope-Imposter type
  108093. */
  108094. static RopeImpostor: number;
  108095. /**
  108096. * Cloth-Imposter type
  108097. */
  108098. static ClothImpostor: number;
  108099. /**
  108100. * Softbody-Imposter type
  108101. */
  108102. static SoftbodyImpostor: number;
  108103. }
  108104. }
  108105. declare module BABYLON {
  108106. /**
  108107. * @hidden
  108108. **/
  108109. export class _CreationDataStorage {
  108110. closePath?: boolean;
  108111. closeArray?: boolean;
  108112. idx: number[];
  108113. dashSize: number;
  108114. gapSize: number;
  108115. path3D: Path3D;
  108116. pathArray: Vector3[][];
  108117. arc: number;
  108118. radius: number;
  108119. cap: number;
  108120. tessellation: number;
  108121. }
  108122. /**
  108123. * @hidden
  108124. **/
  108125. class _InstanceDataStorage {
  108126. visibleInstances: any;
  108127. batchCache: _InstancesBatch;
  108128. instancesBufferSize: number;
  108129. instancesBuffer: Nullable<Buffer>;
  108130. instancesData: Float32Array;
  108131. overridenInstanceCount: number;
  108132. isFrozen: boolean;
  108133. previousBatch: Nullable<_InstancesBatch>;
  108134. hardwareInstancedRendering: boolean;
  108135. sideOrientation: number;
  108136. manualUpdate: boolean;
  108137. previousRenderId: number;
  108138. }
  108139. /**
  108140. * @hidden
  108141. **/
  108142. export class _InstancesBatch {
  108143. mustReturn: boolean;
  108144. visibleInstances: Nullable<InstancedMesh[]>[];
  108145. renderSelf: boolean[];
  108146. hardwareInstancedRendering: boolean[];
  108147. }
  108148. /**
  108149. * @hidden
  108150. **/
  108151. class _ThinInstanceDataStorage {
  108152. instancesCount: number;
  108153. matrixBuffer: Nullable<Buffer>;
  108154. matrixBufferSize: number;
  108155. matrixData: Nullable<Float32Array>;
  108156. boundingVectors: Array<Vector3>;
  108157. worldMatrices: Nullable<Matrix[]>;
  108158. }
  108159. /**
  108160. * Class used to represent renderable models
  108161. */
  108162. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108163. /**
  108164. * Mesh side orientation : usually the external or front surface
  108165. */
  108166. static readonly FRONTSIDE: number;
  108167. /**
  108168. * Mesh side orientation : usually the internal or back surface
  108169. */
  108170. static readonly BACKSIDE: number;
  108171. /**
  108172. * Mesh side orientation : both internal and external or front and back surfaces
  108173. */
  108174. static readonly DOUBLESIDE: number;
  108175. /**
  108176. * Mesh side orientation : by default, `FRONTSIDE`
  108177. */
  108178. static readonly DEFAULTSIDE: number;
  108179. /**
  108180. * Mesh cap setting : no cap
  108181. */
  108182. static readonly NO_CAP: number;
  108183. /**
  108184. * Mesh cap setting : one cap at the beginning of the mesh
  108185. */
  108186. static readonly CAP_START: number;
  108187. /**
  108188. * Mesh cap setting : one cap at the end of the mesh
  108189. */
  108190. static readonly CAP_END: number;
  108191. /**
  108192. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108193. */
  108194. static readonly CAP_ALL: number;
  108195. /**
  108196. * Mesh pattern setting : no flip or rotate
  108197. */
  108198. static readonly NO_FLIP: number;
  108199. /**
  108200. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108201. */
  108202. static readonly FLIP_TILE: number;
  108203. /**
  108204. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108205. */
  108206. static readonly ROTATE_TILE: number;
  108207. /**
  108208. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108209. */
  108210. static readonly FLIP_ROW: number;
  108211. /**
  108212. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108213. */
  108214. static readonly ROTATE_ROW: number;
  108215. /**
  108216. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108217. */
  108218. static readonly FLIP_N_ROTATE_TILE: number;
  108219. /**
  108220. * Mesh pattern setting : rotate pattern and rotate
  108221. */
  108222. static readonly FLIP_N_ROTATE_ROW: number;
  108223. /**
  108224. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108225. */
  108226. static readonly CENTER: number;
  108227. /**
  108228. * Mesh tile positioning : part tiles on left
  108229. */
  108230. static readonly LEFT: number;
  108231. /**
  108232. * Mesh tile positioning : part tiles on right
  108233. */
  108234. static readonly RIGHT: number;
  108235. /**
  108236. * Mesh tile positioning : part tiles on top
  108237. */
  108238. static readonly TOP: number;
  108239. /**
  108240. * Mesh tile positioning : part tiles on bottom
  108241. */
  108242. static readonly BOTTOM: number;
  108243. /**
  108244. * Gets the default side orientation.
  108245. * @param orientation the orientation to value to attempt to get
  108246. * @returns the default orientation
  108247. * @hidden
  108248. */
  108249. static _GetDefaultSideOrientation(orientation?: number): number;
  108250. private _internalMeshDataInfo;
  108251. get computeBonesUsingShaders(): boolean;
  108252. set computeBonesUsingShaders(value: boolean);
  108253. /**
  108254. * An event triggered before rendering the mesh
  108255. */
  108256. get onBeforeRenderObservable(): Observable<Mesh>;
  108257. /**
  108258. * An event triggered before binding the mesh
  108259. */
  108260. get onBeforeBindObservable(): Observable<Mesh>;
  108261. /**
  108262. * An event triggered after rendering the mesh
  108263. */
  108264. get onAfterRenderObservable(): Observable<Mesh>;
  108265. /**
  108266. * An event triggered before drawing the mesh
  108267. */
  108268. get onBeforeDrawObservable(): Observable<Mesh>;
  108269. private _onBeforeDrawObserver;
  108270. /**
  108271. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108272. */
  108273. set onBeforeDraw(callback: () => void);
  108274. get hasInstances(): boolean;
  108275. get hasThinInstances(): boolean;
  108276. /**
  108277. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108278. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108279. */
  108280. delayLoadState: number;
  108281. /**
  108282. * Gets the list of instances created from this mesh
  108283. * it is not supposed to be modified manually.
  108284. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108285. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108286. */
  108287. instances: InstancedMesh[];
  108288. /**
  108289. * Gets the file containing delay loading data for this mesh
  108290. */
  108291. delayLoadingFile: string;
  108292. /** @hidden */
  108293. _binaryInfo: any;
  108294. /**
  108295. * User defined function used to change how LOD level selection is done
  108296. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108297. */
  108298. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108299. /**
  108300. * Gets or sets the morph target manager
  108301. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108302. */
  108303. get morphTargetManager(): Nullable<MorphTargetManager>;
  108304. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108305. /** @hidden */
  108306. _creationDataStorage: Nullable<_CreationDataStorage>;
  108307. /** @hidden */
  108308. _geometry: Nullable<Geometry>;
  108309. /** @hidden */
  108310. _delayInfo: Array<string>;
  108311. /** @hidden */
  108312. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108313. /** @hidden */
  108314. _instanceDataStorage: _InstanceDataStorage;
  108315. /** @hidden */
  108316. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108317. private _effectiveMaterial;
  108318. /** @hidden */
  108319. _shouldGenerateFlatShading: boolean;
  108320. /** @hidden */
  108321. _originalBuilderSideOrientation: number;
  108322. /**
  108323. * Use this property to change the original side orientation defined at construction time
  108324. */
  108325. overrideMaterialSideOrientation: Nullable<number>;
  108326. /**
  108327. * Gets the source mesh (the one used to clone this one from)
  108328. */
  108329. get source(): Nullable<Mesh>;
  108330. /**
  108331. * Gets the list of clones of this mesh
  108332. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108333. * Note that useClonedMeshMap=true is the default setting
  108334. */
  108335. get cloneMeshMap(): Nullable<{
  108336. [id: string]: Mesh | undefined;
  108337. }>;
  108338. /**
  108339. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108340. */
  108341. get isUnIndexed(): boolean;
  108342. set isUnIndexed(value: boolean);
  108343. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108344. get worldMatrixInstancedBuffer(): Float32Array;
  108345. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108346. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108347. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108348. /**
  108349. * @constructor
  108350. * @param name The value used by scene.getMeshByName() to do a lookup.
  108351. * @param scene The scene to add this mesh to.
  108352. * @param parent The parent of this mesh, if it has one
  108353. * @param source An optional Mesh from which geometry is shared, cloned.
  108354. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108355. * When false, achieved by calling a clone(), also passing False.
  108356. * This will make creation of children, recursive.
  108357. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108358. */
  108359. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108360. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108361. doNotInstantiate: boolean;
  108362. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108363. /**
  108364. * Gets the class name
  108365. * @returns the string "Mesh".
  108366. */
  108367. getClassName(): string;
  108368. /** @hidden */
  108369. get _isMesh(): boolean;
  108370. /**
  108371. * Returns a description of this mesh
  108372. * @param fullDetails define if full details about this mesh must be used
  108373. * @returns a descriptive string representing this mesh
  108374. */
  108375. toString(fullDetails?: boolean): string;
  108376. /** @hidden */
  108377. _unBindEffect(): void;
  108378. /**
  108379. * Gets a boolean indicating if this mesh has LOD
  108380. */
  108381. get hasLODLevels(): boolean;
  108382. /**
  108383. * Gets the list of MeshLODLevel associated with the current mesh
  108384. * @returns an array of MeshLODLevel
  108385. */
  108386. getLODLevels(): MeshLODLevel[];
  108387. private _sortLODLevels;
  108388. /**
  108389. * Add a mesh as LOD level triggered at the given distance.
  108390. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108391. * @param distance The distance from the center of the object to show this level
  108392. * @param mesh The mesh to be added as LOD level (can be null)
  108393. * @return This mesh (for chaining)
  108394. */
  108395. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108396. /**
  108397. * Returns the LOD level mesh at the passed distance or null if not found.
  108398. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108399. * @param distance The distance from the center of the object to show this level
  108400. * @returns a Mesh or `null`
  108401. */
  108402. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108403. /**
  108404. * Remove a mesh from the LOD array
  108405. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108406. * @param mesh defines the mesh to be removed
  108407. * @return This mesh (for chaining)
  108408. */
  108409. removeLODLevel(mesh: Mesh): Mesh;
  108410. /**
  108411. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108412. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108413. * @param camera defines the camera to use to compute distance
  108414. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108415. * @return This mesh (for chaining)
  108416. */
  108417. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108418. /**
  108419. * Gets the mesh internal Geometry object
  108420. */
  108421. get geometry(): Nullable<Geometry>;
  108422. /**
  108423. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108424. * @returns the total number of vertices
  108425. */
  108426. getTotalVertices(): number;
  108427. /**
  108428. * Returns the content of an associated vertex buffer
  108429. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108430. * - VertexBuffer.PositionKind
  108431. * - VertexBuffer.UVKind
  108432. * - VertexBuffer.UV2Kind
  108433. * - VertexBuffer.UV3Kind
  108434. * - VertexBuffer.UV4Kind
  108435. * - VertexBuffer.UV5Kind
  108436. * - VertexBuffer.UV6Kind
  108437. * - VertexBuffer.ColorKind
  108438. * - VertexBuffer.MatricesIndicesKind
  108439. * - VertexBuffer.MatricesIndicesExtraKind
  108440. * - VertexBuffer.MatricesWeightsKind
  108441. * - VertexBuffer.MatricesWeightsExtraKind
  108442. * @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
  108443. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108444. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108445. */
  108446. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108447. /**
  108448. * Returns the mesh VertexBuffer object from the requested `kind`
  108449. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108450. * - VertexBuffer.PositionKind
  108451. * - VertexBuffer.NormalKind
  108452. * - VertexBuffer.UVKind
  108453. * - VertexBuffer.UV2Kind
  108454. * - VertexBuffer.UV3Kind
  108455. * - VertexBuffer.UV4Kind
  108456. * - VertexBuffer.UV5Kind
  108457. * - VertexBuffer.UV6Kind
  108458. * - VertexBuffer.ColorKind
  108459. * - VertexBuffer.MatricesIndicesKind
  108460. * - VertexBuffer.MatricesIndicesExtraKind
  108461. * - VertexBuffer.MatricesWeightsKind
  108462. * - VertexBuffer.MatricesWeightsExtraKind
  108463. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108464. */
  108465. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108466. /**
  108467. * Tests if a specific vertex buffer is associated with this mesh
  108468. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108469. * - VertexBuffer.PositionKind
  108470. * - VertexBuffer.NormalKind
  108471. * - VertexBuffer.UVKind
  108472. * - VertexBuffer.UV2Kind
  108473. * - VertexBuffer.UV3Kind
  108474. * - VertexBuffer.UV4Kind
  108475. * - VertexBuffer.UV5Kind
  108476. * - VertexBuffer.UV6Kind
  108477. * - VertexBuffer.ColorKind
  108478. * - VertexBuffer.MatricesIndicesKind
  108479. * - VertexBuffer.MatricesIndicesExtraKind
  108480. * - VertexBuffer.MatricesWeightsKind
  108481. * - VertexBuffer.MatricesWeightsExtraKind
  108482. * @returns a boolean
  108483. */
  108484. isVerticesDataPresent(kind: string): boolean;
  108485. /**
  108486. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108487. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108488. * - VertexBuffer.PositionKind
  108489. * - VertexBuffer.UVKind
  108490. * - VertexBuffer.UV2Kind
  108491. * - VertexBuffer.UV3Kind
  108492. * - VertexBuffer.UV4Kind
  108493. * - VertexBuffer.UV5Kind
  108494. * - VertexBuffer.UV6Kind
  108495. * - VertexBuffer.ColorKind
  108496. * - VertexBuffer.MatricesIndicesKind
  108497. * - VertexBuffer.MatricesIndicesExtraKind
  108498. * - VertexBuffer.MatricesWeightsKind
  108499. * - VertexBuffer.MatricesWeightsExtraKind
  108500. * @returns a boolean
  108501. */
  108502. isVertexBufferUpdatable(kind: string): boolean;
  108503. /**
  108504. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108505. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108506. * - VertexBuffer.PositionKind
  108507. * - VertexBuffer.NormalKind
  108508. * - VertexBuffer.UVKind
  108509. * - VertexBuffer.UV2Kind
  108510. * - VertexBuffer.UV3Kind
  108511. * - VertexBuffer.UV4Kind
  108512. * - VertexBuffer.UV5Kind
  108513. * - VertexBuffer.UV6Kind
  108514. * - VertexBuffer.ColorKind
  108515. * - VertexBuffer.MatricesIndicesKind
  108516. * - VertexBuffer.MatricesIndicesExtraKind
  108517. * - VertexBuffer.MatricesWeightsKind
  108518. * - VertexBuffer.MatricesWeightsExtraKind
  108519. * @returns an array of strings
  108520. */
  108521. getVerticesDataKinds(): string[];
  108522. /**
  108523. * Returns a positive integer : the total number of indices in this mesh geometry.
  108524. * @returns the numner of indices or zero if the mesh has no geometry.
  108525. */
  108526. getTotalIndices(): number;
  108527. /**
  108528. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108529. * @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.
  108530. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108531. * @returns the indices array or an empty array if the mesh has no geometry
  108532. */
  108533. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108534. get isBlocked(): boolean;
  108535. /**
  108536. * Determine if the current mesh is ready to be rendered
  108537. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108538. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108539. * @returns true if all associated assets are ready (material, textures, shaders)
  108540. */
  108541. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108542. /**
  108543. * 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.
  108544. */
  108545. get areNormalsFrozen(): boolean;
  108546. /**
  108547. * 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.
  108548. * @returns the current mesh
  108549. */
  108550. freezeNormals(): Mesh;
  108551. /**
  108552. * 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
  108553. * @returns the current mesh
  108554. */
  108555. unfreezeNormals(): Mesh;
  108556. /**
  108557. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108558. */
  108559. set overridenInstanceCount(count: number);
  108560. /** @hidden */
  108561. _preActivate(): Mesh;
  108562. /** @hidden */
  108563. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108564. /** @hidden */
  108565. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108566. protected _afterComputeWorldMatrix(): void;
  108567. /** @hidden */
  108568. _postActivate(): void;
  108569. /**
  108570. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108571. * This means the mesh underlying bounding box and sphere are recomputed.
  108572. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108573. * @returns the current mesh
  108574. */
  108575. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108576. /** @hidden */
  108577. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108578. /**
  108579. * This function will subdivide the mesh into multiple submeshes
  108580. * @param count defines the expected number of submeshes
  108581. */
  108582. subdivide(count: number): void;
  108583. /**
  108584. * Copy a FloatArray into a specific associated vertex buffer
  108585. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108586. * - VertexBuffer.PositionKind
  108587. * - VertexBuffer.UVKind
  108588. * - VertexBuffer.UV2Kind
  108589. * - VertexBuffer.UV3Kind
  108590. * - VertexBuffer.UV4Kind
  108591. * - VertexBuffer.UV5Kind
  108592. * - VertexBuffer.UV6Kind
  108593. * - VertexBuffer.ColorKind
  108594. * - VertexBuffer.MatricesIndicesKind
  108595. * - VertexBuffer.MatricesIndicesExtraKind
  108596. * - VertexBuffer.MatricesWeightsKind
  108597. * - VertexBuffer.MatricesWeightsExtraKind
  108598. * @param data defines the data source
  108599. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108600. * @param stride defines the data stride size (can be null)
  108601. * @returns the current mesh
  108602. */
  108603. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108604. /**
  108605. * Delete a vertex buffer associated with this mesh
  108606. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108607. * - VertexBuffer.PositionKind
  108608. * - VertexBuffer.UVKind
  108609. * - VertexBuffer.UV2Kind
  108610. * - VertexBuffer.UV3Kind
  108611. * - VertexBuffer.UV4Kind
  108612. * - VertexBuffer.UV5Kind
  108613. * - VertexBuffer.UV6Kind
  108614. * - VertexBuffer.ColorKind
  108615. * - VertexBuffer.MatricesIndicesKind
  108616. * - VertexBuffer.MatricesIndicesExtraKind
  108617. * - VertexBuffer.MatricesWeightsKind
  108618. * - VertexBuffer.MatricesWeightsExtraKind
  108619. */
  108620. removeVerticesData(kind: string): void;
  108621. /**
  108622. * Flags an associated vertex buffer as updatable
  108623. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108624. * - VertexBuffer.PositionKind
  108625. * - VertexBuffer.UVKind
  108626. * - VertexBuffer.UV2Kind
  108627. * - VertexBuffer.UV3Kind
  108628. * - VertexBuffer.UV4Kind
  108629. * - VertexBuffer.UV5Kind
  108630. * - VertexBuffer.UV6Kind
  108631. * - VertexBuffer.ColorKind
  108632. * - VertexBuffer.MatricesIndicesKind
  108633. * - VertexBuffer.MatricesIndicesExtraKind
  108634. * - VertexBuffer.MatricesWeightsKind
  108635. * - VertexBuffer.MatricesWeightsExtraKind
  108636. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108637. */
  108638. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108639. /**
  108640. * Sets the mesh global Vertex Buffer
  108641. * @param buffer defines the buffer to use
  108642. * @returns the current mesh
  108643. */
  108644. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108645. /**
  108646. * Update a specific associated vertex buffer
  108647. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108648. * - VertexBuffer.PositionKind
  108649. * - VertexBuffer.UVKind
  108650. * - VertexBuffer.UV2Kind
  108651. * - VertexBuffer.UV3Kind
  108652. * - VertexBuffer.UV4Kind
  108653. * - VertexBuffer.UV5Kind
  108654. * - VertexBuffer.UV6Kind
  108655. * - VertexBuffer.ColorKind
  108656. * - VertexBuffer.MatricesIndicesKind
  108657. * - VertexBuffer.MatricesIndicesExtraKind
  108658. * - VertexBuffer.MatricesWeightsKind
  108659. * - VertexBuffer.MatricesWeightsExtraKind
  108660. * @param data defines the data source
  108661. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108662. * @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)
  108663. * @returns the current mesh
  108664. */
  108665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108666. /**
  108667. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108668. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108669. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108670. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108671. * @returns the current mesh
  108672. */
  108673. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108674. /**
  108675. * Creates a un-shared specific occurence of the geometry for the mesh.
  108676. * @returns the current mesh
  108677. */
  108678. makeGeometryUnique(): Mesh;
  108679. /**
  108680. * Set the index buffer of this mesh
  108681. * @param indices defines the source data
  108682. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108683. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108684. * @returns the current mesh
  108685. */
  108686. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108687. /**
  108688. * Update the current index buffer
  108689. * @param indices defines the source data
  108690. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108691. * @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)
  108692. * @returns the current mesh
  108693. */
  108694. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108695. /**
  108696. * Invert the geometry to move from a right handed system to a left handed one.
  108697. * @returns the current mesh
  108698. */
  108699. toLeftHanded(): Mesh;
  108700. /** @hidden */
  108701. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  108702. /** @hidden */
  108703. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  108704. /**
  108705. * Registers for this mesh a javascript function called just before the rendering process
  108706. * @param func defines the function to call before rendering this mesh
  108707. * @returns the current mesh
  108708. */
  108709. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108710. /**
  108711. * Disposes a previously registered javascript function called before the rendering
  108712. * @param func defines the function to remove
  108713. * @returns the current mesh
  108714. */
  108715. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108716. /**
  108717. * Registers for this mesh a javascript function called just after the rendering is complete
  108718. * @param func defines the function to call after rendering this mesh
  108719. * @returns the current mesh
  108720. */
  108721. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108722. /**
  108723. * Disposes a previously registered javascript function called after the rendering.
  108724. * @param func defines the function to remove
  108725. * @returns the current mesh
  108726. */
  108727. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108728. /** @hidden */
  108729. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  108730. /** @hidden */
  108731. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  108732. /** @hidden */
  108733. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  108734. /** @hidden */
  108735. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  108736. /** @hidden */
  108737. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  108738. /** @hidden */
  108739. _rebuild(): void;
  108740. /** @hidden */
  108741. _freeze(): void;
  108742. /** @hidden */
  108743. _unFreeze(): void;
  108744. /**
  108745. * 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
  108746. * @param subMesh defines the subMesh to render
  108747. * @param enableAlphaMode defines if alpha mode can be changed
  108748. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  108749. * @returns the current mesh
  108750. */
  108751. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  108752. private _onBeforeDraw;
  108753. /**
  108754. * Renormalize the mesh and patch it up if there are no weights
  108755. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  108756. * However in the case of zero weights then we set just a single influence to 1.
  108757. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  108758. */
  108759. cleanMatrixWeights(): void;
  108760. private normalizeSkinFourWeights;
  108761. private normalizeSkinWeightsAndExtra;
  108762. /**
  108763. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  108764. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  108765. * the user know there was an issue with importing the mesh
  108766. * @returns a validation object with skinned, valid and report string
  108767. */
  108768. validateSkinning(): {
  108769. skinned: boolean;
  108770. valid: boolean;
  108771. report: string;
  108772. };
  108773. /** @hidden */
  108774. _checkDelayState(): Mesh;
  108775. private _queueLoad;
  108776. /**
  108777. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108778. * A mesh is in the frustum if its bounding box intersects the frustum
  108779. * @param frustumPlanes defines the frustum to test
  108780. * @returns true if the mesh is in the frustum planes
  108781. */
  108782. isInFrustum(frustumPlanes: Plane[]): boolean;
  108783. /**
  108784. * Sets the mesh material by the material or multiMaterial `id` property
  108785. * @param id is a string identifying the material or the multiMaterial
  108786. * @returns the current mesh
  108787. */
  108788. setMaterialByID(id: string): Mesh;
  108789. /**
  108790. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  108791. * @returns an array of IAnimatable
  108792. */
  108793. getAnimatables(): IAnimatable[];
  108794. /**
  108795. * Modifies the mesh geometry according to the passed transformation matrix.
  108796. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  108797. * The mesh normals are modified using the same transformation.
  108798. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108799. * @param transform defines the transform matrix to use
  108800. * @see https://doc.babylonjs.com/resources/baking_transformations
  108801. * @returns the current mesh
  108802. */
  108803. bakeTransformIntoVertices(transform: Matrix): Mesh;
  108804. /**
  108805. * Modifies the mesh geometry according to its own current World Matrix.
  108806. * The mesh World Matrix is then reset.
  108807. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  108808. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108809. * @see https://doc.babylonjs.com/resources/baking_transformations
  108810. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  108811. * @returns the current mesh
  108812. */
  108813. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  108814. /** @hidden */
  108815. get _positions(): Nullable<Vector3[]>;
  108816. /** @hidden */
  108817. _resetPointsArrayCache(): Mesh;
  108818. /** @hidden */
  108819. _generatePointsArray(): boolean;
  108820. /**
  108821. * Returns a new Mesh object generated from the current mesh properties.
  108822. * This method must not get confused with createInstance()
  108823. * @param name is a string, the name given to the new mesh
  108824. * @param newParent can be any Node object (default `null`)
  108825. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  108826. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  108827. * @returns a new mesh
  108828. */
  108829. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  108830. /**
  108831. * Releases resources associated with this mesh.
  108832. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108833. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108834. */
  108835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108836. /** @hidden */
  108837. _disposeInstanceSpecificData(): void;
  108838. /** @hidden */
  108839. _disposeThinInstanceSpecificData(): void;
  108840. /**
  108841. * Modifies the mesh geometry according to a displacement map.
  108842. * 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.
  108843. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108844. * @param url is a string, the URL from the image file is to be downloaded.
  108845. * @param minHeight is the lower limit of the displacement.
  108846. * @param maxHeight is the upper limit of the displacement.
  108847. * @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.
  108848. * @param uvOffset is an optional vector2 used to offset UV.
  108849. * @param uvScale is an optional vector2 used to scale UV.
  108850. * @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.
  108851. * @returns the Mesh.
  108852. */
  108853. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108854. /**
  108855. * Modifies the mesh geometry according to a displacementMap buffer.
  108856. * 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.
  108857. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108858. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  108859. * @param heightMapWidth is the width of the buffer image.
  108860. * @param heightMapHeight is the height of the buffer image.
  108861. * @param minHeight is the lower limit of the displacement.
  108862. * @param maxHeight is the upper limit of the displacement.
  108863. * @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.
  108864. * @param uvOffset is an optional vector2 used to offset UV.
  108865. * @param uvScale is an optional vector2 used to scale UV.
  108866. * @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.
  108867. * @returns the Mesh.
  108868. */
  108869. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108870. /**
  108871. * Modify the mesh to get a flat shading rendering.
  108872. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  108873. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  108874. * @returns current mesh
  108875. */
  108876. convertToFlatShadedMesh(): Mesh;
  108877. /**
  108878. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  108879. * In other words, more vertices, no more indices and a single bigger VBO.
  108880. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  108881. * @returns current mesh
  108882. */
  108883. convertToUnIndexedMesh(): Mesh;
  108884. /**
  108885. * Inverses facet orientations.
  108886. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108887. * @param flipNormals will also inverts the normals
  108888. * @returns current mesh
  108889. */
  108890. flipFaces(flipNormals?: boolean): Mesh;
  108891. /**
  108892. * Increase the number of facets and hence vertices in a mesh
  108893. * Vertex normals are interpolated from existing vertex normals
  108894. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108895. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  108896. */
  108897. increaseVertices(numberPerEdge: number): void;
  108898. /**
  108899. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  108900. * This will undo any application of covertToFlatShadedMesh
  108901. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108902. */
  108903. forceSharedVertices(): void;
  108904. /** @hidden */
  108905. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  108906. /** @hidden */
  108907. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  108908. /**
  108909. * Creates a new InstancedMesh object from the mesh model.
  108910. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108911. * @param name defines the name of the new instance
  108912. * @returns a new InstancedMesh
  108913. */
  108914. createInstance(name: string): InstancedMesh;
  108915. /**
  108916. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  108917. * After this call, all the mesh instances have the same submeshes than the current mesh.
  108918. * @returns the current mesh
  108919. */
  108920. synchronizeInstances(): Mesh;
  108921. /**
  108922. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  108923. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  108924. * This should be used together with the simplification to avoid disappearing triangles.
  108925. * @param successCallback an optional success callback to be called after the optimization finished.
  108926. * @returns the current mesh
  108927. */
  108928. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  108929. /**
  108930. * Serialize current mesh
  108931. * @param serializationObject defines the object which will receive the serialization data
  108932. */
  108933. serialize(serializationObject: any): void;
  108934. /** @hidden */
  108935. _syncGeometryWithMorphTargetManager(): void;
  108936. /** @hidden */
  108937. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  108938. /**
  108939. * Returns a new Mesh object parsed from the source provided.
  108940. * @param parsedMesh is the source
  108941. * @param scene defines the hosting scene
  108942. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  108943. * @returns a new Mesh
  108944. */
  108945. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  108946. /**
  108947. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  108948. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108949. * @param name defines the name of the mesh to create
  108950. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  108951. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  108952. * @param closePath creates a seam between the first and the last points of each path of the path array
  108953. * @param offset is taken in account only if the `pathArray` is containing a single path
  108954. * @param scene defines the hosting scene
  108955. * @param updatable defines if the mesh must be flagged as updatable
  108956. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108957. * @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)
  108958. * @returns a new Mesh
  108959. */
  108960. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108961. /**
  108962. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  108963. * @param name defines the name of the mesh to create
  108964. * @param radius sets the radius size (float) of the polygon (default 0.5)
  108965. * @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
  108966. * @param scene defines the hosting scene
  108967. * @param updatable defines if the mesh must be flagged as updatable
  108968. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108969. * @returns a new Mesh
  108970. */
  108971. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108972. /**
  108973. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  108974. * @param name defines the name of the mesh to create
  108975. * @param size sets the size (float) of each box side (default 1)
  108976. * @param scene defines the hosting scene
  108977. * @param updatable defines if the mesh must be flagged as updatable
  108978. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108979. * @returns a new Mesh
  108980. */
  108981. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108982. /**
  108983. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  108984. * @param name defines the name of the mesh to create
  108985. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108986. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108987. * @param scene defines the hosting scene
  108988. * @param updatable defines if the mesh must be flagged as updatable
  108989. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108990. * @returns a new Mesh
  108991. */
  108992. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108993. /**
  108994. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  108995. * @param name defines the name of the mesh to create
  108996. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108997. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108998. * @param scene defines the hosting scene
  108999. * @returns a new Mesh
  109000. */
  109001. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109002. /**
  109003. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109004. * @param name defines the name of the mesh to create
  109005. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109006. * @param diameterTop set the top cap diameter (floats, default 1)
  109007. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109008. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109009. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109010. * @param scene defines the hosting scene
  109011. * @param updatable defines if the mesh must be flagged as updatable
  109012. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109013. * @returns a new Mesh
  109014. */
  109015. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109016. /**
  109017. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109018. * @param name defines the name of the mesh to create
  109019. * @param diameter sets the diameter size (float) of the torus (default 1)
  109020. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109021. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109022. * @param scene defines the hosting scene
  109023. * @param updatable defines if the mesh must be flagged as updatable
  109024. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109025. * @returns a new Mesh
  109026. */
  109027. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109028. /**
  109029. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109030. * @param name defines the name of the mesh to create
  109031. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109032. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109033. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109034. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109035. * @param p the number of windings on X axis (positive integers, default 2)
  109036. * @param q the number of windings on Y axis (positive integers, default 3)
  109037. * @param scene defines the hosting scene
  109038. * @param updatable defines if the mesh must be flagged as updatable
  109039. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109040. * @returns a new Mesh
  109041. */
  109042. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109043. /**
  109044. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109045. * @param name defines the name of the mesh to create
  109046. * @param points is an array successive Vector3
  109047. * @param scene defines the hosting scene
  109048. * @param updatable defines if the mesh must be flagged as updatable
  109049. * @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).
  109050. * @returns a new Mesh
  109051. */
  109052. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109053. /**
  109054. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109055. * @param name defines the name of the mesh to create
  109056. * @param points is an array successive Vector3
  109057. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109058. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109059. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109060. * @param scene defines the hosting scene
  109061. * @param updatable defines if the mesh must be flagged as updatable
  109062. * @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)
  109063. * @returns a new Mesh
  109064. */
  109065. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109066. /**
  109067. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109068. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109069. * 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.
  109070. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109071. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109072. * Remember you can only change the shape positions, not their number when updating a polygon.
  109073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109074. * @param name defines the name of the mesh to create
  109075. * @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
  109076. * @param scene defines the hosting scene
  109077. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109078. * @param updatable defines if the mesh must be flagged as updatable
  109079. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109080. * @param earcutInjection can be used to inject your own earcut reference
  109081. * @returns a new Mesh
  109082. */
  109083. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109084. /**
  109085. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109087. * @param name defines the name of the mesh to create
  109088. * @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
  109089. * @param depth defines the height of extrusion
  109090. * @param scene defines the hosting scene
  109091. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109092. * @param updatable defines if the mesh must be flagged as updatable
  109093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109094. * @param earcutInjection can be used to inject your own earcut reference
  109095. * @returns a new Mesh
  109096. */
  109097. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109098. /**
  109099. * Creates an extruded shape mesh.
  109100. * 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
  109101. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109103. * @param name defines the name of the mesh to create
  109104. * @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
  109105. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109106. * @param scale is the value to scale the shape
  109107. * @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
  109108. * @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
  109109. * @param scene defines the hosting scene
  109110. * @param updatable defines if the mesh must be flagged as updatable
  109111. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109112. * @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)
  109113. * @returns a new Mesh
  109114. */
  109115. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109116. /**
  109117. * Creates an custom extruded shape mesh.
  109118. * The custom extrusion is a parametric shape.
  109119. * It has no predefined shape. Its final shape will depend on the input parameters.
  109120. * Please consider using the same method from the MeshBuilder class instead
  109121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109122. * @param name defines the name of the mesh to create
  109123. * @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
  109124. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109125. * @param scaleFunction is a custom Javascript function called on each path point
  109126. * @param rotationFunction is a custom Javascript function called on each path point
  109127. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109128. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109129. * @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
  109130. * @param scene defines the hosting scene
  109131. * @param updatable defines if the mesh must be flagged as updatable
  109132. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109133. * @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)
  109134. * @returns a new Mesh
  109135. */
  109136. 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;
  109137. /**
  109138. * Creates lathe mesh.
  109139. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109140. * Please consider using the same method from the MeshBuilder class instead
  109141. * @param name defines the name of the mesh to create
  109142. * @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
  109143. * @param radius is the radius value of the lathe
  109144. * @param tessellation is the side number of the lathe.
  109145. * @param scene defines the hosting scene
  109146. * @param updatable defines if the mesh must be flagged as updatable
  109147. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109148. * @returns a new Mesh
  109149. */
  109150. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109151. /**
  109152. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109153. * @param name defines the name of the mesh to create
  109154. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109155. * @param scene defines the hosting scene
  109156. * @param updatable defines if the mesh must be flagged as updatable
  109157. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109158. * @returns a new Mesh
  109159. */
  109160. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109161. /**
  109162. * Creates a ground mesh.
  109163. * Please consider using the same method from the MeshBuilder class instead
  109164. * @param name defines the name of the mesh to create
  109165. * @param width set the width of the ground
  109166. * @param height set the height of the ground
  109167. * @param subdivisions sets the number of subdivisions per side
  109168. * @param scene defines the hosting scene
  109169. * @param updatable defines if the mesh must be flagged as updatable
  109170. * @returns a new Mesh
  109171. */
  109172. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109173. /**
  109174. * Creates a tiled ground mesh.
  109175. * Please consider using the same method from the MeshBuilder class instead
  109176. * @param name defines the name of the mesh to create
  109177. * @param xmin set the ground minimum X coordinate
  109178. * @param zmin set the ground minimum Y coordinate
  109179. * @param xmax set the ground maximum X coordinate
  109180. * @param zmax set the ground maximum Z coordinate
  109181. * @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
  109182. * @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
  109183. * @param scene defines the hosting scene
  109184. * @param updatable defines if the mesh must be flagged as updatable
  109185. * @returns a new Mesh
  109186. */
  109187. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109188. w: number;
  109189. h: number;
  109190. }, precision: {
  109191. w: number;
  109192. h: number;
  109193. }, scene: Scene, updatable?: boolean): Mesh;
  109194. /**
  109195. * Creates a ground mesh from a height map.
  109196. * Please consider using the same method from the MeshBuilder class instead
  109197. * @see https://doc.babylonjs.com/babylon101/height_map
  109198. * @param name defines the name of the mesh to create
  109199. * @param url sets the URL of the height map image resource
  109200. * @param width set the ground width size
  109201. * @param height set the ground height size
  109202. * @param subdivisions sets the number of subdivision per side
  109203. * @param minHeight is the minimum altitude on the ground
  109204. * @param maxHeight is the maximum altitude on the ground
  109205. * @param scene defines the hosting scene
  109206. * @param updatable defines if the mesh must be flagged as updatable
  109207. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109208. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109209. * @returns a new Mesh
  109210. */
  109211. 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;
  109212. /**
  109213. * Creates a tube mesh.
  109214. * The tube is a parametric shape.
  109215. * It has no predefined shape. Its final shape will depend on the input parameters.
  109216. * Please consider using the same method from the MeshBuilder class instead
  109217. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109218. * @param name defines the name of the mesh to create
  109219. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109220. * @param radius sets the tube radius size
  109221. * @param tessellation is the number of sides on the tubular surface
  109222. * @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
  109223. * @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
  109224. * @param scene defines the hosting scene
  109225. * @param updatable defines if the mesh must be flagged as updatable
  109226. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109227. * @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)
  109228. * @returns a new Mesh
  109229. */
  109230. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109231. (i: number, distance: number): number;
  109232. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109233. /**
  109234. * Creates a polyhedron mesh.
  109235. * Please consider using the same method from the MeshBuilder class instead.
  109236. * * 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
  109237. * * The parameter `size` (positive float, default 1) sets the polygon size
  109238. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109239. * * 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`
  109240. * * 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
  109241. * * 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)`)
  109242. * * 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
  109243. * * 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
  109244. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109247. * @param name defines the name of the mesh to create
  109248. * @param options defines the options used to create the mesh
  109249. * @param scene defines the hosting scene
  109250. * @returns a new Mesh
  109251. */
  109252. static CreatePolyhedron(name: string, options: {
  109253. type?: number;
  109254. size?: number;
  109255. sizeX?: number;
  109256. sizeY?: number;
  109257. sizeZ?: number;
  109258. custom?: any;
  109259. faceUV?: Vector4[];
  109260. faceColors?: Color4[];
  109261. updatable?: boolean;
  109262. sideOrientation?: number;
  109263. }, scene: Scene): Mesh;
  109264. /**
  109265. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109266. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109267. * * 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`)
  109268. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109269. * * 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
  109270. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109273. * @param name defines the name of the mesh
  109274. * @param options defines the options used to create the mesh
  109275. * @param scene defines the hosting scene
  109276. * @returns a new Mesh
  109277. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109278. */
  109279. static CreateIcoSphere(name: string, options: {
  109280. radius?: number;
  109281. flat?: boolean;
  109282. subdivisions?: number;
  109283. sideOrientation?: number;
  109284. updatable?: boolean;
  109285. }, scene: Scene): Mesh;
  109286. /**
  109287. * Creates a decal mesh.
  109288. * Please consider using the same method from the MeshBuilder class instead.
  109289. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109290. * @param name defines the name of the mesh
  109291. * @param sourceMesh defines the mesh receiving the decal
  109292. * @param position sets the position of the decal in world coordinates
  109293. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109294. * @param size sets the decal scaling
  109295. * @param angle sets the angle to rotate the decal
  109296. * @returns a new Mesh
  109297. */
  109298. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109299. /** Creates a Capsule Mesh
  109300. * @param name defines the name of the mesh.
  109301. * @param options the constructors options used to shape the mesh.
  109302. * @param scene defines the scene the mesh is scoped to.
  109303. * @returns the capsule mesh
  109304. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109305. */
  109306. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109307. /**
  109308. * Prepare internal position array for software CPU skinning
  109309. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109310. */
  109311. setPositionsForCPUSkinning(): Float32Array;
  109312. /**
  109313. * Prepare internal normal array for software CPU skinning
  109314. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109315. */
  109316. setNormalsForCPUSkinning(): Float32Array;
  109317. /**
  109318. * Updates the vertex buffer by applying transformation from the bones
  109319. * @param skeleton defines the skeleton to apply to current mesh
  109320. * @returns the current mesh
  109321. */
  109322. applySkeleton(skeleton: Skeleton): Mesh;
  109323. /**
  109324. * 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
  109325. * @param meshes defines the list of meshes to scan
  109326. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109327. */
  109328. static MinMax(meshes: AbstractMesh[]): {
  109329. min: Vector3;
  109330. max: Vector3;
  109331. };
  109332. /**
  109333. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109334. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109335. * @returns a vector3
  109336. */
  109337. static Center(meshesOrMinMaxVector: {
  109338. min: Vector3;
  109339. max: Vector3;
  109340. } | AbstractMesh[]): Vector3;
  109341. /**
  109342. * Merge the array of meshes into a single mesh for performance reasons.
  109343. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109344. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109345. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109346. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109347. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109348. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109349. * @returns a new mesh
  109350. */
  109351. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109352. /** @hidden */
  109353. addInstance(instance: InstancedMesh): void;
  109354. /** @hidden */
  109355. removeInstance(instance: InstancedMesh): void;
  109356. }
  109357. }
  109358. declare module BABYLON {
  109359. /**
  109360. * This is the base class of all the camera used in the application.
  109361. * @see https://doc.babylonjs.com/features/cameras
  109362. */
  109363. export class Camera extends Node {
  109364. /** @hidden */
  109365. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109366. /**
  109367. * This is the default projection mode used by the cameras.
  109368. * It helps recreating a feeling of perspective and better appreciate depth.
  109369. * This is the best way to simulate real life cameras.
  109370. */
  109371. static readonly PERSPECTIVE_CAMERA: number;
  109372. /**
  109373. * This helps creating camera with an orthographic mode.
  109374. * 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.
  109375. */
  109376. static readonly ORTHOGRAPHIC_CAMERA: number;
  109377. /**
  109378. * This is the default FOV mode for perspective cameras.
  109379. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109380. */
  109381. static readonly FOVMODE_VERTICAL_FIXED: number;
  109382. /**
  109383. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109384. */
  109385. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109386. /**
  109387. * This specifies ther is no need for a camera rig.
  109388. * Basically only one eye is rendered corresponding to the camera.
  109389. */
  109390. static readonly RIG_MODE_NONE: number;
  109391. /**
  109392. * Simulates a camera Rig with one blue eye and one red eye.
  109393. * This can be use with 3d blue and red glasses.
  109394. */
  109395. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109396. /**
  109397. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109398. */
  109399. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109400. /**
  109401. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109402. */
  109403. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109404. /**
  109405. * Defines that both eyes of the camera will be rendered over under each other.
  109406. */
  109407. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109408. /**
  109409. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109410. */
  109411. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109412. /**
  109413. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109414. */
  109415. static readonly RIG_MODE_VR: number;
  109416. /**
  109417. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109418. */
  109419. static readonly RIG_MODE_WEBVR: number;
  109420. /**
  109421. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109422. */
  109423. static readonly RIG_MODE_CUSTOM: number;
  109424. /**
  109425. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109426. */
  109427. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109428. /**
  109429. * Define the input manager associated with the camera.
  109430. */
  109431. inputs: CameraInputsManager<Camera>;
  109432. /** @hidden */
  109433. _position: Vector3;
  109434. /**
  109435. * Define the current local position of the camera in the scene
  109436. */
  109437. get position(): Vector3;
  109438. set position(newPosition: Vector3);
  109439. protected _upVector: Vector3;
  109440. /**
  109441. * The vector the camera should consider as up.
  109442. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109443. */
  109444. set upVector(vec: Vector3);
  109445. get upVector(): Vector3;
  109446. /**
  109447. * Define the current limit on the left side for an orthographic camera
  109448. * In scene unit
  109449. */
  109450. orthoLeft: Nullable<number>;
  109451. /**
  109452. * Define the current limit on the right side for an orthographic camera
  109453. * In scene unit
  109454. */
  109455. orthoRight: Nullable<number>;
  109456. /**
  109457. * Define the current limit on the bottom side for an orthographic camera
  109458. * In scene unit
  109459. */
  109460. orthoBottom: Nullable<number>;
  109461. /**
  109462. * Define the current limit on the top side for an orthographic camera
  109463. * In scene unit
  109464. */
  109465. orthoTop: Nullable<number>;
  109466. /**
  109467. * Field Of View is set in Radians. (default is 0.8)
  109468. */
  109469. fov: number;
  109470. /**
  109471. * Define the minimum distance the camera can see from.
  109472. * This is important to note that the depth buffer are not infinite and the closer it starts
  109473. * the more your scene might encounter depth fighting issue.
  109474. */
  109475. minZ: number;
  109476. /**
  109477. * Define the maximum distance the camera can see to.
  109478. * This is important to note that the depth buffer are not infinite and the further it end
  109479. * the more your scene might encounter depth fighting issue.
  109480. */
  109481. maxZ: number;
  109482. /**
  109483. * Define the default inertia of the camera.
  109484. * This helps giving a smooth feeling to the camera movement.
  109485. */
  109486. inertia: number;
  109487. /**
  109488. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109489. */
  109490. mode: number;
  109491. /**
  109492. * Define whether the camera is intermediate.
  109493. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109494. */
  109495. isIntermediate: boolean;
  109496. /**
  109497. * Define the viewport of the camera.
  109498. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109499. */
  109500. viewport: Viewport;
  109501. /**
  109502. * Restricts the camera to viewing objects with the same layerMask.
  109503. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109504. */
  109505. layerMask: number;
  109506. /**
  109507. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109508. */
  109509. fovMode: number;
  109510. /**
  109511. * Rig mode of the camera.
  109512. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109513. * This is normally controlled byt the camera themselves as internal use.
  109514. */
  109515. cameraRigMode: number;
  109516. /**
  109517. * Defines the distance between both "eyes" in case of a RIG
  109518. */
  109519. interaxialDistance: number;
  109520. /**
  109521. * Defines if stereoscopic rendering is done side by side or over under.
  109522. */
  109523. isStereoscopicSideBySide: boolean;
  109524. /**
  109525. * 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
  109526. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109527. * else in the scene. (Eg. security camera)
  109528. *
  109529. * 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)
  109530. */
  109531. customRenderTargets: RenderTargetTexture[];
  109532. /**
  109533. * When set, the camera will render to this render target instead of the default canvas
  109534. *
  109535. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109536. */
  109537. outputRenderTarget: Nullable<RenderTargetTexture>;
  109538. /**
  109539. * Observable triggered when the camera view matrix has changed.
  109540. */
  109541. onViewMatrixChangedObservable: Observable<Camera>;
  109542. /**
  109543. * Observable triggered when the camera Projection matrix has changed.
  109544. */
  109545. onProjectionMatrixChangedObservable: Observable<Camera>;
  109546. /**
  109547. * Observable triggered when the inputs have been processed.
  109548. */
  109549. onAfterCheckInputsObservable: Observable<Camera>;
  109550. /**
  109551. * Observable triggered when reset has been called and applied to the camera.
  109552. */
  109553. onRestoreStateObservable: Observable<Camera>;
  109554. /**
  109555. * Is this camera a part of a rig system?
  109556. */
  109557. isRigCamera: boolean;
  109558. /**
  109559. * If isRigCamera set to true this will be set with the parent camera.
  109560. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109561. */
  109562. rigParent?: Camera;
  109563. /** @hidden */
  109564. _cameraRigParams: any;
  109565. /** @hidden */
  109566. _rigCameras: Camera[];
  109567. /** @hidden */
  109568. _rigPostProcess: Nullable<PostProcess>;
  109569. protected _webvrViewMatrix: Matrix;
  109570. /** @hidden */
  109571. _skipRendering: boolean;
  109572. /** @hidden */
  109573. _projectionMatrix: Matrix;
  109574. /** @hidden */
  109575. _postProcesses: Nullable<PostProcess>[];
  109576. /** @hidden */
  109577. _activeMeshes: SmartArray<AbstractMesh>;
  109578. protected _globalPosition: Vector3;
  109579. /** @hidden */
  109580. _computedViewMatrix: Matrix;
  109581. private _doNotComputeProjectionMatrix;
  109582. private _transformMatrix;
  109583. private _frustumPlanes;
  109584. private _refreshFrustumPlanes;
  109585. private _storedFov;
  109586. private _stateStored;
  109587. /**
  109588. * Instantiates a new camera object.
  109589. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109590. * @see https://doc.babylonjs.com/features/cameras
  109591. * @param name Defines the name of the camera in the scene
  109592. * @param position Defines the position of the camera
  109593. * @param scene Defines the scene the camera belongs too
  109594. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109595. */
  109596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109597. /**
  109598. * Store current camera state (fov, position, etc..)
  109599. * @returns the camera
  109600. */
  109601. storeState(): Camera;
  109602. /**
  109603. * Restores the camera state values if it has been stored. You must call storeState() first
  109604. */
  109605. protected _restoreStateValues(): boolean;
  109606. /**
  109607. * Restored camera state. You must call storeState() first.
  109608. * @returns true if restored and false otherwise
  109609. */
  109610. restoreState(): boolean;
  109611. /**
  109612. * Gets the class name of the camera.
  109613. * @returns the class name
  109614. */
  109615. getClassName(): string;
  109616. /** @hidden */
  109617. readonly _isCamera: boolean;
  109618. /**
  109619. * Gets a string representation of the camera useful for debug purpose.
  109620. * @param fullDetails Defines that a more verboe level of logging is required
  109621. * @returns the string representation
  109622. */
  109623. toString(fullDetails?: boolean): string;
  109624. /**
  109625. * Gets the current world space position of the camera.
  109626. */
  109627. get globalPosition(): Vector3;
  109628. /**
  109629. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109630. * @returns the active meshe list
  109631. */
  109632. getActiveMeshes(): SmartArray<AbstractMesh>;
  109633. /**
  109634. * Check whether a mesh is part of the current active mesh list of the camera
  109635. * @param mesh Defines the mesh to check
  109636. * @returns true if active, false otherwise
  109637. */
  109638. isActiveMesh(mesh: Mesh): boolean;
  109639. /**
  109640. * Is this camera ready to be used/rendered
  109641. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109642. * @return true if the camera is ready
  109643. */
  109644. isReady(completeCheck?: boolean): boolean;
  109645. /** @hidden */
  109646. _initCache(): void;
  109647. /** @hidden */
  109648. _updateCache(ignoreParentClass?: boolean): void;
  109649. /** @hidden */
  109650. _isSynchronized(): boolean;
  109651. /** @hidden */
  109652. _isSynchronizedViewMatrix(): boolean;
  109653. /** @hidden */
  109654. _isSynchronizedProjectionMatrix(): boolean;
  109655. /**
  109656. * Attach the input controls to a specific dom element to get the input from.
  109657. * @param element Defines the element the controls should be listened from
  109658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109659. */
  109660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109661. /**
  109662. * Detach the current controls from the specified dom element.
  109663. * @param element Defines the element to stop listening the inputs from
  109664. */
  109665. detachControl(element: HTMLElement): void;
  109666. /**
  109667. * Update the camera state according to the different inputs gathered during the frame.
  109668. */
  109669. update(): void;
  109670. /** @hidden */
  109671. _checkInputs(): void;
  109672. /** @hidden */
  109673. get rigCameras(): Camera[];
  109674. /**
  109675. * Gets the post process used by the rig cameras
  109676. */
  109677. get rigPostProcess(): Nullable<PostProcess>;
  109678. /**
  109679. * Internal, gets the first post proces.
  109680. * @returns the first post process to be run on this camera.
  109681. */
  109682. _getFirstPostProcess(): Nullable<PostProcess>;
  109683. private _cascadePostProcessesToRigCams;
  109684. /**
  109685. * Attach a post process to the camera.
  109686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109687. * @param postProcess The post process to attach to the camera
  109688. * @param insertAt The position of the post process in case several of them are in use in the scene
  109689. * @returns the position the post process has been inserted at
  109690. */
  109691. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  109692. /**
  109693. * Detach a post process to the camera.
  109694. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109695. * @param postProcess The post process to detach from the camera
  109696. */
  109697. detachPostProcess(postProcess: PostProcess): void;
  109698. /**
  109699. * Gets the current world matrix of the camera
  109700. */
  109701. getWorldMatrix(): Matrix;
  109702. /** @hidden */
  109703. _getViewMatrix(): Matrix;
  109704. /**
  109705. * Gets the current view matrix of the camera.
  109706. * @param force forces the camera to recompute the matrix without looking at the cached state
  109707. * @returns the view matrix
  109708. */
  109709. getViewMatrix(force?: boolean): Matrix;
  109710. /**
  109711. * Freeze the projection matrix.
  109712. * It will prevent the cache check of the camera projection compute and can speed up perf
  109713. * if no parameter of the camera are meant to change
  109714. * @param projection Defines manually a projection if necessary
  109715. */
  109716. freezeProjectionMatrix(projection?: Matrix): void;
  109717. /**
  109718. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  109719. */
  109720. unfreezeProjectionMatrix(): void;
  109721. /**
  109722. * Gets the current projection matrix of the camera.
  109723. * @param force forces the camera to recompute the matrix without looking at the cached state
  109724. * @returns the projection matrix
  109725. */
  109726. getProjectionMatrix(force?: boolean): Matrix;
  109727. /**
  109728. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  109729. * @returns a Matrix
  109730. */
  109731. getTransformationMatrix(): Matrix;
  109732. private _updateFrustumPlanes;
  109733. /**
  109734. * Checks if a cullable object (mesh...) is in the camera frustum
  109735. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  109736. * @param target The object to check
  109737. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  109738. * @returns true if the object is in frustum otherwise false
  109739. */
  109740. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  109741. /**
  109742. * Checks if a cullable object (mesh...) is in the camera frustum
  109743. * Unlike isInFrustum this cheks the full bounding box
  109744. * @param target The object to check
  109745. * @returns true if the object is in frustum otherwise false
  109746. */
  109747. isCompletelyInFrustum(target: ICullable): boolean;
  109748. /**
  109749. * Gets a ray in the forward direction from the camera.
  109750. * @param length Defines the length of the ray to create
  109751. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109752. * @param origin Defines the start point of the ray which defaults to the camera position
  109753. * @returns the forward ray
  109754. */
  109755. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109756. /**
  109757. * Gets a ray in the forward direction from the camera.
  109758. * @param refRay the ray to (re)use when setting the values
  109759. * @param length Defines the length of the ray to create
  109760. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109761. * @param origin Defines the start point of the ray which defaults to the camera position
  109762. * @returns the forward ray
  109763. */
  109764. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109765. /**
  109766. * Releases resources associated with this node.
  109767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109769. */
  109770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109771. /** @hidden */
  109772. _isLeftCamera: boolean;
  109773. /**
  109774. * Gets the left camera of a rig setup in case of Rigged Camera
  109775. */
  109776. get isLeftCamera(): boolean;
  109777. /** @hidden */
  109778. _isRightCamera: boolean;
  109779. /**
  109780. * Gets the right camera of a rig setup in case of Rigged Camera
  109781. */
  109782. get isRightCamera(): boolean;
  109783. /**
  109784. * Gets the left camera of a rig setup in case of Rigged Camera
  109785. */
  109786. get leftCamera(): Nullable<FreeCamera>;
  109787. /**
  109788. * Gets the right camera of a rig setup in case of Rigged Camera
  109789. */
  109790. get rightCamera(): Nullable<FreeCamera>;
  109791. /**
  109792. * Gets the left camera target of a rig setup in case of Rigged Camera
  109793. * @returns the target position
  109794. */
  109795. getLeftTarget(): Nullable<Vector3>;
  109796. /**
  109797. * Gets the right camera target of a rig setup in case of Rigged Camera
  109798. * @returns the target position
  109799. */
  109800. getRightTarget(): Nullable<Vector3>;
  109801. /**
  109802. * @hidden
  109803. */
  109804. setCameraRigMode(mode: number, rigParams: any): void;
  109805. /** @hidden */
  109806. static _setStereoscopicRigMode(camera: Camera): void;
  109807. /** @hidden */
  109808. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  109809. /** @hidden */
  109810. static _setVRRigMode(camera: Camera, rigParams: any): void;
  109811. /** @hidden */
  109812. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  109813. /** @hidden */
  109814. _getVRProjectionMatrix(): Matrix;
  109815. protected _updateCameraRotationMatrix(): void;
  109816. protected _updateWebVRCameraRotationMatrix(): void;
  109817. /**
  109818. * This function MUST be overwritten by the different WebVR cameras available.
  109819. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109820. * @hidden
  109821. */
  109822. _getWebVRProjectionMatrix(): Matrix;
  109823. /**
  109824. * This function MUST be overwritten by the different WebVR cameras available.
  109825. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109826. * @hidden
  109827. */
  109828. _getWebVRViewMatrix(): Matrix;
  109829. /** @hidden */
  109830. setCameraRigParameter(name: string, value: any): void;
  109831. /**
  109832. * needs to be overridden by children so sub has required properties to be copied
  109833. * @hidden
  109834. */
  109835. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  109836. /**
  109837. * May need to be overridden by children
  109838. * @hidden
  109839. */
  109840. _updateRigCameras(): void;
  109841. /** @hidden */
  109842. _setupInputs(): void;
  109843. /**
  109844. * Serialiaze the camera setup to a json represention
  109845. * @returns the JSON representation
  109846. */
  109847. serialize(): any;
  109848. /**
  109849. * Clones the current camera.
  109850. * @param name The cloned camera name
  109851. * @returns the cloned camera
  109852. */
  109853. clone(name: string): Camera;
  109854. /**
  109855. * Gets the direction of the camera relative to a given local axis.
  109856. * @param localAxis Defines the reference axis to provide a relative direction.
  109857. * @return the direction
  109858. */
  109859. getDirection(localAxis: Vector3): Vector3;
  109860. /**
  109861. * Returns the current camera absolute rotation
  109862. */
  109863. get absoluteRotation(): Quaternion;
  109864. /**
  109865. * Gets the direction of the camera relative to a given local axis into a passed vector.
  109866. * @param localAxis Defines the reference axis to provide a relative direction.
  109867. * @param result Defines the vector to store the result in
  109868. */
  109869. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  109870. /**
  109871. * Gets a camera constructor for a given camera type
  109872. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  109873. * @param name The name of the camera the result will be able to instantiate
  109874. * @param scene The scene the result will construct the camera in
  109875. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  109876. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  109877. * @returns a factory method to construc the camera
  109878. */
  109879. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  109880. /**
  109881. * Compute the world matrix of the camera.
  109882. * @returns the camera world matrix
  109883. */
  109884. computeWorldMatrix(): Matrix;
  109885. /**
  109886. * Parse a JSON and creates the camera from the parsed information
  109887. * @param parsedCamera The JSON to parse
  109888. * @param scene The scene to instantiate the camera in
  109889. * @returns the newly constructed camera
  109890. */
  109891. static Parse(parsedCamera: any, scene: Scene): Camera;
  109892. }
  109893. }
  109894. declare module BABYLON {
  109895. /**
  109896. * Class containing static functions to help procedurally build meshes
  109897. */
  109898. export class DiscBuilder {
  109899. /**
  109900. * Creates a plane polygonal mesh. By default, this is a disc
  109901. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109902. * * 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
  109903. * * 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
  109904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109907. * @param name defines the name of the mesh
  109908. * @param options defines the options used to create the mesh
  109909. * @param scene defines the hosting scene
  109910. * @returns the plane polygonal mesh
  109911. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109912. */
  109913. static CreateDisc(name: string, options: {
  109914. radius?: number;
  109915. tessellation?: number;
  109916. arc?: number;
  109917. updatable?: boolean;
  109918. sideOrientation?: number;
  109919. frontUVs?: Vector4;
  109920. backUVs?: Vector4;
  109921. }, scene?: Nullable<Scene>): Mesh;
  109922. }
  109923. }
  109924. declare module BABYLON {
  109925. /**
  109926. * Options to be used when creating a FresnelParameters.
  109927. */
  109928. export type IFresnelParametersCreationOptions = {
  109929. /**
  109930. * Define the color used on edges (grazing angle)
  109931. */
  109932. leftColor?: Color3;
  109933. /**
  109934. * Define the color used on center
  109935. */
  109936. rightColor?: Color3;
  109937. /**
  109938. * Define bias applied to computed fresnel term
  109939. */
  109940. bias?: number;
  109941. /**
  109942. * Defined the power exponent applied to fresnel term
  109943. */
  109944. power?: number;
  109945. /**
  109946. * Define if the fresnel effect is enable or not.
  109947. */
  109948. isEnabled?: boolean;
  109949. };
  109950. /**
  109951. * Serialized format for FresnelParameters.
  109952. */
  109953. export type IFresnelParametersSerialized = {
  109954. /**
  109955. * Define the color used on edges (grazing angle) [as an array]
  109956. */
  109957. leftColor: number[];
  109958. /**
  109959. * Define the color used on center [as an array]
  109960. */
  109961. rightColor: number[];
  109962. /**
  109963. * Define bias applied to computed fresnel term
  109964. */
  109965. bias: number;
  109966. /**
  109967. * Defined the power exponent applied to fresnel term
  109968. */
  109969. power?: number;
  109970. /**
  109971. * Define if the fresnel effect is enable or not.
  109972. */
  109973. isEnabled: boolean;
  109974. };
  109975. /**
  109976. * This represents all the required information to add a fresnel effect on a material:
  109977. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109978. */
  109979. export class FresnelParameters {
  109980. private _isEnabled;
  109981. /**
  109982. * Define if the fresnel effect is enable or not.
  109983. */
  109984. get isEnabled(): boolean;
  109985. set isEnabled(value: boolean);
  109986. /**
  109987. * Define the color used on edges (grazing angle)
  109988. */
  109989. leftColor: Color3;
  109990. /**
  109991. * Define the color used on center
  109992. */
  109993. rightColor: Color3;
  109994. /**
  109995. * Define bias applied to computed fresnel term
  109996. */
  109997. bias: number;
  109998. /**
  109999. * Defined the power exponent applied to fresnel term
  110000. */
  110001. power: number;
  110002. /**
  110003. * Creates a new FresnelParameters object.
  110004. *
  110005. * @param options provide your own settings to optionally to override defaults
  110006. */
  110007. constructor(options?: IFresnelParametersCreationOptions);
  110008. /**
  110009. * Clones the current fresnel and its valuues
  110010. * @returns a clone fresnel configuration
  110011. */
  110012. clone(): FresnelParameters;
  110013. /**
  110014. * Determines equality between FresnelParameters objects
  110015. * @param otherFresnelParameters defines the second operand
  110016. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110017. */
  110018. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110019. /**
  110020. * Serializes the current fresnel parameters to a JSON representation.
  110021. * @return the JSON serialization
  110022. */
  110023. serialize(): IFresnelParametersSerialized;
  110024. /**
  110025. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110026. * @param parsedFresnelParameters Define the JSON representation
  110027. * @returns the parsed parameters
  110028. */
  110029. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110030. }
  110031. }
  110032. declare module BABYLON {
  110033. /**
  110034. * This groups all the flags used to control the materials channel.
  110035. */
  110036. export class MaterialFlags {
  110037. private static _DiffuseTextureEnabled;
  110038. /**
  110039. * Are diffuse textures enabled in the application.
  110040. */
  110041. static get DiffuseTextureEnabled(): boolean;
  110042. static set DiffuseTextureEnabled(value: boolean);
  110043. private static _DetailTextureEnabled;
  110044. /**
  110045. * Are detail textures enabled in the application.
  110046. */
  110047. static get DetailTextureEnabled(): boolean;
  110048. static set DetailTextureEnabled(value: boolean);
  110049. private static _AmbientTextureEnabled;
  110050. /**
  110051. * Are ambient textures enabled in the application.
  110052. */
  110053. static get AmbientTextureEnabled(): boolean;
  110054. static set AmbientTextureEnabled(value: boolean);
  110055. private static _OpacityTextureEnabled;
  110056. /**
  110057. * Are opacity textures enabled in the application.
  110058. */
  110059. static get OpacityTextureEnabled(): boolean;
  110060. static set OpacityTextureEnabled(value: boolean);
  110061. private static _ReflectionTextureEnabled;
  110062. /**
  110063. * Are reflection textures enabled in the application.
  110064. */
  110065. static get ReflectionTextureEnabled(): boolean;
  110066. static set ReflectionTextureEnabled(value: boolean);
  110067. private static _EmissiveTextureEnabled;
  110068. /**
  110069. * Are emissive textures enabled in the application.
  110070. */
  110071. static get EmissiveTextureEnabled(): boolean;
  110072. static set EmissiveTextureEnabled(value: boolean);
  110073. private static _SpecularTextureEnabled;
  110074. /**
  110075. * Are specular textures enabled in the application.
  110076. */
  110077. static get SpecularTextureEnabled(): boolean;
  110078. static set SpecularTextureEnabled(value: boolean);
  110079. private static _BumpTextureEnabled;
  110080. /**
  110081. * Are bump textures enabled in the application.
  110082. */
  110083. static get BumpTextureEnabled(): boolean;
  110084. static set BumpTextureEnabled(value: boolean);
  110085. private static _LightmapTextureEnabled;
  110086. /**
  110087. * Are lightmap textures enabled in the application.
  110088. */
  110089. static get LightmapTextureEnabled(): boolean;
  110090. static set LightmapTextureEnabled(value: boolean);
  110091. private static _RefractionTextureEnabled;
  110092. /**
  110093. * Are refraction textures enabled in the application.
  110094. */
  110095. static get RefractionTextureEnabled(): boolean;
  110096. static set RefractionTextureEnabled(value: boolean);
  110097. private static _ColorGradingTextureEnabled;
  110098. /**
  110099. * Are color grading textures enabled in the application.
  110100. */
  110101. static get ColorGradingTextureEnabled(): boolean;
  110102. static set ColorGradingTextureEnabled(value: boolean);
  110103. private static _FresnelEnabled;
  110104. /**
  110105. * Are fresnels enabled in the application.
  110106. */
  110107. static get FresnelEnabled(): boolean;
  110108. static set FresnelEnabled(value: boolean);
  110109. private static _ClearCoatTextureEnabled;
  110110. /**
  110111. * Are clear coat textures enabled in the application.
  110112. */
  110113. static get ClearCoatTextureEnabled(): boolean;
  110114. static set ClearCoatTextureEnabled(value: boolean);
  110115. private static _ClearCoatBumpTextureEnabled;
  110116. /**
  110117. * Are clear coat bump textures enabled in the application.
  110118. */
  110119. static get ClearCoatBumpTextureEnabled(): boolean;
  110120. static set ClearCoatBumpTextureEnabled(value: boolean);
  110121. private static _ClearCoatTintTextureEnabled;
  110122. /**
  110123. * Are clear coat tint textures enabled in the application.
  110124. */
  110125. static get ClearCoatTintTextureEnabled(): boolean;
  110126. static set ClearCoatTintTextureEnabled(value: boolean);
  110127. private static _SheenTextureEnabled;
  110128. /**
  110129. * Are sheen textures enabled in the application.
  110130. */
  110131. static get SheenTextureEnabled(): boolean;
  110132. static set SheenTextureEnabled(value: boolean);
  110133. private static _AnisotropicTextureEnabled;
  110134. /**
  110135. * Are anisotropic textures enabled in the application.
  110136. */
  110137. static get AnisotropicTextureEnabled(): boolean;
  110138. static set AnisotropicTextureEnabled(value: boolean);
  110139. private static _ThicknessTextureEnabled;
  110140. /**
  110141. * Are thickness textures enabled in the application.
  110142. */
  110143. static get ThicknessTextureEnabled(): boolean;
  110144. static set ThicknessTextureEnabled(value: boolean);
  110145. }
  110146. }
  110147. declare module BABYLON {
  110148. /** @hidden */
  110149. export var defaultFragmentDeclaration: {
  110150. name: string;
  110151. shader: string;
  110152. };
  110153. }
  110154. declare module BABYLON {
  110155. /** @hidden */
  110156. export var defaultUboDeclaration: {
  110157. name: string;
  110158. shader: string;
  110159. };
  110160. }
  110161. declare module BABYLON {
  110162. /** @hidden */
  110163. export var prePassDeclaration: {
  110164. name: string;
  110165. shader: string;
  110166. };
  110167. }
  110168. declare module BABYLON {
  110169. /** @hidden */
  110170. export var lightFragmentDeclaration: {
  110171. name: string;
  110172. shader: string;
  110173. };
  110174. }
  110175. declare module BABYLON {
  110176. /** @hidden */
  110177. export var lightUboDeclaration: {
  110178. name: string;
  110179. shader: string;
  110180. };
  110181. }
  110182. declare module BABYLON {
  110183. /** @hidden */
  110184. export var lightsFragmentFunctions: {
  110185. name: string;
  110186. shader: string;
  110187. };
  110188. }
  110189. declare module BABYLON {
  110190. /** @hidden */
  110191. export var shadowsFragmentFunctions: {
  110192. name: string;
  110193. shader: string;
  110194. };
  110195. }
  110196. declare module BABYLON {
  110197. /** @hidden */
  110198. export var fresnelFunction: {
  110199. name: string;
  110200. shader: string;
  110201. };
  110202. }
  110203. declare module BABYLON {
  110204. /** @hidden */
  110205. export var bumpFragmentMainFunctions: {
  110206. name: string;
  110207. shader: string;
  110208. };
  110209. }
  110210. declare module BABYLON {
  110211. /** @hidden */
  110212. export var bumpFragmentFunctions: {
  110213. name: string;
  110214. shader: string;
  110215. };
  110216. }
  110217. declare module BABYLON {
  110218. /** @hidden */
  110219. export var logDepthDeclaration: {
  110220. name: string;
  110221. shader: string;
  110222. };
  110223. }
  110224. declare module BABYLON {
  110225. /** @hidden */
  110226. export var bumpFragment: {
  110227. name: string;
  110228. shader: string;
  110229. };
  110230. }
  110231. declare module BABYLON {
  110232. /** @hidden */
  110233. export var depthPrePass: {
  110234. name: string;
  110235. shader: string;
  110236. };
  110237. }
  110238. declare module BABYLON {
  110239. /** @hidden */
  110240. export var lightFragment: {
  110241. name: string;
  110242. shader: string;
  110243. };
  110244. }
  110245. declare module BABYLON {
  110246. /** @hidden */
  110247. export var logDepthFragment: {
  110248. name: string;
  110249. shader: string;
  110250. };
  110251. }
  110252. declare module BABYLON {
  110253. /** @hidden */
  110254. export var defaultPixelShader: {
  110255. name: string;
  110256. shader: string;
  110257. };
  110258. }
  110259. declare module BABYLON {
  110260. /** @hidden */
  110261. export var defaultVertexDeclaration: {
  110262. name: string;
  110263. shader: string;
  110264. };
  110265. }
  110266. declare module BABYLON {
  110267. /** @hidden */
  110268. export var bumpVertexDeclaration: {
  110269. name: string;
  110270. shader: string;
  110271. };
  110272. }
  110273. declare module BABYLON {
  110274. /** @hidden */
  110275. export var bumpVertex: {
  110276. name: string;
  110277. shader: string;
  110278. };
  110279. }
  110280. declare module BABYLON {
  110281. /** @hidden */
  110282. export var fogVertex: {
  110283. name: string;
  110284. shader: string;
  110285. };
  110286. }
  110287. declare module BABYLON {
  110288. /** @hidden */
  110289. export var shadowsVertex: {
  110290. name: string;
  110291. shader: string;
  110292. };
  110293. }
  110294. declare module BABYLON {
  110295. /** @hidden */
  110296. export var pointCloudVertex: {
  110297. name: string;
  110298. shader: string;
  110299. };
  110300. }
  110301. declare module BABYLON {
  110302. /** @hidden */
  110303. export var logDepthVertex: {
  110304. name: string;
  110305. shader: string;
  110306. };
  110307. }
  110308. declare module BABYLON {
  110309. /** @hidden */
  110310. export var defaultVertexShader: {
  110311. name: string;
  110312. shader: string;
  110313. };
  110314. }
  110315. declare module BABYLON {
  110316. /**
  110317. * @hidden
  110318. */
  110319. export interface IMaterialDetailMapDefines {
  110320. DETAIL: boolean;
  110321. DETAILDIRECTUV: number;
  110322. DETAIL_NORMALBLENDMETHOD: number;
  110323. /** @hidden */
  110324. _areTexturesDirty: boolean;
  110325. }
  110326. /**
  110327. * Define the code related to the detail map parameters of a material
  110328. *
  110329. * Inspired from:
  110330. * 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
  110331. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110332. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110333. */
  110334. export class DetailMapConfiguration {
  110335. private _texture;
  110336. /**
  110337. * The detail texture of the material.
  110338. */
  110339. texture: Nullable<BaseTexture>;
  110340. /**
  110341. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110342. * Bigger values mean stronger blending
  110343. */
  110344. diffuseBlendLevel: number;
  110345. /**
  110346. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110347. * Bigger values mean stronger blending. Only used with PBR materials
  110348. */
  110349. roughnessBlendLevel: number;
  110350. /**
  110351. * Defines how strong the bump effect from the detail map is
  110352. * Bigger values mean stronger effect
  110353. */
  110354. bumpLevel: number;
  110355. private _normalBlendMethod;
  110356. /**
  110357. * The method used to blend the bump and detail normals together
  110358. */
  110359. normalBlendMethod: number;
  110360. private _isEnabled;
  110361. /**
  110362. * Enable or disable the detail map on this material
  110363. */
  110364. isEnabled: boolean;
  110365. /** @hidden */
  110366. private _internalMarkAllSubMeshesAsTexturesDirty;
  110367. /** @hidden */
  110368. _markAllSubMeshesAsTexturesDirty(): void;
  110369. /**
  110370. * Instantiate a new detail map
  110371. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110372. */
  110373. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110374. /**
  110375. * Gets whether the submesh is ready to be used or not.
  110376. * @param defines the list of "defines" to update.
  110377. * @param scene defines the scene the material belongs to.
  110378. * @returns - boolean indicating that the submesh is ready or not.
  110379. */
  110380. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110381. /**
  110382. * Update the defines for detail map usage
  110383. * @param defines the list of "defines" to update.
  110384. * @param scene defines the scene the material belongs to.
  110385. */
  110386. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110387. /**
  110388. * Binds the material data.
  110389. * @param uniformBuffer defines the Uniform buffer to fill in.
  110390. * @param scene defines the scene the material belongs to.
  110391. * @param isFrozen defines whether the material is frozen or not.
  110392. */
  110393. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110394. /**
  110395. * Checks to see if a texture is used in the material.
  110396. * @param texture - Base texture to use.
  110397. * @returns - Boolean specifying if a texture is used in the material.
  110398. */
  110399. hasTexture(texture: BaseTexture): boolean;
  110400. /**
  110401. * Returns an array of the actively used textures.
  110402. * @param activeTextures Array of BaseTextures
  110403. */
  110404. getActiveTextures(activeTextures: BaseTexture[]): void;
  110405. /**
  110406. * Returns the animatable textures.
  110407. * @param animatables Array of animatable textures.
  110408. */
  110409. getAnimatables(animatables: IAnimatable[]): void;
  110410. /**
  110411. * Disposes the resources of the material.
  110412. * @param forceDisposeTextures - Forces the disposal of all textures.
  110413. */
  110414. dispose(forceDisposeTextures?: boolean): void;
  110415. /**
  110416. * Get the current class name useful for serialization or dynamic coding.
  110417. * @returns "DetailMap"
  110418. */
  110419. getClassName(): string;
  110420. /**
  110421. * Add the required uniforms to the current list.
  110422. * @param uniforms defines the current uniform list.
  110423. */
  110424. static AddUniforms(uniforms: string[]): void;
  110425. /**
  110426. * Add the required samplers to the current list.
  110427. * @param samplers defines the current sampler list.
  110428. */
  110429. static AddSamplers(samplers: string[]): void;
  110430. /**
  110431. * Add the required uniforms to the current buffer.
  110432. * @param uniformBuffer defines the current uniform buffer.
  110433. */
  110434. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110435. /**
  110436. * Makes a duplicate of the current instance into another one.
  110437. * @param detailMap define the instance where to copy the info
  110438. */
  110439. copyTo(detailMap: DetailMapConfiguration): void;
  110440. /**
  110441. * Serializes this detail map instance
  110442. * @returns - An object with the serialized instance.
  110443. */
  110444. serialize(): any;
  110445. /**
  110446. * Parses a detail map setting from a serialized object.
  110447. * @param source - Serialized object.
  110448. * @param scene Defines the scene we are parsing for
  110449. * @param rootUrl Defines the rootUrl to load from
  110450. */
  110451. parse(source: any, scene: Scene, rootUrl: string): void;
  110452. }
  110453. }
  110454. declare module BABYLON {
  110455. /** @hidden */
  110456. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110457. MAINUV1: boolean;
  110458. MAINUV2: boolean;
  110459. DIFFUSE: boolean;
  110460. DIFFUSEDIRECTUV: number;
  110461. DETAIL: boolean;
  110462. DETAILDIRECTUV: number;
  110463. DETAIL_NORMALBLENDMETHOD: number;
  110464. AMBIENT: boolean;
  110465. AMBIENTDIRECTUV: number;
  110466. OPACITY: boolean;
  110467. OPACITYDIRECTUV: number;
  110468. OPACITYRGB: boolean;
  110469. REFLECTION: boolean;
  110470. EMISSIVE: boolean;
  110471. EMISSIVEDIRECTUV: number;
  110472. SPECULAR: boolean;
  110473. SPECULARDIRECTUV: number;
  110474. BUMP: boolean;
  110475. BUMPDIRECTUV: number;
  110476. PARALLAX: boolean;
  110477. PARALLAXOCCLUSION: boolean;
  110478. SPECULAROVERALPHA: boolean;
  110479. CLIPPLANE: boolean;
  110480. CLIPPLANE2: boolean;
  110481. CLIPPLANE3: boolean;
  110482. CLIPPLANE4: boolean;
  110483. CLIPPLANE5: boolean;
  110484. CLIPPLANE6: boolean;
  110485. ALPHATEST: boolean;
  110486. DEPTHPREPASS: boolean;
  110487. ALPHAFROMDIFFUSE: boolean;
  110488. POINTSIZE: boolean;
  110489. FOG: boolean;
  110490. SPECULARTERM: boolean;
  110491. DIFFUSEFRESNEL: boolean;
  110492. OPACITYFRESNEL: boolean;
  110493. REFLECTIONFRESNEL: boolean;
  110494. REFRACTIONFRESNEL: boolean;
  110495. EMISSIVEFRESNEL: boolean;
  110496. FRESNEL: boolean;
  110497. NORMAL: boolean;
  110498. UV1: boolean;
  110499. UV2: boolean;
  110500. VERTEXCOLOR: boolean;
  110501. VERTEXALPHA: boolean;
  110502. NUM_BONE_INFLUENCERS: number;
  110503. BonesPerMesh: number;
  110504. BONETEXTURE: boolean;
  110505. INSTANCES: boolean;
  110506. THIN_INSTANCES: boolean;
  110507. GLOSSINESS: boolean;
  110508. ROUGHNESS: boolean;
  110509. EMISSIVEASILLUMINATION: boolean;
  110510. LINKEMISSIVEWITHDIFFUSE: boolean;
  110511. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110512. LIGHTMAP: boolean;
  110513. LIGHTMAPDIRECTUV: number;
  110514. OBJECTSPACE_NORMALMAP: boolean;
  110515. USELIGHTMAPASSHADOWMAP: boolean;
  110516. REFLECTIONMAP_3D: boolean;
  110517. REFLECTIONMAP_SPHERICAL: boolean;
  110518. REFLECTIONMAP_PLANAR: boolean;
  110519. REFLECTIONMAP_CUBIC: boolean;
  110520. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110521. REFLECTIONMAP_PROJECTION: boolean;
  110522. REFLECTIONMAP_SKYBOX: boolean;
  110523. REFLECTIONMAP_EXPLICIT: boolean;
  110524. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110525. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110526. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110527. INVERTCUBICMAP: boolean;
  110528. LOGARITHMICDEPTH: boolean;
  110529. REFRACTION: boolean;
  110530. REFRACTIONMAP_3D: boolean;
  110531. REFLECTIONOVERALPHA: boolean;
  110532. TWOSIDEDLIGHTING: boolean;
  110533. SHADOWFLOAT: boolean;
  110534. MORPHTARGETS: boolean;
  110535. MORPHTARGETS_NORMAL: boolean;
  110536. MORPHTARGETS_TANGENT: boolean;
  110537. MORPHTARGETS_UV: boolean;
  110538. NUM_MORPH_INFLUENCERS: number;
  110539. NONUNIFORMSCALING: boolean;
  110540. PREMULTIPLYALPHA: boolean;
  110541. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110542. ALPHABLEND: boolean;
  110543. PREPASS: boolean;
  110544. SCENE_MRT_COUNT: number;
  110545. RGBDLIGHTMAP: boolean;
  110546. RGBDREFLECTION: boolean;
  110547. RGBDREFRACTION: boolean;
  110548. IMAGEPROCESSING: boolean;
  110549. VIGNETTE: boolean;
  110550. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110551. VIGNETTEBLENDMODEOPAQUE: boolean;
  110552. TONEMAPPING: boolean;
  110553. TONEMAPPING_ACES: boolean;
  110554. CONTRAST: boolean;
  110555. COLORCURVES: boolean;
  110556. COLORGRADING: boolean;
  110557. COLORGRADING3D: boolean;
  110558. SAMPLER3DGREENDEPTH: boolean;
  110559. SAMPLER3DBGRMAP: boolean;
  110560. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110561. MULTIVIEW: boolean;
  110562. /**
  110563. * If the reflection texture on this material is in linear color space
  110564. * @hidden
  110565. */
  110566. IS_REFLECTION_LINEAR: boolean;
  110567. /**
  110568. * If the refraction texture on this material is in linear color space
  110569. * @hidden
  110570. */
  110571. IS_REFRACTION_LINEAR: boolean;
  110572. EXPOSURE: boolean;
  110573. constructor();
  110574. setReflectionMode(modeToEnable: string): void;
  110575. }
  110576. /**
  110577. * This is the default material used in Babylon. It is the best trade off between quality
  110578. * and performances.
  110579. * @see https://doc.babylonjs.com/babylon101/materials
  110580. */
  110581. export class StandardMaterial extends PushMaterial {
  110582. private _diffuseTexture;
  110583. /**
  110584. * The basic texture of the material as viewed under a light.
  110585. */
  110586. diffuseTexture: Nullable<BaseTexture>;
  110587. private _ambientTexture;
  110588. /**
  110589. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110590. */
  110591. ambientTexture: Nullable<BaseTexture>;
  110592. private _opacityTexture;
  110593. /**
  110594. * Define the transparency of the material from a texture.
  110595. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110596. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110597. */
  110598. opacityTexture: Nullable<BaseTexture>;
  110599. private _reflectionTexture;
  110600. /**
  110601. * Define the texture used to display the reflection.
  110602. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110603. */
  110604. reflectionTexture: Nullable<BaseTexture>;
  110605. private _emissiveTexture;
  110606. /**
  110607. * Define texture of the material as if self lit.
  110608. * This will be mixed in the final result even in the absence of light.
  110609. */
  110610. emissiveTexture: Nullable<BaseTexture>;
  110611. private _specularTexture;
  110612. /**
  110613. * Define how the color and intensity of the highlight given by the light in the material.
  110614. */
  110615. specularTexture: Nullable<BaseTexture>;
  110616. private _bumpTexture;
  110617. /**
  110618. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110619. * 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.
  110620. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110621. */
  110622. bumpTexture: Nullable<BaseTexture>;
  110623. private _lightmapTexture;
  110624. /**
  110625. * Complex lighting can be computationally expensive to compute at runtime.
  110626. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110627. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110628. */
  110629. lightmapTexture: Nullable<BaseTexture>;
  110630. private _refractionTexture;
  110631. /**
  110632. * Define the texture used to display the refraction.
  110633. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110634. */
  110635. refractionTexture: Nullable<BaseTexture>;
  110636. /**
  110637. * The color of the material lit by the environmental background lighting.
  110638. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110639. */
  110640. ambientColor: Color3;
  110641. /**
  110642. * The basic color of the material as viewed under a light.
  110643. */
  110644. diffuseColor: Color3;
  110645. /**
  110646. * Define how the color and intensity of the highlight given by the light in the material.
  110647. */
  110648. specularColor: Color3;
  110649. /**
  110650. * Define the color of the material as if self lit.
  110651. * This will be mixed in the final result even in the absence of light.
  110652. */
  110653. emissiveColor: Color3;
  110654. /**
  110655. * Defines how sharp are the highlights in the material.
  110656. * The bigger the value the sharper giving a more glossy feeling to the result.
  110657. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110658. */
  110659. specularPower: number;
  110660. private _useAlphaFromDiffuseTexture;
  110661. /**
  110662. * Does the transparency come from the diffuse texture alpha channel.
  110663. */
  110664. useAlphaFromDiffuseTexture: boolean;
  110665. private _useEmissiveAsIllumination;
  110666. /**
  110667. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110668. */
  110669. useEmissiveAsIllumination: boolean;
  110670. private _linkEmissiveWithDiffuse;
  110671. /**
  110672. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110673. * the emissive level when the final color is close to one.
  110674. */
  110675. linkEmissiveWithDiffuse: boolean;
  110676. private _useSpecularOverAlpha;
  110677. /**
  110678. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110679. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110680. */
  110681. useSpecularOverAlpha: boolean;
  110682. private _useReflectionOverAlpha;
  110683. /**
  110684. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110685. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110686. */
  110687. useReflectionOverAlpha: boolean;
  110688. private _disableLighting;
  110689. /**
  110690. * Does lights from the scene impacts this material.
  110691. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  110692. */
  110693. disableLighting: boolean;
  110694. private _useObjectSpaceNormalMap;
  110695. /**
  110696. * Allows using an object space normal map (instead of tangent space).
  110697. */
  110698. useObjectSpaceNormalMap: boolean;
  110699. private _useParallax;
  110700. /**
  110701. * Is parallax enabled or not.
  110702. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110703. */
  110704. useParallax: boolean;
  110705. private _useParallaxOcclusion;
  110706. /**
  110707. * Is parallax occlusion enabled or not.
  110708. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  110709. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110710. */
  110711. useParallaxOcclusion: boolean;
  110712. /**
  110713. * 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.
  110714. */
  110715. parallaxScaleBias: number;
  110716. private _roughness;
  110717. /**
  110718. * Helps to define how blurry the reflections should appears in the material.
  110719. */
  110720. roughness: number;
  110721. /**
  110722. * In case of refraction, define the value of the index of refraction.
  110723. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110724. */
  110725. indexOfRefraction: number;
  110726. /**
  110727. * Invert the refraction texture alongside the y axis.
  110728. * It can be useful with procedural textures or probe for instance.
  110729. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110730. */
  110731. invertRefractionY: boolean;
  110732. /**
  110733. * Defines the alpha limits in alpha test mode.
  110734. */
  110735. alphaCutOff: number;
  110736. private _useLightmapAsShadowmap;
  110737. /**
  110738. * In case of light mapping, define whether the map contains light or shadow informations.
  110739. */
  110740. useLightmapAsShadowmap: boolean;
  110741. private _diffuseFresnelParameters;
  110742. /**
  110743. * Define the diffuse fresnel parameters of the material.
  110744. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110745. */
  110746. diffuseFresnelParameters: FresnelParameters;
  110747. private _opacityFresnelParameters;
  110748. /**
  110749. * Define the opacity fresnel parameters of the material.
  110750. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110751. */
  110752. opacityFresnelParameters: FresnelParameters;
  110753. private _reflectionFresnelParameters;
  110754. /**
  110755. * Define the reflection fresnel parameters of the material.
  110756. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110757. */
  110758. reflectionFresnelParameters: FresnelParameters;
  110759. private _refractionFresnelParameters;
  110760. /**
  110761. * Define the refraction fresnel parameters of the material.
  110762. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110763. */
  110764. refractionFresnelParameters: FresnelParameters;
  110765. private _emissiveFresnelParameters;
  110766. /**
  110767. * Define the emissive fresnel parameters of the material.
  110768. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110769. */
  110770. emissiveFresnelParameters: FresnelParameters;
  110771. private _useReflectionFresnelFromSpecular;
  110772. /**
  110773. * If true automatically deducts the fresnels values from the material specularity.
  110774. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110775. */
  110776. useReflectionFresnelFromSpecular: boolean;
  110777. private _useGlossinessFromSpecularMapAlpha;
  110778. /**
  110779. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  110780. */
  110781. useGlossinessFromSpecularMapAlpha: boolean;
  110782. private _maxSimultaneousLights;
  110783. /**
  110784. * Defines the maximum number of lights that can be used in the material
  110785. */
  110786. maxSimultaneousLights: number;
  110787. private _invertNormalMapX;
  110788. /**
  110789. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110790. */
  110791. invertNormalMapX: boolean;
  110792. private _invertNormalMapY;
  110793. /**
  110794. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110795. */
  110796. invertNormalMapY: boolean;
  110797. private _twoSidedLighting;
  110798. /**
  110799. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110800. */
  110801. twoSidedLighting: boolean;
  110802. /**
  110803. * Default configuration related to image processing available in the standard Material.
  110804. */
  110805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110806. /**
  110807. * Gets the image processing configuration used either in this material.
  110808. */
  110809. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110810. /**
  110811. * Sets the Default image processing configuration used either in the this material.
  110812. *
  110813. * If sets to null, the scene one is in use.
  110814. */
  110815. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  110816. /**
  110817. * Keep track of the image processing observer to allow dispose and replace.
  110818. */
  110819. private _imageProcessingObserver;
  110820. /**
  110821. * Attaches a new image processing configuration to the Standard Material.
  110822. * @param configuration
  110823. */
  110824. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110825. /**
  110826. * Gets wether the color curves effect is enabled.
  110827. */
  110828. get cameraColorCurvesEnabled(): boolean;
  110829. /**
  110830. * Sets wether the color curves effect is enabled.
  110831. */
  110832. set cameraColorCurvesEnabled(value: boolean);
  110833. /**
  110834. * Gets wether the color grading effect is enabled.
  110835. */
  110836. get cameraColorGradingEnabled(): boolean;
  110837. /**
  110838. * Gets wether the color grading effect is enabled.
  110839. */
  110840. set cameraColorGradingEnabled(value: boolean);
  110841. /**
  110842. * Gets wether tonemapping is enabled or not.
  110843. */
  110844. get cameraToneMappingEnabled(): boolean;
  110845. /**
  110846. * Sets wether tonemapping is enabled or not
  110847. */
  110848. set cameraToneMappingEnabled(value: boolean);
  110849. /**
  110850. * The camera exposure used on this material.
  110851. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110852. * This corresponds to a photographic exposure.
  110853. */
  110854. get cameraExposure(): number;
  110855. /**
  110856. * The camera exposure used on this material.
  110857. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110858. * This corresponds to a photographic exposure.
  110859. */
  110860. set cameraExposure(value: number);
  110861. /**
  110862. * Gets The camera contrast used on this material.
  110863. */
  110864. get cameraContrast(): number;
  110865. /**
  110866. * Sets The camera contrast used on this material.
  110867. */
  110868. set cameraContrast(value: number);
  110869. /**
  110870. * Gets the Color Grading 2D Lookup Texture.
  110871. */
  110872. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  110873. /**
  110874. * Sets the Color Grading 2D Lookup Texture.
  110875. */
  110876. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  110877. /**
  110878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110880. * 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;
  110881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110882. */
  110883. get cameraColorCurves(): Nullable<ColorCurves>;
  110884. /**
  110885. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110887. * 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;
  110888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110889. */
  110890. set cameraColorCurves(value: Nullable<ColorCurves>);
  110891. /**
  110892. * Can this material render to several textures at once
  110893. */
  110894. get canRenderToMRT(): boolean;
  110895. /**
  110896. * Defines the detail map parameters for the material.
  110897. */
  110898. readonly detailMap: DetailMapConfiguration;
  110899. protected _renderTargets: SmartArray<RenderTargetTexture>;
  110900. protected _worldViewProjectionMatrix: Matrix;
  110901. protected _globalAmbientColor: Color3;
  110902. protected _useLogarithmicDepth: boolean;
  110903. protected _rebuildInParallel: boolean;
  110904. /**
  110905. * Instantiates a new standard material.
  110906. * This is the default material used in Babylon. It is the best trade off between quality
  110907. * and performances.
  110908. * @see https://doc.babylonjs.com/babylon101/materials
  110909. * @param name Define the name of the material in the scene
  110910. * @param scene Define the scene the material belong to
  110911. */
  110912. constructor(name: string, scene: Scene);
  110913. /**
  110914. * Gets a boolean indicating that current material needs to register RTT
  110915. */
  110916. get hasRenderTargetTextures(): boolean;
  110917. /**
  110918. * Gets the current class name of the material e.g. "StandardMaterial"
  110919. * Mainly use in serialization.
  110920. * @returns the class name
  110921. */
  110922. getClassName(): string;
  110923. /**
  110924. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  110925. * You can try switching to logarithmic depth.
  110926. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  110927. */
  110928. get useLogarithmicDepth(): boolean;
  110929. set useLogarithmicDepth(value: boolean);
  110930. /**
  110931. * Specifies if the material will require alpha blending
  110932. * @returns a boolean specifying if alpha blending is needed
  110933. */
  110934. needAlphaBlending(): boolean;
  110935. /**
  110936. * Specifies if this material should be rendered in alpha test mode
  110937. * @returns a boolean specifying if an alpha test is needed.
  110938. */
  110939. needAlphaTesting(): boolean;
  110940. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  110941. /**
  110942. * Get the texture used for alpha test purpose.
  110943. * @returns the diffuse texture in case of the standard material.
  110944. */
  110945. getAlphaTestTexture(): Nullable<BaseTexture>;
  110946. /**
  110947. * Get if the submesh is ready to be used and all its information available.
  110948. * Child classes can use it to update shaders
  110949. * @param mesh defines the mesh to check
  110950. * @param subMesh defines which submesh to check
  110951. * @param useInstances specifies that instances should be used
  110952. * @returns a boolean indicating that the submesh is ready or not
  110953. */
  110954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110955. /**
  110956. * Builds the material UBO layouts.
  110957. * Used internally during the effect preparation.
  110958. */
  110959. buildUniformLayout(): void;
  110960. /**
  110961. * Unbinds the material from the mesh
  110962. */
  110963. unbind(): void;
  110964. /**
  110965. * Binds the submesh to this material by preparing the effect and shader to draw
  110966. * @param world defines the world transformation matrix
  110967. * @param mesh defines the mesh containing the submesh
  110968. * @param subMesh defines the submesh to bind the material to
  110969. */
  110970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110971. /**
  110972. * Get the list of animatables in the material.
  110973. * @returns the list of animatables object used in the material
  110974. */
  110975. getAnimatables(): IAnimatable[];
  110976. /**
  110977. * Gets the active textures from the material
  110978. * @returns an array of textures
  110979. */
  110980. getActiveTextures(): BaseTexture[];
  110981. /**
  110982. * Specifies if the material uses a texture
  110983. * @param texture defines the texture to check against the material
  110984. * @returns a boolean specifying if the material uses the texture
  110985. */
  110986. hasTexture(texture: BaseTexture): boolean;
  110987. /**
  110988. * Disposes the material
  110989. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110990. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110991. */
  110992. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110993. /**
  110994. * Makes a duplicate of the material, and gives it a new name
  110995. * @param name defines the new name for the duplicated material
  110996. * @returns the cloned material
  110997. */
  110998. clone(name: string): StandardMaterial;
  110999. /**
  111000. * Serializes this material in a JSON representation
  111001. * @returns the serialized material object
  111002. */
  111003. serialize(): any;
  111004. /**
  111005. * Creates a standard material from parsed material data
  111006. * @param source defines the JSON representation of the material
  111007. * @param scene defines the hosting scene
  111008. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111009. * @returns a new standard material
  111010. */
  111011. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111012. /**
  111013. * Are diffuse textures enabled in the application.
  111014. */
  111015. static get DiffuseTextureEnabled(): boolean;
  111016. static set DiffuseTextureEnabled(value: boolean);
  111017. /**
  111018. * Are detail textures enabled in the application.
  111019. */
  111020. static get DetailTextureEnabled(): boolean;
  111021. static set DetailTextureEnabled(value: boolean);
  111022. /**
  111023. * Are ambient textures enabled in the application.
  111024. */
  111025. static get AmbientTextureEnabled(): boolean;
  111026. static set AmbientTextureEnabled(value: boolean);
  111027. /**
  111028. * Are opacity textures enabled in the application.
  111029. */
  111030. static get OpacityTextureEnabled(): boolean;
  111031. static set OpacityTextureEnabled(value: boolean);
  111032. /**
  111033. * Are reflection textures enabled in the application.
  111034. */
  111035. static get ReflectionTextureEnabled(): boolean;
  111036. static set ReflectionTextureEnabled(value: boolean);
  111037. /**
  111038. * Are emissive textures enabled in the application.
  111039. */
  111040. static get EmissiveTextureEnabled(): boolean;
  111041. static set EmissiveTextureEnabled(value: boolean);
  111042. /**
  111043. * Are specular textures enabled in the application.
  111044. */
  111045. static get SpecularTextureEnabled(): boolean;
  111046. static set SpecularTextureEnabled(value: boolean);
  111047. /**
  111048. * Are bump textures enabled in the application.
  111049. */
  111050. static get BumpTextureEnabled(): boolean;
  111051. static set BumpTextureEnabled(value: boolean);
  111052. /**
  111053. * Are lightmap textures enabled in the application.
  111054. */
  111055. static get LightmapTextureEnabled(): boolean;
  111056. static set LightmapTextureEnabled(value: boolean);
  111057. /**
  111058. * Are refraction textures enabled in the application.
  111059. */
  111060. static get RefractionTextureEnabled(): boolean;
  111061. static set RefractionTextureEnabled(value: boolean);
  111062. /**
  111063. * Are color grading textures enabled in the application.
  111064. */
  111065. static get ColorGradingTextureEnabled(): boolean;
  111066. static set ColorGradingTextureEnabled(value: boolean);
  111067. /**
  111068. * Are fresnels enabled in the application.
  111069. */
  111070. static get FresnelEnabled(): boolean;
  111071. static set FresnelEnabled(value: boolean);
  111072. }
  111073. }
  111074. declare module BABYLON {
  111075. /**
  111076. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111077. *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.
  111078. * The SPS is also a particle system. It provides some methods to manage the particles.
  111079. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111080. *
  111081. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111082. */
  111083. export class SolidParticleSystem implements IDisposable {
  111084. /**
  111085. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111086. * Example : var p = SPS.particles[i];
  111087. */
  111088. particles: SolidParticle[];
  111089. /**
  111090. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111091. */
  111092. nbParticles: number;
  111093. /**
  111094. * If the particles must ever face the camera (default false). Useful for planar particles.
  111095. */
  111096. billboard: boolean;
  111097. /**
  111098. * Recompute normals when adding a shape
  111099. */
  111100. recomputeNormals: boolean;
  111101. /**
  111102. * This a counter ofr your own usage. It's not set by any SPS functions.
  111103. */
  111104. counter: number;
  111105. /**
  111106. * The SPS name. This name is also given to the underlying mesh.
  111107. */
  111108. name: string;
  111109. /**
  111110. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111111. */
  111112. mesh: Mesh;
  111113. /**
  111114. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111115. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111116. */
  111117. vars: any;
  111118. /**
  111119. * This array is populated when the SPS is set as 'pickable'.
  111120. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111121. * Each element of this array is an object `{idx: int, faceId: int}`.
  111122. * `idx` is the picked particle index in the `SPS.particles` array
  111123. * `faceId` is the picked face index counted within this particle.
  111124. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111125. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111126. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111127. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111128. */
  111129. pickedParticles: {
  111130. idx: number;
  111131. faceId: number;
  111132. }[];
  111133. /**
  111134. * This array is populated when the SPS is set as 'pickable'
  111135. * Each key of this array is a submesh index.
  111136. * Each element of this array is a second array defined like this :
  111137. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111138. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111139. * `idx` is the picked particle index in the `SPS.particles` array
  111140. * `faceId` is the picked face index counted within this particle.
  111141. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111142. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111143. */
  111144. pickedBySubMesh: {
  111145. idx: number;
  111146. faceId: number;
  111147. }[][];
  111148. /**
  111149. * This array is populated when `enableDepthSort` is set to true.
  111150. * Each element of this array is an instance of the class DepthSortedParticle.
  111151. */
  111152. depthSortedParticles: DepthSortedParticle[];
  111153. /**
  111154. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111155. * @hidden
  111156. */
  111157. _bSphereOnly: boolean;
  111158. /**
  111159. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111160. * @hidden
  111161. */
  111162. _bSphereRadiusFactor: number;
  111163. private _scene;
  111164. private _positions;
  111165. private _indices;
  111166. private _normals;
  111167. private _colors;
  111168. private _uvs;
  111169. private _indices32;
  111170. private _positions32;
  111171. private _normals32;
  111172. private _fixedNormal32;
  111173. private _colors32;
  111174. private _uvs32;
  111175. private _index;
  111176. private _updatable;
  111177. private _pickable;
  111178. private _isVisibilityBoxLocked;
  111179. private _alwaysVisible;
  111180. private _depthSort;
  111181. private _expandable;
  111182. private _shapeCounter;
  111183. private _copy;
  111184. private _color;
  111185. private _computeParticleColor;
  111186. private _computeParticleTexture;
  111187. private _computeParticleRotation;
  111188. private _computeParticleVertex;
  111189. private _computeBoundingBox;
  111190. private _depthSortParticles;
  111191. private _camera;
  111192. private _mustUnrotateFixedNormals;
  111193. private _particlesIntersect;
  111194. private _needs32Bits;
  111195. private _isNotBuilt;
  111196. private _lastParticleId;
  111197. private _idxOfId;
  111198. private _multimaterialEnabled;
  111199. private _useModelMaterial;
  111200. private _indicesByMaterial;
  111201. private _materialIndexes;
  111202. private _depthSortFunction;
  111203. private _materialSortFunction;
  111204. private _materials;
  111205. private _multimaterial;
  111206. private _materialIndexesById;
  111207. private _defaultMaterial;
  111208. private _autoUpdateSubMeshes;
  111209. private _tmpVertex;
  111210. /**
  111211. * Creates a SPS (Solid Particle System) object.
  111212. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111213. * @param scene (Scene) is the scene in which the SPS is added.
  111214. * @param options defines the options of the sps e.g.
  111215. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111216. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111217. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111218. * * 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.
  111219. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111220. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111221. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111222. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111223. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111224. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111225. */
  111226. constructor(name: string, scene: Scene, options?: {
  111227. updatable?: boolean;
  111228. isPickable?: boolean;
  111229. enableDepthSort?: boolean;
  111230. particleIntersection?: boolean;
  111231. boundingSphereOnly?: boolean;
  111232. bSphereRadiusFactor?: number;
  111233. expandable?: boolean;
  111234. useModelMaterial?: boolean;
  111235. enableMultiMaterial?: boolean;
  111236. });
  111237. /**
  111238. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111239. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111240. * @returns the created mesh
  111241. */
  111242. buildMesh(): Mesh;
  111243. /**
  111244. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111245. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111246. * Thus the particles generated from `digest()` have their property `position` set yet.
  111247. * @param mesh ( Mesh ) is the mesh to be digested
  111248. * @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
  111249. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111250. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111251. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111252. * @returns the current SPS
  111253. */
  111254. digest(mesh: Mesh, options?: {
  111255. facetNb?: number;
  111256. number?: number;
  111257. delta?: number;
  111258. storage?: [];
  111259. }): SolidParticleSystem;
  111260. /**
  111261. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111262. * @hidden
  111263. */
  111264. private _unrotateFixedNormals;
  111265. /**
  111266. * Resets the temporary working copy particle
  111267. * @hidden
  111268. */
  111269. private _resetCopy;
  111270. /**
  111271. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111272. * @param p the current index in the positions array to be updated
  111273. * @param ind the current index in the indices array
  111274. * @param shape a Vector3 array, the shape geometry
  111275. * @param positions the positions array to be updated
  111276. * @param meshInd the shape indices array
  111277. * @param indices the indices array to be updated
  111278. * @param meshUV the shape uv array
  111279. * @param uvs the uv array to be updated
  111280. * @param meshCol the shape color array
  111281. * @param colors the color array to be updated
  111282. * @param meshNor the shape normals array
  111283. * @param normals the normals array to be updated
  111284. * @param idx the particle index
  111285. * @param idxInShape the particle index in its shape
  111286. * @param options the addShape() method passed options
  111287. * @model the particle model
  111288. * @hidden
  111289. */
  111290. private _meshBuilder;
  111291. /**
  111292. * Returns a shape Vector3 array from positions float array
  111293. * @param positions float array
  111294. * @returns a vector3 array
  111295. * @hidden
  111296. */
  111297. private _posToShape;
  111298. /**
  111299. * Returns a shapeUV array from a float uvs (array deep copy)
  111300. * @param uvs as a float array
  111301. * @returns a shapeUV array
  111302. * @hidden
  111303. */
  111304. private _uvsToShapeUV;
  111305. /**
  111306. * Adds a new particle object in the particles array
  111307. * @param idx particle index in particles array
  111308. * @param id particle id
  111309. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111310. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111311. * @param model particle ModelShape object
  111312. * @param shapeId model shape identifier
  111313. * @param idxInShape index of the particle in the current model
  111314. * @param bInfo model bounding info object
  111315. * @param storage target storage array, if any
  111316. * @hidden
  111317. */
  111318. private _addParticle;
  111319. /**
  111320. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111321. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111322. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111323. * @param nb (positive integer) the number of particles to be created from this model
  111324. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111325. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111326. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111327. * @returns the number of shapes in the system
  111328. */
  111329. addShape(mesh: Mesh, nb: number, options?: {
  111330. positionFunction?: any;
  111331. vertexFunction?: any;
  111332. storage?: [];
  111333. }): number;
  111334. /**
  111335. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111336. * @hidden
  111337. */
  111338. private _rebuildParticle;
  111339. /**
  111340. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111341. * @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.
  111342. * @returns the SPS.
  111343. */
  111344. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111345. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111346. * Returns an array with the removed particles.
  111347. * 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.
  111348. * The SPS can't be empty so at least one particle needs to remain in place.
  111349. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111350. * @param start index of the first particle to remove
  111351. * @param end index of the last particle to remove (included)
  111352. * @returns an array populated with the removed particles
  111353. */
  111354. removeParticles(start: number, end: number): SolidParticle[];
  111355. /**
  111356. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111357. * @param solidParticleArray an array populated with Solid Particles objects
  111358. * @returns the SPS
  111359. */
  111360. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111361. /**
  111362. * Creates a new particle and modifies the SPS mesh geometry :
  111363. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111364. * - calls _addParticle() to populate the particle array
  111365. * factorized code from addShape() and insertParticlesFromArray()
  111366. * @param idx particle index in the particles array
  111367. * @param i particle index in its shape
  111368. * @param modelShape particle ModelShape object
  111369. * @param shape shape vertex array
  111370. * @param meshInd shape indices array
  111371. * @param meshUV shape uv array
  111372. * @param meshCol shape color array
  111373. * @param meshNor shape normals array
  111374. * @param bbInfo shape bounding info
  111375. * @param storage target particle storage
  111376. * @options addShape() passed options
  111377. * @hidden
  111378. */
  111379. private _insertNewParticle;
  111380. /**
  111381. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111382. * This method calls `updateParticle()` for each particle of the SPS.
  111383. * For an animated SPS, it is usually called within the render loop.
  111384. * 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.
  111385. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111386. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111387. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111388. * @returns the SPS.
  111389. */
  111390. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111391. /**
  111392. * Disposes the SPS.
  111393. */
  111394. dispose(): void;
  111395. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111396. * idx is the particle index in the SPS
  111397. * faceId is the picked face index counted within this particle.
  111398. * Returns null if the pickInfo can't identify a picked particle.
  111399. * @param pickingInfo (PickingInfo object)
  111400. * @returns {idx: number, faceId: number} or null
  111401. */
  111402. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111403. idx: number;
  111404. faceId: number;
  111405. }>;
  111406. /**
  111407. * Returns a SolidParticle object from its identifier : particle.id
  111408. * @param id (integer) the particle Id
  111409. * @returns the searched particle or null if not found in the SPS.
  111410. */
  111411. getParticleById(id: number): Nullable<SolidParticle>;
  111412. /**
  111413. * Returns a new array populated with the particles having the passed shapeId.
  111414. * @param shapeId (integer) the shape identifier
  111415. * @returns a new solid particle array
  111416. */
  111417. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111418. /**
  111419. * Populates the passed array "ref" with the particles having the passed shapeId.
  111420. * @param shapeId the shape identifier
  111421. * @returns the SPS
  111422. * @param ref
  111423. */
  111424. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111425. /**
  111426. * Computes the required SubMeshes according the materials assigned to the particles.
  111427. * @returns the solid particle system.
  111428. * Does nothing if called before the SPS mesh is built.
  111429. */
  111430. computeSubMeshes(): SolidParticleSystem;
  111431. /**
  111432. * Sorts the solid particles by material when MultiMaterial is enabled.
  111433. * Updates the indices32 array.
  111434. * Updates the indicesByMaterial array.
  111435. * Updates the mesh indices array.
  111436. * @returns the SPS
  111437. * @hidden
  111438. */
  111439. private _sortParticlesByMaterial;
  111440. /**
  111441. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111442. * @hidden
  111443. */
  111444. private _setMaterialIndexesById;
  111445. /**
  111446. * Returns an array with unique values of Materials from the passed array
  111447. * @param array the material array to be checked and filtered
  111448. * @hidden
  111449. */
  111450. private _filterUniqueMaterialId;
  111451. /**
  111452. * Sets a new Standard Material as _defaultMaterial if not already set.
  111453. * @hidden
  111454. */
  111455. private _setDefaultMaterial;
  111456. /**
  111457. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111458. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111459. * @returns the SPS.
  111460. */
  111461. refreshVisibleSize(): SolidParticleSystem;
  111462. /**
  111463. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111464. * @param size the size (float) of the visibility box
  111465. * note : this doesn't lock the SPS mesh bounding box.
  111466. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111467. */
  111468. setVisibilityBox(size: number): void;
  111469. /**
  111470. * Gets whether the SPS as always visible or not
  111471. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111472. */
  111473. get isAlwaysVisible(): boolean;
  111474. /**
  111475. * Sets the SPS as always visible or not
  111476. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111477. */
  111478. set isAlwaysVisible(val: boolean);
  111479. /**
  111480. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111481. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111482. */
  111483. set isVisibilityBoxLocked(val: boolean);
  111484. /**
  111485. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111486. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111487. */
  111488. get isVisibilityBoxLocked(): boolean;
  111489. /**
  111490. * Tells to `setParticles()` to compute the particle rotations or not.
  111491. * Default value : true. The SPS is faster when it's set to false.
  111492. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111493. */
  111494. set computeParticleRotation(val: boolean);
  111495. /**
  111496. * Tells to `setParticles()` to compute the particle colors or not.
  111497. * Default value : true. The SPS is faster when it's set to false.
  111498. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111499. */
  111500. set computeParticleColor(val: boolean);
  111501. set computeParticleTexture(val: boolean);
  111502. /**
  111503. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111504. * Default value : false. The SPS is faster when it's set to false.
  111505. * Note : the particle custom vertex positions aren't stored values.
  111506. */
  111507. set computeParticleVertex(val: boolean);
  111508. /**
  111509. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111510. */
  111511. set computeBoundingBox(val: boolean);
  111512. /**
  111513. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111514. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111515. * Default : `true`
  111516. */
  111517. set depthSortParticles(val: boolean);
  111518. /**
  111519. * Gets if `setParticles()` computes the particle rotations or not.
  111520. * Default value : true. The SPS is faster when it's set to false.
  111521. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111522. */
  111523. get computeParticleRotation(): boolean;
  111524. /**
  111525. * Gets if `setParticles()` computes the particle colors or not.
  111526. * Default value : true. The SPS is faster when it's set to false.
  111527. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111528. */
  111529. get computeParticleColor(): boolean;
  111530. /**
  111531. * Gets if `setParticles()` computes the particle textures or not.
  111532. * Default value : true. The SPS is faster when it's set to false.
  111533. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111534. */
  111535. get computeParticleTexture(): boolean;
  111536. /**
  111537. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111538. * Default value : false. The SPS is faster when it's set to false.
  111539. * Note : the particle custom vertex positions aren't stored values.
  111540. */
  111541. get computeParticleVertex(): boolean;
  111542. /**
  111543. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111544. */
  111545. get computeBoundingBox(): boolean;
  111546. /**
  111547. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111548. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111549. * Default : `true`
  111550. */
  111551. get depthSortParticles(): boolean;
  111552. /**
  111553. * Gets if the SPS is created as expandable at construction time.
  111554. * Default : `false`
  111555. */
  111556. get expandable(): boolean;
  111557. /**
  111558. * Gets if the SPS supports the Multi Materials
  111559. */
  111560. get multimaterialEnabled(): boolean;
  111561. /**
  111562. * Gets if the SPS uses the model materials for its own multimaterial.
  111563. */
  111564. get useModelMaterial(): boolean;
  111565. /**
  111566. * The SPS used material array.
  111567. */
  111568. get materials(): Material[];
  111569. /**
  111570. * Sets the SPS MultiMaterial from the passed materials.
  111571. * Note : the passed array is internally copied and not used then by reference.
  111572. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111573. */
  111574. setMultiMaterial(materials: Material[]): void;
  111575. /**
  111576. * The SPS computed multimaterial object
  111577. */
  111578. get multimaterial(): MultiMaterial;
  111579. set multimaterial(mm: MultiMaterial);
  111580. /**
  111581. * If the subMeshes must be updated on the next call to setParticles()
  111582. */
  111583. get autoUpdateSubMeshes(): boolean;
  111584. set autoUpdateSubMeshes(val: boolean);
  111585. /**
  111586. * This function does nothing. It may be overwritten to set all the particle first values.
  111587. * The SPS doesn't call this function, you may have to call it by your own.
  111588. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111589. */
  111590. initParticles(): void;
  111591. /**
  111592. * This function does nothing. It may be overwritten to recycle a particle.
  111593. * The SPS doesn't call this function, you may have to call it by your own.
  111594. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111595. * @param particle The particle to recycle
  111596. * @returns the recycled particle
  111597. */
  111598. recycleParticle(particle: SolidParticle): SolidParticle;
  111599. /**
  111600. * Updates a particle : this function should be overwritten by the user.
  111601. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111602. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111603. * @example : just set a particle position or velocity and recycle conditions
  111604. * @param particle The particle to update
  111605. * @returns the updated particle
  111606. */
  111607. updateParticle(particle: SolidParticle): SolidParticle;
  111608. /**
  111609. * Updates a vertex of a particle : it can be overwritten by the user.
  111610. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111611. * @param particle the current particle
  111612. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111613. * @param pt the index of the current vertex in the particle shape
  111614. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111615. * @example : just set a vertex particle position or color
  111616. * @returns the sps
  111617. */
  111618. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111619. /**
  111620. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111621. * This does nothing and may be overwritten by the user.
  111622. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111623. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111624. * @param update the boolean update value actually passed to setParticles()
  111625. */
  111626. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111627. /**
  111628. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111629. * This will be passed three parameters.
  111630. * This does nothing and may be overwritten by the user.
  111631. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111632. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111633. * @param update the boolean update value actually passed to setParticles()
  111634. */
  111635. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111636. }
  111637. }
  111638. declare module BABYLON {
  111639. /**
  111640. * Represents one particle of a solid particle system.
  111641. */
  111642. export class SolidParticle {
  111643. /**
  111644. * particle global index
  111645. */
  111646. idx: number;
  111647. /**
  111648. * particle identifier
  111649. */
  111650. id: number;
  111651. /**
  111652. * The color of the particle
  111653. */
  111654. color: Nullable<Color4>;
  111655. /**
  111656. * The world space position of the particle.
  111657. */
  111658. position: Vector3;
  111659. /**
  111660. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111661. */
  111662. rotation: Vector3;
  111663. /**
  111664. * The world space rotation quaternion of the particle.
  111665. */
  111666. rotationQuaternion: Nullable<Quaternion>;
  111667. /**
  111668. * The scaling of the particle.
  111669. */
  111670. scaling: Vector3;
  111671. /**
  111672. * The uvs of the particle.
  111673. */
  111674. uvs: Vector4;
  111675. /**
  111676. * The current speed of the particle.
  111677. */
  111678. velocity: Vector3;
  111679. /**
  111680. * The pivot point in the particle local space.
  111681. */
  111682. pivot: Vector3;
  111683. /**
  111684. * Must the particle be translated from its pivot point in its local space ?
  111685. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111686. * Default : false
  111687. */
  111688. translateFromPivot: boolean;
  111689. /**
  111690. * Is the particle active or not ?
  111691. */
  111692. alive: boolean;
  111693. /**
  111694. * Is the particle visible or not ?
  111695. */
  111696. isVisible: boolean;
  111697. /**
  111698. * Index of this particle in the global "positions" array (Internal use)
  111699. * @hidden
  111700. */
  111701. _pos: number;
  111702. /**
  111703. * @hidden Index of this particle in the global "indices" array (Internal use)
  111704. */
  111705. _ind: number;
  111706. /**
  111707. * @hidden ModelShape of this particle (Internal use)
  111708. */
  111709. _model: ModelShape;
  111710. /**
  111711. * ModelShape id of this particle
  111712. */
  111713. shapeId: number;
  111714. /**
  111715. * Index of the particle in its shape id
  111716. */
  111717. idxInShape: number;
  111718. /**
  111719. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  111720. */
  111721. _modelBoundingInfo: BoundingInfo;
  111722. /**
  111723. * @hidden Particle BoundingInfo object (Internal use)
  111724. */
  111725. _boundingInfo: BoundingInfo;
  111726. /**
  111727. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  111728. */
  111729. _sps: SolidParticleSystem;
  111730. /**
  111731. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  111732. */
  111733. _stillInvisible: boolean;
  111734. /**
  111735. * @hidden Last computed particle rotation matrix
  111736. */
  111737. _rotationMatrix: number[];
  111738. /**
  111739. * Parent particle Id, if any.
  111740. * Default null.
  111741. */
  111742. parentId: Nullable<number>;
  111743. /**
  111744. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  111745. */
  111746. materialIndex: Nullable<number>;
  111747. /**
  111748. * Custom object or properties.
  111749. */
  111750. props: Nullable<any>;
  111751. /**
  111752. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  111753. * The possible values are :
  111754. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111755. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111756. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111757. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111758. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111759. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  111760. * */
  111761. cullingStrategy: number;
  111762. /**
  111763. * @hidden Internal global position in the SPS.
  111764. */
  111765. _globalPosition: Vector3;
  111766. /**
  111767. * Creates a Solid Particle object.
  111768. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  111769. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  111770. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  111771. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  111772. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  111773. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  111774. * @param shapeId (integer) is the model shape identifier in the SPS.
  111775. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  111776. * @param sps defines the sps it is associated to
  111777. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  111778. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  111779. */
  111780. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  111781. /**
  111782. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  111783. * @param target the particle target
  111784. * @returns the current particle
  111785. */
  111786. copyToRef(target: SolidParticle): SolidParticle;
  111787. /**
  111788. * Legacy support, changed scale to scaling
  111789. */
  111790. get scale(): Vector3;
  111791. /**
  111792. * Legacy support, changed scale to scaling
  111793. */
  111794. set scale(scale: Vector3);
  111795. /**
  111796. * Legacy support, changed quaternion to rotationQuaternion
  111797. */
  111798. get quaternion(): Nullable<Quaternion>;
  111799. /**
  111800. * Legacy support, changed quaternion to rotationQuaternion
  111801. */
  111802. set quaternion(q: Nullable<Quaternion>);
  111803. /**
  111804. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111805. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111806. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111807. * @returns true if it intersects
  111808. */
  111809. intersectsMesh(target: Mesh | SolidParticle): boolean;
  111810. /**
  111811. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111812. * A particle is in the frustum if its bounding box intersects the frustum
  111813. * @param frustumPlanes defines the frustum to test
  111814. * @returns true if the particle is in the frustum planes
  111815. */
  111816. isInFrustum(frustumPlanes: Plane[]): boolean;
  111817. /**
  111818. * get the rotation matrix of the particle
  111819. * @hidden
  111820. */
  111821. getRotationMatrix(m: Matrix): void;
  111822. }
  111823. /**
  111824. * Represents the shape of the model used by one particle of a solid particle system.
  111825. * SPS internal tool, don't use it manually.
  111826. */
  111827. export class ModelShape {
  111828. /**
  111829. * The shape id
  111830. * @hidden
  111831. */
  111832. shapeID: number;
  111833. /**
  111834. * flat array of model positions (internal use)
  111835. * @hidden
  111836. */
  111837. _shape: Vector3[];
  111838. /**
  111839. * flat array of model UVs (internal use)
  111840. * @hidden
  111841. */
  111842. _shapeUV: number[];
  111843. /**
  111844. * color array of the model
  111845. * @hidden
  111846. */
  111847. _shapeColors: number[];
  111848. /**
  111849. * indices array of the model
  111850. * @hidden
  111851. */
  111852. _indices: number[];
  111853. /**
  111854. * normals array of the model
  111855. * @hidden
  111856. */
  111857. _normals: number[];
  111858. /**
  111859. * length of the shape in the model indices array (internal use)
  111860. * @hidden
  111861. */
  111862. _indicesLength: number;
  111863. /**
  111864. * Custom position function (internal use)
  111865. * @hidden
  111866. */
  111867. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  111868. /**
  111869. * Custom vertex function (internal use)
  111870. * @hidden
  111871. */
  111872. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  111873. /**
  111874. * Model material (internal use)
  111875. * @hidden
  111876. */
  111877. _material: Nullable<Material>;
  111878. /**
  111879. * 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.
  111880. * SPS internal tool, don't use it manually.
  111881. * @hidden
  111882. */
  111883. 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>);
  111884. }
  111885. /**
  111886. * Represents a Depth Sorted Particle in the solid particle system.
  111887. * @hidden
  111888. */
  111889. export class DepthSortedParticle {
  111890. /**
  111891. * Particle index
  111892. */
  111893. idx: number;
  111894. /**
  111895. * Index of the particle in the "indices" array
  111896. */
  111897. ind: number;
  111898. /**
  111899. * Length of the particle shape in the "indices" array
  111900. */
  111901. indicesLength: number;
  111902. /**
  111903. * Squared distance from the particle to the camera
  111904. */
  111905. sqDistance: number;
  111906. /**
  111907. * Material index when used with MultiMaterials
  111908. */
  111909. materialIndex: number;
  111910. /**
  111911. * Creates a new sorted particle
  111912. * @param materialIndex
  111913. */
  111914. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  111915. }
  111916. /**
  111917. * Represents a solid particle vertex
  111918. */
  111919. export class SolidParticleVertex {
  111920. /**
  111921. * Vertex position
  111922. */
  111923. position: Vector3;
  111924. /**
  111925. * Vertex color
  111926. */
  111927. color: Color4;
  111928. /**
  111929. * Vertex UV
  111930. */
  111931. uv: Vector2;
  111932. /**
  111933. * Creates a new solid particle vertex
  111934. */
  111935. constructor();
  111936. /** Vertex x coordinate */
  111937. get x(): number;
  111938. set x(val: number);
  111939. /** Vertex y coordinate */
  111940. get y(): number;
  111941. set y(val: number);
  111942. /** Vertex z coordinate */
  111943. get z(): number;
  111944. set z(val: number);
  111945. }
  111946. }
  111947. declare module BABYLON {
  111948. /**
  111949. * @hidden
  111950. */
  111951. export class _MeshCollisionData {
  111952. _checkCollisions: boolean;
  111953. _collisionMask: number;
  111954. _collisionGroup: number;
  111955. _surroundingMeshes: Nullable<AbstractMesh[]>;
  111956. _collider: Nullable<Collider>;
  111957. _oldPositionForCollisions: Vector3;
  111958. _diffPositionForCollisions: Vector3;
  111959. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  111960. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  111961. _collisionResponse: boolean;
  111962. }
  111963. }
  111964. declare module BABYLON {
  111965. /** @hidden */
  111966. class _FacetDataStorage {
  111967. facetPositions: Vector3[];
  111968. facetNormals: Vector3[];
  111969. facetPartitioning: number[][];
  111970. facetNb: number;
  111971. partitioningSubdivisions: number;
  111972. partitioningBBoxRatio: number;
  111973. facetDataEnabled: boolean;
  111974. facetParameters: any;
  111975. bbSize: Vector3;
  111976. subDiv: {
  111977. max: number;
  111978. X: number;
  111979. Y: number;
  111980. Z: number;
  111981. };
  111982. facetDepthSort: boolean;
  111983. facetDepthSortEnabled: boolean;
  111984. depthSortedIndices: IndicesArray;
  111985. depthSortedFacets: {
  111986. ind: number;
  111987. sqDistance: number;
  111988. }[];
  111989. facetDepthSortFunction: (f1: {
  111990. ind: number;
  111991. sqDistance: number;
  111992. }, f2: {
  111993. ind: number;
  111994. sqDistance: number;
  111995. }) => number;
  111996. facetDepthSortFrom: Vector3;
  111997. facetDepthSortOrigin: Vector3;
  111998. invertedMatrix: Matrix;
  111999. }
  112000. /**
  112001. * @hidden
  112002. **/
  112003. class _InternalAbstractMeshDataInfo {
  112004. _hasVertexAlpha: boolean;
  112005. _useVertexColors: boolean;
  112006. _numBoneInfluencers: number;
  112007. _applyFog: boolean;
  112008. _receiveShadows: boolean;
  112009. _facetData: _FacetDataStorage;
  112010. _visibility: number;
  112011. _skeleton: Nullable<Skeleton>;
  112012. _layerMask: number;
  112013. _computeBonesUsingShaders: boolean;
  112014. _isActive: boolean;
  112015. _onlyForInstances: boolean;
  112016. _isActiveIntermediate: boolean;
  112017. _onlyForInstancesIntermediate: boolean;
  112018. _actAsRegularMesh: boolean;
  112019. }
  112020. /**
  112021. * Class used to store all common mesh properties
  112022. */
  112023. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112024. /** No occlusion */
  112025. static OCCLUSION_TYPE_NONE: number;
  112026. /** Occlusion set to optimisitic */
  112027. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112028. /** Occlusion set to strict */
  112029. static OCCLUSION_TYPE_STRICT: number;
  112030. /** Use an accurante occlusion algorithm */
  112031. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112032. /** Use a conservative occlusion algorithm */
  112033. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112034. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112035. * Test order :
  112036. * Is the bounding sphere outside the frustum ?
  112037. * If not, are the bounding box vertices outside the frustum ?
  112038. * It not, then the cullable object is in the frustum.
  112039. */
  112040. static readonly CULLINGSTRATEGY_STANDARD: number;
  112041. /** Culling strategy : Bounding Sphere Only.
  112042. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112043. * It's also less accurate than the standard because some not visible objects can still be selected.
  112044. * Test : is the bounding sphere outside the frustum ?
  112045. * If not, then the cullable object is in the frustum.
  112046. */
  112047. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112048. /** Culling strategy : Optimistic Inclusion.
  112049. * This in an inclusion test first, then the standard exclusion test.
  112050. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112051. * 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.
  112052. * Anyway, it's as accurate as the standard strategy.
  112053. * Test :
  112054. * Is the cullable object bounding sphere center in the frustum ?
  112055. * If not, apply the default culling strategy.
  112056. */
  112057. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112058. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112059. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112060. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112061. * 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.
  112062. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112063. * Test :
  112064. * Is the cullable object bounding sphere center in the frustum ?
  112065. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112066. */
  112067. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112068. /**
  112069. * No billboard
  112070. */
  112071. static get BILLBOARDMODE_NONE(): number;
  112072. /** Billboard on X axis */
  112073. static get BILLBOARDMODE_X(): number;
  112074. /** Billboard on Y axis */
  112075. static get BILLBOARDMODE_Y(): number;
  112076. /** Billboard on Z axis */
  112077. static get BILLBOARDMODE_Z(): number;
  112078. /** Billboard on all axes */
  112079. static get BILLBOARDMODE_ALL(): number;
  112080. /** Billboard on using position instead of orientation */
  112081. static get BILLBOARDMODE_USE_POSITION(): number;
  112082. /** @hidden */
  112083. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112084. /**
  112085. * The culling strategy to use to check whether the mesh must be rendered or not.
  112086. * This value can be changed at any time and will be used on the next render mesh selection.
  112087. * The possible values are :
  112088. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112089. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112090. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112091. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112092. * Please read each static variable documentation to get details about the culling process.
  112093. * */
  112094. cullingStrategy: number;
  112095. /**
  112096. * Gets the number of facets in the mesh
  112097. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112098. */
  112099. get facetNb(): number;
  112100. /**
  112101. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112102. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112103. */
  112104. get partitioningSubdivisions(): number;
  112105. set partitioningSubdivisions(nb: number);
  112106. /**
  112107. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112108. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112109. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112110. */
  112111. get partitioningBBoxRatio(): number;
  112112. set partitioningBBoxRatio(ratio: number);
  112113. /**
  112114. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112115. * Works only for updatable meshes.
  112116. * Doesn't work with multi-materials
  112117. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112118. */
  112119. get mustDepthSortFacets(): boolean;
  112120. set mustDepthSortFacets(sort: boolean);
  112121. /**
  112122. * The location (Vector3) where the facet depth sort must be computed from.
  112123. * By default, the active camera position.
  112124. * Used only when facet depth sort is enabled
  112125. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112126. */
  112127. get facetDepthSortFrom(): Vector3;
  112128. set facetDepthSortFrom(location: Vector3);
  112129. /**
  112130. * gets a boolean indicating if facetData is enabled
  112131. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112132. */
  112133. get isFacetDataEnabled(): boolean;
  112134. /** @hidden */
  112135. _updateNonUniformScalingState(value: boolean): boolean;
  112136. /**
  112137. * An event triggered when this mesh collides with another one
  112138. */
  112139. onCollideObservable: Observable<AbstractMesh>;
  112140. /** Set a function to call when this mesh collides with another one */
  112141. set onCollide(callback: () => void);
  112142. /**
  112143. * An event triggered when the collision's position changes
  112144. */
  112145. onCollisionPositionChangeObservable: Observable<Vector3>;
  112146. /** Set a function to call when the collision's position changes */
  112147. set onCollisionPositionChange(callback: () => void);
  112148. /**
  112149. * An event triggered when material is changed
  112150. */
  112151. onMaterialChangedObservable: Observable<AbstractMesh>;
  112152. /**
  112153. * Gets or sets the orientation for POV movement & rotation
  112154. */
  112155. definedFacingForward: boolean;
  112156. /** @hidden */
  112157. _occlusionQuery: Nullable<WebGLQuery>;
  112158. /** @hidden */
  112159. _renderingGroup: Nullable<RenderingGroup>;
  112160. /**
  112161. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112162. */
  112163. get visibility(): number;
  112164. /**
  112165. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112166. */
  112167. set visibility(value: number);
  112168. /** Gets or sets the alpha index used to sort transparent meshes
  112169. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112170. */
  112171. alphaIndex: number;
  112172. /**
  112173. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112174. */
  112175. isVisible: boolean;
  112176. /**
  112177. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112178. */
  112179. isPickable: boolean;
  112180. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112181. showSubMeshesBoundingBox: boolean;
  112182. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112183. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112184. */
  112185. isBlocker: boolean;
  112186. /**
  112187. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112188. */
  112189. enablePointerMoveEvents: boolean;
  112190. private _renderingGroupId;
  112191. /**
  112192. * Specifies the rendering group id for this mesh (0 by default)
  112193. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112194. */
  112195. get renderingGroupId(): number;
  112196. set renderingGroupId(value: number);
  112197. private _material;
  112198. /** Gets or sets current material */
  112199. get material(): Nullable<Material>;
  112200. set material(value: Nullable<Material>);
  112201. /**
  112202. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112203. * @see https://doc.babylonjs.com/babylon101/shadows
  112204. */
  112205. get receiveShadows(): boolean;
  112206. set receiveShadows(value: boolean);
  112207. /** Defines color to use when rendering outline */
  112208. outlineColor: Color3;
  112209. /** Define width to use when rendering outline */
  112210. outlineWidth: number;
  112211. /** Defines color to use when rendering overlay */
  112212. overlayColor: Color3;
  112213. /** Defines alpha to use when rendering overlay */
  112214. overlayAlpha: number;
  112215. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112216. get hasVertexAlpha(): boolean;
  112217. set hasVertexAlpha(value: boolean);
  112218. /** 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) */
  112219. get useVertexColors(): boolean;
  112220. set useVertexColors(value: boolean);
  112221. /**
  112222. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112223. */
  112224. get computeBonesUsingShaders(): boolean;
  112225. set computeBonesUsingShaders(value: boolean);
  112226. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112227. get numBoneInfluencers(): number;
  112228. set numBoneInfluencers(value: number);
  112229. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112230. get applyFog(): boolean;
  112231. set applyFog(value: boolean);
  112232. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112233. useOctreeForRenderingSelection: boolean;
  112234. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112235. useOctreeForPicking: boolean;
  112236. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112237. useOctreeForCollisions: boolean;
  112238. /**
  112239. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112240. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112241. */
  112242. get layerMask(): number;
  112243. set layerMask(value: number);
  112244. /**
  112245. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112246. */
  112247. alwaysSelectAsActiveMesh: boolean;
  112248. /**
  112249. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112250. */
  112251. doNotSyncBoundingInfo: boolean;
  112252. /**
  112253. * Gets or sets the current action manager
  112254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112255. */
  112256. actionManager: Nullable<AbstractActionManager>;
  112257. private _meshCollisionData;
  112258. /**
  112259. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112260. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112261. */
  112262. ellipsoid: Vector3;
  112263. /**
  112264. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112265. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112266. */
  112267. ellipsoidOffset: Vector3;
  112268. /**
  112269. * Gets or sets a collision mask used to mask collisions (default is -1).
  112270. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112271. */
  112272. get collisionMask(): number;
  112273. set collisionMask(mask: number);
  112274. /**
  112275. * Gets or sets a collision response flag (default is true).
  112276. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112277. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112278. * to respond to the collision.
  112279. */
  112280. get collisionResponse(): boolean;
  112281. set collisionResponse(response: boolean);
  112282. /**
  112283. * Gets or sets the current collision group mask (-1 by default).
  112284. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112285. */
  112286. get collisionGroup(): number;
  112287. set collisionGroup(mask: number);
  112288. /**
  112289. * Gets or sets current surrounding meshes (null by default).
  112290. *
  112291. * By default collision detection is tested against every mesh in the scene.
  112292. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112293. * meshes will be tested for the collision.
  112294. *
  112295. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112296. */
  112297. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112298. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112299. /**
  112300. * Defines edge width used when edgesRenderer is enabled
  112301. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112302. */
  112303. edgesWidth: number;
  112304. /**
  112305. * Defines edge color used when edgesRenderer is enabled
  112306. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112307. */
  112308. edgesColor: Color4;
  112309. /** @hidden */
  112310. _edgesRenderer: Nullable<IEdgesRenderer>;
  112311. /** @hidden */
  112312. _masterMesh: Nullable<AbstractMesh>;
  112313. /** @hidden */
  112314. _boundingInfo: Nullable<BoundingInfo>;
  112315. /** @hidden */
  112316. _renderId: number;
  112317. /**
  112318. * Gets or sets the list of subMeshes
  112319. * @see https://doc.babylonjs.com/how_to/multi_materials
  112320. */
  112321. subMeshes: SubMesh[];
  112322. /** @hidden */
  112323. _intersectionsInProgress: AbstractMesh[];
  112324. /** @hidden */
  112325. _unIndexed: boolean;
  112326. /** @hidden */
  112327. _lightSources: Light[];
  112328. /** Gets the list of lights affecting that mesh */
  112329. get lightSources(): Light[];
  112330. /** @hidden */
  112331. get _positions(): Nullable<Vector3[]>;
  112332. /** @hidden */
  112333. _waitingData: {
  112334. lods: Nullable<any>;
  112335. actions: Nullable<any>;
  112336. freezeWorldMatrix: Nullable<boolean>;
  112337. };
  112338. /** @hidden */
  112339. _bonesTransformMatrices: Nullable<Float32Array>;
  112340. /** @hidden */
  112341. _transformMatrixTexture: Nullable<RawTexture>;
  112342. /**
  112343. * Gets or sets a skeleton to apply skining transformations
  112344. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112345. */
  112346. set skeleton(value: Nullable<Skeleton>);
  112347. get skeleton(): Nullable<Skeleton>;
  112348. /**
  112349. * An event triggered when the mesh is rebuilt.
  112350. */
  112351. onRebuildObservable: Observable<AbstractMesh>;
  112352. /**
  112353. * Creates a new AbstractMesh
  112354. * @param name defines the name of the mesh
  112355. * @param scene defines the hosting scene
  112356. */
  112357. constructor(name: string, scene?: Nullable<Scene>);
  112358. /**
  112359. * Returns the string "AbstractMesh"
  112360. * @returns "AbstractMesh"
  112361. */
  112362. getClassName(): string;
  112363. /**
  112364. * Gets a string representation of the current mesh
  112365. * @param fullDetails defines a boolean indicating if full details must be included
  112366. * @returns a string representation of the current mesh
  112367. */
  112368. toString(fullDetails?: boolean): string;
  112369. /**
  112370. * @hidden
  112371. */
  112372. protected _getEffectiveParent(): Nullable<Node>;
  112373. /** @hidden */
  112374. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112375. /** @hidden */
  112376. _rebuild(): void;
  112377. /** @hidden */
  112378. _resyncLightSources(): void;
  112379. /** @hidden */
  112380. _resyncLightSource(light: Light): void;
  112381. /** @hidden */
  112382. _unBindEffect(): void;
  112383. /** @hidden */
  112384. _removeLightSource(light: Light, dispose: boolean): void;
  112385. private _markSubMeshesAsDirty;
  112386. /** @hidden */
  112387. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112388. /** @hidden */
  112389. _markSubMeshesAsAttributesDirty(): void;
  112390. /** @hidden */
  112391. _markSubMeshesAsMiscDirty(): void;
  112392. /**
  112393. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112394. */
  112395. get scaling(): Vector3;
  112396. set scaling(newScaling: Vector3);
  112397. /**
  112398. * Returns true if the mesh is blocked. Implemented by child classes
  112399. */
  112400. get isBlocked(): boolean;
  112401. /**
  112402. * Returns the mesh itself by default. Implemented by child classes
  112403. * @param camera defines the camera to use to pick the right LOD level
  112404. * @returns the currentAbstractMesh
  112405. */
  112406. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112407. /**
  112408. * Returns 0 by default. Implemented by child classes
  112409. * @returns an integer
  112410. */
  112411. getTotalVertices(): number;
  112412. /**
  112413. * Returns a positive integer : the total number of indices in this mesh geometry.
  112414. * @returns the numner of indices or zero if the mesh has no geometry.
  112415. */
  112416. getTotalIndices(): number;
  112417. /**
  112418. * Returns null by default. Implemented by child classes
  112419. * @returns null
  112420. */
  112421. getIndices(): Nullable<IndicesArray>;
  112422. /**
  112423. * Returns the array of the requested vertex data kind. Implemented by child classes
  112424. * @param kind defines the vertex data kind to use
  112425. * @returns null
  112426. */
  112427. getVerticesData(kind: string): Nullable<FloatArray>;
  112428. /**
  112429. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112430. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112431. * Note that a new underlying VertexBuffer object is created each call.
  112432. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112433. * @param kind defines vertex data kind:
  112434. * * VertexBuffer.PositionKind
  112435. * * VertexBuffer.UVKind
  112436. * * VertexBuffer.UV2Kind
  112437. * * VertexBuffer.UV3Kind
  112438. * * VertexBuffer.UV4Kind
  112439. * * VertexBuffer.UV5Kind
  112440. * * VertexBuffer.UV6Kind
  112441. * * VertexBuffer.ColorKind
  112442. * * VertexBuffer.MatricesIndicesKind
  112443. * * VertexBuffer.MatricesIndicesExtraKind
  112444. * * VertexBuffer.MatricesWeightsKind
  112445. * * VertexBuffer.MatricesWeightsExtraKind
  112446. * @param data defines the data source
  112447. * @param updatable defines if the data must be flagged as updatable (or static)
  112448. * @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
  112449. * @returns the current mesh
  112450. */
  112451. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112452. /**
  112453. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112454. * If the mesh has no geometry, it is simply returned as it is.
  112455. * @param kind defines vertex data kind:
  112456. * * VertexBuffer.PositionKind
  112457. * * VertexBuffer.UVKind
  112458. * * VertexBuffer.UV2Kind
  112459. * * VertexBuffer.UV3Kind
  112460. * * VertexBuffer.UV4Kind
  112461. * * VertexBuffer.UV5Kind
  112462. * * VertexBuffer.UV6Kind
  112463. * * VertexBuffer.ColorKind
  112464. * * VertexBuffer.MatricesIndicesKind
  112465. * * VertexBuffer.MatricesIndicesExtraKind
  112466. * * VertexBuffer.MatricesWeightsKind
  112467. * * VertexBuffer.MatricesWeightsExtraKind
  112468. * @param data defines the data source
  112469. * @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
  112470. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112471. * @returns the current mesh
  112472. */
  112473. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112474. /**
  112475. * Sets the mesh indices,
  112476. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112477. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112478. * @param totalVertices Defines the total number of vertices
  112479. * @returns the current mesh
  112480. */
  112481. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112482. /**
  112483. * Gets a boolean indicating if specific vertex data is present
  112484. * @param kind defines the vertex data kind to use
  112485. * @returns true is data kind is present
  112486. */
  112487. isVerticesDataPresent(kind: string): boolean;
  112488. /**
  112489. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112490. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112491. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112492. * @returns a BoundingInfo
  112493. */
  112494. getBoundingInfo(): BoundingInfo;
  112495. /**
  112496. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112497. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112498. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112499. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112500. * @returns the current mesh
  112501. */
  112502. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112503. /**
  112504. * Overwrite the current bounding info
  112505. * @param boundingInfo defines the new bounding info
  112506. * @returns the current mesh
  112507. */
  112508. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112509. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112510. get useBones(): boolean;
  112511. /** @hidden */
  112512. _preActivate(): void;
  112513. /** @hidden */
  112514. _preActivateForIntermediateRendering(renderId: number): void;
  112515. /** @hidden */
  112516. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112517. /** @hidden */
  112518. _postActivate(): void;
  112519. /** @hidden */
  112520. _freeze(): void;
  112521. /** @hidden */
  112522. _unFreeze(): void;
  112523. /**
  112524. * Gets the current world matrix
  112525. * @returns a Matrix
  112526. */
  112527. getWorldMatrix(): Matrix;
  112528. /** @hidden */
  112529. _getWorldMatrixDeterminant(): number;
  112530. /**
  112531. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112532. */
  112533. get isAnInstance(): boolean;
  112534. /**
  112535. * Gets a boolean indicating if this mesh has instances
  112536. */
  112537. get hasInstances(): boolean;
  112538. /**
  112539. * Gets a boolean indicating if this mesh has thin instances
  112540. */
  112541. get hasThinInstances(): boolean;
  112542. /**
  112543. * Perform relative position change from the point of view of behind the front of the mesh.
  112544. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112545. * Supports definition of mesh facing forward or backward
  112546. * @param amountRight defines the distance on the right axis
  112547. * @param amountUp defines the distance on the up axis
  112548. * @param amountForward defines the distance on the forward axis
  112549. * @returns the current mesh
  112550. */
  112551. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112552. /**
  112553. * Calculate relative position change from the point of view of behind the front of the mesh.
  112554. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112555. * Supports definition of mesh facing forward or backward
  112556. * @param amountRight defines the distance on the right axis
  112557. * @param amountUp defines the distance on the up axis
  112558. * @param amountForward defines the distance on the forward axis
  112559. * @returns the new displacement vector
  112560. */
  112561. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112562. /**
  112563. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112564. * Supports definition of mesh facing forward or backward
  112565. * @param flipBack defines the flip
  112566. * @param twirlClockwise defines the twirl
  112567. * @param tiltRight defines the tilt
  112568. * @returns the current mesh
  112569. */
  112570. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112571. /**
  112572. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112573. * Supports definition of mesh facing forward or backward.
  112574. * @param flipBack defines the flip
  112575. * @param twirlClockwise defines the twirl
  112576. * @param tiltRight defines the tilt
  112577. * @returns the new rotation vector
  112578. */
  112579. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112580. /**
  112581. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112582. * This means the mesh underlying bounding box and sphere are recomputed.
  112583. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112584. * @returns the current mesh
  112585. */
  112586. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112587. /** @hidden */
  112588. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112589. /** @hidden */
  112590. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112591. /** @hidden */
  112592. _updateBoundingInfo(): AbstractMesh;
  112593. /** @hidden */
  112594. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112595. /** @hidden */
  112596. protected _afterComputeWorldMatrix(): void;
  112597. /** @hidden */
  112598. get _effectiveMesh(): AbstractMesh;
  112599. /**
  112600. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112601. * A mesh is in the frustum if its bounding box intersects the frustum
  112602. * @param frustumPlanes defines the frustum to test
  112603. * @returns true if the mesh is in the frustum planes
  112604. */
  112605. isInFrustum(frustumPlanes: Plane[]): boolean;
  112606. /**
  112607. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112608. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112609. * @param frustumPlanes defines the frustum to test
  112610. * @returns true if the mesh is completely in the frustum planes
  112611. */
  112612. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112613. /**
  112614. * True if the mesh intersects another mesh or a SolidParticle object
  112615. * @param mesh defines a target mesh or SolidParticle to test
  112616. * @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)
  112617. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112618. * @returns true if there is an intersection
  112619. */
  112620. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112621. /**
  112622. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112623. * @param point defines the point to test
  112624. * @returns true if there is an intersection
  112625. */
  112626. intersectsPoint(point: Vector3): boolean;
  112627. /**
  112628. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112629. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112630. */
  112631. get checkCollisions(): boolean;
  112632. set checkCollisions(collisionEnabled: boolean);
  112633. /**
  112634. * Gets Collider object used to compute collisions (not physics)
  112635. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112636. */
  112637. get collider(): Nullable<Collider>;
  112638. /**
  112639. * Move the mesh using collision engine
  112640. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112641. * @param displacement defines the requested displacement vector
  112642. * @returns the current mesh
  112643. */
  112644. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112645. private _onCollisionPositionChange;
  112646. /** @hidden */
  112647. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112648. /** @hidden */
  112649. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112650. /** @hidden */
  112651. _checkCollision(collider: Collider): AbstractMesh;
  112652. /** @hidden */
  112653. _generatePointsArray(): boolean;
  112654. /**
  112655. * Checks if the passed Ray intersects with the mesh
  112656. * @param ray defines the ray to use
  112657. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112658. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112659. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112660. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112661. * @returns the picking info
  112662. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112663. */
  112664. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112665. /**
  112666. * Clones the current mesh
  112667. * @param name defines the mesh name
  112668. * @param newParent defines the new mesh parent
  112669. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112670. * @returns the new mesh
  112671. */
  112672. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112673. /**
  112674. * Disposes all the submeshes of the current meshnp
  112675. * @returns the current mesh
  112676. */
  112677. releaseSubMeshes(): AbstractMesh;
  112678. /**
  112679. * Releases resources associated with this abstract mesh.
  112680. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112681. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112682. */
  112683. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112684. /**
  112685. * Adds the passed mesh as a child to the current mesh
  112686. * @param mesh defines the child mesh
  112687. * @returns the current mesh
  112688. */
  112689. addChild(mesh: AbstractMesh): AbstractMesh;
  112690. /**
  112691. * Removes the passed mesh from the current mesh children list
  112692. * @param mesh defines the child mesh
  112693. * @returns the current mesh
  112694. */
  112695. removeChild(mesh: AbstractMesh): AbstractMesh;
  112696. /** @hidden */
  112697. private _initFacetData;
  112698. /**
  112699. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  112700. * This method can be called within the render loop.
  112701. * 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
  112702. * @returns the current mesh
  112703. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112704. */
  112705. updateFacetData(): AbstractMesh;
  112706. /**
  112707. * Returns the facetLocalNormals array.
  112708. * The normals are expressed in the mesh local spac
  112709. * @returns an array of Vector3
  112710. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112711. */
  112712. getFacetLocalNormals(): Vector3[];
  112713. /**
  112714. * Returns the facetLocalPositions array.
  112715. * The facet positions are expressed in the mesh local space
  112716. * @returns an array of Vector3
  112717. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112718. */
  112719. getFacetLocalPositions(): Vector3[];
  112720. /**
  112721. * Returns the facetLocalPartioning array
  112722. * @returns an array of array of numbers
  112723. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112724. */
  112725. getFacetLocalPartitioning(): number[][];
  112726. /**
  112727. * Returns the i-th facet position in the world system.
  112728. * This method allocates a new Vector3 per call
  112729. * @param i defines the facet index
  112730. * @returns a new Vector3
  112731. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112732. */
  112733. getFacetPosition(i: number): Vector3;
  112734. /**
  112735. * Sets the reference Vector3 with the i-th facet position in the world system
  112736. * @param i defines the facet index
  112737. * @param ref defines the target vector
  112738. * @returns the current mesh
  112739. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112740. */
  112741. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  112742. /**
  112743. * Returns the i-th facet normal in the world system.
  112744. * This method allocates a new Vector3 per call
  112745. * @param i defines the facet index
  112746. * @returns a new Vector3
  112747. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112748. */
  112749. getFacetNormal(i: number): Vector3;
  112750. /**
  112751. * Sets the reference Vector3 with the i-th facet normal in the world system
  112752. * @param i defines the facet index
  112753. * @param ref defines the target vector
  112754. * @returns the current mesh
  112755. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112756. */
  112757. getFacetNormalToRef(i: number, ref: Vector3): this;
  112758. /**
  112759. * 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)
  112760. * @param x defines x coordinate
  112761. * @param y defines y coordinate
  112762. * @param z defines z coordinate
  112763. * @returns the array of facet indexes
  112764. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112765. */
  112766. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  112767. /**
  112768. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  112769. * @param projected sets as the (x,y,z) world projection on the facet
  112770. * @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
  112771. * @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
  112772. * @param x defines x coordinate
  112773. * @param y defines y coordinate
  112774. * @param z defines z coordinate
  112775. * @returns the face index if found (or null instead)
  112776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112777. */
  112778. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112779. /**
  112780. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  112781. * @param projected sets as the (x,y,z) local projection on the facet
  112782. * @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
  112783. * @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
  112784. * @param x defines x coordinate
  112785. * @param y defines y coordinate
  112786. * @param z defines z coordinate
  112787. * @returns the face index if found (or null instead)
  112788. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112789. */
  112790. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112791. /**
  112792. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  112793. * @returns the parameters
  112794. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112795. */
  112796. getFacetDataParameters(): any;
  112797. /**
  112798. * Disables the feature FacetData and frees the related memory
  112799. * @returns the current mesh
  112800. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112801. */
  112802. disableFacetData(): AbstractMesh;
  112803. /**
  112804. * Updates the AbstractMesh indices array
  112805. * @param indices defines the data source
  112806. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  112807. * @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)
  112808. * @returns the current mesh
  112809. */
  112810. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  112811. /**
  112812. * Creates new normals data for the mesh
  112813. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  112814. * @returns the current mesh
  112815. */
  112816. createNormals(updatable: boolean): AbstractMesh;
  112817. /**
  112818. * Align the mesh with a normal
  112819. * @param normal defines the normal to use
  112820. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  112821. * @returns the current mesh
  112822. */
  112823. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  112824. /** @hidden */
  112825. _checkOcclusionQuery(): boolean;
  112826. /**
  112827. * Disables the mesh edge rendering mode
  112828. * @returns the currentAbstractMesh
  112829. */
  112830. disableEdgesRendering(): AbstractMesh;
  112831. /**
  112832. * Enables the edge rendering mode on the mesh.
  112833. * This mode makes the mesh edges visible
  112834. * @param epsilon defines the maximal distance between two angles to detect a face
  112835. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  112836. * @returns the currentAbstractMesh
  112837. * @see https://www.babylonjs-playground.com/#19O9TU#0
  112838. */
  112839. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  112840. /**
  112841. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  112842. * @returns an array of particle systems in the scene that use the mesh as an emitter
  112843. */
  112844. getConnectedParticleSystems(): IParticleSystem[];
  112845. }
  112846. }
  112847. declare module BABYLON {
  112848. /**
  112849. * Interface used to define ActionEvent
  112850. */
  112851. export interface IActionEvent {
  112852. /** The mesh or sprite that triggered the action */
  112853. source: any;
  112854. /** The X mouse cursor position at the time of the event */
  112855. pointerX: number;
  112856. /** The Y mouse cursor position at the time of the event */
  112857. pointerY: number;
  112858. /** The mesh that is currently pointed at (can be null) */
  112859. meshUnderPointer: Nullable<AbstractMesh>;
  112860. /** the original (browser) event that triggered the ActionEvent */
  112861. sourceEvent?: any;
  112862. /** additional data for the event */
  112863. additionalData?: any;
  112864. }
  112865. /**
  112866. * ActionEvent is the event being sent when an action is triggered.
  112867. */
  112868. export class ActionEvent implements IActionEvent {
  112869. /** The mesh or sprite that triggered the action */
  112870. source: any;
  112871. /** The X mouse cursor position at the time of the event */
  112872. pointerX: number;
  112873. /** The Y mouse cursor position at the time of the event */
  112874. pointerY: number;
  112875. /** The mesh that is currently pointed at (can be null) */
  112876. meshUnderPointer: Nullable<AbstractMesh>;
  112877. /** the original (browser) event that triggered the ActionEvent */
  112878. sourceEvent?: any;
  112879. /** additional data for the event */
  112880. additionalData?: any;
  112881. /**
  112882. * Creates a new ActionEvent
  112883. * @param source The mesh or sprite that triggered the action
  112884. * @param pointerX The X mouse cursor position at the time of the event
  112885. * @param pointerY The Y mouse cursor position at the time of the event
  112886. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  112887. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  112888. * @param additionalData additional data for the event
  112889. */
  112890. constructor(
  112891. /** The mesh or sprite that triggered the action */
  112892. source: any,
  112893. /** The X mouse cursor position at the time of the event */
  112894. pointerX: number,
  112895. /** The Y mouse cursor position at the time of the event */
  112896. pointerY: number,
  112897. /** The mesh that is currently pointed at (can be null) */
  112898. meshUnderPointer: Nullable<AbstractMesh>,
  112899. /** the original (browser) event that triggered the ActionEvent */
  112900. sourceEvent?: any,
  112901. /** additional data for the event */
  112902. additionalData?: any);
  112903. /**
  112904. * Helper function to auto-create an ActionEvent from a source mesh.
  112905. * @param source The source mesh that triggered the event
  112906. * @param evt The original (browser) event
  112907. * @param additionalData additional data for the event
  112908. * @returns the new ActionEvent
  112909. */
  112910. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  112911. /**
  112912. * Helper function to auto-create an ActionEvent from a source sprite
  112913. * @param source The source sprite that triggered the event
  112914. * @param scene Scene associated with the sprite
  112915. * @param evt The original (browser) event
  112916. * @param additionalData additional data for the event
  112917. * @returns the new ActionEvent
  112918. */
  112919. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  112920. /**
  112921. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  112922. * @param scene the scene where the event occurred
  112923. * @param evt The original (browser) event
  112924. * @returns the new ActionEvent
  112925. */
  112926. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  112927. /**
  112928. * Helper function to auto-create an ActionEvent from a primitive
  112929. * @param prim defines the target primitive
  112930. * @param pointerPos defines the pointer position
  112931. * @param evt The original (browser) event
  112932. * @param additionalData additional data for the event
  112933. * @returns the new ActionEvent
  112934. */
  112935. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  112936. }
  112937. }
  112938. declare module BABYLON {
  112939. /**
  112940. * Abstract class used to decouple action Manager from scene and meshes.
  112941. * Do not instantiate.
  112942. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112943. */
  112944. export abstract class AbstractActionManager implements IDisposable {
  112945. /** Gets the list of active triggers */
  112946. static Triggers: {
  112947. [key: string]: number;
  112948. };
  112949. /** Gets the cursor to use when hovering items */
  112950. hoverCursor: string;
  112951. /** Gets the list of actions */
  112952. actions: IAction[];
  112953. /**
  112954. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  112955. */
  112956. isRecursive: boolean;
  112957. /**
  112958. * Releases all associated resources
  112959. */
  112960. abstract dispose(): void;
  112961. /**
  112962. * Does this action manager has pointer triggers
  112963. */
  112964. abstract get hasPointerTriggers(): boolean;
  112965. /**
  112966. * Does this action manager has pick triggers
  112967. */
  112968. abstract get hasPickTriggers(): boolean;
  112969. /**
  112970. * Process a specific trigger
  112971. * @param trigger defines the trigger to process
  112972. * @param evt defines the event details to be processed
  112973. */
  112974. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  112975. /**
  112976. * Does this action manager handles actions of any of the given triggers
  112977. * @param triggers defines the triggers to be tested
  112978. * @return a boolean indicating whether one (or more) of the triggers is handled
  112979. */
  112980. abstract hasSpecificTriggers(triggers: number[]): boolean;
  112981. /**
  112982. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  112983. * speed.
  112984. * @param triggerA defines the trigger to be tested
  112985. * @param triggerB defines the trigger to be tested
  112986. * @return a boolean indicating whether one (or more) of the triggers is handled
  112987. */
  112988. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  112989. /**
  112990. * Does this action manager handles actions of a given trigger
  112991. * @param trigger defines the trigger to be tested
  112992. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  112993. * @return whether the trigger is handled
  112994. */
  112995. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  112996. /**
  112997. * Serialize this manager to a JSON object
  112998. * @param name defines the property name to store this manager
  112999. * @returns a JSON representation of this manager
  113000. */
  113001. abstract serialize(name: string): any;
  113002. /**
  113003. * Registers an action to this action manager
  113004. * @param action defines the action to be registered
  113005. * @return the action amended (prepared) after registration
  113006. */
  113007. abstract registerAction(action: IAction): Nullable<IAction>;
  113008. /**
  113009. * Unregisters an action to this action manager
  113010. * @param action defines the action to be unregistered
  113011. * @return a boolean indicating whether the action has been unregistered
  113012. */
  113013. abstract unregisterAction(action: IAction): Boolean;
  113014. /**
  113015. * Does exist one action manager with at least one trigger
  113016. **/
  113017. static get HasTriggers(): boolean;
  113018. /**
  113019. * Does exist one action manager with at least one pick trigger
  113020. **/
  113021. static get HasPickTriggers(): boolean;
  113022. /**
  113023. * Does exist one action manager that handles actions of a given trigger
  113024. * @param trigger defines the trigger to be tested
  113025. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113026. **/
  113027. static HasSpecificTrigger(trigger: number): boolean;
  113028. }
  113029. }
  113030. declare module BABYLON {
  113031. /**
  113032. * Defines how a node can be built from a string name.
  113033. */
  113034. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113035. /**
  113036. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113037. */
  113038. export class Node implements IBehaviorAware<Node> {
  113039. /** @hidden */
  113040. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113041. private static _NodeConstructors;
  113042. /**
  113043. * Add a new node constructor
  113044. * @param type defines the type name of the node to construct
  113045. * @param constructorFunc defines the constructor function
  113046. */
  113047. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113048. /**
  113049. * Returns a node constructor based on type name
  113050. * @param type defines the type name
  113051. * @param name defines the new node name
  113052. * @param scene defines the hosting scene
  113053. * @param options defines optional options to transmit to constructors
  113054. * @returns the new constructor or null
  113055. */
  113056. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113057. /**
  113058. * Gets or sets the name of the node
  113059. */
  113060. name: string;
  113061. /**
  113062. * Gets or sets the id of the node
  113063. */
  113064. id: string;
  113065. /**
  113066. * Gets or sets the unique id of the node
  113067. */
  113068. uniqueId: number;
  113069. /**
  113070. * Gets or sets a string used to store user defined state for the node
  113071. */
  113072. state: string;
  113073. /**
  113074. * Gets or sets an object used to store user defined information for the node
  113075. */
  113076. metadata: any;
  113077. /**
  113078. * For internal use only. Please do not use.
  113079. */
  113080. reservedDataStore: any;
  113081. /**
  113082. * List of inspectable custom properties (used by the Inspector)
  113083. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113084. */
  113085. inspectableCustomProperties: IInspectable[];
  113086. private _doNotSerialize;
  113087. /**
  113088. * Gets or sets a boolean used to define if the node must be serialized
  113089. */
  113090. get doNotSerialize(): boolean;
  113091. set doNotSerialize(value: boolean);
  113092. /** @hidden */
  113093. _isDisposed: boolean;
  113094. /**
  113095. * Gets a list of Animations associated with the node
  113096. */
  113097. animations: Animation[];
  113098. protected _ranges: {
  113099. [name: string]: Nullable<AnimationRange>;
  113100. };
  113101. /**
  113102. * Callback raised when the node is ready to be used
  113103. */
  113104. onReady: Nullable<(node: Node) => void>;
  113105. private _isEnabled;
  113106. private _isParentEnabled;
  113107. private _isReady;
  113108. /** @hidden */
  113109. _currentRenderId: number;
  113110. private _parentUpdateId;
  113111. /** @hidden */
  113112. _childUpdateId: number;
  113113. /** @hidden */
  113114. _waitingParentId: Nullable<string>;
  113115. /** @hidden */
  113116. _scene: Scene;
  113117. /** @hidden */
  113118. _cache: any;
  113119. private _parentNode;
  113120. private _children;
  113121. /** @hidden */
  113122. _worldMatrix: Matrix;
  113123. /** @hidden */
  113124. _worldMatrixDeterminant: number;
  113125. /** @hidden */
  113126. _worldMatrixDeterminantIsDirty: boolean;
  113127. /** @hidden */
  113128. private _sceneRootNodesIndex;
  113129. /**
  113130. * Gets a boolean indicating if the node has been disposed
  113131. * @returns true if the node was disposed
  113132. */
  113133. isDisposed(): boolean;
  113134. /**
  113135. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113136. * @see https://doc.babylonjs.com/how_to/parenting
  113137. */
  113138. set parent(parent: Nullable<Node>);
  113139. get parent(): Nullable<Node>;
  113140. /** @hidden */
  113141. _addToSceneRootNodes(): void;
  113142. /** @hidden */
  113143. _removeFromSceneRootNodes(): void;
  113144. private _animationPropertiesOverride;
  113145. /**
  113146. * Gets or sets the animation properties override
  113147. */
  113148. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113149. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113150. /**
  113151. * Gets a string identifying the name of the class
  113152. * @returns "Node" string
  113153. */
  113154. getClassName(): string;
  113155. /** @hidden */
  113156. readonly _isNode: boolean;
  113157. /**
  113158. * An event triggered when the mesh is disposed
  113159. */
  113160. onDisposeObservable: Observable<Node>;
  113161. private _onDisposeObserver;
  113162. /**
  113163. * Sets a callback that will be raised when the node will be disposed
  113164. */
  113165. set onDispose(callback: () => void);
  113166. /**
  113167. * Creates a new Node
  113168. * @param name the name and id to be given to this node
  113169. * @param scene the scene this node will be added to
  113170. */
  113171. constructor(name: string, scene?: Nullable<Scene>);
  113172. /**
  113173. * Gets the scene of the node
  113174. * @returns a scene
  113175. */
  113176. getScene(): Scene;
  113177. /**
  113178. * Gets the engine of the node
  113179. * @returns a Engine
  113180. */
  113181. getEngine(): Engine;
  113182. private _behaviors;
  113183. /**
  113184. * Attach a behavior to the node
  113185. * @see https://doc.babylonjs.com/features/behaviour
  113186. * @param behavior defines the behavior to attach
  113187. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113188. * @returns the current Node
  113189. */
  113190. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113191. /**
  113192. * Remove an attached behavior
  113193. * @see https://doc.babylonjs.com/features/behaviour
  113194. * @param behavior defines the behavior to attach
  113195. * @returns the current Node
  113196. */
  113197. removeBehavior(behavior: Behavior<Node>): Node;
  113198. /**
  113199. * Gets the list of attached behaviors
  113200. * @see https://doc.babylonjs.com/features/behaviour
  113201. */
  113202. get behaviors(): Behavior<Node>[];
  113203. /**
  113204. * Gets an attached behavior by name
  113205. * @param name defines the name of the behavior to look for
  113206. * @see https://doc.babylonjs.com/features/behaviour
  113207. * @returns null if behavior was not found else the requested behavior
  113208. */
  113209. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113210. /**
  113211. * Returns the latest update of the World matrix
  113212. * @returns a Matrix
  113213. */
  113214. getWorldMatrix(): Matrix;
  113215. /** @hidden */
  113216. _getWorldMatrixDeterminant(): number;
  113217. /**
  113218. * Returns directly the latest state of the mesh World matrix.
  113219. * A Matrix is returned.
  113220. */
  113221. get worldMatrixFromCache(): Matrix;
  113222. /** @hidden */
  113223. _initCache(): void;
  113224. /** @hidden */
  113225. updateCache(force?: boolean): void;
  113226. /** @hidden */
  113227. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113228. /** @hidden */
  113229. _updateCache(ignoreParentClass?: boolean): void;
  113230. /** @hidden */
  113231. _isSynchronized(): boolean;
  113232. /** @hidden */
  113233. _markSyncedWithParent(): void;
  113234. /** @hidden */
  113235. isSynchronizedWithParent(): boolean;
  113236. /** @hidden */
  113237. isSynchronized(): boolean;
  113238. /**
  113239. * Is this node ready to be used/rendered
  113240. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113241. * @return true if the node is ready
  113242. */
  113243. isReady(completeCheck?: boolean): boolean;
  113244. /**
  113245. * Is this node enabled?
  113246. * 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
  113247. * @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
  113248. * @return whether this node (and its parent) is enabled
  113249. */
  113250. isEnabled(checkAncestors?: boolean): boolean;
  113251. /** @hidden */
  113252. protected _syncParentEnabledState(): void;
  113253. /**
  113254. * Set the enabled state of this node
  113255. * @param value defines the new enabled state
  113256. */
  113257. setEnabled(value: boolean): void;
  113258. /**
  113259. * Is this node a descendant of the given node?
  113260. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113261. * @param ancestor defines the parent node to inspect
  113262. * @returns a boolean indicating if this node is a descendant of the given node
  113263. */
  113264. isDescendantOf(ancestor: Node): boolean;
  113265. /** @hidden */
  113266. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113267. /**
  113268. * Will return all nodes that have this node as ascendant
  113269. * @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
  113270. * @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
  113271. * @return all children nodes of all types
  113272. */
  113273. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113274. /**
  113275. * Get all child-meshes of this node
  113276. * @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)
  113277. * @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
  113278. * @returns an array of AbstractMesh
  113279. */
  113280. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113281. /**
  113282. * Get all direct children of this node
  113283. * @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
  113284. * @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)
  113285. * @returns an array of Node
  113286. */
  113287. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113288. /** @hidden */
  113289. _setReady(state: boolean): void;
  113290. /**
  113291. * Get an animation by name
  113292. * @param name defines the name of the animation to look for
  113293. * @returns null if not found else the requested animation
  113294. */
  113295. getAnimationByName(name: string): Nullable<Animation>;
  113296. /**
  113297. * Creates an animation range for this node
  113298. * @param name defines the name of the range
  113299. * @param from defines the starting key
  113300. * @param to defines the end key
  113301. */
  113302. createAnimationRange(name: string, from: number, to: number): void;
  113303. /**
  113304. * Delete a specific animation range
  113305. * @param name defines the name of the range to delete
  113306. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113307. */
  113308. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113309. /**
  113310. * Get an animation range by name
  113311. * @param name defines the name of the animation range to look for
  113312. * @returns null if not found else the requested animation range
  113313. */
  113314. getAnimationRange(name: string): Nullable<AnimationRange>;
  113315. /**
  113316. * Gets the list of all animation ranges defined on this node
  113317. * @returns an array
  113318. */
  113319. getAnimationRanges(): Nullable<AnimationRange>[];
  113320. /**
  113321. * Will start the animation sequence
  113322. * @param name defines the range frames for animation sequence
  113323. * @param loop defines if the animation should loop (false by default)
  113324. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113325. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113326. * @returns the object created for this animation. If range does not exist, it will return null
  113327. */
  113328. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113329. /**
  113330. * Serialize animation ranges into a JSON compatible object
  113331. * @returns serialization object
  113332. */
  113333. serializeAnimationRanges(): any;
  113334. /**
  113335. * Computes the world matrix of the node
  113336. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113337. * @returns the world matrix
  113338. */
  113339. computeWorldMatrix(force?: boolean): Matrix;
  113340. /**
  113341. * Releases resources associated with this node.
  113342. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113343. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113344. */
  113345. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113346. /**
  113347. * Parse animation range data from a serialization object and store them into a given node
  113348. * @param node defines where to store the animation ranges
  113349. * @param parsedNode defines the serialization object to read data from
  113350. * @param scene defines the hosting scene
  113351. */
  113352. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113353. /**
  113354. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113355. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113356. * @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
  113357. * @returns the new bounding vectors
  113358. */
  113359. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113360. min: Vector3;
  113361. max: Vector3;
  113362. };
  113363. }
  113364. }
  113365. declare module BABYLON {
  113366. /**
  113367. * @hidden
  113368. */
  113369. export class _IAnimationState {
  113370. key: number;
  113371. repeatCount: number;
  113372. workValue?: any;
  113373. loopMode?: number;
  113374. offsetValue?: any;
  113375. highLimitValue?: any;
  113376. }
  113377. /**
  113378. * Class used to store any kind of animation
  113379. */
  113380. export class Animation {
  113381. /**Name of the animation */
  113382. name: string;
  113383. /**Property to animate */
  113384. targetProperty: string;
  113385. /**The frames per second of the animation */
  113386. framePerSecond: number;
  113387. /**The data type of the animation */
  113388. dataType: number;
  113389. /**The loop mode of the animation */
  113390. loopMode?: number | undefined;
  113391. /**Specifies if blending should be enabled */
  113392. enableBlending?: boolean | undefined;
  113393. /**
  113394. * Use matrix interpolation instead of using direct key value when animating matrices
  113395. */
  113396. static AllowMatricesInterpolation: boolean;
  113397. /**
  113398. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113399. */
  113400. static AllowMatrixDecomposeForInterpolation: boolean;
  113401. /** Define the Url to load snippets */
  113402. static SnippetUrl: string;
  113403. /** Snippet ID if the animation was created from the snippet server */
  113404. snippetId: string;
  113405. /**
  113406. * Stores the key frames of the animation
  113407. */
  113408. private _keys;
  113409. /**
  113410. * Stores the easing function of the animation
  113411. */
  113412. private _easingFunction;
  113413. /**
  113414. * @hidden Internal use only
  113415. */
  113416. _runtimeAnimations: RuntimeAnimation[];
  113417. /**
  113418. * The set of event that will be linked to this animation
  113419. */
  113420. private _events;
  113421. /**
  113422. * Stores an array of target property paths
  113423. */
  113424. targetPropertyPath: string[];
  113425. /**
  113426. * Stores the blending speed of the animation
  113427. */
  113428. blendingSpeed: number;
  113429. /**
  113430. * Stores the animation ranges for the animation
  113431. */
  113432. private _ranges;
  113433. /**
  113434. * @hidden Internal use
  113435. */
  113436. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113437. /**
  113438. * Sets up an animation
  113439. * @param property The property to animate
  113440. * @param animationType The animation type to apply
  113441. * @param framePerSecond The frames per second of the animation
  113442. * @param easingFunction The easing function used in the animation
  113443. * @returns The created animation
  113444. */
  113445. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113446. /**
  113447. * Create and start an animation on a node
  113448. * @param name defines the name of the global animation that will be run on all nodes
  113449. * @param node defines the root node where the animation will take place
  113450. * @param targetProperty defines property to animate
  113451. * @param framePerSecond defines the number of frame per second yo use
  113452. * @param totalFrame defines the number of frames in total
  113453. * @param from defines the initial value
  113454. * @param to defines the final value
  113455. * @param loopMode defines which loop mode you want to use (off by default)
  113456. * @param easingFunction defines the easing function to use (linear by default)
  113457. * @param onAnimationEnd defines the callback to call when animation end
  113458. * @returns the animatable created for this animation
  113459. */
  113460. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113461. /**
  113462. * Create and start an animation on a node and its descendants
  113463. * @param name defines the name of the global animation that will be run on all nodes
  113464. * @param node defines the root node where the animation will take place
  113465. * @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
  113466. * @param targetProperty defines property to animate
  113467. * @param framePerSecond defines the number of frame per second to use
  113468. * @param totalFrame defines the number of frames in total
  113469. * @param from defines the initial value
  113470. * @param to defines the final value
  113471. * @param loopMode defines which loop mode you want to use (off by default)
  113472. * @param easingFunction defines the easing function to use (linear by default)
  113473. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113474. * @returns the list of animatables created for all nodes
  113475. * @example https://www.babylonjs-playground.com/#MH0VLI
  113476. */
  113477. 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[]>;
  113478. /**
  113479. * Creates a new animation, merges it with the existing animations and starts it
  113480. * @param name Name of the animation
  113481. * @param node Node which contains the scene that begins the animations
  113482. * @param targetProperty Specifies which property to animate
  113483. * @param framePerSecond The frames per second of the animation
  113484. * @param totalFrame The total number of frames
  113485. * @param from The frame at the beginning of the animation
  113486. * @param to The frame at the end of the animation
  113487. * @param loopMode Specifies the loop mode of the animation
  113488. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113489. * @param onAnimationEnd Callback to run once the animation is complete
  113490. * @returns Nullable animation
  113491. */
  113492. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113493. /**
  113494. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113495. * @param sourceAnimation defines the Animation containing keyframes to convert
  113496. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113497. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113498. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113499. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113500. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113501. */
  113502. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113503. /**
  113504. * Transition property of an host to the target Value
  113505. * @param property The property to transition
  113506. * @param targetValue The target Value of the property
  113507. * @param host The object where the property to animate belongs
  113508. * @param scene Scene used to run the animation
  113509. * @param frameRate Framerate (in frame/s) to use
  113510. * @param transition The transition type we want to use
  113511. * @param duration The duration of the animation, in milliseconds
  113512. * @param onAnimationEnd Callback trigger at the end of the animation
  113513. * @returns Nullable animation
  113514. */
  113515. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113516. /**
  113517. * Return the array of runtime animations currently using this animation
  113518. */
  113519. get runtimeAnimations(): RuntimeAnimation[];
  113520. /**
  113521. * Specifies if any of the runtime animations are currently running
  113522. */
  113523. get hasRunningRuntimeAnimations(): boolean;
  113524. /**
  113525. * Initializes the animation
  113526. * @param name Name of the animation
  113527. * @param targetProperty Property to animate
  113528. * @param framePerSecond The frames per second of the animation
  113529. * @param dataType The data type of the animation
  113530. * @param loopMode The loop mode of the animation
  113531. * @param enableBlending Specifies if blending should be enabled
  113532. */
  113533. constructor(
  113534. /**Name of the animation */
  113535. name: string,
  113536. /**Property to animate */
  113537. targetProperty: string,
  113538. /**The frames per second of the animation */
  113539. framePerSecond: number,
  113540. /**The data type of the animation */
  113541. dataType: number,
  113542. /**The loop mode of the animation */
  113543. loopMode?: number | undefined,
  113544. /**Specifies if blending should be enabled */
  113545. enableBlending?: boolean | undefined);
  113546. /**
  113547. * Converts the animation to a string
  113548. * @param fullDetails support for multiple levels of logging within scene loading
  113549. * @returns String form of the animation
  113550. */
  113551. toString(fullDetails?: boolean): string;
  113552. /**
  113553. * Add an event to this animation
  113554. * @param event Event to add
  113555. */
  113556. addEvent(event: AnimationEvent): void;
  113557. /**
  113558. * Remove all events found at the given frame
  113559. * @param frame The frame to remove events from
  113560. */
  113561. removeEvents(frame: number): void;
  113562. /**
  113563. * Retrieves all the events from the animation
  113564. * @returns Events from the animation
  113565. */
  113566. getEvents(): AnimationEvent[];
  113567. /**
  113568. * Creates an animation range
  113569. * @param name Name of the animation range
  113570. * @param from Starting frame of the animation range
  113571. * @param to Ending frame of the animation
  113572. */
  113573. createRange(name: string, from: number, to: number): void;
  113574. /**
  113575. * Deletes an animation range by name
  113576. * @param name Name of the animation range to delete
  113577. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113578. */
  113579. deleteRange(name: string, deleteFrames?: boolean): void;
  113580. /**
  113581. * Gets the animation range by name, or null if not defined
  113582. * @param name Name of the animation range
  113583. * @returns Nullable animation range
  113584. */
  113585. getRange(name: string): Nullable<AnimationRange>;
  113586. /**
  113587. * Gets the key frames from the animation
  113588. * @returns The key frames of the animation
  113589. */
  113590. getKeys(): Array<IAnimationKey>;
  113591. /**
  113592. * Gets the highest frame rate of the animation
  113593. * @returns Highest frame rate of the animation
  113594. */
  113595. getHighestFrame(): number;
  113596. /**
  113597. * Gets the easing function of the animation
  113598. * @returns Easing function of the animation
  113599. */
  113600. getEasingFunction(): IEasingFunction;
  113601. /**
  113602. * Sets the easing function of the animation
  113603. * @param easingFunction A custom mathematical formula for animation
  113604. */
  113605. setEasingFunction(easingFunction: EasingFunction): void;
  113606. /**
  113607. * Interpolates a scalar linearly
  113608. * @param startValue Start value of the animation curve
  113609. * @param endValue End value of the animation curve
  113610. * @param gradient Scalar amount to interpolate
  113611. * @returns Interpolated scalar value
  113612. */
  113613. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113614. /**
  113615. * Interpolates a scalar cubically
  113616. * @param startValue Start value of the animation curve
  113617. * @param outTangent End tangent of the animation
  113618. * @param endValue End value of the animation curve
  113619. * @param inTangent Start tangent of the animation curve
  113620. * @param gradient Scalar amount to interpolate
  113621. * @returns Interpolated scalar value
  113622. */
  113623. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113624. /**
  113625. * Interpolates a quaternion using a spherical linear interpolation
  113626. * @param startValue Start value of the animation curve
  113627. * @param endValue End value of the animation curve
  113628. * @param gradient Scalar amount to interpolate
  113629. * @returns Interpolated quaternion value
  113630. */
  113631. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113632. /**
  113633. * Interpolates a quaternion cubically
  113634. * @param startValue Start value of the animation curve
  113635. * @param outTangent End tangent of the animation curve
  113636. * @param endValue End value of the animation curve
  113637. * @param inTangent Start tangent of the animation curve
  113638. * @param gradient Scalar amount to interpolate
  113639. * @returns Interpolated quaternion value
  113640. */
  113641. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113642. /**
  113643. * Interpolates a Vector3 linearl
  113644. * @param startValue Start value of the animation curve
  113645. * @param endValue End value of the animation curve
  113646. * @param gradient Scalar amount to interpolate
  113647. * @returns Interpolated scalar value
  113648. */
  113649. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113650. /**
  113651. * Interpolates a Vector3 cubically
  113652. * @param startValue Start value of the animation curve
  113653. * @param outTangent End tangent of the animation
  113654. * @param endValue End value of the animation curve
  113655. * @param inTangent Start tangent of the animation curve
  113656. * @param gradient Scalar amount to interpolate
  113657. * @returns InterpolatedVector3 value
  113658. */
  113659. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113660. /**
  113661. * Interpolates a Vector2 linearly
  113662. * @param startValue Start value of the animation curve
  113663. * @param endValue End value of the animation curve
  113664. * @param gradient Scalar amount to interpolate
  113665. * @returns Interpolated Vector2 value
  113666. */
  113667. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113668. /**
  113669. * Interpolates a Vector2 cubically
  113670. * @param startValue Start value of the animation curve
  113671. * @param outTangent End tangent of the animation
  113672. * @param endValue End value of the animation curve
  113673. * @param inTangent Start tangent of the animation curve
  113674. * @param gradient Scalar amount to interpolate
  113675. * @returns Interpolated Vector2 value
  113676. */
  113677. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113678. /**
  113679. * Interpolates a size linearly
  113680. * @param startValue Start value of the animation curve
  113681. * @param endValue End value of the animation curve
  113682. * @param gradient Scalar amount to interpolate
  113683. * @returns Interpolated Size value
  113684. */
  113685. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  113686. /**
  113687. * Interpolates a Color3 linearly
  113688. * @param startValue Start value of the animation curve
  113689. * @param endValue End value of the animation curve
  113690. * @param gradient Scalar amount to interpolate
  113691. * @returns Interpolated Color3 value
  113692. */
  113693. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  113694. /**
  113695. * Interpolates a Color4 linearly
  113696. * @param startValue Start value of the animation curve
  113697. * @param endValue End value of the animation curve
  113698. * @param gradient Scalar amount to interpolate
  113699. * @returns Interpolated Color3 value
  113700. */
  113701. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  113702. /**
  113703. * @hidden Internal use only
  113704. */
  113705. _getKeyValue(value: any): any;
  113706. /**
  113707. * @hidden Internal use only
  113708. */
  113709. _interpolate(currentFrame: number, state: _IAnimationState): any;
  113710. /**
  113711. * Defines the function to use to interpolate matrices
  113712. * @param startValue defines the start matrix
  113713. * @param endValue defines the end matrix
  113714. * @param gradient defines the gradient between both matrices
  113715. * @param result defines an optional target matrix where to store the interpolation
  113716. * @returns the interpolated matrix
  113717. */
  113718. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  113719. /**
  113720. * Makes a copy of the animation
  113721. * @returns Cloned animation
  113722. */
  113723. clone(): Animation;
  113724. /**
  113725. * Sets the key frames of the animation
  113726. * @param values The animation key frames to set
  113727. */
  113728. setKeys(values: Array<IAnimationKey>): void;
  113729. /**
  113730. * Serializes the animation to an object
  113731. * @returns Serialized object
  113732. */
  113733. serialize(): any;
  113734. /**
  113735. * Float animation type
  113736. */
  113737. static readonly ANIMATIONTYPE_FLOAT: number;
  113738. /**
  113739. * Vector3 animation type
  113740. */
  113741. static readonly ANIMATIONTYPE_VECTOR3: number;
  113742. /**
  113743. * Quaternion animation type
  113744. */
  113745. static readonly ANIMATIONTYPE_QUATERNION: number;
  113746. /**
  113747. * Matrix animation type
  113748. */
  113749. static readonly ANIMATIONTYPE_MATRIX: number;
  113750. /**
  113751. * Color3 animation type
  113752. */
  113753. static readonly ANIMATIONTYPE_COLOR3: number;
  113754. /**
  113755. * Color3 animation type
  113756. */
  113757. static readonly ANIMATIONTYPE_COLOR4: number;
  113758. /**
  113759. * Vector2 animation type
  113760. */
  113761. static readonly ANIMATIONTYPE_VECTOR2: number;
  113762. /**
  113763. * Size animation type
  113764. */
  113765. static readonly ANIMATIONTYPE_SIZE: number;
  113766. /**
  113767. * Relative Loop Mode
  113768. */
  113769. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  113770. /**
  113771. * Cycle Loop Mode
  113772. */
  113773. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  113774. /**
  113775. * Constant Loop Mode
  113776. */
  113777. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  113778. /** @hidden */
  113779. static _UniversalLerp(left: any, right: any, amount: number): any;
  113780. /**
  113781. * Parses an animation object and creates an animation
  113782. * @param parsedAnimation Parsed animation object
  113783. * @returns Animation object
  113784. */
  113785. static Parse(parsedAnimation: any): Animation;
  113786. /**
  113787. * Appends the serialized animations from the source animations
  113788. * @param source Source containing the animations
  113789. * @param destination Target to store the animations
  113790. */
  113791. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113792. /**
  113793. * Creates a new animation or an array of animations from a snippet saved in a remote file
  113794. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  113795. * @param url defines the url to load from
  113796. * @returns a promise that will resolve to the new animation or an array of animations
  113797. */
  113798. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  113799. /**
  113800. * Creates an animation or an array of animations from a snippet saved by the Inspector
  113801. * @param snippetId defines the snippet to load
  113802. * @returns a promise that will resolve to the new animation or a new array of animations
  113803. */
  113804. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  113805. }
  113806. }
  113807. declare module BABYLON {
  113808. /**
  113809. * Interface containing an array of animations
  113810. */
  113811. export interface IAnimatable {
  113812. /**
  113813. * Array of animations
  113814. */
  113815. animations: Nullable<Array<Animation>>;
  113816. }
  113817. }
  113818. declare module BABYLON {
  113819. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  113820. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113821. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113822. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113823. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113824. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113825. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113826. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113827. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113828. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113829. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113830. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113831. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113832. /**
  113833. * Decorator used to define property that can be serialized as reference to a camera
  113834. * @param sourceName defines the name of the property to decorate
  113835. */
  113836. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113837. /**
  113838. * Class used to help serialization objects
  113839. */
  113840. export class SerializationHelper {
  113841. /** @hidden */
  113842. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  113843. /** @hidden */
  113844. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  113845. /** @hidden */
  113846. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  113847. /** @hidden */
  113848. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  113849. /**
  113850. * Appends the serialized animations from the source animations
  113851. * @param source Source containing the animations
  113852. * @param destination Target to store the animations
  113853. */
  113854. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113855. /**
  113856. * Static function used to serialized a specific entity
  113857. * @param entity defines the entity to serialize
  113858. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  113859. * @returns a JSON compatible object representing the serialization of the entity
  113860. */
  113861. static Serialize<T>(entity: T, serializationObject?: any): any;
  113862. /**
  113863. * Creates a new entity from a serialization data object
  113864. * @param creationFunction defines a function used to instanciated the new entity
  113865. * @param source defines the source serialization data
  113866. * @param scene defines the hosting scene
  113867. * @param rootUrl defines the root url for resources
  113868. * @returns a new entity
  113869. */
  113870. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  113871. /**
  113872. * Clones an object
  113873. * @param creationFunction defines the function used to instanciate the new object
  113874. * @param source defines the source object
  113875. * @returns the cloned object
  113876. */
  113877. static Clone<T>(creationFunction: () => T, source: T): T;
  113878. /**
  113879. * Instanciates a new object based on a source one (some data will be shared between both object)
  113880. * @param creationFunction defines the function used to instanciate the new object
  113881. * @param source defines the source object
  113882. * @returns the new object
  113883. */
  113884. static Instanciate<T>(creationFunction: () => T, source: T): T;
  113885. }
  113886. }
  113887. declare module BABYLON {
  113888. /**
  113889. * Base class of all the textures in babylon.
  113890. * It groups all the common properties the materials, post process, lights... might need
  113891. * in order to make a correct use of the texture.
  113892. */
  113893. export class BaseTexture implements IAnimatable {
  113894. /**
  113895. * Default anisotropic filtering level for the application.
  113896. * It is set to 4 as a good tradeoff between perf and quality.
  113897. */
  113898. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  113899. /**
  113900. * Gets or sets the unique id of the texture
  113901. */
  113902. uniqueId: number;
  113903. /**
  113904. * Define the name of the texture.
  113905. */
  113906. name: string;
  113907. /**
  113908. * Gets or sets an object used to store user defined information.
  113909. */
  113910. metadata: any;
  113911. /**
  113912. * For internal use only. Please do not use.
  113913. */
  113914. reservedDataStore: any;
  113915. private _hasAlpha;
  113916. /**
  113917. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  113918. */
  113919. set hasAlpha(value: boolean);
  113920. get hasAlpha(): boolean;
  113921. /**
  113922. * Defines if the alpha value should be determined via the rgb values.
  113923. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  113924. */
  113925. getAlphaFromRGB: boolean;
  113926. /**
  113927. * Intensity or strength of the texture.
  113928. * It is commonly used by materials to fine tune the intensity of the texture
  113929. */
  113930. level: number;
  113931. /**
  113932. * Define the UV chanel to use starting from 0 and defaulting to 0.
  113933. * This is part of the texture as textures usually maps to one uv set.
  113934. */
  113935. coordinatesIndex: number;
  113936. protected _coordinatesMode: number;
  113937. /**
  113938. * How a texture is mapped.
  113939. *
  113940. * | Value | Type | Description |
  113941. * | ----- | ----------------------------------- | ----------- |
  113942. * | 0 | EXPLICIT_MODE | |
  113943. * | 1 | SPHERICAL_MODE | |
  113944. * | 2 | PLANAR_MODE | |
  113945. * | 3 | CUBIC_MODE | |
  113946. * | 4 | PROJECTION_MODE | |
  113947. * | 5 | SKYBOX_MODE | |
  113948. * | 6 | INVCUBIC_MODE | |
  113949. * | 7 | EQUIRECTANGULAR_MODE | |
  113950. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  113951. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  113952. */
  113953. set coordinatesMode(value: number);
  113954. get coordinatesMode(): number;
  113955. private _wrapU;
  113956. /**
  113957. * | Value | Type | Description |
  113958. * | ----- | ------------------ | ----------- |
  113959. * | 0 | CLAMP_ADDRESSMODE | |
  113960. * | 1 | WRAP_ADDRESSMODE | |
  113961. * | 2 | MIRROR_ADDRESSMODE | |
  113962. */
  113963. get wrapU(): number;
  113964. set wrapU(value: number);
  113965. private _wrapV;
  113966. /**
  113967. * | Value | Type | Description |
  113968. * | ----- | ------------------ | ----------- |
  113969. * | 0 | CLAMP_ADDRESSMODE | |
  113970. * | 1 | WRAP_ADDRESSMODE | |
  113971. * | 2 | MIRROR_ADDRESSMODE | |
  113972. */
  113973. get wrapV(): number;
  113974. set wrapV(value: number);
  113975. /**
  113976. * | Value | Type | Description |
  113977. * | ----- | ------------------ | ----------- |
  113978. * | 0 | CLAMP_ADDRESSMODE | |
  113979. * | 1 | WRAP_ADDRESSMODE | |
  113980. * | 2 | MIRROR_ADDRESSMODE | |
  113981. */
  113982. wrapR: number;
  113983. /**
  113984. * With compliant hardware and browser (supporting anisotropic filtering)
  113985. * this defines the level of anisotropic filtering in the texture.
  113986. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  113987. */
  113988. anisotropicFilteringLevel: number;
  113989. /**
  113990. * Define if the texture is a cube texture or if false a 2d texture.
  113991. */
  113992. get isCube(): boolean;
  113993. set isCube(value: boolean);
  113994. /**
  113995. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  113996. */
  113997. get is3D(): boolean;
  113998. set is3D(value: boolean);
  113999. /**
  114000. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114001. */
  114002. get is2DArray(): boolean;
  114003. set is2DArray(value: boolean);
  114004. private _gammaSpace;
  114005. /**
  114006. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114007. * HDR texture are usually stored in linear space.
  114008. * This only impacts the PBR and Background materials
  114009. */
  114010. get gammaSpace(): boolean;
  114011. set gammaSpace(gamma: boolean);
  114012. /**
  114013. * Gets or sets whether or not the texture contains RGBD data.
  114014. */
  114015. get isRGBD(): boolean;
  114016. set isRGBD(value: boolean);
  114017. /**
  114018. * Is Z inverted in the texture (useful in a cube texture).
  114019. */
  114020. invertZ: boolean;
  114021. /**
  114022. * Are mip maps generated for this texture or not.
  114023. */
  114024. get noMipmap(): boolean;
  114025. /**
  114026. * @hidden
  114027. */
  114028. lodLevelInAlpha: boolean;
  114029. /**
  114030. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114031. */
  114032. get lodGenerationOffset(): number;
  114033. set lodGenerationOffset(value: number);
  114034. /**
  114035. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114036. */
  114037. get lodGenerationScale(): number;
  114038. set lodGenerationScale(value: number);
  114039. /**
  114040. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114041. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114042. * average roughness values.
  114043. */
  114044. get linearSpecularLOD(): boolean;
  114045. set linearSpecularLOD(value: boolean);
  114046. /**
  114047. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114048. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114049. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114050. */
  114051. get irradianceTexture(): Nullable<BaseTexture>;
  114052. set irradianceTexture(value: Nullable<BaseTexture>);
  114053. /**
  114054. * Define if the texture is a render target.
  114055. */
  114056. isRenderTarget: boolean;
  114057. /**
  114058. * Define the unique id of the texture in the scene.
  114059. */
  114060. get uid(): string;
  114061. /** @hidden */
  114062. _prefiltered: boolean;
  114063. /**
  114064. * Return a string representation of the texture.
  114065. * @returns the texture as a string
  114066. */
  114067. toString(): string;
  114068. /**
  114069. * Get the class name of the texture.
  114070. * @returns "BaseTexture"
  114071. */
  114072. getClassName(): string;
  114073. /**
  114074. * Define the list of animation attached to the texture.
  114075. */
  114076. animations: Animation[];
  114077. /**
  114078. * An event triggered when the texture is disposed.
  114079. */
  114080. onDisposeObservable: Observable<BaseTexture>;
  114081. private _onDisposeObserver;
  114082. /**
  114083. * Callback triggered when the texture has been disposed.
  114084. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114085. */
  114086. set onDispose(callback: () => void);
  114087. /**
  114088. * Define the current state of the loading sequence when in delayed load mode.
  114089. */
  114090. delayLoadState: number;
  114091. protected _scene: Nullable<Scene>;
  114092. protected _engine: Nullable<ThinEngine>;
  114093. /** @hidden */
  114094. _texture: Nullable<InternalTexture>;
  114095. private _uid;
  114096. /**
  114097. * Define if the texture is preventinga material to render or not.
  114098. * If not and the texture is not ready, the engine will use a default black texture instead.
  114099. */
  114100. get isBlocking(): boolean;
  114101. /**
  114102. * Instantiates a new BaseTexture.
  114103. * Base class of all the textures in babylon.
  114104. * It groups all the common properties the materials, post process, lights... might need
  114105. * in order to make a correct use of the texture.
  114106. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114107. */
  114108. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114109. /**
  114110. * Get the scene the texture belongs to.
  114111. * @returns the scene or null if undefined
  114112. */
  114113. getScene(): Nullable<Scene>;
  114114. /** @hidden */
  114115. protected _getEngine(): Nullable<ThinEngine>;
  114116. /**
  114117. * Get the texture transform matrix used to offset tile the texture for istance.
  114118. * @returns the transformation matrix
  114119. */
  114120. getTextureMatrix(): Matrix;
  114121. /**
  114122. * Get the texture reflection matrix used to rotate/transform the reflection.
  114123. * @returns the reflection matrix
  114124. */
  114125. getReflectionTextureMatrix(): Matrix;
  114126. /**
  114127. * Get the underlying lower level texture from Babylon.
  114128. * @returns the insternal texture
  114129. */
  114130. getInternalTexture(): Nullable<InternalTexture>;
  114131. /**
  114132. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114133. * @returns true if ready or not blocking
  114134. */
  114135. isReadyOrNotBlocking(): boolean;
  114136. /**
  114137. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114138. * @returns true if fully ready
  114139. */
  114140. isReady(): boolean;
  114141. private _cachedSize;
  114142. /**
  114143. * Get the size of the texture.
  114144. * @returns the texture size.
  114145. */
  114146. getSize(): ISize;
  114147. /**
  114148. * Get the base size of the texture.
  114149. * It can be different from the size if the texture has been resized for POT for instance
  114150. * @returns the base size
  114151. */
  114152. getBaseSize(): ISize;
  114153. /**
  114154. * Update the sampling mode of the texture.
  114155. * Default is Trilinear mode.
  114156. *
  114157. * | Value | Type | Description |
  114158. * | ----- | ------------------ | ----------- |
  114159. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114160. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114161. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114162. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114163. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114164. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114165. * | 7 | NEAREST_LINEAR | |
  114166. * | 8 | NEAREST_NEAREST | |
  114167. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114168. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114169. * | 11 | LINEAR_LINEAR | |
  114170. * | 12 | LINEAR_NEAREST | |
  114171. *
  114172. * > _mag_: magnification filter (close to the viewer)
  114173. * > _min_: minification filter (far from the viewer)
  114174. * > _mip_: filter used between mip map levels
  114175. *@param samplingMode Define the new sampling mode of the texture
  114176. */
  114177. updateSamplingMode(samplingMode: number): void;
  114178. /**
  114179. * Scales the texture if is `canRescale()`
  114180. * @param ratio the resize factor we want to use to rescale
  114181. */
  114182. scale(ratio: number): void;
  114183. /**
  114184. * Get if the texture can rescale.
  114185. */
  114186. get canRescale(): boolean;
  114187. /** @hidden */
  114188. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114189. /** @hidden */
  114190. _rebuild(): void;
  114191. /**
  114192. * Triggers the load sequence in delayed load mode.
  114193. */
  114194. delayLoad(): void;
  114195. /**
  114196. * Clones the texture.
  114197. * @returns the cloned texture
  114198. */
  114199. clone(): Nullable<BaseTexture>;
  114200. /**
  114201. * Get the texture underlying type (INT, FLOAT...)
  114202. */
  114203. get textureType(): number;
  114204. /**
  114205. * Get the texture underlying format (RGB, RGBA...)
  114206. */
  114207. get textureFormat(): number;
  114208. /**
  114209. * Indicates that textures need to be re-calculated for all materials
  114210. */
  114211. protected _markAllSubMeshesAsTexturesDirty(): void;
  114212. /**
  114213. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114214. * This will returns an RGBA array buffer containing either in values (0-255) or
  114215. * float values (0-1) depending of the underlying buffer type.
  114216. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114217. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114218. * @param buffer defines a user defined buffer to fill with data (can be null)
  114219. * @returns The Array buffer containing the pixels data.
  114220. */
  114221. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114222. /**
  114223. * Release and destroy the underlying lower level texture aka internalTexture.
  114224. */
  114225. releaseInternalTexture(): void;
  114226. /** @hidden */
  114227. get _lodTextureHigh(): Nullable<BaseTexture>;
  114228. /** @hidden */
  114229. get _lodTextureMid(): Nullable<BaseTexture>;
  114230. /** @hidden */
  114231. get _lodTextureLow(): Nullable<BaseTexture>;
  114232. /**
  114233. * Dispose the texture and release its associated resources.
  114234. */
  114235. dispose(): void;
  114236. /**
  114237. * Serialize the texture into a JSON representation that can be parsed later on.
  114238. * @returns the JSON representation of the texture
  114239. */
  114240. serialize(): any;
  114241. /**
  114242. * Helper function to be called back once a list of texture contains only ready textures.
  114243. * @param textures Define the list of textures to wait for
  114244. * @param callback Define the callback triggered once the entire list will be ready
  114245. */
  114246. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114247. private static _isScene;
  114248. }
  114249. }
  114250. declare module BABYLON {
  114251. /**
  114252. * Options to be used when creating an effect.
  114253. */
  114254. export interface IEffectCreationOptions {
  114255. /**
  114256. * Atrributes that will be used in the shader.
  114257. */
  114258. attributes: string[];
  114259. /**
  114260. * Uniform varible names that will be set in the shader.
  114261. */
  114262. uniformsNames: string[];
  114263. /**
  114264. * Uniform buffer variable names that will be set in the shader.
  114265. */
  114266. uniformBuffersNames: string[];
  114267. /**
  114268. * Sampler texture variable names that will be set in the shader.
  114269. */
  114270. samplers: string[];
  114271. /**
  114272. * Define statements that will be set in the shader.
  114273. */
  114274. defines: any;
  114275. /**
  114276. * Possible fallbacks for this effect to improve performance when needed.
  114277. */
  114278. fallbacks: Nullable<IEffectFallbacks>;
  114279. /**
  114280. * Callback that will be called when the shader is compiled.
  114281. */
  114282. onCompiled: Nullable<(effect: Effect) => void>;
  114283. /**
  114284. * Callback that will be called if an error occurs during shader compilation.
  114285. */
  114286. onError: Nullable<(effect: Effect, errors: string) => void>;
  114287. /**
  114288. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114289. */
  114290. indexParameters?: any;
  114291. /**
  114292. * Max number of lights that can be used in the shader.
  114293. */
  114294. maxSimultaneousLights?: number;
  114295. /**
  114296. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114297. */
  114298. transformFeedbackVaryings?: Nullable<string[]>;
  114299. /**
  114300. * 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
  114301. */
  114302. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114303. /**
  114304. * Is this effect rendering to several color attachments ?
  114305. */
  114306. multiTarget?: boolean;
  114307. }
  114308. /**
  114309. * Effect containing vertex and fragment shader that can be executed on an object.
  114310. */
  114311. export class Effect implements IDisposable {
  114312. /**
  114313. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114314. */
  114315. static ShadersRepository: string;
  114316. /**
  114317. * Enable logging of the shader code when a compilation error occurs
  114318. */
  114319. static LogShaderCodeOnCompilationError: boolean;
  114320. /**
  114321. * Name of the effect.
  114322. */
  114323. name: any;
  114324. /**
  114325. * String container all the define statements that should be set on the shader.
  114326. */
  114327. defines: string;
  114328. /**
  114329. * Callback that will be called when the shader is compiled.
  114330. */
  114331. onCompiled: Nullable<(effect: Effect) => void>;
  114332. /**
  114333. * Callback that will be called if an error occurs during shader compilation.
  114334. */
  114335. onError: Nullable<(effect: Effect, errors: string) => void>;
  114336. /**
  114337. * Callback that will be called when effect is bound.
  114338. */
  114339. onBind: Nullable<(effect: Effect) => void>;
  114340. /**
  114341. * Unique ID of the effect.
  114342. */
  114343. uniqueId: number;
  114344. /**
  114345. * Observable that will be called when the shader is compiled.
  114346. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114347. */
  114348. onCompileObservable: Observable<Effect>;
  114349. /**
  114350. * Observable that will be called if an error occurs during shader compilation.
  114351. */
  114352. onErrorObservable: Observable<Effect>;
  114353. /** @hidden */
  114354. _onBindObservable: Nullable<Observable<Effect>>;
  114355. /**
  114356. * @hidden
  114357. * Specifies if the effect was previously ready
  114358. */
  114359. _wasPreviouslyReady: boolean;
  114360. /**
  114361. * Observable that will be called when effect is bound.
  114362. */
  114363. get onBindObservable(): Observable<Effect>;
  114364. /** @hidden */
  114365. _bonesComputationForcedToCPU: boolean;
  114366. /** @hidden */
  114367. _multiTarget: boolean;
  114368. private static _uniqueIdSeed;
  114369. private _engine;
  114370. private _uniformBuffersNames;
  114371. private _uniformBuffersNamesList;
  114372. private _uniformsNames;
  114373. private _samplerList;
  114374. private _samplers;
  114375. private _isReady;
  114376. private _compilationError;
  114377. private _allFallbacksProcessed;
  114378. private _attributesNames;
  114379. private _attributes;
  114380. private _attributeLocationByName;
  114381. private _uniforms;
  114382. /**
  114383. * Key for the effect.
  114384. * @hidden
  114385. */
  114386. _key: string;
  114387. private _indexParameters;
  114388. private _fallbacks;
  114389. private _vertexSourceCode;
  114390. private _fragmentSourceCode;
  114391. private _vertexSourceCodeOverride;
  114392. private _fragmentSourceCodeOverride;
  114393. private _transformFeedbackVaryings;
  114394. /**
  114395. * Compiled shader to webGL program.
  114396. * @hidden
  114397. */
  114398. _pipelineContext: Nullable<IPipelineContext>;
  114399. private _valueCache;
  114400. private static _baseCache;
  114401. /**
  114402. * Instantiates an effect.
  114403. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114404. * @param baseName Name of the effect.
  114405. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114406. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114407. * @param samplers List of sampler variables that will be passed to the shader.
  114408. * @param engine Engine to be used to render the effect
  114409. * @param defines Define statements to be added to the shader.
  114410. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114411. * @param onCompiled Callback that will be called when the shader is compiled.
  114412. * @param onError Callback that will be called if an error occurs during shader compilation.
  114413. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114414. */
  114415. 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);
  114416. private _useFinalCode;
  114417. /**
  114418. * Unique key for this effect
  114419. */
  114420. get key(): string;
  114421. /**
  114422. * If the effect has been compiled and prepared.
  114423. * @returns if the effect is compiled and prepared.
  114424. */
  114425. isReady(): boolean;
  114426. private _isReadyInternal;
  114427. /**
  114428. * The engine the effect was initialized with.
  114429. * @returns the engine.
  114430. */
  114431. getEngine(): Engine;
  114432. /**
  114433. * The pipeline context for this effect
  114434. * @returns the associated pipeline context
  114435. */
  114436. getPipelineContext(): Nullable<IPipelineContext>;
  114437. /**
  114438. * The set of names of attribute variables for the shader.
  114439. * @returns An array of attribute names.
  114440. */
  114441. getAttributesNames(): string[];
  114442. /**
  114443. * Returns the attribute at the given index.
  114444. * @param index The index of the attribute.
  114445. * @returns The location of the attribute.
  114446. */
  114447. getAttributeLocation(index: number): number;
  114448. /**
  114449. * Returns the attribute based on the name of the variable.
  114450. * @param name of the attribute to look up.
  114451. * @returns the attribute location.
  114452. */
  114453. getAttributeLocationByName(name: string): number;
  114454. /**
  114455. * The number of attributes.
  114456. * @returns the numnber of attributes.
  114457. */
  114458. getAttributesCount(): number;
  114459. /**
  114460. * Gets the index of a uniform variable.
  114461. * @param uniformName of the uniform to look up.
  114462. * @returns the index.
  114463. */
  114464. getUniformIndex(uniformName: string): number;
  114465. /**
  114466. * Returns the attribute based on the name of the variable.
  114467. * @param uniformName of the uniform to look up.
  114468. * @returns the location of the uniform.
  114469. */
  114470. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114471. /**
  114472. * Returns an array of sampler variable names
  114473. * @returns The array of sampler variable names.
  114474. */
  114475. getSamplers(): string[];
  114476. /**
  114477. * Returns an array of uniform variable names
  114478. * @returns The array of uniform variable names.
  114479. */
  114480. getUniformNames(): string[];
  114481. /**
  114482. * Returns an array of uniform buffer variable names
  114483. * @returns The array of uniform buffer variable names.
  114484. */
  114485. getUniformBuffersNames(): string[];
  114486. /**
  114487. * Returns the index parameters used to create the effect
  114488. * @returns The index parameters object
  114489. */
  114490. getIndexParameters(): any;
  114491. /**
  114492. * The error from the last compilation.
  114493. * @returns the error string.
  114494. */
  114495. getCompilationError(): string;
  114496. /**
  114497. * Gets a boolean indicating that all fallbacks were used during compilation
  114498. * @returns true if all fallbacks were used
  114499. */
  114500. allFallbacksProcessed(): boolean;
  114501. /**
  114502. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114503. * @param func The callback to be used.
  114504. */
  114505. executeWhenCompiled(func: (effect: Effect) => void): void;
  114506. private _checkIsReady;
  114507. private _loadShader;
  114508. /**
  114509. * Gets the vertex shader source code of this effect
  114510. */
  114511. get vertexSourceCode(): string;
  114512. /**
  114513. * Gets the fragment shader source code of this effect
  114514. */
  114515. get fragmentSourceCode(): string;
  114516. /**
  114517. * Recompiles the webGL program
  114518. * @param vertexSourceCode The source code for the vertex shader.
  114519. * @param fragmentSourceCode The source code for the fragment shader.
  114520. * @param onCompiled Callback called when completed.
  114521. * @param onError Callback called on error.
  114522. * @hidden
  114523. */
  114524. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114525. /**
  114526. * Prepares the effect
  114527. * @hidden
  114528. */
  114529. _prepareEffect(): void;
  114530. private _getShaderCodeAndErrorLine;
  114531. private _processCompilationErrors;
  114532. /**
  114533. * Checks if the effect is supported. (Must be called after compilation)
  114534. */
  114535. get isSupported(): boolean;
  114536. /**
  114537. * Binds a texture to the engine to be used as output of the shader.
  114538. * @param channel Name of the output variable.
  114539. * @param texture Texture to bind.
  114540. * @hidden
  114541. */
  114542. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114543. /**
  114544. * Sets a texture on the engine to be used in the shader.
  114545. * @param channel Name of the sampler variable.
  114546. * @param texture Texture to set.
  114547. */
  114548. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114549. /**
  114550. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114551. * @param channel Name of the sampler variable.
  114552. * @param texture Texture to set.
  114553. */
  114554. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114555. /**
  114556. * Sets an array of textures on the engine to be used in the shader.
  114557. * @param channel Name of the variable.
  114558. * @param textures Textures to set.
  114559. */
  114560. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114561. /**
  114562. * 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)
  114563. * @param channel Name of the sampler variable.
  114564. * @param postProcess Post process to get the input texture from.
  114565. */
  114566. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114567. /**
  114568. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114569. * 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)
  114570. * @param channel Name of the sampler variable.
  114571. * @param postProcess Post process to get the output texture from.
  114572. */
  114573. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114574. /** @hidden */
  114575. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114576. /** @hidden */
  114577. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114578. /** @hidden */
  114579. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114580. /** @hidden */
  114581. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114582. /**
  114583. * Binds a buffer to a uniform.
  114584. * @param buffer Buffer to bind.
  114585. * @param name Name of the uniform variable to bind to.
  114586. */
  114587. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114588. /**
  114589. * Binds block to a uniform.
  114590. * @param blockName Name of the block to bind.
  114591. * @param index Index to bind.
  114592. */
  114593. bindUniformBlock(blockName: string, index: number): void;
  114594. /**
  114595. * Sets an interger value on a uniform variable.
  114596. * @param uniformName Name of the variable.
  114597. * @param value Value to be set.
  114598. * @returns this effect.
  114599. */
  114600. setInt(uniformName: string, value: number): Effect;
  114601. /**
  114602. * Sets an int array on a uniform variable.
  114603. * @param uniformName Name of the variable.
  114604. * @param array array to be set.
  114605. * @returns this effect.
  114606. */
  114607. setIntArray(uniformName: string, array: Int32Array): Effect;
  114608. /**
  114609. * 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)
  114610. * @param uniformName Name of the variable.
  114611. * @param array array to be set.
  114612. * @returns this effect.
  114613. */
  114614. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114615. /**
  114616. * 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)
  114617. * @param uniformName Name of the variable.
  114618. * @param array array to be set.
  114619. * @returns this effect.
  114620. */
  114621. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114622. /**
  114623. * 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)
  114624. * @param uniformName Name of the variable.
  114625. * @param array array to be set.
  114626. * @returns this effect.
  114627. */
  114628. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114629. /**
  114630. * Sets an float array on a uniform variable.
  114631. * @param uniformName Name of the variable.
  114632. * @param array array to be set.
  114633. * @returns this effect.
  114634. */
  114635. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114636. /**
  114637. * 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)
  114638. * @param uniformName Name of the variable.
  114639. * @param array array to be set.
  114640. * @returns this effect.
  114641. */
  114642. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114643. /**
  114644. * 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)
  114645. * @param uniformName Name of the variable.
  114646. * @param array array to be set.
  114647. * @returns this effect.
  114648. */
  114649. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114650. /**
  114651. * 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)
  114652. * @param uniformName Name of the variable.
  114653. * @param array array to be set.
  114654. * @returns this effect.
  114655. */
  114656. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114657. /**
  114658. * Sets an array on a uniform variable.
  114659. * @param uniformName Name of the variable.
  114660. * @param array array to be set.
  114661. * @returns this effect.
  114662. */
  114663. setArray(uniformName: string, array: number[]): Effect;
  114664. /**
  114665. * 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)
  114666. * @param uniformName Name of the variable.
  114667. * @param array array to be set.
  114668. * @returns this effect.
  114669. */
  114670. setArray2(uniformName: string, array: number[]): Effect;
  114671. /**
  114672. * 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)
  114673. * @param uniformName Name of the variable.
  114674. * @param array array to be set.
  114675. * @returns this effect.
  114676. */
  114677. setArray3(uniformName: string, array: number[]): Effect;
  114678. /**
  114679. * 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)
  114680. * @param uniformName Name of the variable.
  114681. * @param array array to be set.
  114682. * @returns this effect.
  114683. */
  114684. setArray4(uniformName: string, array: number[]): Effect;
  114685. /**
  114686. * Sets matrices on a uniform variable.
  114687. * @param uniformName Name of the variable.
  114688. * @param matrices matrices to be set.
  114689. * @returns this effect.
  114690. */
  114691. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  114692. /**
  114693. * Sets matrix on a uniform variable.
  114694. * @param uniformName Name of the variable.
  114695. * @param matrix matrix to be set.
  114696. * @returns this effect.
  114697. */
  114698. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  114699. /**
  114700. * 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)
  114701. * @param uniformName Name of the variable.
  114702. * @param matrix matrix to be set.
  114703. * @returns this effect.
  114704. */
  114705. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114706. /**
  114707. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  114708. * @param uniformName Name of the variable.
  114709. * @param matrix matrix to be set.
  114710. * @returns this effect.
  114711. */
  114712. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114713. /**
  114714. * Sets a float on a uniform variable.
  114715. * @param uniformName Name of the variable.
  114716. * @param value value to be set.
  114717. * @returns this effect.
  114718. */
  114719. setFloat(uniformName: string, value: number): Effect;
  114720. /**
  114721. * Sets a boolean on a uniform variable.
  114722. * @param uniformName Name of the variable.
  114723. * @param bool value to be set.
  114724. * @returns this effect.
  114725. */
  114726. setBool(uniformName: string, bool: boolean): Effect;
  114727. /**
  114728. * Sets a Vector2 on a uniform variable.
  114729. * @param uniformName Name of the variable.
  114730. * @param vector2 vector2 to be set.
  114731. * @returns this effect.
  114732. */
  114733. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  114734. /**
  114735. * Sets a float2 on a uniform variable.
  114736. * @param uniformName Name of the variable.
  114737. * @param x First float in float2.
  114738. * @param y Second float in float2.
  114739. * @returns this effect.
  114740. */
  114741. setFloat2(uniformName: string, x: number, y: number): Effect;
  114742. /**
  114743. * Sets a Vector3 on a uniform variable.
  114744. * @param uniformName Name of the variable.
  114745. * @param vector3 Value to be set.
  114746. * @returns this effect.
  114747. */
  114748. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  114749. /**
  114750. * Sets a float3 on a uniform variable.
  114751. * @param uniformName Name of the variable.
  114752. * @param x First float in float3.
  114753. * @param y Second float in float3.
  114754. * @param z Third float in float3.
  114755. * @returns this effect.
  114756. */
  114757. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  114758. /**
  114759. * Sets a Vector4 on a uniform variable.
  114760. * @param uniformName Name of the variable.
  114761. * @param vector4 Value to be set.
  114762. * @returns this effect.
  114763. */
  114764. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  114765. /**
  114766. * Sets a float4 on a uniform variable.
  114767. * @param uniformName Name of the variable.
  114768. * @param x First float in float4.
  114769. * @param y Second float in float4.
  114770. * @param z Third float in float4.
  114771. * @param w Fourth float in float4.
  114772. * @returns this effect.
  114773. */
  114774. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  114775. /**
  114776. * Sets a Color3 on a uniform variable.
  114777. * @param uniformName Name of the variable.
  114778. * @param color3 Value to be set.
  114779. * @returns this effect.
  114780. */
  114781. setColor3(uniformName: string, color3: IColor3Like): Effect;
  114782. /**
  114783. * Sets a Color4 on a uniform variable.
  114784. * @param uniformName Name of the variable.
  114785. * @param color3 Value to be set.
  114786. * @param alpha Alpha value to be set.
  114787. * @returns this effect.
  114788. */
  114789. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  114790. /**
  114791. * Sets a Color4 on a uniform variable
  114792. * @param uniformName defines the name of the variable
  114793. * @param color4 defines the value to be set
  114794. * @returns this effect.
  114795. */
  114796. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  114797. /** Release all associated resources */
  114798. dispose(): void;
  114799. /**
  114800. * This function will add a new shader to the shader store
  114801. * @param name the name of the shader
  114802. * @param pixelShader optional pixel shader content
  114803. * @param vertexShader optional vertex shader content
  114804. */
  114805. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  114806. /**
  114807. * Store of each shader (The can be looked up using effect.key)
  114808. */
  114809. static ShadersStore: {
  114810. [key: string]: string;
  114811. };
  114812. /**
  114813. * Store of each included file for a shader (The can be looked up using effect.key)
  114814. */
  114815. static IncludesShadersStore: {
  114816. [key: string]: string;
  114817. };
  114818. /**
  114819. * Resets the cache of effects.
  114820. */
  114821. static ResetCache(): void;
  114822. }
  114823. }
  114824. declare module BABYLON {
  114825. /**
  114826. * Interface used to describe the capabilities of the engine relatively to the current browser
  114827. */
  114828. export interface EngineCapabilities {
  114829. /** Maximum textures units per fragment shader */
  114830. maxTexturesImageUnits: number;
  114831. /** Maximum texture units per vertex shader */
  114832. maxVertexTextureImageUnits: number;
  114833. /** Maximum textures units in the entire pipeline */
  114834. maxCombinedTexturesImageUnits: number;
  114835. /** Maximum texture size */
  114836. maxTextureSize: number;
  114837. /** Maximum texture samples */
  114838. maxSamples?: number;
  114839. /** Maximum cube texture size */
  114840. maxCubemapTextureSize: number;
  114841. /** Maximum render texture size */
  114842. maxRenderTextureSize: number;
  114843. /** Maximum number of vertex attributes */
  114844. maxVertexAttribs: number;
  114845. /** Maximum number of varyings */
  114846. maxVaryingVectors: number;
  114847. /** Maximum number of uniforms per vertex shader */
  114848. maxVertexUniformVectors: number;
  114849. /** Maximum number of uniforms per fragment shader */
  114850. maxFragmentUniformVectors: number;
  114851. /** Defines if standard derivates (dx/dy) are supported */
  114852. standardDerivatives: boolean;
  114853. /** Defines if s3tc texture compression is supported */
  114854. s3tc?: WEBGL_compressed_texture_s3tc;
  114855. /** Defines if pvrtc texture compression is supported */
  114856. pvrtc: any;
  114857. /** Defines if etc1 texture compression is supported */
  114858. etc1: any;
  114859. /** Defines if etc2 texture compression is supported */
  114860. etc2: any;
  114861. /** Defines if astc texture compression is supported */
  114862. astc: any;
  114863. /** Defines if bptc texture compression is supported */
  114864. bptc: any;
  114865. /** Defines if float textures are supported */
  114866. textureFloat: boolean;
  114867. /** Defines if vertex array objects are supported */
  114868. vertexArrayObject: boolean;
  114869. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  114870. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  114871. /** Gets the maximum level of anisotropy supported */
  114872. maxAnisotropy: number;
  114873. /** Defines if instancing is supported */
  114874. instancedArrays: boolean;
  114875. /** Defines if 32 bits indices are supported */
  114876. uintIndices: boolean;
  114877. /** Defines if high precision shaders are supported */
  114878. highPrecisionShaderSupported: boolean;
  114879. /** Defines if depth reading in the fragment shader is supported */
  114880. fragmentDepthSupported: boolean;
  114881. /** Defines if float texture linear filtering is supported*/
  114882. textureFloatLinearFiltering: boolean;
  114883. /** Defines if rendering to float textures is supported */
  114884. textureFloatRender: boolean;
  114885. /** Defines if half float textures are supported*/
  114886. textureHalfFloat: boolean;
  114887. /** Defines if half float texture linear filtering is supported*/
  114888. textureHalfFloatLinearFiltering: boolean;
  114889. /** Defines if rendering to half float textures is supported */
  114890. textureHalfFloatRender: boolean;
  114891. /** Defines if textureLOD shader command is supported */
  114892. textureLOD: boolean;
  114893. /** Defines if draw buffers extension is supported */
  114894. drawBuffersExtension: boolean;
  114895. /** Defines if depth textures are supported */
  114896. depthTextureExtension: boolean;
  114897. /** Defines if float color buffer are supported */
  114898. colorBufferFloat: boolean;
  114899. /** Gets disjoint timer query extension (null if not supported) */
  114900. timerQuery?: EXT_disjoint_timer_query;
  114901. /** Defines if timestamp can be used with timer query */
  114902. canUseTimestampForTimerQuery: boolean;
  114903. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  114904. multiview?: any;
  114905. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  114906. oculusMultiview?: any;
  114907. /** Function used to let the system compiles shaders in background */
  114908. parallelShaderCompile?: {
  114909. COMPLETION_STATUS_KHR: number;
  114910. };
  114911. /** Max number of texture samples for MSAA */
  114912. maxMSAASamples: number;
  114913. /** Defines if the blend min max extension is supported */
  114914. blendMinMax: boolean;
  114915. }
  114916. }
  114917. declare module BABYLON {
  114918. /**
  114919. * @hidden
  114920. **/
  114921. export class DepthCullingState {
  114922. private _isDepthTestDirty;
  114923. private _isDepthMaskDirty;
  114924. private _isDepthFuncDirty;
  114925. private _isCullFaceDirty;
  114926. private _isCullDirty;
  114927. private _isZOffsetDirty;
  114928. private _isFrontFaceDirty;
  114929. private _depthTest;
  114930. private _depthMask;
  114931. private _depthFunc;
  114932. private _cull;
  114933. private _cullFace;
  114934. private _zOffset;
  114935. private _frontFace;
  114936. /**
  114937. * Initializes the state.
  114938. */
  114939. constructor();
  114940. get isDirty(): boolean;
  114941. get zOffset(): number;
  114942. set zOffset(value: number);
  114943. get cullFace(): Nullable<number>;
  114944. set cullFace(value: Nullable<number>);
  114945. get cull(): Nullable<boolean>;
  114946. set cull(value: Nullable<boolean>);
  114947. get depthFunc(): Nullable<number>;
  114948. set depthFunc(value: Nullable<number>);
  114949. get depthMask(): boolean;
  114950. set depthMask(value: boolean);
  114951. get depthTest(): boolean;
  114952. set depthTest(value: boolean);
  114953. get frontFace(): Nullable<number>;
  114954. set frontFace(value: Nullable<number>);
  114955. reset(): void;
  114956. apply(gl: WebGLRenderingContext): void;
  114957. }
  114958. }
  114959. declare module BABYLON {
  114960. /**
  114961. * @hidden
  114962. **/
  114963. export class StencilState {
  114964. /** 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 */
  114965. static readonly ALWAYS: number;
  114966. /** Passed to stencilOperation to specify that stencil value must be kept */
  114967. static readonly KEEP: number;
  114968. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114969. static readonly REPLACE: number;
  114970. private _isStencilTestDirty;
  114971. private _isStencilMaskDirty;
  114972. private _isStencilFuncDirty;
  114973. private _isStencilOpDirty;
  114974. private _stencilTest;
  114975. private _stencilMask;
  114976. private _stencilFunc;
  114977. private _stencilFuncRef;
  114978. private _stencilFuncMask;
  114979. private _stencilOpStencilFail;
  114980. private _stencilOpDepthFail;
  114981. private _stencilOpStencilDepthPass;
  114982. get isDirty(): boolean;
  114983. get stencilFunc(): number;
  114984. set stencilFunc(value: number);
  114985. get stencilFuncRef(): number;
  114986. set stencilFuncRef(value: number);
  114987. get stencilFuncMask(): number;
  114988. set stencilFuncMask(value: number);
  114989. get stencilOpStencilFail(): number;
  114990. set stencilOpStencilFail(value: number);
  114991. get stencilOpDepthFail(): number;
  114992. set stencilOpDepthFail(value: number);
  114993. get stencilOpStencilDepthPass(): number;
  114994. set stencilOpStencilDepthPass(value: number);
  114995. get stencilMask(): number;
  114996. set stencilMask(value: number);
  114997. get stencilTest(): boolean;
  114998. set stencilTest(value: boolean);
  114999. constructor();
  115000. reset(): void;
  115001. apply(gl: WebGLRenderingContext): void;
  115002. }
  115003. }
  115004. declare module BABYLON {
  115005. /**
  115006. * @hidden
  115007. **/
  115008. export class AlphaState {
  115009. private _isAlphaBlendDirty;
  115010. private _isBlendFunctionParametersDirty;
  115011. private _isBlendEquationParametersDirty;
  115012. private _isBlendConstantsDirty;
  115013. private _alphaBlend;
  115014. private _blendFunctionParameters;
  115015. private _blendEquationParameters;
  115016. private _blendConstants;
  115017. /**
  115018. * Initializes the state.
  115019. */
  115020. constructor();
  115021. get isDirty(): boolean;
  115022. get alphaBlend(): boolean;
  115023. set alphaBlend(value: boolean);
  115024. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115025. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115026. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115027. reset(): void;
  115028. apply(gl: WebGLRenderingContext): void;
  115029. }
  115030. }
  115031. declare module BABYLON {
  115032. /** @hidden */
  115033. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115034. attributeProcessor(attribute: string): string;
  115035. varyingProcessor(varying: string, isFragment: boolean): string;
  115036. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115037. }
  115038. }
  115039. declare module BABYLON {
  115040. /**
  115041. * Interface for attribute information associated with buffer instanciation
  115042. */
  115043. export interface InstancingAttributeInfo {
  115044. /**
  115045. * Name of the GLSL attribute
  115046. * if attribute index is not specified, this is used to retrieve the index from the effect
  115047. */
  115048. attributeName: string;
  115049. /**
  115050. * Index/offset of the attribute in the vertex shader
  115051. * if not specified, this will be computes from the name.
  115052. */
  115053. index?: number;
  115054. /**
  115055. * size of the attribute, 1, 2, 3 or 4
  115056. */
  115057. attributeSize: number;
  115058. /**
  115059. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115060. */
  115061. offset: number;
  115062. /**
  115063. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115064. * default to 1
  115065. */
  115066. divisor?: number;
  115067. /**
  115068. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115069. * default is FLOAT
  115070. */
  115071. attributeType?: number;
  115072. /**
  115073. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115074. */
  115075. normalized?: boolean;
  115076. }
  115077. }
  115078. declare module BABYLON {
  115079. interface ThinEngine {
  115080. /**
  115081. * Update a video texture
  115082. * @param texture defines the texture to update
  115083. * @param video defines the video element to use
  115084. * @param invertY defines if data must be stored with Y axis inverted
  115085. */
  115086. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115087. }
  115088. }
  115089. declare module BABYLON {
  115090. interface ThinEngine {
  115091. /**
  115092. * Creates a dynamic texture
  115093. * @param width defines the width of the texture
  115094. * @param height defines the height of the texture
  115095. * @param generateMipMaps defines if the engine should generate the mip levels
  115096. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115097. * @returns the dynamic texture inside an InternalTexture
  115098. */
  115099. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115100. /**
  115101. * Update the content of a dynamic texture
  115102. * @param texture defines the texture to update
  115103. * @param canvas defines the canvas containing the source
  115104. * @param invertY defines if data must be stored with Y axis inverted
  115105. * @param premulAlpha defines if alpha is stored as premultiplied
  115106. * @param format defines the format of the data
  115107. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115108. */
  115109. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115110. }
  115111. }
  115112. declare module BABYLON {
  115113. /**
  115114. * Settings for finer control over video usage
  115115. */
  115116. export interface VideoTextureSettings {
  115117. /**
  115118. * Applies `autoplay` to video, if specified
  115119. */
  115120. autoPlay?: boolean;
  115121. /**
  115122. * Applies `loop` to video, if specified
  115123. */
  115124. loop?: boolean;
  115125. /**
  115126. * Automatically updates internal texture from video at every frame in the render loop
  115127. */
  115128. autoUpdateTexture: boolean;
  115129. /**
  115130. * Image src displayed during the video loading or until the user interacts with the video.
  115131. */
  115132. poster?: string;
  115133. }
  115134. /**
  115135. * If you want to display a video in your scene, this is the special texture for that.
  115136. * This special texture works similar to other textures, with the exception of a few parameters.
  115137. * @see https://doc.babylonjs.com/how_to/video_texture
  115138. */
  115139. export class VideoTexture extends Texture {
  115140. /**
  115141. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115142. */
  115143. readonly autoUpdateTexture: boolean;
  115144. /**
  115145. * The video instance used by the texture internally
  115146. */
  115147. readonly video: HTMLVideoElement;
  115148. private _onUserActionRequestedObservable;
  115149. /**
  115150. * Event triggerd when a dom action is required by the user to play the video.
  115151. * This happens due to recent changes in browser policies preventing video to auto start.
  115152. */
  115153. get onUserActionRequestedObservable(): Observable<Texture>;
  115154. private _generateMipMaps;
  115155. private _stillImageCaptured;
  115156. private _displayingPosterTexture;
  115157. private _settings;
  115158. private _createInternalTextureOnEvent;
  115159. private _frameId;
  115160. private _currentSrc;
  115161. /**
  115162. * Creates a video texture.
  115163. * If you want to display a video in your scene, this is the special texture for that.
  115164. * This special texture works similar to other textures, with the exception of a few parameters.
  115165. * @see https://doc.babylonjs.com/how_to/video_texture
  115166. * @param name optional name, will detect from video source, if not defined
  115167. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115168. * @param scene is obviously the current scene.
  115169. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115170. * @param invertY is false by default but can be used to invert video on Y axis
  115171. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115172. * @param settings allows finer control over video usage
  115173. */
  115174. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115175. private _getName;
  115176. private _getVideo;
  115177. private _createInternalTexture;
  115178. private reset;
  115179. /**
  115180. * @hidden Internal method to initiate `update`.
  115181. */
  115182. _rebuild(): void;
  115183. /**
  115184. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115185. */
  115186. update(): void;
  115187. /**
  115188. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115189. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115190. */
  115191. updateTexture(isVisible: boolean): void;
  115192. protected _updateInternalTexture: () => void;
  115193. /**
  115194. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115195. * @param url New url.
  115196. */
  115197. updateURL(url: string): void;
  115198. /**
  115199. * Clones the texture.
  115200. * @returns the cloned texture
  115201. */
  115202. clone(): VideoTexture;
  115203. /**
  115204. * Dispose the texture and release its associated resources.
  115205. */
  115206. dispose(): void;
  115207. /**
  115208. * Creates a video texture straight from a stream.
  115209. * @param scene Define the scene the texture should be created in
  115210. * @param stream Define the stream the texture should be created from
  115211. * @returns The created video texture as a promise
  115212. */
  115213. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115214. /**
  115215. * Creates a video texture straight from your WebCam video feed.
  115216. * @param scene Define the scene the texture should be created in
  115217. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115218. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115219. * @returns The created video texture as a promise
  115220. */
  115221. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115222. minWidth: number;
  115223. maxWidth: number;
  115224. minHeight: number;
  115225. maxHeight: number;
  115226. deviceId: string;
  115227. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115228. /**
  115229. * Creates a video texture straight from your WebCam video feed.
  115230. * @param scene Define the scene the texture should be created in
  115231. * @param onReady Define a callback to triggered once the texture will be ready
  115232. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115233. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115234. */
  115235. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115236. minWidth: number;
  115237. maxWidth: number;
  115238. minHeight: number;
  115239. maxHeight: number;
  115240. deviceId: string;
  115241. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115242. }
  115243. }
  115244. declare module BABYLON {
  115245. /**
  115246. * Defines the interface used by objects working like Scene
  115247. * @hidden
  115248. */
  115249. export interface ISceneLike {
  115250. _addPendingData(data: any): void;
  115251. _removePendingData(data: any): void;
  115252. offlineProvider: IOfflineProvider;
  115253. }
  115254. /**
  115255. * Information about the current host
  115256. */
  115257. export interface HostInformation {
  115258. /**
  115259. * Defines if the current host is a mobile
  115260. */
  115261. isMobile: boolean;
  115262. }
  115263. /** Interface defining initialization parameters for Engine class */
  115264. export interface EngineOptions extends WebGLContextAttributes {
  115265. /**
  115266. * Defines if the engine should no exceed a specified device ratio
  115267. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115268. */
  115269. limitDeviceRatio?: number;
  115270. /**
  115271. * Defines if webvr should be enabled automatically
  115272. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115273. */
  115274. autoEnableWebVR?: boolean;
  115275. /**
  115276. * Defines if webgl2 should be turned off even if supported
  115277. * @see https://doc.babylonjs.com/features/webgl2
  115278. */
  115279. disableWebGL2Support?: boolean;
  115280. /**
  115281. * Defines if webaudio should be initialized as well
  115282. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115283. */
  115284. audioEngine?: boolean;
  115285. /**
  115286. * Defines if animations should run using a deterministic lock step
  115287. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115288. */
  115289. deterministicLockstep?: boolean;
  115290. /** Defines the maximum steps to use with deterministic lock step mode */
  115291. lockstepMaxSteps?: number;
  115292. /** Defines the seconds between each deterministic lock step */
  115293. timeStep?: number;
  115294. /**
  115295. * Defines that engine should ignore context lost events
  115296. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115297. */
  115298. doNotHandleContextLost?: boolean;
  115299. /**
  115300. * Defines that engine should ignore modifying touch action attribute and style
  115301. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115302. */
  115303. doNotHandleTouchAction?: boolean;
  115304. /**
  115305. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115306. */
  115307. useHighPrecisionFloats?: boolean;
  115308. /**
  115309. * Make the canvas XR Compatible for XR sessions
  115310. */
  115311. xrCompatible?: boolean;
  115312. /**
  115313. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115314. */
  115315. useHighPrecisionMatrix?: boolean;
  115316. }
  115317. /**
  115318. * The base engine class (root of all engines)
  115319. */
  115320. export class ThinEngine {
  115321. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115322. static ExceptionList: ({
  115323. key: string;
  115324. capture: string;
  115325. captureConstraint: number;
  115326. targets: string[];
  115327. } | {
  115328. key: string;
  115329. capture: null;
  115330. captureConstraint: null;
  115331. targets: string[];
  115332. })[];
  115333. /** @hidden */
  115334. static _TextureLoaders: IInternalTextureLoader[];
  115335. /**
  115336. * Returns the current npm package of the sdk
  115337. */
  115338. static get NpmPackage(): string;
  115339. /**
  115340. * Returns the current version of the framework
  115341. */
  115342. static get Version(): string;
  115343. /**
  115344. * Returns a string describing the current engine
  115345. */
  115346. get description(): string;
  115347. /**
  115348. * Gets or sets the epsilon value used by collision engine
  115349. */
  115350. static CollisionsEpsilon: number;
  115351. /**
  115352. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115353. */
  115354. static get ShadersRepository(): string;
  115355. static set ShadersRepository(value: string);
  115356. /** @hidden */
  115357. _shaderProcessor: IShaderProcessor;
  115358. /**
  115359. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115360. */
  115361. forcePOTTextures: boolean;
  115362. /**
  115363. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115364. */
  115365. isFullscreen: boolean;
  115366. /**
  115367. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115368. */
  115369. cullBackFaces: boolean;
  115370. /**
  115371. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115372. */
  115373. renderEvenInBackground: boolean;
  115374. /**
  115375. * Gets or sets a boolean indicating that cache can be kept between frames
  115376. */
  115377. preventCacheWipeBetweenFrames: boolean;
  115378. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115379. validateShaderPrograms: boolean;
  115380. /**
  115381. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115382. * This can provide greater z depth for distant objects.
  115383. */
  115384. useReverseDepthBuffer: boolean;
  115385. /**
  115386. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115387. */
  115388. disableUniformBuffers: boolean;
  115389. /** @hidden */
  115390. _uniformBuffers: UniformBuffer[];
  115391. /**
  115392. * Gets a boolean indicating that the engine supports uniform buffers
  115393. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115394. */
  115395. get supportsUniformBuffers(): boolean;
  115396. /** @hidden */
  115397. _gl: WebGLRenderingContext;
  115398. /** @hidden */
  115399. _webGLVersion: number;
  115400. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115401. protected _windowIsBackground: boolean;
  115402. protected _creationOptions: EngineOptions;
  115403. protected _highPrecisionShadersAllowed: boolean;
  115404. /** @hidden */
  115405. get _shouldUseHighPrecisionShader(): boolean;
  115406. /**
  115407. * Gets a boolean indicating that only power of 2 textures are supported
  115408. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115409. */
  115410. get needPOTTextures(): boolean;
  115411. /** @hidden */
  115412. _badOS: boolean;
  115413. /** @hidden */
  115414. _badDesktopOS: boolean;
  115415. private _hardwareScalingLevel;
  115416. /** @hidden */
  115417. _caps: EngineCapabilities;
  115418. private _isStencilEnable;
  115419. private _glVersion;
  115420. private _glRenderer;
  115421. private _glVendor;
  115422. /** @hidden */
  115423. _videoTextureSupported: boolean;
  115424. protected _renderingQueueLaunched: boolean;
  115425. protected _activeRenderLoops: (() => void)[];
  115426. /**
  115427. * Observable signaled when a context lost event is raised
  115428. */
  115429. onContextLostObservable: Observable<ThinEngine>;
  115430. /**
  115431. * Observable signaled when a context restored event is raised
  115432. */
  115433. onContextRestoredObservable: Observable<ThinEngine>;
  115434. private _onContextLost;
  115435. private _onContextRestored;
  115436. protected _contextWasLost: boolean;
  115437. /** @hidden */
  115438. _doNotHandleContextLost: boolean;
  115439. /**
  115440. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115441. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115442. */
  115443. get doNotHandleContextLost(): boolean;
  115444. set doNotHandleContextLost(value: boolean);
  115445. /**
  115446. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115447. */
  115448. disableVertexArrayObjects: boolean;
  115449. /** @hidden */
  115450. protected _colorWrite: boolean;
  115451. /** @hidden */
  115452. protected _colorWriteChanged: boolean;
  115453. /** @hidden */
  115454. protected _depthCullingState: DepthCullingState;
  115455. /** @hidden */
  115456. protected _stencilState: StencilState;
  115457. /** @hidden */
  115458. _alphaState: AlphaState;
  115459. /** @hidden */
  115460. _alphaMode: number;
  115461. /** @hidden */
  115462. _alphaEquation: number;
  115463. /** @hidden */
  115464. _internalTexturesCache: InternalTexture[];
  115465. /** @hidden */
  115466. protected _activeChannel: number;
  115467. private _currentTextureChannel;
  115468. /** @hidden */
  115469. protected _boundTexturesCache: {
  115470. [key: string]: Nullable<InternalTexture>;
  115471. };
  115472. /** @hidden */
  115473. protected _currentEffect: Nullable<Effect>;
  115474. /** @hidden */
  115475. protected _currentProgram: Nullable<WebGLProgram>;
  115476. private _compiledEffects;
  115477. private _vertexAttribArraysEnabled;
  115478. /** @hidden */
  115479. protected _cachedViewport: Nullable<IViewportLike>;
  115480. private _cachedVertexArrayObject;
  115481. /** @hidden */
  115482. protected _cachedVertexBuffers: any;
  115483. /** @hidden */
  115484. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115485. /** @hidden */
  115486. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115487. /** @hidden */
  115488. _currentRenderTarget: Nullable<InternalTexture>;
  115489. private _uintIndicesCurrentlySet;
  115490. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115491. /** @hidden */
  115492. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115493. /** @hidden */
  115494. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115495. private _currentBufferPointers;
  115496. private _currentInstanceLocations;
  115497. private _currentInstanceBuffers;
  115498. private _textureUnits;
  115499. /** @hidden */
  115500. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115501. /** @hidden */
  115502. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115503. /** @hidden */
  115504. _boundRenderFunction: any;
  115505. private _vaoRecordInProgress;
  115506. private _mustWipeVertexAttributes;
  115507. private _emptyTexture;
  115508. private _emptyCubeTexture;
  115509. private _emptyTexture3D;
  115510. private _emptyTexture2DArray;
  115511. /** @hidden */
  115512. _frameHandler: number;
  115513. private _nextFreeTextureSlots;
  115514. private _maxSimultaneousTextures;
  115515. private _activeRequests;
  115516. /** @hidden */
  115517. _transformTextureUrl: Nullable<(url: string) => string>;
  115518. /**
  115519. * Gets information about the current host
  115520. */
  115521. hostInformation: HostInformation;
  115522. protected get _supportsHardwareTextureRescaling(): boolean;
  115523. private _framebufferDimensionsObject;
  115524. /**
  115525. * sets the object from which width and height will be taken from when getting render width and height
  115526. * Will fallback to the gl object
  115527. * @param dimensions the framebuffer width and height that will be used.
  115528. */
  115529. set framebufferDimensionsObject(dimensions: Nullable<{
  115530. framebufferWidth: number;
  115531. framebufferHeight: number;
  115532. }>);
  115533. /**
  115534. * Gets the current viewport
  115535. */
  115536. get currentViewport(): Nullable<IViewportLike>;
  115537. /**
  115538. * Gets the default empty texture
  115539. */
  115540. get emptyTexture(): InternalTexture;
  115541. /**
  115542. * Gets the default empty 3D texture
  115543. */
  115544. get emptyTexture3D(): InternalTexture;
  115545. /**
  115546. * Gets the default empty 2D array texture
  115547. */
  115548. get emptyTexture2DArray(): InternalTexture;
  115549. /**
  115550. * Gets the default empty cube texture
  115551. */
  115552. get emptyCubeTexture(): InternalTexture;
  115553. /**
  115554. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115555. */
  115556. readonly premultipliedAlpha: boolean;
  115557. /**
  115558. * Observable event triggered before each texture is initialized
  115559. */
  115560. onBeforeTextureInitObservable: Observable<Texture>;
  115561. /**
  115562. * Creates a new engine
  115563. * @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
  115564. * @param antialias defines enable antialiasing (default: false)
  115565. * @param options defines further options to be sent to the getContext() function
  115566. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115567. */
  115568. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115569. private _rebuildInternalTextures;
  115570. private _rebuildEffects;
  115571. /**
  115572. * Gets a boolean indicating if all created effects are ready
  115573. * @returns true if all effects are ready
  115574. */
  115575. areAllEffectsReady(): boolean;
  115576. protected _rebuildBuffers(): void;
  115577. protected _initGLContext(): void;
  115578. /**
  115579. * Gets version of the current webGL context
  115580. */
  115581. get webGLVersion(): number;
  115582. /**
  115583. * Gets a string identifying the name of the class
  115584. * @returns "Engine" string
  115585. */
  115586. getClassName(): string;
  115587. /**
  115588. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115589. */
  115590. get isStencilEnable(): boolean;
  115591. /** @hidden */
  115592. _prepareWorkingCanvas(): void;
  115593. /**
  115594. * Reset the texture cache to empty state
  115595. */
  115596. resetTextureCache(): void;
  115597. /**
  115598. * Gets an object containing information about the current webGL context
  115599. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115600. */
  115601. getGlInfo(): {
  115602. vendor: string;
  115603. renderer: string;
  115604. version: string;
  115605. };
  115606. /**
  115607. * Defines the hardware scaling level.
  115608. * By default the hardware scaling level is computed from the window device ratio.
  115609. * 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.
  115610. * @param level defines the level to use
  115611. */
  115612. setHardwareScalingLevel(level: number): void;
  115613. /**
  115614. * Gets the current hardware scaling level.
  115615. * By default the hardware scaling level is computed from the window device ratio.
  115616. * 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.
  115617. * @returns a number indicating the current hardware scaling level
  115618. */
  115619. getHardwareScalingLevel(): number;
  115620. /**
  115621. * Gets the list of loaded textures
  115622. * @returns an array containing all loaded textures
  115623. */
  115624. getLoadedTexturesCache(): InternalTexture[];
  115625. /**
  115626. * Gets the object containing all engine capabilities
  115627. * @returns the EngineCapabilities object
  115628. */
  115629. getCaps(): EngineCapabilities;
  115630. /**
  115631. * stop executing a render loop function and remove it from the execution array
  115632. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115633. */
  115634. stopRenderLoop(renderFunction?: () => void): void;
  115635. /** @hidden */
  115636. _renderLoop(): void;
  115637. /**
  115638. * Gets the HTML canvas attached with the current webGL context
  115639. * @returns a HTML canvas
  115640. */
  115641. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115642. /**
  115643. * Gets host window
  115644. * @returns the host window object
  115645. */
  115646. getHostWindow(): Nullable<Window>;
  115647. /**
  115648. * Gets the current render width
  115649. * @param useScreen defines if screen size must be used (or the current render target if any)
  115650. * @returns a number defining the current render width
  115651. */
  115652. getRenderWidth(useScreen?: boolean): number;
  115653. /**
  115654. * Gets the current render height
  115655. * @param useScreen defines if screen size must be used (or the current render target if any)
  115656. * @returns a number defining the current render height
  115657. */
  115658. getRenderHeight(useScreen?: boolean): number;
  115659. /**
  115660. * Can be used to override the current requestAnimationFrame requester.
  115661. * @hidden
  115662. */
  115663. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115664. /**
  115665. * Register and execute a render loop. The engine can have more than one render function
  115666. * @param renderFunction defines the function to continuously execute
  115667. */
  115668. runRenderLoop(renderFunction: () => void): void;
  115669. /**
  115670. * Clear the current render buffer or the current render target (if any is set up)
  115671. * @param color defines the color to use
  115672. * @param backBuffer defines if the back buffer must be cleared
  115673. * @param depth defines if the depth buffer must be cleared
  115674. * @param stencil defines if the stencil buffer must be cleared
  115675. */
  115676. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115677. private _viewportCached;
  115678. /** @hidden */
  115679. _viewport(x: number, y: number, width: number, height: number): void;
  115680. /**
  115681. * Set the WebGL's viewport
  115682. * @param viewport defines the viewport element to be used
  115683. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115684. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115685. */
  115686. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115687. /**
  115688. * Begin a new frame
  115689. */
  115690. beginFrame(): void;
  115691. /**
  115692. * Enf the current frame
  115693. */
  115694. endFrame(): void;
  115695. /**
  115696. * Resize the view according to the canvas' size
  115697. */
  115698. resize(): void;
  115699. /**
  115700. * Force a specific size of the canvas
  115701. * @param width defines the new canvas' width
  115702. * @param height defines the new canvas' height
  115703. * @returns true if the size was changed
  115704. */
  115705. setSize(width: number, height: number): boolean;
  115706. /**
  115707. * Binds the frame buffer to the specified texture.
  115708. * @param texture The texture to render to or null for the default canvas
  115709. * @param faceIndex The face of the texture to render to in case of cube texture
  115710. * @param requiredWidth The width of the target to render to
  115711. * @param requiredHeight The height of the target to render to
  115712. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  115713. * @param lodLevel defines the lod level to bind to the frame buffer
  115714. * @param layer defines the 2d array index to bind to frame buffer to
  115715. */
  115716. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  115717. /** @hidden */
  115718. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115719. /**
  115720. * Unbind the current render target texture from the webGL context
  115721. * @param texture defines the render target texture to unbind
  115722. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115723. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115724. */
  115725. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115726. /**
  115727. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  115728. */
  115729. flushFramebuffer(): void;
  115730. /**
  115731. * Unbind the current render target and bind the default framebuffer
  115732. */
  115733. restoreDefaultFramebuffer(): void;
  115734. /** @hidden */
  115735. protected _resetVertexBufferBinding(): void;
  115736. /**
  115737. * Creates a vertex buffer
  115738. * @param data the data for the vertex buffer
  115739. * @returns the new WebGL static buffer
  115740. */
  115741. createVertexBuffer(data: DataArray): DataBuffer;
  115742. private _createVertexBuffer;
  115743. /**
  115744. * Creates a dynamic vertex buffer
  115745. * @param data the data for the dynamic vertex buffer
  115746. * @returns the new WebGL dynamic buffer
  115747. */
  115748. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115749. protected _resetIndexBufferBinding(): void;
  115750. /**
  115751. * Creates a new index buffer
  115752. * @param indices defines the content of the index buffer
  115753. * @param updatable defines if the index buffer must be updatable
  115754. * @returns a new webGL buffer
  115755. */
  115756. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  115757. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  115758. /**
  115759. * Bind a webGL buffer to the webGL context
  115760. * @param buffer defines the buffer to bind
  115761. */
  115762. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  115763. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  115764. private bindBuffer;
  115765. /**
  115766. * update the bound buffer with the given data
  115767. * @param data defines the data to update
  115768. */
  115769. updateArrayBuffer(data: Float32Array): void;
  115770. private _vertexAttribPointer;
  115771. /** @hidden */
  115772. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  115773. private _bindVertexBuffersAttributes;
  115774. /**
  115775. * Records a vertex array object
  115776. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115777. * @param vertexBuffers defines the list of vertex buffers to store
  115778. * @param indexBuffer defines the index buffer to store
  115779. * @param effect defines the effect to store
  115780. * @returns the new vertex array object
  115781. */
  115782. recordVertexArrayObject(vertexBuffers: {
  115783. [key: string]: VertexBuffer;
  115784. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  115785. /**
  115786. * Bind a specific vertex array object
  115787. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115788. * @param vertexArrayObject defines the vertex array object to bind
  115789. * @param indexBuffer defines the index buffer to bind
  115790. */
  115791. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  115792. /**
  115793. * Bind webGl buffers directly to the webGL context
  115794. * @param vertexBuffer defines the vertex buffer to bind
  115795. * @param indexBuffer defines the index buffer to bind
  115796. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  115797. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  115798. * @param effect defines the effect associated with the vertex buffer
  115799. */
  115800. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  115801. private _unbindVertexArrayObject;
  115802. /**
  115803. * Bind a list of vertex buffers to the webGL context
  115804. * @param vertexBuffers defines the list of vertex buffers to bind
  115805. * @param indexBuffer defines the index buffer to bind
  115806. * @param effect defines the effect associated with the vertex buffers
  115807. */
  115808. bindBuffers(vertexBuffers: {
  115809. [key: string]: Nullable<VertexBuffer>;
  115810. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  115811. /**
  115812. * Unbind all instance attributes
  115813. */
  115814. unbindInstanceAttributes(): void;
  115815. /**
  115816. * Release and free the memory of a vertex array object
  115817. * @param vao defines the vertex array object to delete
  115818. */
  115819. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  115820. /** @hidden */
  115821. _releaseBuffer(buffer: DataBuffer): boolean;
  115822. protected _deleteBuffer(buffer: DataBuffer): void;
  115823. /**
  115824. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  115825. * @param instancesBuffer defines the webGL buffer to update and bind
  115826. * @param data defines the data to store in the buffer
  115827. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  115828. */
  115829. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  115830. /**
  115831. * Bind the content of a webGL buffer used with instantiation
  115832. * @param instancesBuffer defines the webGL buffer to bind
  115833. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  115834. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  115835. */
  115836. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  115837. /**
  115838. * Disable the instance attribute corresponding to the name in parameter
  115839. * @param name defines the name of the attribute to disable
  115840. */
  115841. disableInstanceAttributeByName(name: string): void;
  115842. /**
  115843. * Disable the instance attribute corresponding to the location in parameter
  115844. * @param attributeLocation defines the attribute location of the attribute to disable
  115845. */
  115846. disableInstanceAttribute(attributeLocation: number): void;
  115847. /**
  115848. * Disable the attribute corresponding to the location in parameter
  115849. * @param attributeLocation defines the attribute location of the attribute to disable
  115850. */
  115851. disableAttributeByIndex(attributeLocation: number): void;
  115852. /**
  115853. * Send a draw order
  115854. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115855. * @param indexStart defines the starting index
  115856. * @param indexCount defines the number of index to draw
  115857. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115858. */
  115859. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115860. /**
  115861. * Draw a list of points
  115862. * @param verticesStart defines the index of first vertex to draw
  115863. * @param verticesCount defines the count of vertices to draw
  115864. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115865. */
  115866. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115867. /**
  115868. * Draw a list of unindexed primitives
  115869. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115870. * @param verticesStart defines the index of first vertex to draw
  115871. * @param verticesCount defines the count of vertices to draw
  115872. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115873. */
  115874. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115875. /**
  115876. * Draw a list of indexed primitives
  115877. * @param fillMode defines the primitive to use
  115878. * @param indexStart defines the starting index
  115879. * @param indexCount defines the number of index to draw
  115880. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115881. */
  115882. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115883. /**
  115884. * Draw a list of unindexed primitives
  115885. * @param fillMode defines the primitive to use
  115886. * @param verticesStart defines the index of first vertex to draw
  115887. * @param verticesCount defines the count of vertices to draw
  115888. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115889. */
  115890. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115891. private _drawMode;
  115892. /** @hidden */
  115893. protected _reportDrawCall(): void;
  115894. /** @hidden */
  115895. _releaseEffect(effect: Effect): void;
  115896. /** @hidden */
  115897. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115898. /**
  115899. * Create a new effect (used to store vertex/fragment shaders)
  115900. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  115901. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  115902. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  115903. * @param samplers defines an array of string used to represent textures
  115904. * @param defines defines the string containing the defines to use to compile the shaders
  115905. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115906. * @param onCompiled defines a function to call when the effect creation is successful
  115907. * @param onError defines a function to call when the effect creation has failed
  115908. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  115909. * @returns the new Effect
  115910. */
  115911. 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;
  115912. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  115913. private _compileShader;
  115914. private _compileRawShader;
  115915. /** @hidden */
  115916. _getShaderSource(shader: WebGLShader): Nullable<string>;
  115917. /**
  115918. * Directly creates a webGL program
  115919. * @param pipelineContext defines the pipeline context to attach to
  115920. * @param vertexCode defines the vertex shader code to use
  115921. * @param fragmentCode defines the fragment shader code to use
  115922. * @param context defines the webGL context to use (if not set, the current one will be used)
  115923. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115924. * @returns the new webGL program
  115925. */
  115926. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115927. /**
  115928. * Creates a webGL program
  115929. * @param pipelineContext defines the pipeline context to attach to
  115930. * @param vertexCode defines the vertex shader code to use
  115931. * @param fragmentCode defines the fragment shader code to use
  115932. * @param defines defines the string containing the defines to use to compile the shaders
  115933. * @param context defines the webGL context to use (if not set, the current one will be used)
  115934. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115935. * @returns the new webGL program
  115936. */
  115937. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115938. /**
  115939. * Creates a new pipeline context
  115940. * @returns the new pipeline
  115941. */
  115942. createPipelineContext(): IPipelineContext;
  115943. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115944. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  115945. /** @hidden */
  115946. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115947. /** @hidden */
  115948. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115949. /** @hidden */
  115950. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115951. /**
  115952. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115953. * @param pipelineContext defines the pipeline context to use
  115954. * @param uniformsNames defines the list of uniform names
  115955. * @returns an array of webGL uniform locations
  115956. */
  115957. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115958. /**
  115959. * Gets the lsit of active attributes for a given webGL program
  115960. * @param pipelineContext defines the pipeline context to use
  115961. * @param attributesNames defines the list of attribute names to get
  115962. * @returns an array of indices indicating the offset of each attribute
  115963. */
  115964. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115965. /**
  115966. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115967. * @param effect defines the effect to activate
  115968. */
  115969. enableEffect(effect: Nullable<Effect>): void;
  115970. /**
  115971. * Set the value of an uniform to a number (int)
  115972. * @param uniform defines the webGL uniform location where to store the value
  115973. * @param value defines the int number to store
  115974. */
  115975. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115976. /**
  115977. * Set the value of an uniform to an array of int32
  115978. * @param uniform defines the webGL uniform location where to store the value
  115979. * @param array defines the array of int32 to store
  115980. */
  115981. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115982. /**
  115983. * Set the value of an uniform to an array of int32 (stored as vec2)
  115984. * @param uniform defines the webGL uniform location where to store the value
  115985. * @param array defines the array of int32 to store
  115986. */
  115987. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115988. /**
  115989. * Set the value of an uniform to an array of int32 (stored as vec3)
  115990. * @param uniform defines the webGL uniform location where to store the value
  115991. * @param array defines the array of int32 to store
  115992. */
  115993. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115994. /**
  115995. * Set the value of an uniform to an array of int32 (stored as vec4)
  115996. * @param uniform defines the webGL uniform location where to store the value
  115997. * @param array defines the array of int32 to store
  115998. */
  115999. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  116000. /**
  116001. * Set the value of an uniform to an array of number
  116002. * @param uniform defines the webGL uniform location where to store the value
  116003. * @param array defines the array of number to store
  116004. */
  116005. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  116006. /**
  116007. * Set the value of an uniform to an array of number (stored as vec2)
  116008. * @param uniform defines the webGL uniform location where to store the value
  116009. * @param array defines the array of number to store
  116010. */
  116011. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  116012. /**
  116013. * Set the value of an uniform to an array of number (stored as vec3)
  116014. * @param uniform defines the webGL uniform location where to store the value
  116015. * @param array defines the array of number to store
  116016. */
  116017. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  116018. /**
  116019. * Set the value of an uniform to an array of number (stored as vec4)
  116020. * @param uniform defines the webGL uniform location where to store the value
  116021. * @param array defines the array of number to store
  116022. */
  116023. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  116024. /**
  116025. * Set the value of an uniform to an array of float32 (stored as matrices)
  116026. * @param uniform defines the webGL uniform location where to store the value
  116027. * @param matrices defines the array of float32 to store
  116028. */
  116029. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  116030. /**
  116031. * Set the value of an uniform to a matrix (3x3)
  116032. * @param uniform defines the webGL uniform location where to store the value
  116033. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116034. */
  116035. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  116036. /**
  116037. * Set the value of an uniform to a matrix (2x2)
  116038. * @param uniform defines the webGL uniform location where to store the value
  116039. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116040. */
  116041. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  116042. /**
  116043. * Set the value of an uniform to a number (float)
  116044. * @param uniform defines the webGL uniform location where to store the value
  116045. * @param value defines the float number to store
  116046. */
  116047. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  116048. /**
  116049. * Set the value of an uniform to a vec2
  116050. * @param uniform defines the webGL uniform location where to store the value
  116051. * @param x defines the 1st component of the value
  116052. * @param y defines the 2nd component of the value
  116053. */
  116054. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  116055. /**
  116056. * Set the value of an uniform to a vec3
  116057. * @param uniform defines the webGL uniform location where to store the value
  116058. * @param x defines the 1st component of the value
  116059. * @param y defines the 2nd component of the value
  116060. * @param z defines the 3rd component of the value
  116061. */
  116062. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  116063. /**
  116064. * Set the value of an uniform to a vec4
  116065. * @param uniform defines the webGL uniform location where to store the value
  116066. * @param x defines the 1st component of the value
  116067. * @param y defines the 2nd component of the value
  116068. * @param z defines the 3rd component of the value
  116069. * @param w defines the 4th component of the value
  116070. */
  116071. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  116072. /**
  116073. * Apply all cached states (depth, culling, stencil and alpha)
  116074. */
  116075. applyStates(): void;
  116076. /**
  116077. * Enable or disable color writing
  116078. * @param enable defines the state to set
  116079. */
  116080. setColorWrite(enable: boolean): void;
  116081. /**
  116082. * Gets a boolean indicating if color writing is enabled
  116083. * @returns the current color writing state
  116084. */
  116085. getColorWrite(): boolean;
  116086. /**
  116087. * Gets the depth culling state manager
  116088. */
  116089. get depthCullingState(): DepthCullingState;
  116090. /**
  116091. * Gets the alpha state manager
  116092. */
  116093. get alphaState(): AlphaState;
  116094. /**
  116095. * Gets the stencil state manager
  116096. */
  116097. get stencilState(): StencilState;
  116098. /**
  116099. * Clears the list of texture accessible through engine.
  116100. * This can help preventing texture load conflict due to name collision.
  116101. */
  116102. clearInternalTexturesCache(): void;
  116103. /**
  116104. * Force the entire cache to be cleared
  116105. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116106. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116107. */
  116108. wipeCaches(bruteForce?: boolean): void;
  116109. /** @hidden */
  116110. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116111. min: number;
  116112. mag: number;
  116113. };
  116114. /** @hidden */
  116115. _createTexture(): WebGLTexture;
  116116. /**
  116117. * Usually called from Texture.ts.
  116118. * Passed information to create a WebGLTexture
  116119. * @param url defines a value which contains one of the following:
  116120. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116121. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116122. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116123. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116124. * @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)
  116125. * @param scene needed for loading to the correct scene
  116126. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116127. * @param onLoad optional callback to be called upon successful completion
  116128. * @param onError optional callback to be called upon failure
  116129. * @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
  116130. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116131. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116132. * @param forcedExtension defines the extension to use to pick the right loader
  116133. * @param mimeType defines an optional mime type
  116134. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116135. */
  116136. 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;
  116137. /**
  116138. * Loads an image as an HTMLImageElement.
  116139. * @param input url string, ArrayBuffer, or Blob to load
  116140. * @param onLoad callback called when the image successfully loads
  116141. * @param onError callback called when the image fails to load
  116142. * @param offlineProvider offline provider for caching
  116143. * @param mimeType optional mime type
  116144. * @returns the HTMLImageElement of the loaded image
  116145. * @hidden
  116146. */
  116147. 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>;
  116148. /**
  116149. * @hidden
  116150. */
  116151. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116152. private _unpackFlipYCached;
  116153. /**
  116154. * In case you are sharing the context with other applications, it might
  116155. * be interested to not cache the unpack flip y state to ensure a consistent
  116156. * value would be set.
  116157. */
  116158. enableUnpackFlipYCached: boolean;
  116159. /** @hidden */
  116160. _unpackFlipY(value: boolean): void;
  116161. /** @hidden */
  116162. _getUnpackAlignement(): number;
  116163. private _getTextureTarget;
  116164. /**
  116165. * Update the sampling mode of a given texture
  116166. * @param samplingMode defines the required sampling mode
  116167. * @param texture defines the texture to update
  116168. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116169. */
  116170. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116171. /**
  116172. * Update the sampling mode of a given texture
  116173. * @param texture defines the texture to update
  116174. * @param wrapU defines the texture wrap mode of the u coordinates
  116175. * @param wrapV defines the texture wrap mode of the v coordinates
  116176. * @param wrapR defines the texture wrap mode of the r coordinates
  116177. */
  116178. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116179. /** @hidden */
  116180. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116181. width: number;
  116182. height: number;
  116183. layers?: number;
  116184. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116185. /** @hidden */
  116186. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116187. /** @hidden */
  116188. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116189. /**
  116190. * Update a portion of an internal texture
  116191. * @param texture defines the texture to update
  116192. * @param imageData defines the data to store into the texture
  116193. * @param xOffset defines the x coordinates of the update rectangle
  116194. * @param yOffset defines the y coordinates of the update rectangle
  116195. * @param width defines the width of the update rectangle
  116196. * @param height defines the height of the update rectangle
  116197. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116198. * @param lod defines the lod level to update (0 by default)
  116199. */
  116200. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116201. /** @hidden */
  116202. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116203. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116204. private _prepareWebGLTexture;
  116205. /** @hidden */
  116206. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116207. private _getDepthStencilBuffer;
  116208. /** @hidden */
  116209. _releaseFramebufferObjects(texture: InternalTexture): void;
  116210. /** @hidden */
  116211. _releaseTexture(texture: InternalTexture): void;
  116212. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116213. protected _setProgram(program: WebGLProgram): void;
  116214. protected _boundUniforms: {
  116215. [key: number]: WebGLUniformLocation;
  116216. };
  116217. /**
  116218. * Binds an effect to the webGL context
  116219. * @param effect defines the effect to bind
  116220. */
  116221. bindSamplers(effect: Effect): void;
  116222. private _activateCurrentTexture;
  116223. /** @hidden */
  116224. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116225. /** @hidden */
  116226. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116227. /**
  116228. * Unbind all textures from the webGL context
  116229. */
  116230. unbindAllTextures(): void;
  116231. /**
  116232. * Sets a texture to the according uniform.
  116233. * @param channel The texture channel
  116234. * @param uniform The uniform to set
  116235. * @param texture The texture to apply
  116236. */
  116237. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116238. private _bindSamplerUniformToChannel;
  116239. private _getTextureWrapMode;
  116240. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116241. /**
  116242. * Sets an array of texture to the webGL context
  116243. * @param channel defines the channel where the texture array must be set
  116244. * @param uniform defines the associated uniform location
  116245. * @param textures defines the array of textures to bind
  116246. */
  116247. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116248. /** @hidden */
  116249. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116250. private _setTextureParameterFloat;
  116251. private _setTextureParameterInteger;
  116252. /**
  116253. * Unbind all vertex attributes from the webGL context
  116254. */
  116255. unbindAllAttributes(): void;
  116256. /**
  116257. * 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
  116258. */
  116259. releaseEffects(): void;
  116260. /**
  116261. * Dispose and release all associated resources
  116262. */
  116263. dispose(): void;
  116264. /**
  116265. * Attach a new callback raised when context lost event is fired
  116266. * @param callback defines the callback to call
  116267. */
  116268. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116269. /**
  116270. * Attach a new callback raised when context restored event is fired
  116271. * @param callback defines the callback to call
  116272. */
  116273. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116274. /**
  116275. * Get the current error code of the webGL context
  116276. * @returns the error code
  116277. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116278. */
  116279. getError(): number;
  116280. private _canRenderToFloatFramebuffer;
  116281. private _canRenderToHalfFloatFramebuffer;
  116282. private _canRenderToFramebuffer;
  116283. /** @hidden */
  116284. _getWebGLTextureType(type: number): number;
  116285. /** @hidden */
  116286. _getInternalFormat(format: number): number;
  116287. /** @hidden */
  116288. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116289. /** @hidden */
  116290. _getRGBAMultiSampleBufferFormat(type: number): number;
  116291. /** @hidden */
  116292. _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;
  116293. /**
  116294. * Loads a file from a url
  116295. * @param url url to load
  116296. * @param onSuccess callback called when the file successfully loads
  116297. * @param onProgress callback called while file is loading (if the server supports this mode)
  116298. * @param offlineProvider defines the offline provider for caching
  116299. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116300. * @param onError callback called when the file fails to load
  116301. * @returns a file request object
  116302. * @hidden
  116303. */
  116304. 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;
  116305. /**
  116306. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116307. * @param x defines the x coordinate of the rectangle where pixels must be read
  116308. * @param y defines the y coordinate of the rectangle where pixels must be read
  116309. * @param width defines the width of the rectangle where pixels must be read
  116310. * @param height defines the height of the rectangle where pixels must be read
  116311. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116312. * @returns a Uint8Array containing RGBA colors
  116313. */
  116314. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116315. private static _isSupported;
  116316. /**
  116317. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116318. * @returns true if the engine can be created
  116319. * @ignorenaming
  116320. */
  116321. static isSupported(): boolean;
  116322. /**
  116323. * Find the next highest power of two.
  116324. * @param x Number to start search from.
  116325. * @return Next highest power of two.
  116326. */
  116327. static CeilingPOT(x: number): number;
  116328. /**
  116329. * Find the next lowest power of two.
  116330. * @param x Number to start search from.
  116331. * @return Next lowest power of two.
  116332. */
  116333. static FloorPOT(x: number): number;
  116334. /**
  116335. * Find the nearest power of two.
  116336. * @param x Number to start search from.
  116337. * @return Next nearest power of two.
  116338. */
  116339. static NearestPOT(x: number): number;
  116340. /**
  116341. * Get the closest exponent of two
  116342. * @param value defines the value to approximate
  116343. * @param max defines the maximum value to return
  116344. * @param mode defines how to define the closest value
  116345. * @returns closest exponent of two of the given value
  116346. */
  116347. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116348. /**
  116349. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116350. * @param func - the function to be called
  116351. * @param requester - the object that will request the next frame. Falls back to window.
  116352. * @returns frame number
  116353. */
  116354. static QueueNewFrame(func: () => void, requester?: any): number;
  116355. /**
  116356. * Gets host document
  116357. * @returns the host document object
  116358. */
  116359. getHostDocument(): Nullable<Document>;
  116360. }
  116361. }
  116362. declare module BABYLON {
  116363. /**
  116364. * Class representing spherical harmonics coefficients to the 3rd degree
  116365. */
  116366. export class SphericalHarmonics {
  116367. /**
  116368. * Defines whether or not the harmonics have been prescaled for rendering.
  116369. */
  116370. preScaled: boolean;
  116371. /**
  116372. * The l0,0 coefficients of the spherical harmonics
  116373. */
  116374. l00: Vector3;
  116375. /**
  116376. * The l1,-1 coefficients of the spherical harmonics
  116377. */
  116378. l1_1: Vector3;
  116379. /**
  116380. * The l1,0 coefficients of the spherical harmonics
  116381. */
  116382. l10: Vector3;
  116383. /**
  116384. * The l1,1 coefficients of the spherical harmonics
  116385. */
  116386. l11: Vector3;
  116387. /**
  116388. * The l2,-2 coefficients of the spherical harmonics
  116389. */
  116390. l2_2: Vector3;
  116391. /**
  116392. * The l2,-1 coefficients of the spherical harmonics
  116393. */
  116394. l2_1: Vector3;
  116395. /**
  116396. * The l2,0 coefficients of the spherical harmonics
  116397. */
  116398. l20: Vector3;
  116399. /**
  116400. * The l2,1 coefficients of the spherical harmonics
  116401. */
  116402. l21: Vector3;
  116403. /**
  116404. * The l2,2 coefficients of the spherical harmonics
  116405. */
  116406. l22: Vector3;
  116407. /**
  116408. * Adds a light to the spherical harmonics
  116409. * @param direction the direction of the light
  116410. * @param color the color of the light
  116411. * @param deltaSolidAngle the delta solid angle of the light
  116412. */
  116413. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116414. /**
  116415. * Scales the spherical harmonics by the given amount
  116416. * @param scale the amount to scale
  116417. */
  116418. scaleInPlace(scale: number): void;
  116419. /**
  116420. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116421. *
  116422. * ```
  116423. * E_lm = A_l * L_lm
  116424. * ```
  116425. *
  116426. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116427. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116428. * the scaling factors are given in equation 9.
  116429. */
  116430. convertIncidentRadianceToIrradiance(): void;
  116431. /**
  116432. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116433. *
  116434. * ```
  116435. * L = (1/pi) * E * rho
  116436. * ```
  116437. *
  116438. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116439. */
  116440. convertIrradianceToLambertianRadiance(): void;
  116441. /**
  116442. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116443. * required operations at run time.
  116444. *
  116445. * This is simply done by scaling back the SH with Ylm constants parameter.
  116446. * The trigonometric part being applied by the shader at run time.
  116447. */
  116448. preScaleForRendering(): void;
  116449. /**
  116450. * Constructs a spherical harmonics from an array.
  116451. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116452. * @returns the spherical harmonics
  116453. */
  116454. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116455. /**
  116456. * Gets the spherical harmonics from polynomial
  116457. * @param polynomial the spherical polynomial
  116458. * @returns the spherical harmonics
  116459. */
  116460. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116461. }
  116462. /**
  116463. * Class representing spherical polynomial coefficients to the 3rd degree
  116464. */
  116465. export class SphericalPolynomial {
  116466. private _harmonics;
  116467. /**
  116468. * The spherical harmonics used to create the polynomials.
  116469. */
  116470. get preScaledHarmonics(): SphericalHarmonics;
  116471. /**
  116472. * The x coefficients of the spherical polynomial
  116473. */
  116474. x: Vector3;
  116475. /**
  116476. * The y coefficients of the spherical polynomial
  116477. */
  116478. y: Vector3;
  116479. /**
  116480. * The z coefficients of the spherical polynomial
  116481. */
  116482. z: Vector3;
  116483. /**
  116484. * The xx coefficients of the spherical polynomial
  116485. */
  116486. xx: Vector3;
  116487. /**
  116488. * The yy coefficients of the spherical polynomial
  116489. */
  116490. yy: Vector3;
  116491. /**
  116492. * The zz coefficients of the spherical polynomial
  116493. */
  116494. zz: Vector3;
  116495. /**
  116496. * The xy coefficients of the spherical polynomial
  116497. */
  116498. xy: Vector3;
  116499. /**
  116500. * The yz coefficients of the spherical polynomial
  116501. */
  116502. yz: Vector3;
  116503. /**
  116504. * The zx coefficients of the spherical polynomial
  116505. */
  116506. zx: Vector3;
  116507. /**
  116508. * Adds an ambient color to the spherical polynomial
  116509. * @param color the color to add
  116510. */
  116511. addAmbient(color: Color3): void;
  116512. /**
  116513. * Scales the spherical polynomial by the given amount
  116514. * @param scale the amount to scale
  116515. */
  116516. scaleInPlace(scale: number): void;
  116517. /**
  116518. * Gets the spherical polynomial from harmonics
  116519. * @param harmonics the spherical harmonics
  116520. * @returns the spherical polynomial
  116521. */
  116522. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116523. /**
  116524. * Constructs a spherical polynomial from an array.
  116525. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116526. * @returns the spherical polynomial
  116527. */
  116528. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116529. }
  116530. }
  116531. declare module BABYLON {
  116532. /**
  116533. * Defines the source of the internal texture
  116534. */
  116535. export enum InternalTextureSource {
  116536. /**
  116537. * The source of the texture data is unknown
  116538. */
  116539. Unknown = 0,
  116540. /**
  116541. * Texture data comes from an URL
  116542. */
  116543. Url = 1,
  116544. /**
  116545. * Texture data is only used for temporary storage
  116546. */
  116547. Temp = 2,
  116548. /**
  116549. * Texture data comes from raw data (ArrayBuffer)
  116550. */
  116551. Raw = 3,
  116552. /**
  116553. * Texture content is dynamic (video or dynamic texture)
  116554. */
  116555. Dynamic = 4,
  116556. /**
  116557. * Texture content is generated by rendering to it
  116558. */
  116559. RenderTarget = 5,
  116560. /**
  116561. * Texture content is part of a multi render target process
  116562. */
  116563. MultiRenderTarget = 6,
  116564. /**
  116565. * Texture data comes from a cube data file
  116566. */
  116567. Cube = 7,
  116568. /**
  116569. * Texture data comes from a raw cube data
  116570. */
  116571. CubeRaw = 8,
  116572. /**
  116573. * Texture data come from a prefiltered cube data file
  116574. */
  116575. CubePrefiltered = 9,
  116576. /**
  116577. * Texture content is raw 3D data
  116578. */
  116579. Raw3D = 10,
  116580. /**
  116581. * Texture content is raw 2D array data
  116582. */
  116583. Raw2DArray = 11,
  116584. /**
  116585. * Texture content is a depth texture
  116586. */
  116587. Depth = 12,
  116588. /**
  116589. * Texture data comes from a raw cube data encoded with RGBD
  116590. */
  116591. CubeRawRGBD = 13
  116592. }
  116593. /**
  116594. * Class used to store data associated with WebGL texture data for the engine
  116595. * This class should not be used directly
  116596. */
  116597. export class InternalTexture {
  116598. /** @hidden */
  116599. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116600. /**
  116601. * Defines if the texture is ready
  116602. */
  116603. isReady: boolean;
  116604. /**
  116605. * Defines if the texture is a cube texture
  116606. */
  116607. isCube: boolean;
  116608. /**
  116609. * Defines if the texture contains 3D data
  116610. */
  116611. is3D: boolean;
  116612. /**
  116613. * Defines if the texture contains 2D array data
  116614. */
  116615. is2DArray: boolean;
  116616. /**
  116617. * Defines if the texture contains multiview data
  116618. */
  116619. isMultiview: boolean;
  116620. /**
  116621. * Gets the URL used to load this texture
  116622. */
  116623. url: string;
  116624. /**
  116625. * Gets the sampling mode of the texture
  116626. */
  116627. samplingMode: number;
  116628. /**
  116629. * Gets a boolean indicating if the texture needs mipmaps generation
  116630. */
  116631. generateMipMaps: boolean;
  116632. /**
  116633. * Gets the number of samples used by the texture (WebGL2+ only)
  116634. */
  116635. samples: number;
  116636. /**
  116637. * Gets the type of the texture (int, float...)
  116638. */
  116639. type: number;
  116640. /**
  116641. * Gets the format of the texture (RGB, RGBA...)
  116642. */
  116643. format: number;
  116644. /**
  116645. * Observable called when the texture is loaded
  116646. */
  116647. onLoadedObservable: Observable<InternalTexture>;
  116648. /**
  116649. * Gets the width of the texture
  116650. */
  116651. width: number;
  116652. /**
  116653. * Gets the height of the texture
  116654. */
  116655. height: number;
  116656. /**
  116657. * Gets the depth of the texture
  116658. */
  116659. depth: number;
  116660. /**
  116661. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116662. */
  116663. baseWidth: number;
  116664. /**
  116665. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116666. */
  116667. baseHeight: number;
  116668. /**
  116669. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  116670. */
  116671. baseDepth: number;
  116672. /**
  116673. * Gets a boolean indicating if the texture is inverted on Y axis
  116674. */
  116675. invertY: boolean;
  116676. /** @hidden */
  116677. _invertVScale: boolean;
  116678. /** @hidden */
  116679. _associatedChannel: number;
  116680. /** @hidden */
  116681. _source: InternalTextureSource;
  116682. /** @hidden */
  116683. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  116684. /** @hidden */
  116685. _bufferView: Nullable<ArrayBufferView>;
  116686. /** @hidden */
  116687. _bufferViewArray: Nullable<ArrayBufferView[]>;
  116688. /** @hidden */
  116689. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  116690. /** @hidden */
  116691. _size: number;
  116692. /** @hidden */
  116693. _extension: string;
  116694. /** @hidden */
  116695. _files: Nullable<string[]>;
  116696. /** @hidden */
  116697. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116698. /** @hidden */
  116699. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116700. /** @hidden */
  116701. _framebuffer: Nullable<WebGLFramebuffer>;
  116702. /** @hidden */
  116703. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  116704. /** @hidden */
  116705. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  116706. /** @hidden */
  116707. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  116708. /** @hidden */
  116709. _attachments: Nullable<number[]>;
  116710. /** @hidden */
  116711. _textureArray: Nullable<InternalTexture[]>;
  116712. /** @hidden */
  116713. _cachedCoordinatesMode: Nullable<number>;
  116714. /** @hidden */
  116715. _cachedWrapU: Nullable<number>;
  116716. /** @hidden */
  116717. _cachedWrapV: Nullable<number>;
  116718. /** @hidden */
  116719. _cachedWrapR: Nullable<number>;
  116720. /** @hidden */
  116721. _cachedAnisotropicFilteringLevel: Nullable<number>;
  116722. /** @hidden */
  116723. _isDisabled: boolean;
  116724. /** @hidden */
  116725. _compression: Nullable<string>;
  116726. /** @hidden */
  116727. _generateStencilBuffer: boolean;
  116728. /** @hidden */
  116729. _generateDepthBuffer: boolean;
  116730. /** @hidden */
  116731. _comparisonFunction: number;
  116732. /** @hidden */
  116733. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  116734. /** @hidden */
  116735. _lodGenerationScale: number;
  116736. /** @hidden */
  116737. _lodGenerationOffset: number;
  116738. /** @hidden */
  116739. _depthStencilTexture: Nullable<InternalTexture>;
  116740. /** @hidden */
  116741. _colorTextureArray: Nullable<WebGLTexture>;
  116742. /** @hidden */
  116743. _depthStencilTextureArray: Nullable<WebGLTexture>;
  116744. /** @hidden */
  116745. _lodTextureHigh: Nullable<BaseTexture>;
  116746. /** @hidden */
  116747. _lodTextureMid: Nullable<BaseTexture>;
  116748. /** @hidden */
  116749. _lodTextureLow: Nullable<BaseTexture>;
  116750. /** @hidden */
  116751. _isRGBD: boolean;
  116752. /** @hidden */
  116753. _linearSpecularLOD: boolean;
  116754. /** @hidden */
  116755. _irradianceTexture: Nullable<BaseTexture>;
  116756. /** @hidden */
  116757. _webGLTexture: Nullable<WebGLTexture>;
  116758. /** @hidden */
  116759. _references: number;
  116760. /** @hidden */
  116761. _gammaSpace: Nullable<boolean>;
  116762. private _engine;
  116763. /**
  116764. * Gets the Engine the texture belongs to.
  116765. * @returns The babylon engine
  116766. */
  116767. getEngine(): ThinEngine;
  116768. /**
  116769. * Gets the data source type of the texture
  116770. */
  116771. get source(): InternalTextureSource;
  116772. /**
  116773. * Creates a new InternalTexture
  116774. * @param engine defines the engine to use
  116775. * @param source defines the type of data that will be used
  116776. * @param delayAllocation if the texture allocation should be delayed (default: false)
  116777. */
  116778. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  116779. /**
  116780. * Increments the number of references (ie. the number of Texture that point to it)
  116781. */
  116782. incrementReferences(): void;
  116783. /**
  116784. * Change the size of the texture (not the size of the content)
  116785. * @param width defines the new width
  116786. * @param height defines the new height
  116787. * @param depth defines the new depth (1 by default)
  116788. */
  116789. updateSize(width: int, height: int, depth?: int): void;
  116790. /** @hidden */
  116791. _rebuild(): void;
  116792. /** @hidden */
  116793. _swapAndDie(target: InternalTexture): void;
  116794. /**
  116795. * Dispose the current allocated resources
  116796. */
  116797. dispose(): void;
  116798. }
  116799. }
  116800. declare module BABYLON {
  116801. /**
  116802. * Class used to work with sound analyzer using fast fourier transform (FFT)
  116803. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116804. */
  116805. export class Analyser {
  116806. /**
  116807. * Gets or sets the smoothing
  116808. * @ignorenaming
  116809. */
  116810. SMOOTHING: number;
  116811. /**
  116812. * Gets or sets the FFT table size
  116813. * @ignorenaming
  116814. */
  116815. FFT_SIZE: number;
  116816. /**
  116817. * Gets or sets the bar graph amplitude
  116818. * @ignorenaming
  116819. */
  116820. BARGRAPHAMPLITUDE: number;
  116821. /**
  116822. * Gets or sets the position of the debug canvas
  116823. * @ignorenaming
  116824. */
  116825. DEBUGCANVASPOS: {
  116826. x: number;
  116827. y: number;
  116828. };
  116829. /**
  116830. * Gets or sets the debug canvas size
  116831. * @ignorenaming
  116832. */
  116833. DEBUGCANVASSIZE: {
  116834. width: number;
  116835. height: number;
  116836. };
  116837. private _byteFreqs;
  116838. private _byteTime;
  116839. private _floatFreqs;
  116840. private _webAudioAnalyser;
  116841. private _debugCanvas;
  116842. private _debugCanvasContext;
  116843. private _scene;
  116844. private _registerFunc;
  116845. private _audioEngine;
  116846. /**
  116847. * Creates a new analyser
  116848. * @param scene defines hosting scene
  116849. */
  116850. constructor(scene: Scene);
  116851. /**
  116852. * Get the number of data values you will have to play with for the visualization
  116853. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  116854. * @returns a number
  116855. */
  116856. getFrequencyBinCount(): number;
  116857. /**
  116858. * Gets the current frequency data as a byte array
  116859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116860. * @returns a Uint8Array
  116861. */
  116862. getByteFrequencyData(): Uint8Array;
  116863. /**
  116864. * Gets the current waveform as a byte array
  116865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  116866. * @returns a Uint8Array
  116867. */
  116868. getByteTimeDomainData(): Uint8Array;
  116869. /**
  116870. * Gets the current frequency data as a float array
  116871. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116872. * @returns a Float32Array
  116873. */
  116874. getFloatFrequencyData(): Float32Array;
  116875. /**
  116876. * Renders the debug canvas
  116877. */
  116878. drawDebugCanvas(): void;
  116879. /**
  116880. * Stops rendering the debug canvas and removes it
  116881. */
  116882. stopDebugCanvas(): void;
  116883. /**
  116884. * Connects two audio nodes
  116885. * @param inputAudioNode defines first node to connect
  116886. * @param outputAudioNode defines second node to connect
  116887. */
  116888. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  116889. /**
  116890. * Releases all associated resources
  116891. */
  116892. dispose(): void;
  116893. }
  116894. }
  116895. declare module BABYLON {
  116896. /**
  116897. * This represents an audio engine and it is responsible
  116898. * to play, synchronize and analyse sounds throughout the application.
  116899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116900. */
  116901. export interface IAudioEngine extends IDisposable {
  116902. /**
  116903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116904. */
  116905. readonly canUseWebAudio: boolean;
  116906. /**
  116907. * Gets the current AudioContext if available.
  116908. */
  116909. readonly audioContext: Nullable<AudioContext>;
  116910. /**
  116911. * The master gain node defines the global audio volume of your audio engine.
  116912. */
  116913. readonly masterGain: GainNode;
  116914. /**
  116915. * Gets whether or not mp3 are supported by your browser.
  116916. */
  116917. readonly isMP3supported: boolean;
  116918. /**
  116919. * Gets whether or not ogg are supported by your browser.
  116920. */
  116921. readonly isOGGsupported: boolean;
  116922. /**
  116923. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116924. * @ignoreNaming
  116925. */
  116926. WarnedWebAudioUnsupported: boolean;
  116927. /**
  116928. * Defines if the audio engine relies on a custom unlocked button.
  116929. * In this case, the embedded button will not be displayed.
  116930. */
  116931. useCustomUnlockedButton: boolean;
  116932. /**
  116933. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  116934. */
  116935. readonly unlocked: boolean;
  116936. /**
  116937. * Event raised when audio has been unlocked on the browser.
  116938. */
  116939. onAudioUnlockedObservable: Observable<AudioEngine>;
  116940. /**
  116941. * Event raised when audio has been locked on the browser.
  116942. */
  116943. onAudioLockedObservable: Observable<AudioEngine>;
  116944. /**
  116945. * Flags the audio engine in Locked state.
  116946. * This happens due to new browser policies preventing audio to autoplay.
  116947. */
  116948. lock(): void;
  116949. /**
  116950. * Unlocks the audio engine once a user action has been done on the dom.
  116951. * This is helpful to resume play once browser policies have been satisfied.
  116952. */
  116953. unlock(): void;
  116954. /**
  116955. * Gets the global volume sets on the master gain.
  116956. * @returns the global volume if set or -1 otherwise
  116957. */
  116958. getGlobalVolume(): number;
  116959. /**
  116960. * Sets the global volume of your experience (sets on the master gain).
  116961. * @param newVolume Defines the new global volume of the application
  116962. */
  116963. setGlobalVolume(newVolume: number): void;
  116964. /**
  116965. * Connect the audio engine to an audio analyser allowing some amazing
  116966. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116968. * @param analyser The analyser to connect to the engine
  116969. */
  116970. connectToAnalyser(analyser: Analyser): void;
  116971. }
  116972. /**
  116973. * This represents the default audio engine used in babylon.
  116974. * It is responsible to play, synchronize and analyse sounds throughout the application.
  116975. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116976. */
  116977. export class AudioEngine implements IAudioEngine {
  116978. private _audioContext;
  116979. private _audioContextInitialized;
  116980. private _muteButton;
  116981. private _hostElement;
  116982. /**
  116983. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116984. */
  116985. canUseWebAudio: boolean;
  116986. /**
  116987. * The master gain node defines the global audio volume of your audio engine.
  116988. */
  116989. masterGain: GainNode;
  116990. /**
  116991. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116992. * @ignoreNaming
  116993. */
  116994. WarnedWebAudioUnsupported: boolean;
  116995. /**
  116996. * Gets whether or not mp3 are supported by your browser.
  116997. */
  116998. isMP3supported: boolean;
  116999. /**
  117000. * Gets whether or not ogg are supported by your browser.
  117001. */
  117002. isOGGsupported: boolean;
  117003. /**
  117004. * Gets whether audio has been unlocked on the device.
  117005. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117006. * a user interaction has happened.
  117007. */
  117008. unlocked: boolean;
  117009. /**
  117010. * Defines if the audio engine relies on a custom unlocked button.
  117011. * In this case, the embedded button will not be displayed.
  117012. */
  117013. useCustomUnlockedButton: boolean;
  117014. /**
  117015. * Event raised when audio has been unlocked on the browser.
  117016. */
  117017. onAudioUnlockedObservable: Observable<AudioEngine>;
  117018. /**
  117019. * Event raised when audio has been locked on the browser.
  117020. */
  117021. onAudioLockedObservable: Observable<AudioEngine>;
  117022. /**
  117023. * Gets the current AudioContext if available.
  117024. */
  117025. get audioContext(): Nullable<AudioContext>;
  117026. private _connectedAnalyser;
  117027. /**
  117028. * Instantiates a new audio engine.
  117029. *
  117030. * There should be only one per page as some browsers restrict the number
  117031. * of audio contexts you can create.
  117032. * @param hostElement defines the host element where to display the mute icon if necessary
  117033. */
  117034. constructor(hostElement?: Nullable<HTMLElement>);
  117035. /**
  117036. * Flags the audio engine in Locked state.
  117037. * This happens due to new browser policies preventing audio to autoplay.
  117038. */
  117039. lock(): void;
  117040. /**
  117041. * Unlocks the audio engine once a user action has been done on the dom.
  117042. * This is helpful to resume play once browser policies have been satisfied.
  117043. */
  117044. unlock(): void;
  117045. private _resumeAudioContext;
  117046. private _initializeAudioContext;
  117047. private _tryToRun;
  117048. private _triggerRunningState;
  117049. private _triggerSuspendedState;
  117050. private _displayMuteButton;
  117051. private _moveButtonToTopLeft;
  117052. private _onResize;
  117053. private _hideMuteButton;
  117054. /**
  117055. * Destroy and release the resources associated with the audio ccontext.
  117056. */
  117057. dispose(): void;
  117058. /**
  117059. * Gets the global volume sets on the master gain.
  117060. * @returns the global volume if set or -1 otherwise
  117061. */
  117062. getGlobalVolume(): number;
  117063. /**
  117064. * Sets the global volume of your experience (sets on the master gain).
  117065. * @param newVolume Defines the new global volume of the application
  117066. */
  117067. setGlobalVolume(newVolume: number): void;
  117068. /**
  117069. * Connect the audio engine to an audio analyser allowing some amazing
  117070. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117072. * @param analyser The analyser to connect to the engine
  117073. */
  117074. connectToAnalyser(analyser: Analyser): void;
  117075. }
  117076. }
  117077. declare module BABYLON {
  117078. /**
  117079. * Interface used to present a loading screen while loading a scene
  117080. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117081. */
  117082. export interface ILoadingScreen {
  117083. /**
  117084. * Function called to display the loading screen
  117085. */
  117086. displayLoadingUI: () => void;
  117087. /**
  117088. * Function called to hide the loading screen
  117089. */
  117090. hideLoadingUI: () => void;
  117091. /**
  117092. * Gets or sets the color to use for the background
  117093. */
  117094. loadingUIBackgroundColor: string;
  117095. /**
  117096. * Gets or sets the text to display while loading
  117097. */
  117098. loadingUIText: string;
  117099. }
  117100. /**
  117101. * Class used for the default loading screen
  117102. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117103. */
  117104. export class DefaultLoadingScreen implements ILoadingScreen {
  117105. private _renderingCanvas;
  117106. private _loadingText;
  117107. private _loadingDivBackgroundColor;
  117108. private _loadingDiv;
  117109. private _loadingTextDiv;
  117110. /** Gets or sets the logo url to use for the default loading screen */
  117111. static DefaultLogoUrl: string;
  117112. /** Gets or sets the spinner url to use for the default loading screen */
  117113. static DefaultSpinnerUrl: string;
  117114. /**
  117115. * Creates a new default loading screen
  117116. * @param _renderingCanvas defines the canvas used to render the scene
  117117. * @param _loadingText defines the default text to display
  117118. * @param _loadingDivBackgroundColor defines the default background color
  117119. */
  117120. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117121. /**
  117122. * Function called to display the loading screen
  117123. */
  117124. displayLoadingUI(): void;
  117125. /**
  117126. * Function called to hide the loading screen
  117127. */
  117128. hideLoadingUI(): void;
  117129. /**
  117130. * Gets or sets the text to display while loading
  117131. */
  117132. set loadingUIText(text: string);
  117133. get loadingUIText(): string;
  117134. /**
  117135. * Gets or sets the color to use for the background
  117136. */
  117137. get loadingUIBackgroundColor(): string;
  117138. set loadingUIBackgroundColor(color: string);
  117139. private _resizeLoadingUI;
  117140. }
  117141. }
  117142. declare module BABYLON {
  117143. /**
  117144. * Interface for any object that can request an animation frame
  117145. */
  117146. export interface ICustomAnimationFrameRequester {
  117147. /**
  117148. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117149. */
  117150. renderFunction?: Function;
  117151. /**
  117152. * Called to request the next frame to render to
  117153. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117154. */
  117155. requestAnimationFrame: Function;
  117156. /**
  117157. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117158. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117159. */
  117160. requestID?: number;
  117161. }
  117162. }
  117163. declare module BABYLON {
  117164. /**
  117165. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117166. */
  117167. export class PerformanceMonitor {
  117168. private _enabled;
  117169. private _rollingFrameTime;
  117170. private _lastFrameTimeMs;
  117171. /**
  117172. * constructor
  117173. * @param frameSampleSize The number of samples required to saturate the sliding window
  117174. */
  117175. constructor(frameSampleSize?: number);
  117176. /**
  117177. * Samples current frame
  117178. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117179. */
  117180. sampleFrame(timeMs?: number): void;
  117181. /**
  117182. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117183. */
  117184. get averageFrameTime(): number;
  117185. /**
  117186. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117187. */
  117188. get averageFrameTimeVariance(): number;
  117189. /**
  117190. * Returns the frame time of the most recent frame
  117191. */
  117192. get instantaneousFrameTime(): number;
  117193. /**
  117194. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117195. */
  117196. get averageFPS(): number;
  117197. /**
  117198. * Returns the average framerate in frames per second using the most recent frame time
  117199. */
  117200. get instantaneousFPS(): number;
  117201. /**
  117202. * Returns true if enough samples have been taken to completely fill the sliding window
  117203. */
  117204. get isSaturated(): boolean;
  117205. /**
  117206. * Enables contributions to the sliding window sample set
  117207. */
  117208. enable(): void;
  117209. /**
  117210. * Disables contributions to the sliding window sample set
  117211. * Samples will not be interpolated over the disabled period
  117212. */
  117213. disable(): void;
  117214. /**
  117215. * Returns true if sampling is enabled
  117216. */
  117217. get isEnabled(): boolean;
  117218. /**
  117219. * Resets performance monitor
  117220. */
  117221. reset(): void;
  117222. }
  117223. /**
  117224. * RollingAverage
  117225. *
  117226. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117227. */
  117228. export class RollingAverage {
  117229. /**
  117230. * Current average
  117231. */
  117232. average: number;
  117233. /**
  117234. * Current variance
  117235. */
  117236. variance: number;
  117237. protected _samples: Array<number>;
  117238. protected _sampleCount: number;
  117239. protected _pos: number;
  117240. protected _m2: number;
  117241. /**
  117242. * constructor
  117243. * @param length The number of samples required to saturate the sliding window
  117244. */
  117245. constructor(length: number);
  117246. /**
  117247. * Adds a sample to the sample set
  117248. * @param v The sample value
  117249. */
  117250. add(v: number): void;
  117251. /**
  117252. * Returns previously added values or null if outside of history or outside the sliding window domain
  117253. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117254. * @return Value previously recorded with add() or null if outside of range
  117255. */
  117256. history(i: number): number;
  117257. /**
  117258. * Returns true if enough samples have been taken to completely fill the sliding window
  117259. * @return true if sample-set saturated
  117260. */
  117261. isSaturated(): boolean;
  117262. /**
  117263. * Resets the rolling average (equivalent to 0 samples taken so far)
  117264. */
  117265. reset(): void;
  117266. /**
  117267. * Wraps a value around the sample range boundaries
  117268. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117269. * @return Wrapped position in sample range
  117270. */
  117271. protected _wrapPosition(i: number): number;
  117272. }
  117273. }
  117274. declare module BABYLON {
  117275. /**
  117276. * This class is used to track a performance counter which is number based.
  117277. * The user has access to many properties which give statistics of different nature.
  117278. *
  117279. * The implementer can track two kinds of Performance Counter: time and count.
  117280. * 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.
  117281. * 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.
  117282. */
  117283. export class PerfCounter {
  117284. /**
  117285. * Gets or sets a global boolean to turn on and off all the counters
  117286. */
  117287. static Enabled: boolean;
  117288. /**
  117289. * Returns the smallest value ever
  117290. */
  117291. get min(): number;
  117292. /**
  117293. * Returns the biggest value ever
  117294. */
  117295. get max(): number;
  117296. /**
  117297. * Returns the average value since the performance counter is running
  117298. */
  117299. get average(): number;
  117300. /**
  117301. * Returns the average value of the last second the counter was monitored
  117302. */
  117303. get lastSecAverage(): number;
  117304. /**
  117305. * Returns the current value
  117306. */
  117307. get current(): number;
  117308. /**
  117309. * Gets the accumulated total
  117310. */
  117311. get total(): number;
  117312. /**
  117313. * Gets the total value count
  117314. */
  117315. get count(): number;
  117316. /**
  117317. * Creates a new counter
  117318. */
  117319. constructor();
  117320. /**
  117321. * Call this method to start monitoring a new frame.
  117322. * 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.
  117323. */
  117324. fetchNewFrame(): void;
  117325. /**
  117326. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117327. * @param newCount the count value to add to the monitored count
  117328. * @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.
  117329. */
  117330. addCount(newCount: number, fetchResult: boolean): void;
  117331. /**
  117332. * Start monitoring this performance counter
  117333. */
  117334. beginMonitoring(): void;
  117335. /**
  117336. * Compute the time lapsed since the previous beginMonitoring() call.
  117337. * @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
  117338. */
  117339. endMonitoring(newFrame?: boolean): void;
  117340. private _fetchResult;
  117341. private _startMonitoringTime;
  117342. private _min;
  117343. private _max;
  117344. private _average;
  117345. private _current;
  117346. private _totalValueCount;
  117347. private _totalAccumulated;
  117348. private _lastSecAverage;
  117349. private _lastSecAccumulated;
  117350. private _lastSecTime;
  117351. private _lastSecValueCount;
  117352. }
  117353. }
  117354. declare module BABYLON {
  117355. interface ThinEngine {
  117356. /** @hidden */
  117357. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117358. }
  117359. }
  117360. declare module BABYLON {
  117361. /**
  117362. * Defines the interface used by display changed events
  117363. */
  117364. export interface IDisplayChangedEventArgs {
  117365. /** Gets the vrDisplay object (if any) */
  117366. vrDisplay: Nullable<any>;
  117367. /** Gets a boolean indicating if webVR is supported */
  117368. vrSupported: boolean;
  117369. }
  117370. /**
  117371. * Defines the interface used by objects containing a viewport (like a camera)
  117372. */
  117373. interface IViewportOwnerLike {
  117374. /**
  117375. * Gets or sets the viewport
  117376. */
  117377. viewport: IViewportLike;
  117378. }
  117379. /**
  117380. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117381. */
  117382. export class Engine extends ThinEngine {
  117383. /** Defines that alpha blending is disabled */
  117384. static readonly ALPHA_DISABLE: number;
  117385. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117386. static readonly ALPHA_ADD: number;
  117387. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117388. static readonly ALPHA_COMBINE: number;
  117389. /** Defines that alpha blending to DEST - SRC * DEST */
  117390. static readonly ALPHA_SUBTRACT: number;
  117391. /** Defines that alpha blending to SRC * DEST */
  117392. static readonly ALPHA_MULTIPLY: number;
  117393. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117394. static readonly ALPHA_MAXIMIZED: number;
  117395. /** Defines that alpha blending to SRC + DEST */
  117396. static readonly ALPHA_ONEONE: number;
  117397. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117398. static readonly ALPHA_PREMULTIPLIED: number;
  117399. /**
  117400. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117401. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117402. */
  117403. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117404. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117405. static readonly ALPHA_INTERPOLATE: number;
  117406. /**
  117407. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117408. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117409. */
  117410. static readonly ALPHA_SCREENMODE: number;
  117411. /** Defines that the ressource is not delayed*/
  117412. static readonly DELAYLOADSTATE_NONE: number;
  117413. /** Defines that the ressource was successfully delay loaded */
  117414. static readonly DELAYLOADSTATE_LOADED: number;
  117415. /** Defines that the ressource is currently delay loading */
  117416. static readonly DELAYLOADSTATE_LOADING: number;
  117417. /** Defines that the ressource is delayed and has not started loading */
  117418. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117419. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117420. static readonly NEVER: number;
  117421. /** 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 */
  117422. static readonly ALWAYS: number;
  117423. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117424. static readonly LESS: number;
  117425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117426. static readonly EQUAL: number;
  117427. /** 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 */
  117428. static readonly LEQUAL: number;
  117429. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117430. static readonly GREATER: number;
  117431. /** 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 */
  117432. static readonly GEQUAL: number;
  117433. /** 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 */
  117434. static readonly NOTEQUAL: number;
  117435. /** Passed to stencilOperation to specify that stencil value must be kept */
  117436. static readonly KEEP: number;
  117437. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117438. static readonly REPLACE: number;
  117439. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117440. static readonly INCR: number;
  117441. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117442. static readonly DECR: number;
  117443. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117444. static readonly INVERT: number;
  117445. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117446. static readonly INCR_WRAP: number;
  117447. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117448. static readonly DECR_WRAP: number;
  117449. /** Texture is not repeating outside of 0..1 UVs */
  117450. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117451. /** Texture is repeating outside of 0..1 UVs */
  117452. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117453. /** Texture is repeating and mirrored */
  117454. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117455. /** ALPHA */
  117456. static readonly TEXTUREFORMAT_ALPHA: number;
  117457. /** LUMINANCE */
  117458. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117459. /** LUMINANCE_ALPHA */
  117460. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117461. /** RGB */
  117462. static readonly TEXTUREFORMAT_RGB: number;
  117463. /** RGBA */
  117464. static readonly TEXTUREFORMAT_RGBA: number;
  117465. /** RED */
  117466. static readonly TEXTUREFORMAT_RED: number;
  117467. /** RED (2nd reference) */
  117468. static readonly TEXTUREFORMAT_R: number;
  117469. /** RG */
  117470. static readonly TEXTUREFORMAT_RG: number;
  117471. /** RED_INTEGER */
  117472. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117473. /** RED_INTEGER (2nd reference) */
  117474. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117475. /** RG_INTEGER */
  117476. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117477. /** RGB_INTEGER */
  117478. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117479. /** RGBA_INTEGER */
  117480. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117481. /** UNSIGNED_BYTE */
  117482. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117483. /** UNSIGNED_BYTE (2nd reference) */
  117484. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117485. /** FLOAT */
  117486. static readonly TEXTURETYPE_FLOAT: number;
  117487. /** HALF_FLOAT */
  117488. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117489. /** BYTE */
  117490. static readonly TEXTURETYPE_BYTE: number;
  117491. /** SHORT */
  117492. static readonly TEXTURETYPE_SHORT: number;
  117493. /** UNSIGNED_SHORT */
  117494. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117495. /** INT */
  117496. static readonly TEXTURETYPE_INT: number;
  117497. /** UNSIGNED_INT */
  117498. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117499. /** UNSIGNED_SHORT_4_4_4_4 */
  117500. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117501. /** UNSIGNED_SHORT_5_5_5_1 */
  117502. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117503. /** UNSIGNED_SHORT_5_6_5 */
  117504. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117505. /** UNSIGNED_INT_2_10_10_10_REV */
  117506. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117507. /** UNSIGNED_INT_24_8 */
  117508. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117509. /** UNSIGNED_INT_10F_11F_11F_REV */
  117510. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117511. /** UNSIGNED_INT_5_9_9_9_REV */
  117512. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117513. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117514. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117515. /** nearest is mag = nearest and min = nearest and mip = linear */
  117516. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117517. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117518. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117519. /** Trilinear is mag = linear and min = linear and mip = linear */
  117520. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117521. /** nearest is mag = nearest and min = nearest and mip = linear */
  117522. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117524. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117525. /** Trilinear is mag = linear and min = linear and mip = linear */
  117526. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117527. /** mag = nearest and min = nearest and mip = nearest */
  117528. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117529. /** mag = nearest and min = linear and mip = nearest */
  117530. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117531. /** mag = nearest and min = linear and mip = linear */
  117532. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117533. /** mag = nearest and min = linear and mip = none */
  117534. static readonly TEXTURE_NEAREST_LINEAR: number;
  117535. /** mag = nearest and min = nearest and mip = none */
  117536. static readonly TEXTURE_NEAREST_NEAREST: number;
  117537. /** mag = linear and min = nearest and mip = nearest */
  117538. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117539. /** mag = linear and min = nearest and mip = linear */
  117540. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117541. /** mag = linear and min = linear and mip = none */
  117542. static readonly TEXTURE_LINEAR_LINEAR: number;
  117543. /** mag = linear and min = nearest and mip = none */
  117544. static readonly TEXTURE_LINEAR_NEAREST: number;
  117545. /** Explicit coordinates mode */
  117546. static readonly TEXTURE_EXPLICIT_MODE: number;
  117547. /** Spherical coordinates mode */
  117548. static readonly TEXTURE_SPHERICAL_MODE: number;
  117549. /** Planar coordinates mode */
  117550. static readonly TEXTURE_PLANAR_MODE: number;
  117551. /** Cubic coordinates mode */
  117552. static readonly TEXTURE_CUBIC_MODE: number;
  117553. /** Projection coordinates mode */
  117554. static readonly TEXTURE_PROJECTION_MODE: number;
  117555. /** Skybox coordinates mode */
  117556. static readonly TEXTURE_SKYBOX_MODE: number;
  117557. /** Inverse Cubic coordinates mode */
  117558. static readonly TEXTURE_INVCUBIC_MODE: number;
  117559. /** Equirectangular coordinates mode */
  117560. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117561. /** Equirectangular Fixed coordinates mode */
  117562. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117563. /** Equirectangular Fixed Mirrored coordinates mode */
  117564. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117565. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117566. static readonly SCALEMODE_FLOOR: number;
  117567. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117568. static readonly SCALEMODE_NEAREST: number;
  117569. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117570. static readonly SCALEMODE_CEILING: number;
  117571. /**
  117572. * Returns the current npm package of the sdk
  117573. */
  117574. static get NpmPackage(): string;
  117575. /**
  117576. * Returns the current version of the framework
  117577. */
  117578. static get Version(): string;
  117579. /** Gets the list of created engines */
  117580. static get Instances(): Engine[];
  117581. /**
  117582. * Gets the latest created engine
  117583. */
  117584. static get LastCreatedEngine(): Nullable<Engine>;
  117585. /**
  117586. * Gets the latest created scene
  117587. */
  117588. static get LastCreatedScene(): Nullable<Scene>;
  117589. /**
  117590. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117591. * @param flag defines which part of the materials must be marked as dirty
  117592. * @param predicate defines a predicate used to filter which materials should be affected
  117593. */
  117594. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117595. /**
  117596. * Method called to create the default loading screen.
  117597. * This can be overriden in your own app.
  117598. * @param canvas The rendering canvas element
  117599. * @returns The loading screen
  117600. */
  117601. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117602. /**
  117603. * Method called to create the default rescale post process on each engine.
  117604. */
  117605. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117606. /**
  117607. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117608. **/
  117609. enableOfflineSupport: boolean;
  117610. /**
  117611. * 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)
  117612. **/
  117613. disableManifestCheck: boolean;
  117614. /**
  117615. * Gets the list of created scenes
  117616. */
  117617. scenes: Scene[];
  117618. /**
  117619. * Event raised when a new scene is created
  117620. */
  117621. onNewSceneAddedObservable: Observable<Scene>;
  117622. /**
  117623. * Gets the list of created postprocesses
  117624. */
  117625. postProcesses: PostProcess[];
  117626. /**
  117627. * Gets a boolean indicating if the pointer is currently locked
  117628. */
  117629. isPointerLock: boolean;
  117630. /**
  117631. * Observable event triggered each time the rendering canvas is resized
  117632. */
  117633. onResizeObservable: Observable<Engine>;
  117634. /**
  117635. * Observable event triggered each time the canvas loses focus
  117636. */
  117637. onCanvasBlurObservable: Observable<Engine>;
  117638. /**
  117639. * Observable event triggered each time the canvas gains focus
  117640. */
  117641. onCanvasFocusObservable: Observable<Engine>;
  117642. /**
  117643. * Observable event triggered each time the canvas receives pointerout event
  117644. */
  117645. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117646. /**
  117647. * Observable raised when the engine begins a new frame
  117648. */
  117649. onBeginFrameObservable: Observable<Engine>;
  117650. /**
  117651. * If set, will be used to request the next animation frame for the render loop
  117652. */
  117653. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117654. /**
  117655. * Observable raised when the engine ends the current frame
  117656. */
  117657. onEndFrameObservable: Observable<Engine>;
  117658. /**
  117659. * Observable raised when the engine is about to compile a shader
  117660. */
  117661. onBeforeShaderCompilationObservable: Observable<Engine>;
  117662. /**
  117663. * Observable raised when the engine has jsut compiled a shader
  117664. */
  117665. onAfterShaderCompilationObservable: Observable<Engine>;
  117666. /**
  117667. * Gets the audio engine
  117668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117669. * @ignorenaming
  117670. */
  117671. static audioEngine: IAudioEngine;
  117672. /**
  117673. * Default AudioEngine factory responsible of creating the Audio Engine.
  117674. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  117675. */
  117676. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  117677. /**
  117678. * Default offline support factory responsible of creating a tool used to store data locally.
  117679. * By default, this will create a Database object if the workload has been embedded.
  117680. */
  117681. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  117682. private _loadingScreen;
  117683. private _pointerLockRequested;
  117684. private _rescalePostProcess;
  117685. private _deterministicLockstep;
  117686. private _lockstepMaxSteps;
  117687. private _timeStep;
  117688. protected get _supportsHardwareTextureRescaling(): boolean;
  117689. private _fps;
  117690. private _deltaTime;
  117691. /** @hidden */
  117692. _drawCalls: PerfCounter;
  117693. /** 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 */
  117694. canvasTabIndex: number;
  117695. /**
  117696. * Turn this value on if you want to pause FPS computation when in background
  117697. */
  117698. disablePerformanceMonitorInBackground: boolean;
  117699. private _performanceMonitor;
  117700. /**
  117701. * Gets the performance monitor attached to this engine
  117702. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117703. */
  117704. get performanceMonitor(): PerformanceMonitor;
  117705. private _onFocus;
  117706. private _onBlur;
  117707. private _onCanvasPointerOut;
  117708. private _onCanvasBlur;
  117709. private _onCanvasFocus;
  117710. private _onFullscreenChange;
  117711. private _onPointerLockChange;
  117712. /**
  117713. * Gets the HTML element used to attach event listeners
  117714. * @returns a HTML element
  117715. */
  117716. getInputElement(): Nullable<HTMLElement>;
  117717. /**
  117718. * Creates a new engine
  117719. * @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
  117720. * @param antialias defines enable antialiasing (default: false)
  117721. * @param options defines further options to be sent to the getContext() function
  117722. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  117723. */
  117724. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  117725. /**
  117726. * Gets current aspect ratio
  117727. * @param viewportOwner defines the camera to use to get the aspect ratio
  117728. * @param useScreen defines if screen size must be used (or the current render target if any)
  117729. * @returns a number defining the aspect ratio
  117730. */
  117731. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  117732. /**
  117733. * Gets current screen aspect ratio
  117734. * @returns a number defining the aspect ratio
  117735. */
  117736. getScreenAspectRatio(): number;
  117737. /**
  117738. * Gets the client rect of the HTML canvas attached with the current webGL context
  117739. * @returns a client rectanglee
  117740. */
  117741. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  117742. /**
  117743. * Gets the client rect of the HTML element used for events
  117744. * @returns a client rectanglee
  117745. */
  117746. getInputElementClientRect(): Nullable<ClientRect>;
  117747. /**
  117748. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117749. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117750. * @returns true if engine is in deterministic lock step mode
  117751. */
  117752. isDeterministicLockStep(): boolean;
  117753. /**
  117754. * Gets the max steps when engine is running in deterministic lock step
  117755. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117756. * @returns the max steps
  117757. */
  117758. getLockstepMaxSteps(): number;
  117759. /**
  117760. * Returns the time in ms between steps when using deterministic lock step.
  117761. * @returns time step in (ms)
  117762. */
  117763. getTimeStep(): number;
  117764. /**
  117765. * Force the mipmap generation for the given render target texture
  117766. * @param texture defines the render target texture to use
  117767. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  117768. */
  117769. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  117770. /** States */
  117771. /**
  117772. * Set various states to the webGL context
  117773. * @param culling defines backface culling state
  117774. * @param zOffset defines the value to apply to zOffset (0 by default)
  117775. * @param force defines if states must be applied even if cache is up to date
  117776. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117777. */
  117778. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117779. /**
  117780. * Set the z offset to apply to current rendering
  117781. * @param value defines the offset to apply
  117782. */
  117783. setZOffset(value: number): void;
  117784. /**
  117785. * Gets the current value of the zOffset
  117786. * @returns the current zOffset state
  117787. */
  117788. getZOffset(): number;
  117789. /**
  117790. * Enable or disable depth buffering
  117791. * @param enable defines the state to set
  117792. */
  117793. setDepthBuffer(enable: boolean): void;
  117794. /**
  117795. * Gets a boolean indicating if depth writing is enabled
  117796. * @returns the current depth writing state
  117797. */
  117798. getDepthWrite(): boolean;
  117799. /**
  117800. * Enable or disable depth writing
  117801. * @param enable defines the state to set
  117802. */
  117803. setDepthWrite(enable: boolean): void;
  117804. /**
  117805. * Gets a boolean indicating if stencil buffer is enabled
  117806. * @returns the current stencil buffer state
  117807. */
  117808. getStencilBuffer(): boolean;
  117809. /**
  117810. * Enable or disable the stencil buffer
  117811. * @param enable defines if the stencil buffer must be enabled or disabled
  117812. */
  117813. setStencilBuffer(enable: boolean): void;
  117814. /**
  117815. * Gets the current stencil mask
  117816. * @returns a number defining the new stencil mask to use
  117817. */
  117818. getStencilMask(): number;
  117819. /**
  117820. * Sets the current stencil mask
  117821. * @param mask defines the new stencil mask to use
  117822. */
  117823. setStencilMask(mask: number): void;
  117824. /**
  117825. * Gets the current stencil function
  117826. * @returns a number defining the stencil function to use
  117827. */
  117828. getStencilFunction(): number;
  117829. /**
  117830. * Gets the current stencil reference value
  117831. * @returns a number defining the stencil reference value to use
  117832. */
  117833. getStencilFunctionReference(): number;
  117834. /**
  117835. * Gets the current stencil mask
  117836. * @returns a number defining the stencil mask to use
  117837. */
  117838. getStencilFunctionMask(): number;
  117839. /**
  117840. * Sets the current stencil function
  117841. * @param stencilFunc defines the new stencil function to use
  117842. */
  117843. setStencilFunction(stencilFunc: number): void;
  117844. /**
  117845. * Sets the current stencil reference
  117846. * @param reference defines the new stencil reference to use
  117847. */
  117848. setStencilFunctionReference(reference: number): void;
  117849. /**
  117850. * Sets the current stencil mask
  117851. * @param mask defines the new stencil mask to use
  117852. */
  117853. setStencilFunctionMask(mask: number): void;
  117854. /**
  117855. * Gets the current stencil operation when stencil fails
  117856. * @returns a number defining stencil operation to use when stencil fails
  117857. */
  117858. getStencilOperationFail(): number;
  117859. /**
  117860. * Gets the current stencil operation when depth fails
  117861. * @returns a number defining stencil operation to use when depth fails
  117862. */
  117863. getStencilOperationDepthFail(): number;
  117864. /**
  117865. * Gets the current stencil operation when stencil passes
  117866. * @returns a number defining stencil operation to use when stencil passes
  117867. */
  117868. getStencilOperationPass(): number;
  117869. /**
  117870. * Sets the stencil operation to use when stencil fails
  117871. * @param operation defines the stencil operation to use when stencil fails
  117872. */
  117873. setStencilOperationFail(operation: number): void;
  117874. /**
  117875. * Sets the stencil operation to use when depth fails
  117876. * @param operation defines the stencil operation to use when depth fails
  117877. */
  117878. setStencilOperationDepthFail(operation: number): void;
  117879. /**
  117880. * Sets the stencil operation to use when stencil passes
  117881. * @param operation defines the stencil operation to use when stencil passes
  117882. */
  117883. setStencilOperationPass(operation: number): void;
  117884. /**
  117885. * Sets a boolean indicating if the dithering state is enabled or disabled
  117886. * @param value defines the dithering state
  117887. */
  117888. setDitheringState(value: boolean): void;
  117889. /**
  117890. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  117891. * @param value defines the rasterizer state
  117892. */
  117893. setRasterizerState(value: boolean): void;
  117894. /**
  117895. * Gets the current depth function
  117896. * @returns a number defining the depth function
  117897. */
  117898. getDepthFunction(): Nullable<number>;
  117899. /**
  117900. * Sets the current depth function
  117901. * @param depthFunc defines the function to use
  117902. */
  117903. setDepthFunction(depthFunc: number): void;
  117904. /**
  117905. * Sets the current depth function to GREATER
  117906. */
  117907. setDepthFunctionToGreater(): void;
  117908. /**
  117909. * Sets the current depth function to GEQUAL
  117910. */
  117911. setDepthFunctionToGreaterOrEqual(): void;
  117912. /**
  117913. * Sets the current depth function to LESS
  117914. */
  117915. setDepthFunctionToLess(): void;
  117916. /**
  117917. * Sets the current depth function to LEQUAL
  117918. */
  117919. setDepthFunctionToLessOrEqual(): void;
  117920. private _cachedStencilBuffer;
  117921. private _cachedStencilFunction;
  117922. private _cachedStencilMask;
  117923. private _cachedStencilOperationPass;
  117924. private _cachedStencilOperationFail;
  117925. private _cachedStencilOperationDepthFail;
  117926. private _cachedStencilReference;
  117927. /**
  117928. * Caches the the state of the stencil buffer
  117929. */
  117930. cacheStencilState(): void;
  117931. /**
  117932. * Restores the state of the stencil buffer
  117933. */
  117934. restoreStencilState(): void;
  117935. /**
  117936. * Directly set the WebGL Viewport
  117937. * @param x defines the x coordinate of the viewport (in screen space)
  117938. * @param y defines the y coordinate of the viewport (in screen space)
  117939. * @param width defines the width of the viewport (in screen space)
  117940. * @param height defines the height of the viewport (in screen space)
  117941. * @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
  117942. */
  117943. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  117944. /**
  117945. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  117946. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117947. * @param y defines the y-coordinate of the corner of the clear rectangle
  117948. * @param width defines the width of the clear rectangle
  117949. * @param height defines the height of the clear rectangle
  117950. * @param clearColor defines the clear color
  117951. */
  117952. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  117953. /**
  117954. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  117955. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117956. * @param y defines the y-coordinate of the corner of the clear rectangle
  117957. * @param width defines the width of the clear rectangle
  117958. * @param height defines the height of the clear rectangle
  117959. */
  117960. enableScissor(x: number, y: number, width: number, height: number): void;
  117961. /**
  117962. * Disable previously set scissor test rectangle
  117963. */
  117964. disableScissor(): void;
  117965. protected _reportDrawCall(): void;
  117966. /**
  117967. * Initializes a webVR display and starts listening to display change events
  117968. * The onVRDisplayChangedObservable will be notified upon these changes
  117969. * @returns The onVRDisplayChangedObservable
  117970. */
  117971. initWebVR(): Observable<IDisplayChangedEventArgs>;
  117972. /** @hidden */
  117973. _prepareVRComponent(): void;
  117974. /** @hidden */
  117975. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  117976. /** @hidden */
  117977. _submitVRFrame(): void;
  117978. /**
  117979. * Call this function to leave webVR mode
  117980. * Will do nothing if webVR is not supported or if there is no webVR device
  117981. * @see https://doc.babylonjs.com/how_to/webvr_camera
  117982. */
  117983. disableVR(): void;
  117984. /**
  117985. * Gets a boolean indicating that the system is in VR mode and is presenting
  117986. * @returns true if VR mode is engaged
  117987. */
  117988. isVRPresenting(): boolean;
  117989. /** @hidden */
  117990. _requestVRFrame(): void;
  117991. /** @hidden */
  117992. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117993. /**
  117994. * Gets the source code of the vertex shader associated with a specific webGL program
  117995. * @param program defines the program to use
  117996. * @returns a string containing the source code of the vertex shader associated with the program
  117997. */
  117998. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  117999. /**
  118000. * Gets the source code of the fragment shader associated with a specific webGL program
  118001. * @param program defines the program to use
  118002. * @returns a string containing the source code of the fragment shader associated with the program
  118003. */
  118004. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118005. /**
  118006. * Sets a depth stencil texture from a render target to the according uniform.
  118007. * @param channel The texture channel
  118008. * @param uniform The uniform to set
  118009. * @param texture The render target texture containing the depth stencil texture to apply
  118010. */
  118011. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118012. /**
  118013. * Sets a texture to the webGL context from a postprocess
  118014. * @param channel defines the channel to use
  118015. * @param postProcess defines the source postprocess
  118016. */
  118017. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118018. /**
  118019. * Binds the output of the passed in post process to the texture channel specified
  118020. * @param channel The channel the texture should be bound to
  118021. * @param postProcess The post process which's output should be bound
  118022. */
  118023. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118024. protected _rebuildBuffers(): void;
  118025. /** @hidden */
  118026. _renderFrame(): void;
  118027. _renderLoop(): void;
  118028. /** @hidden */
  118029. _renderViews(): boolean;
  118030. /**
  118031. * Toggle full screen mode
  118032. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118033. */
  118034. switchFullscreen(requestPointerLock: boolean): void;
  118035. /**
  118036. * Enters full screen mode
  118037. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118038. */
  118039. enterFullscreen(requestPointerLock: boolean): void;
  118040. /**
  118041. * Exits full screen mode
  118042. */
  118043. exitFullscreen(): void;
  118044. /**
  118045. * Enters Pointerlock mode
  118046. */
  118047. enterPointerlock(): void;
  118048. /**
  118049. * Exits Pointerlock mode
  118050. */
  118051. exitPointerlock(): void;
  118052. /**
  118053. * Begin a new frame
  118054. */
  118055. beginFrame(): void;
  118056. /**
  118057. * Enf the current frame
  118058. */
  118059. endFrame(): void;
  118060. resize(): void;
  118061. /**
  118062. * Force a specific size of the canvas
  118063. * @param width defines the new canvas' width
  118064. * @param height defines the new canvas' height
  118065. * @returns true if the size was changed
  118066. */
  118067. setSize(width: number, height: number): boolean;
  118068. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118069. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118070. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118071. _releaseTexture(texture: InternalTexture): void;
  118072. /**
  118073. * @hidden
  118074. * Rescales a texture
  118075. * @param source input texutre
  118076. * @param destination destination texture
  118077. * @param scene scene to use to render the resize
  118078. * @param internalFormat format to use when resizing
  118079. * @param onComplete callback to be called when resize has completed
  118080. */
  118081. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118082. /**
  118083. * Gets the current framerate
  118084. * @returns a number representing the framerate
  118085. */
  118086. getFps(): number;
  118087. /**
  118088. * Gets the time spent between current and previous frame
  118089. * @returns a number representing the delta time in ms
  118090. */
  118091. getDeltaTime(): number;
  118092. private _measureFps;
  118093. /** @hidden */
  118094. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118095. /**
  118096. * Updates the sample count of a render target texture
  118097. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118098. * @param texture defines the texture to update
  118099. * @param samples defines the sample count to set
  118100. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118101. */
  118102. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118103. /**
  118104. * Updates a depth texture Comparison Mode and Function.
  118105. * If the comparison Function is equal to 0, the mode will be set to none.
  118106. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118107. * @param texture The texture to set the comparison function for
  118108. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118109. */
  118110. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118111. /**
  118112. * Creates a webGL buffer to use with instanciation
  118113. * @param capacity defines the size of the buffer
  118114. * @returns the webGL buffer
  118115. */
  118116. createInstancesBuffer(capacity: number): DataBuffer;
  118117. /**
  118118. * Delete a webGL buffer used with instanciation
  118119. * @param buffer defines the webGL buffer to delete
  118120. */
  118121. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118122. private _clientWaitAsync;
  118123. /** @hidden */
  118124. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118125. dispose(): void;
  118126. private _disableTouchAction;
  118127. /**
  118128. * Display the loading screen
  118129. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118130. */
  118131. displayLoadingUI(): void;
  118132. /**
  118133. * Hide the loading screen
  118134. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118135. */
  118136. hideLoadingUI(): void;
  118137. /**
  118138. * Gets the current loading screen object
  118139. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118140. */
  118141. get loadingScreen(): ILoadingScreen;
  118142. /**
  118143. * Sets the current loading screen object
  118144. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118145. */
  118146. set loadingScreen(loadingScreen: ILoadingScreen);
  118147. /**
  118148. * Sets the current loading screen text
  118149. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118150. */
  118151. set loadingUIText(text: string);
  118152. /**
  118153. * Sets the current loading screen background color
  118154. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118155. */
  118156. set loadingUIBackgroundColor(color: string);
  118157. /** Pointerlock and fullscreen */
  118158. /**
  118159. * Ask the browser to promote the current element to pointerlock mode
  118160. * @param element defines the DOM element to promote
  118161. */
  118162. static _RequestPointerlock(element: HTMLElement): void;
  118163. /**
  118164. * Asks the browser to exit pointerlock mode
  118165. */
  118166. static _ExitPointerlock(): void;
  118167. /**
  118168. * Ask the browser to promote the current element to fullscreen rendering mode
  118169. * @param element defines the DOM element to promote
  118170. */
  118171. static _RequestFullscreen(element: HTMLElement): void;
  118172. /**
  118173. * Asks the browser to exit fullscreen mode
  118174. */
  118175. static _ExitFullscreen(): void;
  118176. }
  118177. }
  118178. declare module BABYLON {
  118179. /**
  118180. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118181. * during the life time of the application.
  118182. */
  118183. export class EngineStore {
  118184. /** Gets the list of created engines */
  118185. static Instances: Engine[];
  118186. /** @hidden */
  118187. static _LastCreatedScene: Nullable<Scene>;
  118188. /**
  118189. * Gets the latest created engine
  118190. */
  118191. static get LastCreatedEngine(): Nullable<Engine>;
  118192. /**
  118193. * Gets the latest created scene
  118194. */
  118195. static get LastCreatedScene(): Nullable<Scene>;
  118196. /**
  118197. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118198. * @ignorenaming
  118199. */
  118200. static UseFallbackTexture: boolean;
  118201. /**
  118202. * Texture content used if a texture cannot loaded
  118203. * @ignorenaming
  118204. */
  118205. static FallbackTexture: string;
  118206. }
  118207. }
  118208. declare module BABYLON {
  118209. /**
  118210. * Helper class that provides a small promise polyfill
  118211. */
  118212. export class PromisePolyfill {
  118213. /**
  118214. * Static function used to check if the polyfill is required
  118215. * If this is the case then the function will inject the polyfill to window.Promise
  118216. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118217. */
  118218. static Apply(force?: boolean): void;
  118219. }
  118220. }
  118221. declare module BABYLON {
  118222. /**
  118223. * Interface for screenshot methods with describe argument called `size` as object with options
  118224. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118225. */
  118226. export interface IScreenshotSize {
  118227. /**
  118228. * number in pixels for canvas height
  118229. */
  118230. height?: number;
  118231. /**
  118232. * multiplier allowing render at a higher or lower resolution
  118233. * If value is defined then height and width will be ignored and taken from camera
  118234. */
  118235. precision?: number;
  118236. /**
  118237. * number in pixels for canvas width
  118238. */
  118239. width?: number;
  118240. }
  118241. }
  118242. declare module BABYLON {
  118243. interface IColor4Like {
  118244. r: float;
  118245. g: float;
  118246. b: float;
  118247. a: float;
  118248. }
  118249. /**
  118250. * Class containing a set of static utilities functions
  118251. */
  118252. export class Tools {
  118253. /**
  118254. * Gets or sets the base URL to use to load assets
  118255. */
  118256. static get BaseUrl(): string;
  118257. static set BaseUrl(value: string);
  118258. /**
  118259. * Enable/Disable Custom HTTP Request Headers globally.
  118260. * default = false
  118261. * @see CustomRequestHeaders
  118262. */
  118263. static UseCustomRequestHeaders: boolean;
  118264. /**
  118265. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118266. * i.e. when loading files, where the server/service expects an Authorization header
  118267. */
  118268. static CustomRequestHeaders: {
  118269. [key: string]: string;
  118270. };
  118271. /**
  118272. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118273. */
  118274. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118275. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118276. /**
  118277. * Default behaviour for cors in the application.
  118278. * It can be a string if the expected behavior is identical in the entire app.
  118279. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118280. */
  118281. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118282. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118283. /**
  118284. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118285. * @ignorenaming
  118286. */
  118287. static get UseFallbackTexture(): boolean;
  118288. static set UseFallbackTexture(value: boolean);
  118289. /**
  118290. * Use this object to register external classes like custom textures or material
  118291. * to allow the laoders to instantiate them
  118292. */
  118293. static get RegisteredExternalClasses(): {
  118294. [key: string]: Object;
  118295. };
  118296. static set RegisteredExternalClasses(classes: {
  118297. [key: string]: Object;
  118298. });
  118299. /**
  118300. * Texture content used if a texture cannot loaded
  118301. * @ignorenaming
  118302. */
  118303. static get fallbackTexture(): string;
  118304. static set fallbackTexture(value: string);
  118305. /**
  118306. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118307. * @param u defines the coordinate on X axis
  118308. * @param v defines the coordinate on Y axis
  118309. * @param width defines the width of the source data
  118310. * @param height defines the height of the source data
  118311. * @param pixels defines the source byte array
  118312. * @param color defines the output color
  118313. */
  118314. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118315. /**
  118316. * Interpolates between a and b via alpha
  118317. * @param a The lower value (returned when alpha = 0)
  118318. * @param b The upper value (returned when alpha = 1)
  118319. * @param alpha The interpolation-factor
  118320. * @return The mixed value
  118321. */
  118322. static Mix(a: number, b: number, alpha: number): number;
  118323. /**
  118324. * Tries to instantiate a new object from a given class name
  118325. * @param className defines the class name to instantiate
  118326. * @returns the new object or null if the system was not able to do the instantiation
  118327. */
  118328. static Instantiate(className: string): any;
  118329. /**
  118330. * Provides a slice function that will work even on IE
  118331. * @param data defines the array to slice
  118332. * @param start defines the start of the data (optional)
  118333. * @param end defines the end of the data (optional)
  118334. * @returns the new sliced array
  118335. */
  118336. static Slice<T>(data: T, start?: number, end?: number): T;
  118337. /**
  118338. * Polyfill for setImmediate
  118339. * @param action defines the action to execute after the current execution block
  118340. */
  118341. static SetImmediate(action: () => void): void;
  118342. /**
  118343. * Function indicating if a number is an exponent of 2
  118344. * @param value defines the value to test
  118345. * @returns true if the value is an exponent of 2
  118346. */
  118347. static IsExponentOfTwo(value: number): boolean;
  118348. private static _tmpFloatArray;
  118349. /**
  118350. * Returns the nearest 32-bit single precision float representation of a Number
  118351. * @param value A Number. If the parameter is of a different type, it will get converted
  118352. * to a number or to NaN if it cannot be converted
  118353. * @returns number
  118354. */
  118355. static FloatRound(value: number): number;
  118356. /**
  118357. * Extracts the filename from a path
  118358. * @param path defines the path to use
  118359. * @returns the filename
  118360. */
  118361. static GetFilename(path: string): string;
  118362. /**
  118363. * Extracts the "folder" part of a path (everything before the filename).
  118364. * @param uri The URI to extract the info from
  118365. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118366. * @returns The "folder" part of the path
  118367. */
  118368. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118369. /**
  118370. * Extracts text content from a DOM element hierarchy
  118371. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118372. */
  118373. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118374. /**
  118375. * Convert an angle in radians to degrees
  118376. * @param angle defines the angle to convert
  118377. * @returns the angle in degrees
  118378. */
  118379. static ToDegrees(angle: number): number;
  118380. /**
  118381. * Convert an angle in degrees to radians
  118382. * @param angle defines the angle to convert
  118383. * @returns the angle in radians
  118384. */
  118385. static ToRadians(angle: number): number;
  118386. /**
  118387. * Returns an array if obj is not an array
  118388. * @param obj defines the object to evaluate as an array
  118389. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118390. * @returns either obj directly if obj is an array or a new array containing obj
  118391. */
  118392. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118393. /**
  118394. * Gets the pointer prefix to use
  118395. * @param engine defines the engine we are finding the prefix for
  118396. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118397. */
  118398. static GetPointerPrefix(engine: Engine): string;
  118399. /**
  118400. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118401. * @param url define the url we are trying
  118402. * @param element define the dom element where to configure the cors policy
  118403. */
  118404. static SetCorsBehavior(url: string | string[], element: {
  118405. crossOrigin: string | null;
  118406. }): void;
  118407. /**
  118408. * Removes unwanted characters from an url
  118409. * @param url defines the url to clean
  118410. * @returns the cleaned url
  118411. */
  118412. static CleanUrl(url: string): string;
  118413. /**
  118414. * Gets or sets a function used to pre-process url before using them to load assets
  118415. */
  118416. static get PreprocessUrl(): (url: string) => string;
  118417. static set PreprocessUrl(processor: (url: string) => string);
  118418. /**
  118419. * Loads an image as an HTMLImageElement.
  118420. * @param input url string, ArrayBuffer, or Blob to load
  118421. * @param onLoad callback called when the image successfully loads
  118422. * @param onError callback called when the image fails to load
  118423. * @param offlineProvider offline provider for caching
  118424. * @param mimeType optional mime type
  118425. * @returns the HTMLImageElement of the loaded image
  118426. */
  118427. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118428. /**
  118429. * Loads a file from a url
  118430. * @param url url string, ArrayBuffer, or Blob to load
  118431. * @param onSuccess callback called when the file successfully loads
  118432. * @param onProgress callback called while file is loading (if the server supports this mode)
  118433. * @param offlineProvider defines the offline provider for caching
  118434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118435. * @param onError callback called when the file fails to load
  118436. * @returns a file request object
  118437. */
  118438. 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;
  118439. /**
  118440. * Loads a file from a url
  118441. * @param url the file url to load
  118442. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118443. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118444. */
  118445. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118446. /**
  118447. * Load a script (identified by an url). When the url returns, the
  118448. * content of this file is added into a new script element, attached to the DOM (body element)
  118449. * @param scriptUrl defines the url of the script to laod
  118450. * @param onSuccess defines the callback called when the script is loaded
  118451. * @param onError defines the callback to call if an error occurs
  118452. * @param scriptId defines the id of the script element
  118453. */
  118454. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118455. /**
  118456. * Load an asynchronous script (identified by an url). When the url returns, the
  118457. * content of this file is added into a new script element, attached to the DOM (body element)
  118458. * @param scriptUrl defines the url of the script to laod
  118459. * @param scriptId defines the id of the script element
  118460. * @returns a promise request object
  118461. */
  118462. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118463. /**
  118464. * Loads a file from a blob
  118465. * @param fileToLoad defines the blob to use
  118466. * @param callback defines the callback to call when data is loaded
  118467. * @param progressCallback defines the callback to call during loading process
  118468. * @returns a file request object
  118469. */
  118470. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118471. /**
  118472. * Reads a file from a File object
  118473. * @param file defines the file to load
  118474. * @param onSuccess defines the callback to call when data is loaded
  118475. * @param onProgress defines the callback to call during loading process
  118476. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118477. * @param onError defines the callback to call when an error occurs
  118478. * @returns a file request object
  118479. */
  118480. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118481. /**
  118482. * Creates a data url from a given string content
  118483. * @param content defines the content to convert
  118484. * @returns the new data url link
  118485. */
  118486. static FileAsURL(content: string): string;
  118487. /**
  118488. * Format the given number to a specific decimal format
  118489. * @param value defines the number to format
  118490. * @param decimals defines the number of decimals to use
  118491. * @returns the formatted string
  118492. */
  118493. static Format(value: number, decimals?: number): string;
  118494. /**
  118495. * Tries to copy an object by duplicating every property
  118496. * @param source defines the source object
  118497. * @param destination defines the target object
  118498. * @param doNotCopyList defines a list of properties to avoid
  118499. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118500. */
  118501. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118502. /**
  118503. * Gets a boolean indicating if the given object has no own property
  118504. * @param obj defines the object to test
  118505. * @returns true if object has no own property
  118506. */
  118507. static IsEmpty(obj: any): boolean;
  118508. /**
  118509. * Function used to register events at window level
  118510. * @param windowElement defines the Window object to use
  118511. * @param events defines the events to register
  118512. */
  118513. static RegisterTopRootEvents(windowElement: Window, events: {
  118514. name: string;
  118515. handler: Nullable<(e: FocusEvent) => any>;
  118516. }[]): void;
  118517. /**
  118518. * Function used to unregister events from window level
  118519. * @param windowElement defines the Window object to use
  118520. * @param events defines the events to unregister
  118521. */
  118522. static UnregisterTopRootEvents(windowElement: Window, events: {
  118523. name: string;
  118524. handler: Nullable<(e: FocusEvent) => any>;
  118525. }[]): void;
  118526. /**
  118527. * @ignore
  118528. */
  118529. static _ScreenshotCanvas: HTMLCanvasElement;
  118530. /**
  118531. * Dumps the current bound framebuffer
  118532. * @param width defines the rendering width
  118533. * @param height defines the rendering height
  118534. * @param engine defines the hosting engine
  118535. * @param successCallback defines the callback triggered once the data are available
  118536. * @param mimeType defines the mime type of the result
  118537. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118538. */
  118539. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118540. /**
  118541. * Converts the canvas data to blob.
  118542. * This acts as a polyfill for browsers not supporting the to blob function.
  118543. * @param canvas Defines the canvas to extract the data from
  118544. * @param successCallback Defines the callback triggered once the data are available
  118545. * @param mimeType Defines the mime type of the result
  118546. */
  118547. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118548. /**
  118549. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118550. * @param successCallback defines the callback triggered once the data are available
  118551. * @param mimeType defines the mime type of the result
  118552. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118553. */
  118554. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118555. /**
  118556. * Downloads a blob in the browser
  118557. * @param blob defines the blob to download
  118558. * @param fileName defines the name of the downloaded file
  118559. */
  118560. static Download(blob: Blob, fileName: string): void;
  118561. /**
  118562. * Captures a screenshot of the current rendering
  118563. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118564. * @param engine defines the rendering engine
  118565. * @param camera defines the source camera
  118566. * @param size This parameter can be set to a single number or to an object with the
  118567. * following (optional) properties: precision, width, height. If a single number is passed,
  118568. * it will be used for both width and height. If an object is passed, the screenshot size
  118569. * will be derived from the parameters. The precision property is a multiplier allowing
  118570. * rendering at a higher or lower resolution
  118571. * @param successCallback defines the callback receives a single parameter which contains the
  118572. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118573. * src parameter of an <img> to display it
  118574. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118575. * Check your browser for supported MIME types
  118576. */
  118577. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118578. /**
  118579. * Captures a screenshot of the current rendering
  118580. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118581. * @param engine defines the rendering engine
  118582. * @param camera defines the source camera
  118583. * @param size This parameter can be set to a single number or to an object with the
  118584. * following (optional) properties: precision, width, height. If a single number is passed,
  118585. * it will be used for both width and height. If an object is passed, the screenshot size
  118586. * will be derived from the parameters. The precision property is a multiplier allowing
  118587. * rendering at a higher or lower resolution
  118588. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118589. * Check your browser for supported MIME types
  118590. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118591. * to the src parameter of an <img> to display it
  118592. */
  118593. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118594. /**
  118595. * Generates an image screenshot from the specified camera.
  118596. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118597. * @param engine The engine to use for rendering
  118598. * @param camera The camera to use for rendering
  118599. * @param size This parameter can be set to a single number or to an object with the
  118600. * following (optional) properties: precision, width, height. If a single number is passed,
  118601. * it will be used for both width and height. If an object is passed, the screenshot size
  118602. * will be derived from the parameters. The precision property is a multiplier allowing
  118603. * rendering at a higher or lower resolution
  118604. * @param successCallback The callback receives a single parameter which contains the
  118605. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118606. * src parameter of an <img> to display it
  118607. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118608. * Check your browser for supported MIME types
  118609. * @param samples Texture samples (default: 1)
  118610. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118611. * @param fileName A name for for the downloaded file.
  118612. */
  118613. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118614. /**
  118615. * Generates an image screenshot from the specified camera.
  118616. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118617. * @param engine The engine to use for rendering
  118618. * @param camera The camera to use for rendering
  118619. * @param size This parameter can be set to a single number or to an object with the
  118620. * following (optional) properties: precision, width, height. If a single number is passed,
  118621. * it will be used for both width and height. If an object is passed, the screenshot size
  118622. * will be derived from the parameters. The precision property is a multiplier allowing
  118623. * rendering at a higher or lower resolution
  118624. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118625. * Check your browser for supported MIME types
  118626. * @param samples Texture samples (default: 1)
  118627. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118628. * @param fileName A name for for the downloaded file.
  118629. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118630. * to the src parameter of an <img> to display it
  118631. */
  118632. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118633. /**
  118634. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118635. * Be aware Math.random() could cause collisions, but:
  118636. * "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"
  118637. * @returns a pseudo random id
  118638. */
  118639. static RandomId(): string;
  118640. /**
  118641. * Test if the given uri is a base64 string
  118642. * @param uri The uri to test
  118643. * @return True if the uri is a base64 string or false otherwise
  118644. */
  118645. static IsBase64(uri: string): boolean;
  118646. /**
  118647. * Decode the given base64 uri.
  118648. * @param uri The uri to decode
  118649. * @return The decoded base64 data.
  118650. */
  118651. static DecodeBase64(uri: string): ArrayBuffer;
  118652. /**
  118653. * Gets the absolute url.
  118654. * @param url the input url
  118655. * @return the absolute url
  118656. */
  118657. static GetAbsoluteUrl(url: string): string;
  118658. /**
  118659. * No log
  118660. */
  118661. static readonly NoneLogLevel: number;
  118662. /**
  118663. * Only message logs
  118664. */
  118665. static readonly MessageLogLevel: number;
  118666. /**
  118667. * Only warning logs
  118668. */
  118669. static readonly WarningLogLevel: number;
  118670. /**
  118671. * Only error logs
  118672. */
  118673. static readonly ErrorLogLevel: number;
  118674. /**
  118675. * All logs
  118676. */
  118677. static readonly AllLogLevel: number;
  118678. /**
  118679. * Gets a value indicating the number of loading errors
  118680. * @ignorenaming
  118681. */
  118682. static get errorsCount(): number;
  118683. /**
  118684. * Callback called when a new log is added
  118685. */
  118686. static OnNewCacheEntry: (entry: string) => void;
  118687. /**
  118688. * Log a message to the console
  118689. * @param message defines the message to log
  118690. */
  118691. static Log(message: string): void;
  118692. /**
  118693. * Write a warning message to the console
  118694. * @param message defines the message to log
  118695. */
  118696. static Warn(message: string): void;
  118697. /**
  118698. * Write an error message to the console
  118699. * @param message defines the message to log
  118700. */
  118701. static Error(message: string): void;
  118702. /**
  118703. * Gets current log cache (list of logs)
  118704. */
  118705. static get LogCache(): string;
  118706. /**
  118707. * Clears the log cache
  118708. */
  118709. static ClearLogCache(): void;
  118710. /**
  118711. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  118712. */
  118713. static set LogLevels(level: number);
  118714. /**
  118715. * Checks if the window object exists
  118716. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  118717. */
  118718. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  118719. /**
  118720. * No performance log
  118721. */
  118722. static readonly PerformanceNoneLogLevel: number;
  118723. /**
  118724. * Use user marks to log performance
  118725. */
  118726. static readonly PerformanceUserMarkLogLevel: number;
  118727. /**
  118728. * Log performance to the console
  118729. */
  118730. static readonly PerformanceConsoleLogLevel: number;
  118731. private static _performance;
  118732. /**
  118733. * Sets the current performance log level
  118734. */
  118735. static set PerformanceLogLevel(level: number);
  118736. private static _StartPerformanceCounterDisabled;
  118737. private static _EndPerformanceCounterDisabled;
  118738. private static _StartUserMark;
  118739. private static _EndUserMark;
  118740. private static _StartPerformanceConsole;
  118741. private static _EndPerformanceConsole;
  118742. /**
  118743. * Starts a performance counter
  118744. */
  118745. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118746. /**
  118747. * Ends a specific performance coutner
  118748. */
  118749. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118750. /**
  118751. * Gets either window.performance.now() if supported or Date.now() else
  118752. */
  118753. static get Now(): number;
  118754. /**
  118755. * This method will return the name of the class used to create the instance of the given object.
  118756. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  118757. * @param object the object to get the class name from
  118758. * @param isType defines if the object is actually a type
  118759. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  118760. */
  118761. static GetClassName(object: any, isType?: boolean): string;
  118762. /**
  118763. * Gets the first element of an array satisfying a given predicate
  118764. * @param array defines the array to browse
  118765. * @param predicate defines the predicate to use
  118766. * @returns null if not found or the element
  118767. */
  118768. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  118769. /**
  118770. * This method will return the name of the full name of the class, including its owning module (if any).
  118771. * 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).
  118772. * @param object the object to get the class name from
  118773. * @param isType defines if the object is actually a type
  118774. * @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.
  118775. * @ignorenaming
  118776. */
  118777. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  118778. /**
  118779. * Returns a promise that resolves after the given amount of time.
  118780. * @param delay Number of milliseconds to delay
  118781. * @returns Promise that resolves after the given amount of time
  118782. */
  118783. static DelayAsync(delay: number): Promise<void>;
  118784. /**
  118785. * Utility function to detect if the current user agent is Safari
  118786. * @returns whether or not the current user agent is safari
  118787. */
  118788. static IsSafari(): boolean;
  118789. }
  118790. /**
  118791. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  118792. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  118793. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  118794. * @param name The name of the class, case should be preserved
  118795. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  118796. */
  118797. export function className(name: string, module?: string): (target: Object) => void;
  118798. /**
  118799. * An implementation of a loop for asynchronous functions.
  118800. */
  118801. export class AsyncLoop {
  118802. /**
  118803. * Defines the number of iterations for the loop
  118804. */
  118805. iterations: number;
  118806. /**
  118807. * Defines the current index of the loop.
  118808. */
  118809. index: number;
  118810. private _done;
  118811. private _fn;
  118812. private _successCallback;
  118813. /**
  118814. * Constructor.
  118815. * @param iterations the number of iterations.
  118816. * @param func the function to run each iteration
  118817. * @param successCallback the callback that will be called upon succesful execution
  118818. * @param offset starting offset.
  118819. */
  118820. constructor(
  118821. /**
  118822. * Defines the number of iterations for the loop
  118823. */
  118824. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  118825. /**
  118826. * Execute the next iteration. Must be called after the last iteration was finished.
  118827. */
  118828. executeNext(): void;
  118829. /**
  118830. * Break the loop and run the success callback.
  118831. */
  118832. breakLoop(): void;
  118833. /**
  118834. * Create and run an async loop.
  118835. * @param iterations the number of iterations.
  118836. * @param fn the function to run each iteration
  118837. * @param successCallback the callback that will be called upon succesful execution
  118838. * @param offset starting offset.
  118839. * @returns the created async loop object
  118840. */
  118841. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  118842. /**
  118843. * A for-loop that will run a given number of iterations synchronous and the rest async.
  118844. * @param iterations total number of iterations
  118845. * @param syncedIterations number of synchronous iterations in each async iteration.
  118846. * @param fn the function to call each iteration.
  118847. * @param callback a success call back that will be called when iterating stops.
  118848. * @param breakFunction a break condition (optional)
  118849. * @param timeout timeout settings for the setTimeout function. default - 0.
  118850. * @returns the created async loop object
  118851. */
  118852. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  118853. }
  118854. }
  118855. declare module BABYLON {
  118856. /**
  118857. * This class implement a typical dictionary using a string as key and the generic type T as value.
  118858. * The underlying implementation relies on an associative array to ensure the best performances.
  118859. * The value can be anything including 'null' but except 'undefined'
  118860. */
  118861. export class StringDictionary<T> {
  118862. /**
  118863. * This will clear this dictionary and copy the content from the 'source' one.
  118864. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  118865. * @param source the dictionary to take the content from and copy to this dictionary
  118866. */
  118867. copyFrom(source: StringDictionary<T>): void;
  118868. /**
  118869. * Get a value based from its key
  118870. * @param key the given key to get the matching value from
  118871. * @return the value if found, otherwise undefined is returned
  118872. */
  118873. get(key: string): T | undefined;
  118874. /**
  118875. * Get a value from its key or add it if it doesn't exist.
  118876. * This method will ensure you that a given key/data will be present in the dictionary.
  118877. * @param key the given key to get the matching value from
  118878. * @param factory the factory that will create the value if the key is not present in the dictionary.
  118879. * The factory will only be invoked if there's no data for the given key.
  118880. * @return the value corresponding to the key.
  118881. */
  118882. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  118883. /**
  118884. * Get a value from its key if present in the dictionary otherwise add it
  118885. * @param key the key to get the value from
  118886. * @param val if there's no such key/value pair in the dictionary add it with this value
  118887. * @return the value corresponding to the key
  118888. */
  118889. getOrAdd(key: string, val: T): T;
  118890. /**
  118891. * Check if there's a given key in the dictionary
  118892. * @param key the key to check for
  118893. * @return true if the key is present, false otherwise
  118894. */
  118895. contains(key: string): boolean;
  118896. /**
  118897. * Add a new key and its corresponding value
  118898. * @param key the key to add
  118899. * @param value the value corresponding to the key
  118900. * @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
  118901. */
  118902. add(key: string, value: T): boolean;
  118903. /**
  118904. * Update a specific value associated to a key
  118905. * @param key defines the key to use
  118906. * @param value defines the value to store
  118907. * @returns true if the value was updated (or false if the key was not found)
  118908. */
  118909. set(key: string, value: T): boolean;
  118910. /**
  118911. * Get the element of the given key and remove it from the dictionary
  118912. * @param key defines the key to search
  118913. * @returns the value associated with the key or null if not found
  118914. */
  118915. getAndRemove(key: string): Nullable<T>;
  118916. /**
  118917. * Remove a key/value from the dictionary.
  118918. * @param key the key to remove
  118919. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  118920. */
  118921. remove(key: string): boolean;
  118922. /**
  118923. * Clear the whole content of the dictionary
  118924. */
  118925. clear(): void;
  118926. /**
  118927. * Gets the current count
  118928. */
  118929. get count(): number;
  118930. /**
  118931. * Execute a callback on each key/val of the dictionary.
  118932. * Note that you can remove any element in this dictionary in the callback implementation
  118933. * @param callback the callback to execute on a given key/value pair
  118934. */
  118935. forEach(callback: (key: string, val: T) => void): void;
  118936. /**
  118937. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  118938. * If the callback returns null or undefined the method will iterate to the next key/value pair
  118939. * Note that you can remove any element in this dictionary in the callback implementation
  118940. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  118941. * @returns the first item
  118942. */
  118943. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  118944. private _count;
  118945. private _data;
  118946. }
  118947. }
  118948. declare module BABYLON {
  118949. /** @hidden */
  118950. export interface ICollisionCoordinator {
  118951. createCollider(): Collider;
  118952. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118953. init(scene: Scene): void;
  118954. }
  118955. /** @hidden */
  118956. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  118957. private _scene;
  118958. private _scaledPosition;
  118959. private _scaledVelocity;
  118960. private _finalPosition;
  118961. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118962. createCollider(): Collider;
  118963. init(scene: Scene): void;
  118964. private _collideWithWorld;
  118965. }
  118966. }
  118967. declare module BABYLON {
  118968. /**
  118969. * Class used to manage all inputs for the scene.
  118970. */
  118971. export class InputManager {
  118972. /** The distance in pixel that you have to move to prevent some events */
  118973. static DragMovementThreshold: number;
  118974. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  118975. static LongPressDelay: number;
  118976. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  118977. static DoubleClickDelay: number;
  118978. /** If you need to check double click without raising a single click at first click, enable this flag */
  118979. static ExclusiveDoubleClickMode: boolean;
  118980. /** 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. */
  118981. private _alreadyAttached;
  118982. private _wheelEventName;
  118983. private _onPointerMove;
  118984. private _onPointerDown;
  118985. private _onPointerUp;
  118986. private _initClickEvent;
  118987. private _initActionManager;
  118988. private _delayedSimpleClick;
  118989. private _delayedSimpleClickTimeout;
  118990. private _previousDelayedSimpleClickTimeout;
  118991. private _meshPickProceed;
  118992. private _previousButtonPressed;
  118993. private _currentPickResult;
  118994. private _previousPickResult;
  118995. private _totalPointersPressed;
  118996. private _doubleClickOccured;
  118997. private _pointerOverMesh;
  118998. private _pickedDownMesh;
  118999. private _pickedUpMesh;
  119000. private _pointerX;
  119001. private _pointerY;
  119002. private _unTranslatedPointerX;
  119003. private _unTranslatedPointerY;
  119004. private _startingPointerPosition;
  119005. private _previousStartingPointerPosition;
  119006. private _startingPointerTime;
  119007. private _previousStartingPointerTime;
  119008. private _pointerCaptures;
  119009. private _meshUnderPointerId;
  119010. private _onKeyDown;
  119011. private _onKeyUp;
  119012. private _onCanvasFocusObserver;
  119013. private _onCanvasBlurObserver;
  119014. private _scene;
  119015. /**
  119016. * Creates a new InputManager
  119017. * @param scene defines the hosting scene
  119018. */
  119019. constructor(scene: Scene);
  119020. /**
  119021. * Gets the mesh that is currently under the pointer
  119022. */
  119023. get meshUnderPointer(): Nullable<AbstractMesh>;
  119024. /**
  119025. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119026. * @param pointerId the pointer id to use
  119027. * @returns The mesh under this pointer id or null if not found
  119028. */
  119029. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119030. /**
  119031. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119032. */
  119033. get unTranslatedPointer(): Vector2;
  119034. /**
  119035. * Gets or sets the current on-screen X position of the pointer
  119036. */
  119037. get pointerX(): number;
  119038. set pointerX(value: number);
  119039. /**
  119040. * Gets or sets the current on-screen Y position of the pointer
  119041. */
  119042. get pointerY(): number;
  119043. set pointerY(value: number);
  119044. private _updatePointerPosition;
  119045. private _processPointerMove;
  119046. private _setRayOnPointerInfo;
  119047. private _checkPrePointerObservable;
  119048. /**
  119049. * Use this method to simulate a pointer move on a mesh
  119050. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119051. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119052. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119053. */
  119054. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119055. /**
  119056. * Use this method to simulate a pointer down on a mesh
  119057. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119058. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119059. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119060. */
  119061. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119062. private _processPointerDown;
  119063. /** @hidden */
  119064. _isPointerSwiping(): boolean;
  119065. /**
  119066. * Use this method to simulate a pointer up on a mesh
  119067. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119068. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119069. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119070. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119071. */
  119072. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119073. private _processPointerUp;
  119074. /**
  119075. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119076. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119077. * @returns true if the pointer was captured
  119078. */
  119079. isPointerCaptured(pointerId?: number): boolean;
  119080. /**
  119081. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119082. * @param attachUp defines if you want to attach events to pointerup
  119083. * @param attachDown defines if you want to attach events to pointerdown
  119084. * @param attachMove defines if you want to attach events to pointermove
  119085. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119086. */
  119087. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119088. /**
  119089. * Detaches all event handlers
  119090. */
  119091. detachControl(): void;
  119092. /**
  119093. * Force the value of meshUnderPointer
  119094. * @param mesh defines the mesh to use
  119095. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119096. */
  119097. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119098. /**
  119099. * Gets the mesh under the pointer
  119100. * @returns a Mesh or null if no mesh is under the pointer
  119101. */
  119102. getPointerOverMesh(): Nullable<AbstractMesh>;
  119103. }
  119104. }
  119105. declare module BABYLON {
  119106. /**
  119107. * This class defines the direct association between an animation and a target
  119108. */
  119109. export class TargetedAnimation {
  119110. /**
  119111. * Animation to perform
  119112. */
  119113. animation: Animation;
  119114. /**
  119115. * Target to animate
  119116. */
  119117. target: any;
  119118. /**
  119119. * Returns the string "TargetedAnimation"
  119120. * @returns "TargetedAnimation"
  119121. */
  119122. getClassName(): string;
  119123. /**
  119124. * Serialize the object
  119125. * @returns the JSON object representing the current entity
  119126. */
  119127. serialize(): any;
  119128. }
  119129. /**
  119130. * Use this class to create coordinated animations on multiple targets
  119131. */
  119132. export class AnimationGroup implements IDisposable {
  119133. /** The name of the animation group */
  119134. name: string;
  119135. private _scene;
  119136. private _targetedAnimations;
  119137. private _animatables;
  119138. private _from;
  119139. private _to;
  119140. private _isStarted;
  119141. private _isPaused;
  119142. private _speedRatio;
  119143. private _loopAnimation;
  119144. private _isAdditive;
  119145. /**
  119146. * Gets or sets the unique id of the node
  119147. */
  119148. uniqueId: number;
  119149. /**
  119150. * This observable will notify when one animation have ended
  119151. */
  119152. onAnimationEndObservable: Observable<TargetedAnimation>;
  119153. /**
  119154. * Observer raised when one animation loops
  119155. */
  119156. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119157. /**
  119158. * Observer raised when all animations have looped
  119159. */
  119160. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119161. /**
  119162. * This observable will notify when all animations have ended.
  119163. */
  119164. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119165. /**
  119166. * This observable will notify when all animations have paused.
  119167. */
  119168. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119169. /**
  119170. * This observable will notify when all animations are playing.
  119171. */
  119172. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119173. /**
  119174. * Gets the first frame
  119175. */
  119176. get from(): number;
  119177. /**
  119178. * Gets the last frame
  119179. */
  119180. get to(): number;
  119181. /**
  119182. * Define if the animations are started
  119183. */
  119184. get isStarted(): boolean;
  119185. /**
  119186. * Gets a value indicating that the current group is playing
  119187. */
  119188. get isPlaying(): boolean;
  119189. /**
  119190. * Gets or sets the speed ratio to use for all animations
  119191. */
  119192. get speedRatio(): number;
  119193. /**
  119194. * Gets or sets the speed ratio to use for all animations
  119195. */
  119196. set speedRatio(value: number);
  119197. /**
  119198. * Gets or sets if all animations should loop or not
  119199. */
  119200. get loopAnimation(): boolean;
  119201. set loopAnimation(value: boolean);
  119202. /**
  119203. * Gets or sets if all animations should be evaluated additively
  119204. */
  119205. get isAdditive(): boolean;
  119206. set isAdditive(value: boolean);
  119207. /**
  119208. * Gets the targeted animations for this animation group
  119209. */
  119210. get targetedAnimations(): Array<TargetedAnimation>;
  119211. /**
  119212. * returning the list of animatables controlled by this animation group.
  119213. */
  119214. get animatables(): Array<Animatable>;
  119215. /**
  119216. * Gets the list of target animations
  119217. */
  119218. get children(): TargetedAnimation[];
  119219. /**
  119220. * Instantiates a new Animation Group.
  119221. * This helps managing several animations at once.
  119222. * @see https://doc.babylonjs.com/how_to/group
  119223. * @param name Defines the name of the group
  119224. * @param scene Defines the scene the group belongs to
  119225. */
  119226. constructor(
  119227. /** The name of the animation group */
  119228. name: string, scene?: Nullable<Scene>);
  119229. /**
  119230. * Add an animation (with its target) in the group
  119231. * @param animation defines the animation we want to add
  119232. * @param target defines the target of the animation
  119233. * @returns the TargetedAnimation object
  119234. */
  119235. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119236. /**
  119237. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119238. * It can add constant keys at begin or end
  119239. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119240. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119241. * @returns the animation group
  119242. */
  119243. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119244. private _animationLoopCount;
  119245. private _animationLoopFlags;
  119246. private _processLoop;
  119247. /**
  119248. * Start all animations on given targets
  119249. * @param loop defines if animations must loop
  119250. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119251. * @param from defines the from key (optional)
  119252. * @param to defines the to key (optional)
  119253. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119254. * @returns the current animation group
  119255. */
  119256. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119257. /**
  119258. * Pause all animations
  119259. * @returns the animation group
  119260. */
  119261. pause(): AnimationGroup;
  119262. /**
  119263. * Play all animations to initial state
  119264. * This function will start() the animations if they were not started or will restart() them if they were paused
  119265. * @param loop defines if animations must loop
  119266. * @returns the animation group
  119267. */
  119268. play(loop?: boolean): AnimationGroup;
  119269. /**
  119270. * Reset all animations to initial state
  119271. * @returns the animation group
  119272. */
  119273. reset(): AnimationGroup;
  119274. /**
  119275. * Restart animations from key 0
  119276. * @returns the animation group
  119277. */
  119278. restart(): AnimationGroup;
  119279. /**
  119280. * Stop all animations
  119281. * @returns the animation group
  119282. */
  119283. stop(): AnimationGroup;
  119284. /**
  119285. * Set animation weight for all animatables
  119286. * @param weight defines the weight to use
  119287. * @return the animationGroup
  119288. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119289. */
  119290. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119291. /**
  119292. * Synchronize and normalize all animatables with a source animatable
  119293. * @param root defines the root animatable to synchronize with
  119294. * @return the animationGroup
  119295. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119296. */
  119297. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119298. /**
  119299. * Goes to a specific frame in this animation group
  119300. * @param frame the frame number to go to
  119301. * @return the animationGroup
  119302. */
  119303. goToFrame(frame: number): AnimationGroup;
  119304. /**
  119305. * Dispose all associated resources
  119306. */
  119307. dispose(): void;
  119308. private _checkAnimationGroupEnded;
  119309. /**
  119310. * Clone the current animation group and returns a copy
  119311. * @param newName defines the name of the new group
  119312. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119313. * @returns the new aniamtion group
  119314. */
  119315. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119316. /**
  119317. * Serializes the animationGroup to an object
  119318. * @returns Serialized object
  119319. */
  119320. serialize(): any;
  119321. /**
  119322. * Returns a new AnimationGroup object parsed from the source provided.
  119323. * @param parsedAnimationGroup defines the source
  119324. * @param scene defines the scene that will receive the animationGroup
  119325. * @returns a new AnimationGroup
  119326. */
  119327. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119328. /**
  119329. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119330. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119331. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119332. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119333. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119334. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119335. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119336. */
  119337. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119338. /**
  119339. * Returns the string "AnimationGroup"
  119340. * @returns "AnimationGroup"
  119341. */
  119342. getClassName(): string;
  119343. /**
  119344. * Creates a detailled string about the object
  119345. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119346. * @returns a string representing the object
  119347. */
  119348. toString(fullDetails?: boolean): string;
  119349. }
  119350. }
  119351. declare module BABYLON {
  119352. /**
  119353. * Define an interface for all classes that will hold resources
  119354. */
  119355. export interface IDisposable {
  119356. /**
  119357. * Releases all held resources
  119358. */
  119359. dispose(): void;
  119360. }
  119361. /** Interface defining initialization parameters for Scene class */
  119362. export interface SceneOptions {
  119363. /**
  119364. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119365. * It will improve performance when the number of geometries becomes important.
  119366. */
  119367. useGeometryUniqueIdsMap?: boolean;
  119368. /**
  119369. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119370. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119371. */
  119372. useMaterialMeshMap?: boolean;
  119373. /**
  119374. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119375. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119376. */
  119377. useClonedMeshMap?: boolean;
  119378. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119379. virtual?: boolean;
  119380. }
  119381. /**
  119382. * Represents a scene to be rendered by the engine.
  119383. * @see https://doc.babylonjs.com/features/scene
  119384. */
  119385. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119386. /** The fog is deactivated */
  119387. static readonly FOGMODE_NONE: number;
  119388. /** The fog density is following an exponential function */
  119389. static readonly FOGMODE_EXP: number;
  119390. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119391. static readonly FOGMODE_EXP2: number;
  119392. /** The fog density is following a linear function. */
  119393. static readonly FOGMODE_LINEAR: number;
  119394. /**
  119395. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119396. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119397. */
  119398. static MinDeltaTime: number;
  119399. /**
  119400. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119401. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119402. */
  119403. static MaxDeltaTime: number;
  119404. /**
  119405. * Factory used to create the default material.
  119406. * @param name The name of the material to create
  119407. * @param scene The scene to create the material for
  119408. * @returns The default material
  119409. */
  119410. static DefaultMaterialFactory(scene: Scene): Material;
  119411. /**
  119412. * Factory used to create the a collision coordinator.
  119413. * @returns The collision coordinator
  119414. */
  119415. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119416. /** @hidden */
  119417. _inputManager: InputManager;
  119418. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119419. cameraToUseForPointers: Nullable<Camera>;
  119420. /** @hidden */
  119421. readonly _isScene: boolean;
  119422. /** @hidden */
  119423. _blockEntityCollection: boolean;
  119424. /**
  119425. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119426. */
  119427. autoClear: boolean;
  119428. /**
  119429. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119430. */
  119431. autoClearDepthAndStencil: boolean;
  119432. /**
  119433. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119434. */
  119435. clearColor: Color4;
  119436. /**
  119437. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119438. */
  119439. ambientColor: Color3;
  119440. /**
  119441. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119442. * It should only be one of the following (if not the default embedded one):
  119443. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119444. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119445. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119446. * The material properties need to be setup according to the type of texture in use.
  119447. */
  119448. environmentBRDFTexture: BaseTexture;
  119449. /**
  119450. * Texture used in all pbr material as the reflection texture.
  119451. * As in the majority of the scene they are the same (exception for multi room and so on),
  119452. * this is easier to reference from here than from all the materials.
  119453. */
  119454. get environmentTexture(): Nullable<BaseTexture>;
  119455. /**
  119456. * Texture used in all pbr material as the reflection texture.
  119457. * As in the majority of the scene they are the same (exception for multi room and so on),
  119458. * this is easier to set here than in all the materials.
  119459. */
  119460. set environmentTexture(value: Nullable<BaseTexture>);
  119461. /** @hidden */
  119462. protected _environmentIntensity: number;
  119463. /**
  119464. * Intensity of the environment in all pbr material.
  119465. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119466. * As in the majority of the scene they are the same (exception for multi room and so on),
  119467. * this is easier to reference from here than from all the materials.
  119468. */
  119469. get environmentIntensity(): number;
  119470. /**
  119471. * Intensity of the environment in all pbr material.
  119472. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119473. * As in the majority of the scene they are the same (exception for multi room and so on),
  119474. * this is easier to set here than in all the materials.
  119475. */
  119476. set environmentIntensity(value: number);
  119477. /** @hidden */
  119478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119479. /**
  119480. * Default image processing configuration used either in the rendering
  119481. * Forward main pass or through the imageProcessingPostProcess if present.
  119482. * As in the majority of the scene they are the same (exception for multi camera),
  119483. * this is easier to reference from here than from all the materials and post process.
  119484. *
  119485. * No setter as we it is a shared configuration, you can set the values instead.
  119486. */
  119487. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119488. private _forceWireframe;
  119489. /**
  119490. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119491. */
  119492. set forceWireframe(value: boolean);
  119493. get forceWireframe(): boolean;
  119494. private _skipFrustumClipping;
  119495. /**
  119496. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119497. */
  119498. set skipFrustumClipping(value: boolean);
  119499. get skipFrustumClipping(): boolean;
  119500. private _forcePointsCloud;
  119501. /**
  119502. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119503. */
  119504. set forcePointsCloud(value: boolean);
  119505. get forcePointsCloud(): boolean;
  119506. /**
  119507. * Gets or sets the active clipplane 1
  119508. */
  119509. clipPlane: Nullable<Plane>;
  119510. /**
  119511. * Gets or sets the active clipplane 2
  119512. */
  119513. clipPlane2: Nullable<Plane>;
  119514. /**
  119515. * Gets or sets the active clipplane 3
  119516. */
  119517. clipPlane3: Nullable<Plane>;
  119518. /**
  119519. * Gets or sets the active clipplane 4
  119520. */
  119521. clipPlane4: Nullable<Plane>;
  119522. /**
  119523. * Gets or sets the active clipplane 5
  119524. */
  119525. clipPlane5: Nullable<Plane>;
  119526. /**
  119527. * Gets or sets the active clipplane 6
  119528. */
  119529. clipPlane6: Nullable<Plane>;
  119530. /**
  119531. * Gets or sets a boolean indicating if animations are enabled
  119532. */
  119533. animationsEnabled: boolean;
  119534. private _animationPropertiesOverride;
  119535. /**
  119536. * Gets or sets the animation properties override
  119537. */
  119538. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119539. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119540. /**
  119541. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119542. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119543. */
  119544. useConstantAnimationDeltaTime: boolean;
  119545. /**
  119546. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119547. * Please note that it requires to run a ray cast through the scene on every frame
  119548. */
  119549. constantlyUpdateMeshUnderPointer: boolean;
  119550. /**
  119551. * Defines the HTML cursor to use when hovering over interactive elements
  119552. */
  119553. hoverCursor: string;
  119554. /**
  119555. * Defines the HTML default cursor to use (empty by default)
  119556. */
  119557. defaultCursor: string;
  119558. /**
  119559. * Defines whether cursors are handled by the scene.
  119560. */
  119561. doNotHandleCursors: boolean;
  119562. /**
  119563. * This is used to call preventDefault() on pointer down
  119564. * in order to block unwanted artifacts like system double clicks
  119565. */
  119566. preventDefaultOnPointerDown: boolean;
  119567. /**
  119568. * This is used to call preventDefault() on pointer up
  119569. * in order to block unwanted artifacts like system double clicks
  119570. */
  119571. preventDefaultOnPointerUp: boolean;
  119572. /**
  119573. * Gets or sets user defined metadata
  119574. */
  119575. metadata: any;
  119576. /**
  119577. * For internal use only. Please do not use.
  119578. */
  119579. reservedDataStore: any;
  119580. /**
  119581. * Gets the name of the plugin used to load this scene (null by default)
  119582. */
  119583. loadingPluginName: string;
  119584. /**
  119585. * Use this array to add regular expressions used to disable offline support for specific urls
  119586. */
  119587. disableOfflineSupportExceptionRules: RegExp[];
  119588. /**
  119589. * An event triggered when the scene is disposed.
  119590. */
  119591. onDisposeObservable: Observable<Scene>;
  119592. private _onDisposeObserver;
  119593. /** Sets a function to be executed when this scene is disposed. */
  119594. set onDispose(callback: () => void);
  119595. /**
  119596. * An event triggered before rendering the scene (right after animations and physics)
  119597. */
  119598. onBeforeRenderObservable: Observable<Scene>;
  119599. private _onBeforeRenderObserver;
  119600. /** Sets a function to be executed before rendering this scene */
  119601. set beforeRender(callback: Nullable<() => void>);
  119602. /**
  119603. * An event triggered after rendering the scene
  119604. */
  119605. onAfterRenderObservable: Observable<Scene>;
  119606. /**
  119607. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119608. */
  119609. onAfterRenderCameraObservable: Observable<Camera>;
  119610. private _onAfterRenderObserver;
  119611. /** Sets a function to be executed after rendering this scene */
  119612. set afterRender(callback: Nullable<() => void>);
  119613. /**
  119614. * An event triggered before animating the scene
  119615. */
  119616. onBeforeAnimationsObservable: Observable<Scene>;
  119617. /**
  119618. * An event triggered after animations processing
  119619. */
  119620. onAfterAnimationsObservable: Observable<Scene>;
  119621. /**
  119622. * An event triggered before draw calls are ready to be sent
  119623. */
  119624. onBeforeDrawPhaseObservable: Observable<Scene>;
  119625. /**
  119626. * An event triggered after draw calls have been sent
  119627. */
  119628. onAfterDrawPhaseObservable: Observable<Scene>;
  119629. /**
  119630. * An event triggered when the scene is ready
  119631. */
  119632. onReadyObservable: Observable<Scene>;
  119633. /**
  119634. * An event triggered before rendering a camera
  119635. */
  119636. onBeforeCameraRenderObservable: Observable<Camera>;
  119637. private _onBeforeCameraRenderObserver;
  119638. /** Sets a function to be executed before rendering a camera*/
  119639. set beforeCameraRender(callback: () => void);
  119640. /**
  119641. * An event triggered after rendering a camera
  119642. */
  119643. onAfterCameraRenderObservable: Observable<Camera>;
  119644. private _onAfterCameraRenderObserver;
  119645. /** Sets a function to be executed after rendering a camera*/
  119646. set afterCameraRender(callback: () => void);
  119647. /**
  119648. * An event triggered when active meshes evaluation is about to start
  119649. */
  119650. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119651. /**
  119652. * An event triggered when active meshes evaluation is done
  119653. */
  119654. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119655. /**
  119656. * An event triggered when particles rendering is about to start
  119657. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119658. */
  119659. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119660. /**
  119661. * An event triggered when particles rendering is done
  119662. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119663. */
  119664. onAfterParticlesRenderingObservable: Observable<Scene>;
  119665. /**
  119666. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119667. */
  119668. onDataLoadedObservable: Observable<Scene>;
  119669. /**
  119670. * An event triggered when a camera is created
  119671. */
  119672. onNewCameraAddedObservable: Observable<Camera>;
  119673. /**
  119674. * An event triggered when a camera is removed
  119675. */
  119676. onCameraRemovedObservable: Observable<Camera>;
  119677. /**
  119678. * An event triggered when a light is created
  119679. */
  119680. onNewLightAddedObservable: Observable<Light>;
  119681. /**
  119682. * An event triggered when a light is removed
  119683. */
  119684. onLightRemovedObservable: Observable<Light>;
  119685. /**
  119686. * An event triggered when a geometry is created
  119687. */
  119688. onNewGeometryAddedObservable: Observable<Geometry>;
  119689. /**
  119690. * An event triggered when a geometry is removed
  119691. */
  119692. onGeometryRemovedObservable: Observable<Geometry>;
  119693. /**
  119694. * An event triggered when a transform node is created
  119695. */
  119696. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  119697. /**
  119698. * An event triggered when a transform node is removed
  119699. */
  119700. onTransformNodeRemovedObservable: Observable<TransformNode>;
  119701. /**
  119702. * An event triggered when a mesh is created
  119703. */
  119704. onNewMeshAddedObservable: Observable<AbstractMesh>;
  119705. /**
  119706. * An event triggered when a mesh is removed
  119707. */
  119708. onMeshRemovedObservable: Observable<AbstractMesh>;
  119709. /**
  119710. * An event triggered when a skeleton is created
  119711. */
  119712. onNewSkeletonAddedObservable: Observable<Skeleton>;
  119713. /**
  119714. * An event triggered when a skeleton is removed
  119715. */
  119716. onSkeletonRemovedObservable: Observable<Skeleton>;
  119717. /**
  119718. * An event triggered when a material is created
  119719. */
  119720. onNewMaterialAddedObservable: Observable<Material>;
  119721. /**
  119722. * An event triggered when a material is removed
  119723. */
  119724. onMaterialRemovedObservable: Observable<Material>;
  119725. /**
  119726. * An event triggered when a texture is created
  119727. */
  119728. onNewTextureAddedObservable: Observable<BaseTexture>;
  119729. /**
  119730. * An event triggered when a texture is removed
  119731. */
  119732. onTextureRemovedObservable: Observable<BaseTexture>;
  119733. /**
  119734. * An event triggered when render targets are about to be rendered
  119735. * Can happen multiple times per frame.
  119736. */
  119737. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  119738. /**
  119739. * An event triggered when render targets were rendered.
  119740. * Can happen multiple times per frame.
  119741. */
  119742. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  119743. /**
  119744. * An event triggered before calculating deterministic simulation step
  119745. */
  119746. onBeforeStepObservable: Observable<Scene>;
  119747. /**
  119748. * An event triggered after calculating deterministic simulation step
  119749. */
  119750. onAfterStepObservable: Observable<Scene>;
  119751. /**
  119752. * An event triggered when the activeCamera property is updated
  119753. */
  119754. onActiveCameraChanged: Observable<Scene>;
  119755. /**
  119756. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  119757. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119758. * 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)
  119759. */
  119760. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119761. /**
  119762. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  119763. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119764. * 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)
  119765. */
  119766. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119767. /**
  119768. * This Observable will when a mesh has been imported into the scene.
  119769. */
  119770. onMeshImportedObservable: Observable<AbstractMesh>;
  119771. /**
  119772. * This Observable will when an animation file has been imported into the scene.
  119773. */
  119774. onAnimationFileImportedObservable: Observable<Scene>;
  119775. /**
  119776. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  119777. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  119778. */
  119779. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  119780. /** @hidden */
  119781. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  119782. /**
  119783. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  119784. */
  119785. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  119786. /**
  119787. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  119788. */
  119789. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  119790. /**
  119791. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  119792. */
  119793. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  119794. /** Callback called when a pointer move is detected */
  119795. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119796. /** Callback called when a pointer down is detected */
  119797. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119798. /** Callback called when a pointer up is detected */
  119799. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  119800. /** Callback called when a pointer pick is detected */
  119801. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  119802. /**
  119803. * 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).
  119804. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  119805. */
  119806. onPrePointerObservable: Observable<PointerInfoPre>;
  119807. /**
  119808. * Observable event triggered each time an input event is received from the rendering canvas
  119809. */
  119810. onPointerObservable: Observable<PointerInfo>;
  119811. /**
  119812. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  119813. */
  119814. get unTranslatedPointer(): Vector2;
  119815. /**
  119816. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  119817. */
  119818. static get DragMovementThreshold(): number;
  119819. static set DragMovementThreshold(value: number);
  119820. /**
  119821. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  119822. */
  119823. static get LongPressDelay(): number;
  119824. static set LongPressDelay(value: number);
  119825. /**
  119826. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  119827. */
  119828. static get DoubleClickDelay(): number;
  119829. static set DoubleClickDelay(value: number);
  119830. /** If you need to check double click without raising a single click at first click, enable this flag */
  119831. static get ExclusiveDoubleClickMode(): boolean;
  119832. static set ExclusiveDoubleClickMode(value: boolean);
  119833. /** @hidden */
  119834. _mirroredCameraPosition: Nullable<Vector3>;
  119835. /**
  119836. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  119837. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  119838. */
  119839. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  119840. /**
  119841. * Observable event triggered each time an keyboard event is received from the hosting window
  119842. */
  119843. onKeyboardObservable: Observable<KeyboardInfo>;
  119844. private _useRightHandedSystem;
  119845. /**
  119846. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  119847. */
  119848. set useRightHandedSystem(value: boolean);
  119849. get useRightHandedSystem(): boolean;
  119850. private _timeAccumulator;
  119851. private _currentStepId;
  119852. private _currentInternalStep;
  119853. /**
  119854. * Sets the step Id used by deterministic lock step
  119855. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119856. * @param newStepId defines the step Id
  119857. */
  119858. setStepId(newStepId: number): void;
  119859. /**
  119860. * Gets the step Id used by deterministic lock step
  119861. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119862. * @returns the step Id
  119863. */
  119864. getStepId(): number;
  119865. /**
  119866. * Gets the internal step used by deterministic lock step
  119867. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119868. * @returns the internal step
  119869. */
  119870. getInternalStep(): number;
  119871. private _fogEnabled;
  119872. /**
  119873. * Gets or sets a boolean indicating if fog is enabled on this scene
  119874. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119875. * (Default is true)
  119876. */
  119877. set fogEnabled(value: boolean);
  119878. get fogEnabled(): boolean;
  119879. private _fogMode;
  119880. /**
  119881. * Gets or sets the fog mode to use
  119882. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119883. * | mode | value |
  119884. * | --- | --- |
  119885. * | FOGMODE_NONE | 0 |
  119886. * | FOGMODE_EXP | 1 |
  119887. * | FOGMODE_EXP2 | 2 |
  119888. * | FOGMODE_LINEAR | 3 |
  119889. */
  119890. set fogMode(value: number);
  119891. get fogMode(): number;
  119892. /**
  119893. * Gets or sets the fog color to use
  119894. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119895. * (Default is Color3(0.2, 0.2, 0.3))
  119896. */
  119897. fogColor: Color3;
  119898. /**
  119899. * Gets or sets the fog density to use
  119900. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119901. * (Default is 0.1)
  119902. */
  119903. fogDensity: number;
  119904. /**
  119905. * Gets or sets the fog start distance to use
  119906. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119907. * (Default is 0)
  119908. */
  119909. fogStart: number;
  119910. /**
  119911. * Gets or sets the fog end distance to use
  119912. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119913. * (Default is 1000)
  119914. */
  119915. fogEnd: number;
  119916. /**
  119917. * Flag indicating that the frame buffer binding is handled by another component
  119918. */
  119919. prePass: boolean;
  119920. private _shadowsEnabled;
  119921. /**
  119922. * Gets or sets a boolean indicating if shadows are enabled on this scene
  119923. */
  119924. set shadowsEnabled(value: boolean);
  119925. get shadowsEnabled(): boolean;
  119926. private _lightsEnabled;
  119927. /**
  119928. * Gets or sets a boolean indicating if lights are enabled on this scene
  119929. */
  119930. set lightsEnabled(value: boolean);
  119931. get lightsEnabled(): boolean;
  119932. /** All of the active cameras added to this scene. */
  119933. activeCameras: Camera[];
  119934. /** @hidden */
  119935. _activeCamera: Nullable<Camera>;
  119936. /** Gets or sets the current active camera */
  119937. get activeCamera(): Nullable<Camera>;
  119938. set activeCamera(value: Nullable<Camera>);
  119939. private _defaultMaterial;
  119940. /** The default material used on meshes when no material is affected */
  119941. get defaultMaterial(): Material;
  119942. /** The default material used on meshes when no material is affected */
  119943. set defaultMaterial(value: Material);
  119944. private _texturesEnabled;
  119945. /**
  119946. * Gets or sets a boolean indicating if textures are enabled on this scene
  119947. */
  119948. set texturesEnabled(value: boolean);
  119949. get texturesEnabled(): boolean;
  119950. /**
  119951. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  119952. */
  119953. physicsEnabled: boolean;
  119954. /**
  119955. * Gets or sets a boolean indicating if particles are enabled on this scene
  119956. */
  119957. particlesEnabled: boolean;
  119958. /**
  119959. * Gets or sets a boolean indicating if sprites are enabled on this scene
  119960. */
  119961. spritesEnabled: boolean;
  119962. private _skeletonsEnabled;
  119963. /**
  119964. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  119965. */
  119966. set skeletonsEnabled(value: boolean);
  119967. get skeletonsEnabled(): boolean;
  119968. /**
  119969. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  119970. */
  119971. lensFlaresEnabled: boolean;
  119972. /**
  119973. * Gets or sets a boolean indicating if collisions are enabled on this scene
  119974. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119975. */
  119976. collisionsEnabled: boolean;
  119977. private _collisionCoordinator;
  119978. /** @hidden */
  119979. get collisionCoordinator(): ICollisionCoordinator;
  119980. /**
  119981. * Defines the gravity applied to this scene (used only for collisions)
  119982. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119983. */
  119984. gravity: Vector3;
  119985. /**
  119986. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  119987. */
  119988. postProcessesEnabled: boolean;
  119989. /**
  119990. * Gets the current postprocess manager
  119991. */
  119992. postProcessManager: PostProcessManager;
  119993. /**
  119994. * Gets or sets a boolean indicating if render targets are enabled on this scene
  119995. */
  119996. renderTargetsEnabled: boolean;
  119997. /**
  119998. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  119999. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120000. */
  120001. dumpNextRenderTargets: boolean;
  120002. /**
  120003. * The list of user defined render targets added to the scene
  120004. */
  120005. customRenderTargets: RenderTargetTexture[];
  120006. /**
  120007. * Defines if texture loading must be delayed
  120008. * If true, textures will only be loaded when they need to be rendered
  120009. */
  120010. useDelayedTextureLoading: boolean;
  120011. /**
  120012. * Gets the list of meshes imported to the scene through SceneLoader
  120013. */
  120014. importedMeshesFiles: String[];
  120015. /**
  120016. * Gets or sets a boolean indicating if probes are enabled on this scene
  120017. */
  120018. probesEnabled: boolean;
  120019. /**
  120020. * Gets or sets the current offline provider to use to store scene data
  120021. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120022. */
  120023. offlineProvider: IOfflineProvider;
  120024. /**
  120025. * Gets or sets the action manager associated with the scene
  120026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120027. */
  120028. actionManager: AbstractActionManager;
  120029. private _meshesForIntersections;
  120030. /**
  120031. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120032. */
  120033. proceduralTexturesEnabled: boolean;
  120034. private _engine;
  120035. private _totalVertices;
  120036. /** @hidden */
  120037. _activeIndices: PerfCounter;
  120038. /** @hidden */
  120039. _activeParticles: PerfCounter;
  120040. /** @hidden */
  120041. _activeBones: PerfCounter;
  120042. private _animationRatio;
  120043. /** @hidden */
  120044. _animationTimeLast: number;
  120045. /** @hidden */
  120046. _animationTime: number;
  120047. /**
  120048. * Gets or sets a general scale for animation speed
  120049. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120050. */
  120051. animationTimeScale: number;
  120052. /** @hidden */
  120053. _cachedMaterial: Nullable<Material>;
  120054. /** @hidden */
  120055. _cachedEffect: Nullable<Effect>;
  120056. /** @hidden */
  120057. _cachedVisibility: Nullable<number>;
  120058. private _renderId;
  120059. private _frameId;
  120060. private _executeWhenReadyTimeoutId;
  120061. private _intermediateRendering;
  120062. private _viewUpdateFlag;
  120063. private _projectionUpdateFlag;
  120064. /** @hidden */
  120065. _toBeDisposed: Nullable<IDisposable>[];
  120066. private _activeRequests;
  120067. /** @hidden */
  120068. _pendingData: any[];
  120069. private _isDisposed;
  120070. /**
  120071. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120072. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120073. */
  120074. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120075. private _activeMeshes;
  120076. private _processedMaterials;
  120077. private _renderTargets;
  120078. /** @hidden */
  120079. _activeParticleSystems: SmartArray<IParticleSystem>;
  120080. private _activeSkeletons;
  120081. private _softwareSkinnedMeshes;
  120082. private _renderingManager;
  120083. /** @hidden */
  120084. _activeAnimatables: Animatable[];
  120085. private _transformMatrix;
  120086. private _sceneUbo;
  120087. /** @hidden */
  120088. _viewMatrix: Matrix;
  120089. private _projectionMatrix;
  120090. /** @hidden */
  120091. _forcedViewPosition: Nullable<Vector3>;
  120092. /** @hidden */
  120093. _frustumPlanes: Plane[];
  120094. /**
  120095. * Gets the list of frustum planes (built from the active camera)
  120096. */
  120097. get frustumPlanes(): Plane[];
  120098. /**
  120099. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120100. * This is useful if there are more lights that the maximum simulteanous authorized
  120101. */
  120102. requireLightSorting: boolean;
  120103. /** @hidden */
  120104. readonly useMaterialMeshMap: boolean;
  120105. /** @hidden */
  120106. readonly useClonedMeshMap: boolean;
  120107. private _externalData;
  120108. private _uid;
  120109. /**
  120110. * @hidden
  120111. * Backing store of defined scene components.
  120112. */
  120113. _components: ISceneComponent[];
  120114. /**
  120115. * @hidden
  120116. * Backing store of defined scene components.
  120117. */
  120118. _serializableComponents: ISceneSerializableComponent[];
  120119. /**
  120120. * List of components to register on the next registration step.
  120121. */
  120122. private _transientComponents;
  120123. /**
  120124. * Registers the transient components if needed.
  120125. */
  120126. private _registerTransientComponents;
  120127. /**
  120128. * @hidden
  120129. * Add a component to the scene.
  120130. * Note that the ccomponent could be registered on th next frame if this is called after
  120131. * the register component stage.
  120132. * @param component Defines the component to add to the scene
  120133. */
  120134. _addComponent(component: ISceneComponent): void;
  120135. /**
  120136. * @hidden
  120137. * Gets a component from the scene.
  120138. * @param name defines the name of the component to retrieve
  120139. * @returns the component or null if not present
  120140. */
  120141. _getComponent(name: string): Nullable<ISceneComponent>;
  120142. /**
  120143. * @hidden
  120144. * Defines the actions happening before camera updates.
  120145. */
  120146. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120147. /**
  120148. * @hidden
  120149. * Defines the actions happening before clear the canvas.
  120150. */
  120151. _beforeClearStage: Stage<SimpleStageAction>;
  120152. /**
  120153. * @hidden
  120154. * Defines the actions when collecting render targets for the frame.
  120155. */
  120156. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120157. /**
  120158. * @hidden
  120159. * Defines the actions happening for one camera in the frame.
  120160. */
  120161. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120162. /**
  120163. * @hidden
  120164. * Defines the actions happening during the per mesh ready checks.
  120165. */
  120166. _isReadyForMeshStage: Stage<MeshStageAction>;
  120167. /**
  120168. * @hidden
  120169. * Defines the actions happening before evaluate active mesh checks.
  120170. */
  120171. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120172. /**
  120173. * @hidden
  120174. * Defines the actions happening during the evaluate sub mesh checks.
  120175. */
  120176. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120177. /**
  120178. * @hidden
  120179. * Defines the actions happening during the active mesh stage.
  120180. */
  120181. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120182. /**
  120183. * @hidden
  120184. * Defines the actions happening during the per camera render target step.
  120185. */
  120186. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120187. /**
  120188. * @hidden
  120189. * Defines the actions happening just before the active camera is drawing.
  120190. */
  120191. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120192. /**
  120193. * @hidden
  120194. * Defines the actions happening just before a render target is drawing.
  120195. */
  120196. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120197. /**
  120198. * @hidden
  120199. * Defines the actions happening just before a rendering group is drawing.
  120200. */
  120201. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120202. /**
  120203. * @hidden
  120204. * Defines the actions happening just before a mesh is drawing.
  120205. */
  120206. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120207. /**
  120208. * @hidden
  120209. * Defines the actions happening just after a mesh has been drawn.
  120210. */
  120211. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120212. /**
  120213. * @hidden
  120214. * Defines the actions happening just after a rendering group has been drawn.
  120215. */
  120216. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120217. /**
  120218. * @hidden
  120219. * Defines the actions happening just after the active camera has been drawn.
  120220. */
  120221. _afterCameraDrawStage: Stage<CameraStageAction>;
  120222. /**
  120223. * @hidden
  120224. * Defines the actions happening just after a render target has been drawn.
  120225. */
  120226. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120227. /**
  120228. * @hidden
  120229. * Defines the actions happening just after rendering all cameras and computing intersections.
  120230. */
  120231. _afterRenderStage: Stage<SimpleStageAction>;
  120232. /**
  120233. * @hidden
  120234. * Defines the actions happening when a pointer move event happens.
  120235. */
  120236. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120237. /**
  120238. * @hidden
  120239. * Defines the actions happening when a pointer down event happens.
  120240. */
  120241. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120242. /**
  120243. * @hidden
  120244. * Defines the actions happening when a pointer up event happens.
  120245. */
  120246. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120247. /**
  120248. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120249. */
  120250. private geometriesByUniqueId;
  120251. /**
  120252. * Creates a new Scene
  120253. * @param engine defines the engine to use to render this scene
  120254. * @param options defines the scene options
  120255. */
  120256. constructor(engine: Engine, options?: SceneOptions);
  120257. /**
  120258. * Gets a string identifying the name of the class
  120259. * @returns "Scene" string
  120260. */
  120261. getClassName(): string;
  120262. private _defaultMeshCandidates;
  120263. /**
  120264. * @hidden
  120265. */
  120266. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120267. private _defaultSubMeshCandidates;
  120268. /**
  120269. * @hidden
  120270. */
  120271. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120272. /**
  120273. * Sets the default candidate providers for the scene.
  120274. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120275. * and getCollidingSubMeshCandidates to their default function
  120276. */
  120277. setDefaultCandidateProviders(): void;
  120278. /**
  120279. * Gets the mesh that is currently under the pointer
  120280. */
  120281. get meshUnderPointer(): Nullable<AbstractMesh>;
  120282. /**
  120283. * Gets or sets the current on-screen X position of the pointer
  120284. */
  120285. get pointerX(): number;
  120286. set pointerX(value: number);
  120287. /**
  120288. * Gets or sets the current on-screen Y position of the pointer
  120289. */
  120290. get pointerY(): number;
  120291. set pointerY(value: number);
  120292. /**
  120293. * Gets the cached material (ie. the latest rendered one)
  120294. * @returns the cached material
  120295. */
  120296. getCachedMaterial(): Nullable<Material>;
  120297. /**
  120298. * Gets the cached effect (ie. the latest rendered one)
  120299. * @returns the cached effect
  120300. */
  120301. getCachedEffect(): Nullable<Effect>;
  120302. /**
  120303. * Gets the cached visibility state (ie. the latest rendered one)
  120304. * @returns the cached visibility state
  120305. */
  120306. getCachedVisibility(): Nullable<number>;
  120307. /**
  120308. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120309. * @param material defines the current material
  120310. * @param effect defines the current effect
  120311. * @param visibility defines the current visibility state
  120312. * @returns true if one parameter is not cached
  120313. */
  120314. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120315. /**
  120316. * Gets the engine associated with the scene
  120317. * @returns an Engine
  120318. */
  120319. getEngine(): Engine;
  120320. /**
  120321. * Gets the total number of vertices rendered per frame
  120322. * @returns the total number of vertices rendered per frame
  120323. */
  120324. getTotalVertices(): number;
  120325. /**
  120326. * Gets the performance counter for total vertices
  120327. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120328. */
  120329. get totalVerticesPerfCounter(): PerfCounter;
  120330. /**
  120331. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120332. * @returns the total number of active indices rendered per frame
  120333. */
  120334. getActiveIndices(): number;
  120335. /**
  120336. * Gets the performance counter for active indices
  120337. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120338. */
  120339. get totalActiveIndicesPerfCounter(): PerfCounter;
  120340. /**
  120341. * Gets the total number of active particles rendered per frame
  120342. * @returns the total number of active particles rendered per frame
  120343. */
  120344. getActiveParticles(): number;
  120345. /**
  120346. * Gets the performance counter for active particles
  120347. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120348. */
  120349. get activeParticlesPerfCounter(): PerfCounter;
  120350. /**
  120351. * Gets the total number of active bones rendered per frame
  120352. * @returns the total number of active bones rendered per frame
  120353. */
  120354. getActiveBones(): number;
  120355. /**
  120356. * Gets the performance counter for active bones
  120357. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120358. */
  120359. get activeBonesPerfCounter(): PerfCounter;
  120360. /**
  120361. * Gets the array of active meshes
  120362. * @returns an array of AbstractMesh
  120363. */
  120364. getActiveMeshes(): SmartArray<AbstractMesh>;
  120365. /**
  120366. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120367. * @returns a number
  120368. */
  120369. getAnimationRatio(): number;
  120370. /**
  120371. * Gets an unique Id for the current render phase
  120372. * @returns a number
  120373. */
  120374. getRenderId(): number;
  120375. /**
  120376. * Gets an unique Id for the current frame
  120377. * @returns a number
  120378. */
  120379. getFrameId(): number;
  120380. /** Call this function if you want to manually increment the render Id*/
  120381. incrementRenderId(): void;
  120382. private _createUbo;
  120383. /**
  120384. * Use this method to simulate a pointer move on a mesh
  120385. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120386. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120387. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120388. * @returns the current scene
  120389. */
  120390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120391. /**
  120392. * Use this method to simulate a pointer down on a mesh
  120393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120396. * @returns the current scene
  120397. */
  120398. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120399. /**
  120400. * Use this method to simulate a pointer up on a mesh
  120401. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120402. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120403. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120404. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120405. * @returns the current scene
  120406. */
  120407. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120408. /**
  120409. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120410. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120411. * @returns true if the pointer was captured
  120412. */
  120413. isPointerCaptured(pointerId?: number): boolean;
  120414. /**
  120415. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120416. * @param attachUp defines if you want to attach events to pointerup
  120417. * @param attachDown defines if you want to attach events to pointerdown
  120418. * @param attachMove defines if you want to attach events to pointermove
  120419. */
  120420. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120421. /** Detaches all event handlers*/
  120422. detachControl(): void;
  120423. /**
  120424. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120425. * Delay loaded resources are not taking in account
  120426. * @return true if all required resources are ready
  120427. */
  120428. isReady(): boolean;
  120429. /** Resets all cached information relative to material (including effect and visibility) */
  120430. resetCachedMaterial(): void;
  120431. /**
  120432. * Registers a function to be called before every frame render
  120433. * @param func defines the function to register
  120434. */
  120435. registerBeforeRender(func: () => void): void;
  120436. /**
  120437. * Unregisters a function called before every frame render
  120438. * @param func defines the function to unregister
  120439. */
  120440. unregisterBeforeRender(func: () => void): void;
  120441. /**
  120442. * Registers a function to be called after every frame render
  120443. * @param func defines the function to register
  120444. */
  120445. registerAfterRender(func: () => void): void;
  120446. /**
  120447. * Unregisters a function called after every frame render
  120448. * @param func defines the function to unregister
  120449. */
  120450. unregisterAfterRender(func: () => void): void;
  120451. private _executeOnceBeforeRender;
  120452. /**
  120453. * The provided function will run before render once and will be disposed afterwards.
  120454. * A timeout delay can be provided so that the function will be executed in N ms.
  120455. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120456. * @param func The function to be executed.
  120457. * @param timeout optional delay in ms
  120458. */
  120459. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120460. /** @hidden */
  120461. _addPendingData(data: any): void;
  120462. /** @hidden */
  120463. _removePendingData(data: any): void;
  120464. /**
  120465. * Returns the number of items waiting to be loaded
  120466. * @returns the number of items waiting to be loaded
  120467. */
  120468. getWaitingItemsCount(): number;
  120469. /**
  120470. * Returns a boolean indicating if the scene is still loading data
  120471. */
  120472. get isLoading(): boolean;
  120473. /**
  120474. * Registers a function to be executed when the scene is ready
  120475. * @param {Function} func - the function to be executed
  120476. */
  120477. executeWhenReady(func: () => void): void;
  120478. /**
  120479. * Returns a promise that resolves when the scene is ready
  120480. * @returns A promise that resolves when the scene is ready
  120481. */
  120482. whenReadyAsync(): Promise<void>;
  120483. /** @hidden */
  120484. _checkIsReady(): void;
  120485. /**
  120486. * Gets all animatable attached to the scene
  120487. */
  120488. get animatables(): Animatable[];
  120489. /**
  120490. * Resets the last animation time frame.
  120491. * Useful to override when animations start running when loading a scene for the first time.
  120492. */
  120493. resetLastAnimationTimeFrame(): void;
  120494. /**
  120495. * Gets the current view matrix
  120496. * @returns a Matrix
  120497. */
  120498. getViewMatrix(): Matrix;
  120499. /**
  120500. * Gets the current projection matrix
  120501. * @returns a Matrix
  120502. */
  120503. getProjectionMatrix(): Matrix;
  120504. /**
  120505. * Gets the current transform matrix
  120506. * @returns a Matrix made of View * Projection
  120507. */
  120508. getTransformMatrix(): Matrix;
  120509. /**
  120510. * Sets the current transform matrix
  120511. * @param viewL defines the View matrix to use
  120512. * @param projectionL defines the Projection matrix to use
  120513. * @param viewR defines the right View matrix to use (if provided)
  120514. * @param projectionR defines the right Projection matrix to use (if provided)
  120515. */
  120516. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120517. /**
  120518. * Gets the uniform buffer used to store scene data
  120519. * @returns a UniformBuffer
  120520. */
  120521. getSceneUniformBuffer(): UniformBuffer;
  120522. /**
  120523. * Gets an unique (relatively to the current scene) Id
  120524. * @returns an unique number for the scene
  120525. */
  120526. getUniqueId(): number;
  120527. /**
  120528. * Add a mesh to the list of scene's meshes
  120529. * @param newMesh defines the mesh to add
  120530. * @param recursive if all child meshes should also be added to the scene
  120531. */
  120532. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120533. /**
  120534. * Remove a mesh for the list of scene's meshes
  120535. * @param toRemove defines the mesh to remove
  120536. * @param recursive if all child meshes should also be removed from the scene
  120537. * @returns the index where the mesh was in the mesh list
  120538. */
  120539. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120540. /**
  120541. * Add a transform node to the list of scene's transform nodes
  120542. * @param newTransformNode defines the transform node to add
  120543. */
  120544. addTransformNode(newTransformNode: TransformNode): void;
  120545. /**
  120546. * Remove a transform node for the list of scene's transform nodes
  120547. * @param toRemove defines the transform node to remove
  120548. * @returns the index where the transform node was in the transform node list
  120549. */
  120550. removeTransformNode(toRemove: TransformNode): number;
  120551. /**
  120552. * Remove a skeleton for the list of scene's skeletons
  120553. * @param toRemove defines the skeleton to remove
  120554. * @returns the index where the skeleton was in the skeleton list
  120555. */
  120556. removeSkeleton(toRemove: Skeleton): number;
  120557. /**
  120558. * Remove a morph target for the list of scene's morph targets
  120559. * @param toRemove defines the morph target to remove
  120560. * @returns the index where the morph target was in the morph target list
  120561. */
  120562. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120563. /**
  120564. * Remove a light for the list of scene's lights
  120565. * @param toRemove defines the light to remove
  120566. * @returns the index where the light was in the light list
  120567. */
  120568. removeLight(toRemove: Light): number;
  120569. /**
  120570. * Remove a camera for the list of scene's cameras
  120571. * @param toRemove defines the camera to remove
  120572. * @returns the index where the camera was in the camera list
  120573. */
  120574. removeCamera(toRemove: Camera): number;
  120575. /**
  120576. * Remove a particle system for the list of scene's particle systems
  120577. * @param toRemove defines the particle system to remove
  120578. * @returns the index where the particle system was in the particle system list
  120579. */
  120580. removeParticleSystem(toRemove: IParticleSystem): number;
  120581. /**
  120582. * Remove a animation for the list of scene's animations
  120583. * @param toRemove defines the animation to remove
  120584. * @returns the index where the animation was in the animation list
  120585. */
  120586. removeAnimation(toRemove: Animation): number;
  120587. /**
  120588. * Will stop the animation of the given target
  120589. * @param target - the target
  120590. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120591. * @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)
  120592. */
  120593. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120594. /**
  120595. * Removes the given animation group from this scene.
  120596. * @param toRemove The animation group to remove
  120597. * @returns The index of the removed animation group
  120598. */
  120599. removeAnimationGroup(toRemove: AnimationGroup): number;
  120600. /**
  120601. * Removes the given multi-material from this scene.
  120602. * @param toRemove The multi-material to remove
  120603. * @returns The index of the removed multi-material
  120604. */
  120605. removeMultiMaterial(toRemove: MultiMaterial): number;
  120606. /**
  120607. * Removes the given material from this scene.
  120608. * @param toRemove The material to remove
  120609. * @returns The index of the removed material
  120610. */
  120611. removeMaterial(toRemove: Material): number;
  120612. /**
  120613. * Removes the given action manager from this scene.
  120614. * @param toRemove The action manager to remove
  120615. * @returns The index of the removed action manager
  120616. */
  120617. removeActionManager(toRemove: AbstractActionManager): number;
  120618. /**
  120619. * Removes the given texture from this scene.
  120620. * @param toRemove The texture to remove
  120621. * @returns The index of the removed texture
  120622. */
  120623. removeTexture(toRemove: BaseTexture): number;
  120624. /**
  120625. * Adds the given light to this scene
  120626. * @param newLight The light to add
  120627. */
  120628. addLight(newLight: Light): void;
  120629. /**
  120630. * Sorts the list list based on light priorities
  120631. */
  120632. sortLightsByPriority(): void;
  120633. /**
  120634. * Adds the given camera to this scene
  120635. * @param newCamera The camera to add
  120636. */
  120637. addCamera(newCamera: Camera): void;
  120638. /**
  120639. * Adds the given skeleton to this scene
  120640. * @param newSkeleton The skeleton to add
  120641. */
  120642. addSkeleton(newSkeleton: Skeleton): void;
  120643. /**
  120644. * Adds the given particle system to this scene
  120645. * @param newParticleSystem The particle system to add
  120646. */
  120647. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120648. /**
  120649. * Adds the given animation to this scene
  120650. * @param newAnimation The animation to add
  120651. */
  120652. addAnimation(newAnimation: Animation): void;
  120653. /**
  120654. * Adds the given animation group to this scene.
  120655. * @param newAnimationGroup The animation group to add
  120656. */
  120657. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120658. /**
  120659. * Adds the given multi-material to this scene
  120660. * @param newMultiMaterial The multi-material to add
  120661. */
  120662. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120663. /**
  120664. * Adds the given material to this scene
  120665. * @param newMaterial The material to add
  120666. */
  120667. addMaterial(newMaterial: Material): void;
  120668. /**
  120669. * Adds the given morph target to this scene
  120670. * @param newMorphTargetManager The morph target to add
  120671. */
  120672. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  120673. /**
  120674. * Adds the given geometry to this scene
  120675. * @param newGeometry The geometry to add
  120676. */
  120677. addGeometry(newGeometry: Geometry): void;
  120678. /**
  120679. * Adds the given action manager to this scene
  120680. * @param newActionManager The action manager to add
  120681. */
  120682. addActionManager(newActionManager: AbstractActionManager): void;
  120683. /**
  120684. * Adds the given texture to this scene.
  120685. * @param newTexture The texture to add
  120686. */
  120687. addTexture(newTexture: BaseTexture): void;
  120688. /**
  120689. * Switch active camera
  120690. * @param newCamera defines the new active camera
  120691. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  120692. */
  120693. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  120694. /**
  120695. * sets the active camera of the scene using its ID
  120696. * @param id defines the camera's ID
  120697. * @return the new active camera or null if none found.
  120698. */
  120699. setActiveCameraByID(id: string): Nullable<Camera>;
  120700. /**
  120701. * sets the active camera of the scene using its name
  120702. * @param name defines the camera's name
  120703. * @returns the new active camera or null if none found.
  120704. */
  120705. setActiveCameraByName(name: string): Nullable<Camera>;
  120706. /**
  120707. * get an animation group using its name
  120708. * @param name defines the material's name
  120709. * @return the animation group or null if none found.
  120710. */
  120711. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  120712. /**
  120713. * Get a material using its unique id
  120714. * @param uniqueId defines the material's unique id
  120715. * @return the material or null if none found.
  120716. */
  120717. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  120718. /**
  120719. * get a material using its id
  120720. * @param id defines the material's ID
  120721. * @return the material or null if none found.
  120722. */
  120723. getMaterialByID(id: string): Nullable<Material>;
  120724. /**
  120725. * Gets a the last added material using a given id
  120726. * @param id defines the material's ID
  120727. * @return the last material with the given id or null if none found.
  120728. */
  120729. getLastMaterialByID(id: string): Nullable<Material>;
  120730. /**
  120731. * Gets a material using its name
  120732. * @param name defines the material's name
  120733. * @return the material or null if none found.
  120734. */
  120735. getMaterialByName(name: string): Nullable<Material>;
  120736. /**
  120737. * Get a texture using its unique id
  120738. * @param uniqueId defines the texture's unique id
  120739. * @return the texture or null if none found.
  120740. */
  120741. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  120742. /**
  120743. * Gets a camera using its id
  120744. * @param id defines the id to look for
  120745. * @returns the camera or null if not found
  120746. */
  120747. getCameraByID(id: string): Nullable<Camera>;
  120748. /**
  120749. * Gets a camera using its unique id
  120750. * @param uniqueId defines the unique id to look for
  120751. * @returns the camera or null if not found
  120752. */
  120753. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  120754. /**
  120755. * Gets a camera using its name
  120756. * @param name defines the camera's name
  120757. * @return the camera or null if none found.
  120758. */
  120759. getCameraByName(name: string): Nullable<Camera>;
  120760. /**
  120761. * Gets a bone using its id
  120762. * @param id defines the bone's id
  120763. * @return the bone or null if not found
  120764. */
  120765. getBoneByID(id: string): Nullable<Bone>;
  120766. /**
  120767. * Gets a bone using its id
  120768. * @param name defines the bone's name
  120769. * @return the bone or null if not found
  120770. */
  120771. getBoneByName(name: string): Nullable<Bone>;
  120772. /**
  120773. * Gets a light node using its name
  120774. * @param name defines the the light's name
  120775. * @return the light or null if none found.
  120776. */
  120777. getLightByName(name: string): Nullable<Light>;
  120778. /**
  120779. * Gets a light node using its id
  120780. * @param id defines the light's id
  120781. * @return the light or null if none found.
  120782. */
  120783. getLightByID(id: string): Nullable<Light>;
  120784. /**
  120785. * Gets a light node using its scene-generated unique ID
  120786. * @param uniqueId defines the light's unique id
  120787. * @return the light or null if none found.
  120788. */
  120789. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  120790. /**
  120791. * Gets a particle system by id
  120792. * @param id defines the particle system id
  120793. * @return the corresponding system or null if none found
  120794. */
  120795. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  120796. /**
  120797. * Gets a geometry using its ID
  120798. * @param id defines the geometry's id
  120799. * @return the geometry or null if none found.
  120800. */
  120801. getGeometryByID(id: string): Nullable<Geometry>;
  120802. private _getGeometryByUniqueID;
  120803. /**
  120804. * Add a new geometry to this scene
  120805. * @param geometry defines the geometry to be added to the scene.
  120806. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  120807. * @return a boolean defining if the geometry was added or not
  120808. */
  120809. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  120810. /**
  120811. * Removes an existing geometry
  120812. * @param geometry defines the geometry to be removed from the scene
  120813. * @return a boolean defining if the geometry was removed or not
  120814. */
  120815. removeGeometry(geometry: Geometry): boolean;
  120816. /**
  120817. * Gets the list of geometries attached to the scene
  120818. * @returns an array of Geometry
  120819. */
  120820. getGeometries(): Geometry[];
  120821. /**
  120822. * Gets the first added mesh found of a given ID
  120823. * @param id defines the id to search for
  120824. * @return the mesh found or null if not found at all
  120825. */
  120826. getMeshByID(id: string): Nullable<AbstractMesh>;
  120827. /**
  120828. * Gets a list of meshes using their id
  120829. * @param id defines the id to search for
  120830. * @returns a list of meshes
  120831. */
  120832. getMeshesByID(id: string): Array<AbstractMesh>;
  120833. /**
  120834. * Gets the first added transform node found of a given ID
  120835. * @param id defines the id to search for
  120836. * @return the found transform node or null if not found at all.
  120837. */
  120838. getTransformNodeByID(id: string): Nullable<TransformNode>;
  120839. /**
  120840. * Gets a transform node with its auto-generated unique id
  120841. * @param uniqueId efines the unique id to search for
  120842. * @return the found transform node or null if not found at all.
  120843. */
  120844. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  120845. /**
  120846. * Gets a list of transform nodes using their id
  120847. * @param id defines the id to search for
  120848. * @returns a list of transform nodes
  120849. */
  120850. getTransformNodesByID(id: string): Array<TransformNode>;
  120851. /**
  120852. * Gets a mesh with its auto-generated unique id
  120853. * @param uniqueId defines the unique id to search for
  120854. * @return the found mesh or null if not found at all.
  120855. */
  120856. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  120857. /**
  120858. * Gets a the last added mesh using a given id
  120859. * @param id defines the id to search for
  120860. * @return the found mesh or null if not found at all.
  120861. */
  120862. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  120863. /**
  120864. * Gets a the last added node (Mesh, Camera, Light) using a given id
  120865. * @param id defines the id to search for
  120866. * @return the found node or null if not found at all
  120867. */
  120868. getLastEntryByID(id: string): Nullable<Node>;
  120869. /**
  120870. * Gets a node (Mesh, Camera, Light) using a given id
  120871. * @param id defines the id to search for
  120872. * @return the found node or null if not found at all
  120873. */
  120874. getNodeByID(id: string): Nullable<Node>;
  120875. /**
  120876. * Gets a node (Mesh, Camera, Light) using a given name
  120877. * @param name defines the name to search for
  120878. * @return the found node or null if not found at all.
  120879. */
  120880. getNodeByName(name: string): Nullable<Node>;
  120881. /**
  120882. * Gets a mesh using a given name
  120883. * @param name defines the name to search for
  120884. * @return the found mesh or null if not found at all.
  120885. */
  120886. getMeshByName(name: string): Nullable<AbstractMesh>;
  120887. /**
  120888. * Gets a transform node using a given name
  120889. * @param name defines the name to search for
  120890. * @return the found transform node or null if not found at all.
  120891. */
  120892. getTransformNodeByName(name: string): Nullable<TransformNode>;
  120893. /**
  120894. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  120895. * @param id defines the id to search for
  120896. * @return the found skeleton or null if not found at all.
  120897. */
  120898. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  120899. /**
  120900. * Gets a skeleton using a given auto generated unique id
  120901. * @param uniqueId defines the unique id to search for
  120902. * @return the found skeleton or null if not found at all.
  120903. */
  120904. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  120905. /**
  120906. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  120907. * @param id defines the id to search for
  120908. * @return the found skeleton or null if not found at all.
  120909. */
  120910. getSkeletonById(id: string): Nullable<Skeleton>;
  120911. /**
  120912. * Gets a skeleton using a given name
  120913. * @param name defines the name to search for
  120914. * @return the found skeleton or null if not found at all.
  120915. */
  120916. getSkeletonByName(name: string): Nullable<Skeleton>;
  120917. /**
  120918. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  120919. * @param id defines the id to search for
  120920. * @return the found morph target manager or null if not found at all.
  120921. */
  120922. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  120923. /**
  120924. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  120925. * @param id defines the id to search for
  120926. * @return the found morph target or null if not found at all.
  120927. */
  120928. getMorphTargetById(id: string): Nullable<MorphTarget>;
  120929. /**
  120930. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  120931. * @param name defines the name to search for
  120932. * @return the found morph target or null if not found at all.
  120933. */
  120934. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  120935. /**
  120936. * Gets a post process using a given name (if many are found, this function will pick the first one)
  120937. * @param name defines the name to search for
  120938. * @return the found post process or null if not found at all.
  120939. */
  120940. getPostProcessByName(name: string): Nullable<PostProcess>;
  120941. /**
  120942. * Gets a boolean indicating if the given mesh is active
  120943. * @param mesh defines the mesh to look for
  120944. * @returns true if the mesh is in the active list
  120945. */
  120946. isActiveMesh(mesh: AbstractMesh): boolean;
  120947. /**
  120948. * Return a unique id as a string which can serve as an identifier for the scene
  120949. */
  120950. get uid(): string;
  120951. /**
  120952. * Add an externaly attached data from its key.
  120953. * This method call will fail and return false, if such key already exists.
  120954. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  120955. * @param key the unique key that identifies the data
  120956. * @param data the data object to associate to the key for this Engine instance
  120957. * @return true if no such key were already present and the data was added successfully, false otherwise
  120958. */
  120959. addExternalData<T>(key: string, data: T): boolean;
  120960. /**
  120961. * Get an externaly attached data from its key
  120962. * @param key the unique key that identifies the data
  120963. * @return the associated data, if present (can be null), or undefined if not present
  120964. */
  120965. getExternalData<T>(key: string): Nullable<T>;
  120966. /**
  120967. * Get an externaly attached data from its key, create it using a factory if it's not already present
  120968. * @param key the unique key that identifies the data
  120969. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  120970. * @return the associated data, can be null if the factory returned null.
  120971. */
  120972. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  120973. /**
  120974. * Remove an externaly attached data from the Engine instance
  120975. * @param key the unique key that identifies the data
  120976. * @return true if the data was successfully removed, false if it doesn't exist
  120977. */
  120978. removeExternalData(key: string): boolean;
  120979. private _evaluateSubMesh;
  120980. /**
  120981. * Clear the processed materials smart array preventing retention point in material dispose.
  120982. */
  120983. freeProcessedMaterials(): void;
  120984. private _preventFreeActiveMeshesAndRenderingGroups;
  120985. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  120986. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  120987. * when disposing several meshes in a row or a hierarchy of meshes.
  120988. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  120989. */
  120990. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  120991. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  120992. /**
  120993. * Clear the active meshes smart array preventing retention point in mesh dispose.
  120994. */
  120995. freeActiveMeshes(): void;
  120996. /**
  120997. * Clear the info related to rendering groups preventing retention points during dispose.
  120998. */
  120999. freeRenderingGroups(): void;
  121000. /** @hidden */
  121001. _isInIntermediateRendering(): boolean;
  121002. /**
  121003. * Lambda returning the list of potentially active meshes.
  121004. */
  121005. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121006. /**
  121007. * Lambda returning the list of potentially active sub meshes.
  121008. */
  121009. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121010. /**
  121011. * Lambda returning the list of potentially intersecting sub meshes.
  121012. */
  121013. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121014. /**
  121015. * Lambda returning the list of potentially colliding sub meshes.
  121016. */
  121017. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121018. private _activeMeshesFrozen;
  121019. private _skipEvaluateActiveMeshesCompletely;
  121020. /**
  121021. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121022. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121023. * @returns the current scene
  121024. */
  121025. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121026. /**
  121027. * Use this function to restart evaluating active meshes on every frame
  121028. * @returns the current scene
  121029. */
  121030. unfreezeActiveMeshes(): Scene;
  121031. private _evaluateActiveMeshes;
  121032. private _activeMesh;
  121033. /**
  121034. * Update the transform matrix to update from the current active camera
  121035. * @param force defines a boolean used to force the update even if cache is up to date
  121036. */
  121037. updateTransformMatrix(force?: boolean): void;
  121038. private _bindFrameBuffer;
  121039. /** @hidden */
  121040. _allowPostProcessClearColor: boolean;
  121041. /** @hidden */
  121042. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121043. private _processSubCameras;
  121044. private _checkIntersections;
  121045. /** @hidden */
  121046. _advancePhysicsEngineStep(step: number): void;
  121047. /**
  121048. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121049. */
  121050. getDeterministicFrameTime: () => number;
  121051. /** @hidden */
  121052. _animate(): void;
  121053. /** Execute all animations (for a frame) */
  121054. animate(): void;
  121055. /**
  121056. * Render the scene
  121057. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121058. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121059. */
  121060. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121061. /**
  121062. * Freeze all materials
  121063. * A frozen material will not be updatable but should be faster to render
  121064. */
  121065. freezeMaterials(): void;
  121066. /**
  121067. * Unfreeze all materials
  121068. * A frozen material will not be updatable but should be faster to render
  121069. */
  121070. unfreezeMaterials(): void;
  121071. /**
  121072. * Releases all held ressources
  121073. */
  121074. dispose(): void;
  121075. /**
  121076. * Gets if the scene is already disposed
  121077. */
  121078. get isDisposed(): boolean;
  121079. /**
  121080. * Call this function to reduce memory footprint of the scene.
  121081. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121082. */
  121083. clearCachedVertexData(): void;
  121084. /**
  121085. * This function will remove the local cached buffer data from texture.
  121086. * It will save memory but will prevent the texture from being rebuilt
  121087. */
  121088. cleanCachedTextureBuffer(): void;
  121089. /**
  121090. * Get the world extend vectors with an optional filter
  121091. *
  121092. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121093. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121094. */
  121095. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121096. min: Vector3;
  121097. max: Vector3;
  121098. };
  121099. /**
  121100. * Creates a ray that can be used to pick in the scene
  121101. * @param x defines the x coordinate of the origin (on-screen)
  121102. * @param y defines the y coordinate of the origin (on-screen)
  121103. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121104. * @param camera defines the camera to use for the picking
  121105. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121106. * @returns a Ray
  121107. */
  121108. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121109. /**
  121110. * Creates a ray that can be used to pick in the scene
  121111. * @param x defines the x coordinate of the origin (on-screen)
  121112. * @param y defines the y coordinate of the origin (on-screen)
  121113. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121114. * @param result defines the ray where to store the picking ray
  121115. * @param camera defines the camera to use for the picking
  121116. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121117. * @returns the current scene
  121118. */
  121119. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121120. /**
  121121. * Creates a ray that can be used to pick in the scene
  121122. * @param x defines the x coordinate of the origin (on-screen)
  121123. * @param y defines the y coordinate of the origin (on-screen)
  121124. * @param camera defines the camera to use for the picking
  121125. * @returns a Ray
  121126. */
  121127. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121128. /**
  121129. * Creates a ray that can be used to pick in the scene
  121130. * @param x defines the x coordinate of the origin (on-screen)
  121131. * @param y defines the y coordinate of the origin (on-screen)
  121132. * @param result defines the ray where to store the picking ray
  121133. * @param camera defines the camera to use for the picking
  121134. * @returns the current scene
  121135. */
  121136. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121137. /** Launch a ray to try to pick a mesh in the scene
  121138. * @param x position on screen
  121139. * @param y position on screen
  121140. * @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
  121141. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121142. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121143. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121144. * @returns a PickingInfo
  121145. */
  121146. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121147. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121148. * @param x position on screen
  121149. * @param y position on screen
  121150. * @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
  121151. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121152. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121153. * @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)
  121154. */
  121155. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121156. /** Use the given ray to pick a mesh in the scene
  121157. * @param ray The ray to use to pick meshes
  121158. * @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
  121159. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121160. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121161. * @returns a PickingInfo
  121162. */
  121163. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121164. /**
  121165. * Launch a ray to try to pick a mesh in the scene
  121166. * @param x X position on screen
  121167. * @param y Y position on screen
  121168. * @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
  121169. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121170. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121171. * @returns an array of PickingInfo
  121172. */
  121173. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121174. /**
  121175. * Launch a ray to try to pick a mesh in the scene
  121176. * @param ray Ray to use
  121177. * @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
  121178. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121179. * @returns an array of PickingInfo
  121180. */
  121181. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121182. /**
  121183. * Force the value of meshUnderPointer
  121184. * @param mesh defines the mesh to use
  121185. * @param pointerId optional pointer id when using more than one pointer
  121186. */
  121187. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121188. /**
  121189. * Gets the mesh under the pointer
  121190. * @returns a Mesh or null if no mesh is under the pointer
  121191. */
  121192. getPointerOverMesh(): Nullable<AbstractMesh>;
  121193. /** @hidden */
  121194. _rebuildGeometries(): void;
  121195. /** @hidden */
  121196. _rebuildTextures(): void;
  121197. private _getByTags;
  121198. /**
  121199. * Get a list of meshes by tags
  121200. * @param tagsQuery defines the tags query to use
  121201. * @param forEach defines a predicate used to filter results
  121202. * @returns an array of Mesh
  121203. */
  121204. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121205. /**
  121206. * Get a list of cameras by tags
  121207. * @param tagsQuery defines the tags query to use
  121208. * @param forEach defines a predicate used to filter results
  121209. * @returns an array of Camera
  121210. */
  121211. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121212. /**
  121213. * Get a list of lights by tags
  121214. * @param tagsQuery defines the tags query to use
  121215. * @param forEach defines a predicate used to filter results
  121216. * @returns an array of Light
  121217. */
  121218. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121219. /**
  121220. * Get a list of materials by tags
  121221. * @param tagsQuery defines the tags query to use
  121222. * @param forEach defines a predicate used to filter results
  121223. * @returns an array of Material
  121224. */
  121225. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121226. /**
  121227. * Get a list of transform nodes by tags
  121228. * @param tagsQuery defines the tags query to use
  121229. * @param forEach defines a predicate used to filter results
  121230. * @returns an array of TransformNode
  121231. */
  121232. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121233. /**
  121234. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121235. * This allowed control for front to back rendering or reversly depending of the special needs.
  121236. *
  121237. * @param renderingGroupId The rendering group id corresponding to its index
  121238. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121239. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121240. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121241. */
  121242. 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;
  121243. /**
  121244. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121245. *
  121246. * @param renderingGroupId The rendering group id corresponding to its index
  121247. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121248. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121249. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121250. */
  121251. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121252. /**
  121253. * Gets the current auto clear configuration for one rendering group of the rendering
  121254. * manager.
  121255. * @param index the rendering group index to get the information for
  121256. * @returns The auto clear setup for the requested rendering group
  121257. */
  121258. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121259. private _blockMaterialDirtyMechanism;
  121260. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121261. get blockMaterialDirtyMechanism(): boolean;
  121262. set blockMaterialDirtyMechanism(value: boolean);
  121263. /**
  121264. * Will flag all materials as dirty to trigger new shader compilation
  121265. * @param flag defines the flag used to specify which material part must be marked as dirty
  121266. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121267. */
  121268. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121269. /** @hidden */
  121270. _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;
  121271. /** @hidden */
  121272. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121273. /** @hidden */
  121274. _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;
  121275. /** @hidden */
  121276. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121277. /** @hidden */
  121278. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121279. /** @hidden */
  121280. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121281. }
  121282. }
  121283. declare module BABYLON {
  121284. /**
  121285. * Set of assets to keep when moving a scene into an asset container.
  121286. */
  121287. export class KeepAssets extends AbstractScene {
  121288. }
  121289. /**
  121290. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121291. */
  121292. export class InstantiatedEntries {
  121293. /**
  121294. * List of new root nodes (eg. nodes with no parent)
  121295. */
  121296. rootNodes: TransformNode[];
  121297. /**
  121298. * List of new skeletons
  121299. */
  121300. skeletons: Skeleton[];
  121301. /**
  121302. * List of new animation groups
  121303. */
  121304. animationGroups: AnimationGroup[];
  121305. }
  121306. /**
  121307. * Container with a set of assets that can be added or removed from a scene.
  121308. */
  121309. export class AssetContainer extends AbstractScene {
  121310. private _wasAddedToScene;
  121311. /**
  121312. * The scene the AssetContainer belongs to.
  121313. */
  121314. scene: Scene;
  121315. /**
  121316. * Instantiates an AssetContainer.
  121317. * @param scene The scene the AssetContainer belongs to.
  121318. */
  121319. constructor(scene: Scene);
  121320. /**
  121321. * Instantiate or clone all meshes and add the new ones to the scene.
  121322. * Skeletons and animation groups will all be cloned
  121323. * @param nameFunction defines an optional function used to get new names for clones
  121324. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121325. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121326. */
  121327. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121328. /**
  121329. * Adds all the assets from the container to the scene.
  121330. */
  121331. addAllToScene(): void;
  121332. /**
  121333. * Removes all the assets in the container from the scene
  121334. */
  121335. removeAllFromScene(): void;
  121336. /**
  121337. * Disposes all the assets in the container
  121338. */
  121339. dispose(): void;
  121340. private _moveAssets;
  121341. /**
  121342. * Removes all the assets contained in the scene and adds them to the container.
  121343. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121344. */
  121345. moveAllFromScene(keepAssets?: KeepAssets): void;
  121346. /**
  121347. * 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.
  121348. * @returns the root mesh
  121349. */
  121350. createRootMesh(): Mesh;
  121351. /**
  121352. * Merge animations (direct and animation groups) from this asset container into a scene
  121353. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121354. * @param animatables set of animatables to retarget to a node from the scene
  121355. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121356. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121357. */
  121358. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121359. }
  121360. }
  121361. declare module BABYLON {
  121362. /**
  121363. * Defines how the parser contract is defined.
  121364. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121365. */
  121366. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121367. /**
  121368. * Defines how the individual parser contract is defined.
  121369. * These parser can parse an individual asset
  121370. */
  121371. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121372. /**
  121373. * Base class of the scene acting as a container for the different elements composing a scene.
  121374. * This class is dynamically extended by the different components of the scene increasing
  121375. * flexibility and reducing coupling
  121376. */
  121377. export abstract class AbstractScene {
  121378. /**
  121379. * Stores the list of available parsers in the application.
  121380. */
  121381. private static _BabylonFileParsers;
  121382. /**
  121383. * Stores the list of available individual parsers in the application.
  121384. */
  121385. private static _IndividualBabylonFileParsers;
  121386. /**
  121387. * Adds a parser in the list of available ones
  121388. * @param name Defines the name of the parser
  121389. * @param parser Defines the parser to add
  121390. */
  121391. static AddParser(name: string, parser: BabylonFileParser): void;
  121392. /**
  121393. * Gets a general parser from the list of avaialble ones
  121394. * @param name Defines the name of the parser
  121395. * @returns the requested parser or null
  121396. */
  121397. static GetParser(name: string): Nullable<BabylonFileParser>;
  121398. /**
  121399. * Adds n individual parser in the list of available ones
  121400. * @param name Defines the name of the parser
  121401. * @param parser Defines the parser to add
  121402. */
  121403. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121404. /**
  121405. * Gets an individual parser from the list of avaialble ones
  121406. * @param name Defines the name of the parser
  121407. * @returns the requested parser or null
  121408. */
  121409. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121410. /**
  121411. * Parser json data and populate both a scene and its associated container object
  121412. * @param jsonData Defines the data to parse
  121413. * @param scene Defines the scene to parse the data for
  121414. * @param container Defines the container attached to the parsing sequence
  121415. * @param rootUrl Defines the root url of the data
  121416. */
  121417. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121418. /**
  121419. * Gets the list of root nodes (ie. nodes with no parent)
  121420. */
  121421. rootNodes: Node[];
  121422. /** All of the cameras added to this scene
  121423. * @see https://doc.babylonjs.com/babylon101/cameras
  121424. */
  121425. cameras: Camera[];
  121426. /**
  121427. * All of the lights added to this scene
  121428. * @see https://doc.babylonjs.com/babylon101/lights
  121429. */
  121430. lights: Light[];
  121431. /**
  121432. * All of the (abstract) meshes added to this scene
  121433. */
  121434. meshes: AbstractMesh[];
  121435. /**
  121436. * The list of skeletons added to the scene
  121437. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121438. */
  121439. skeletons: Skeleton[];
  121440. /**
  121441. * All of the particle systems added to this scene
  121442. * @see https://doc.babylonjs.com/babylon101/particles
  121443. */
  121444. particleSystems: IParticleSystem[];
  121445. /**
  121446. * Gets a list of Animations associated with the scene
  121447. */
  121448. animations: Animation[];
  121449. /**
  121450. * All of the animation groups added to this scene
  121451. * @see https://doc.babylonjs.com/how_to/group
  121452. */
  121453. animationGroups: AnimationGroup[];
  121454. /**
  121455. * All of the multi-materials added to this scene
  121456. * @see https://doc.babylonjs.com/how_to/multi_materials
  121457. */
  121458. multiMaterials: MultiMaterial[];
  121459. /**
  121460. * All of the materials added to this scene
  121461. * In the context of a Scene, it is not supposed to be modified manually.
  121462. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121463. * Note also that the order of the Material within the array is not significant and might change.
  121464. * @see https://doc.babylonjs.com/babylon101/materials
  121465. */
  121466. materials: Material[];
  121467. /**
  121468. * The list of morph target managers added to the scene
  121469. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121470. */
  121471. morphTargetManagers: MorphTargetManager[];
  121472. /**
  121473. * The list of geometries used in the scene.
  121474. */
  121475. geometries: Geometry[];
  121476. /**
  121477. * All of the tranform nodes added to this scene
  121478. * In the context of a Scene, it is not supposed to be modified manually.
  121479. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121480. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121481. * @see https://doc.babylonjs.com/how_to/transformnode
  121482. */
  121483. transformNodes: TransformNode[];
  121484. /**
  121485. * ActionManagers available on the scene.
  121486. */
  121487. actionManagers: AbstractActionManager[];
  121488. /**
  121489. * Textures to keep.
  121490. */
  121491. textures: BaseTexture[];
  121492. /** @hidden */
  121493. protected _environmentTexture: Nullable<BaseTexture>;
  121494. /**
  121495. * Texture used in all pbr material as the reflection texture.
  121496. * As in the majority of the scene they are the same (exception for multi room and so on),
  121497. * this is easier to reference from here than from all the materials.
  121498. */
  121499. get environmentTexture(): Nullable<BaseTexture>;
  121500. set environmentTexture(value: Nullable<BaseTexture>);
  121501. /**
  121502. * The list of postprocesses added to the scene
  121503. */
  121504. postProcesses: PostProcess[];
  121505. /**
  121506. * @returns all meshes, lights, cameras, transformNodes and bones
  121507. */
  121508. getNodes(): Array<Node>;
  121509. }
  121510. }
  121511. declare module BABYLON {
  121512. /**
  121513. * Interface used to define options for Sound class
  121514. */
  121515. export interface ISoundOptions {
  121516. /**
  121517. * Does the sound autoplay once loaded.
  121518. */
  121519. autoplay?: boolean;
  121520. /**
  121521. * Does the sound loop after it finishes playing once.
  121522. */
  121523. loop?: boolean;
  121524. /**
  121525. * Sound's volume
  121526. */
  121527. volume?: number;
  121528. /**
  121529. * Is it a spatial sound?
  121530. */
  121531. spatialSound?: boolean;
  121532. /**
  121533. * Maximum distance to hear that sound
  121534. */
  121535. maxDistance?: number;
  121536. /**
  121537. * Uses user defined attenuation function
  121538. */
  121539. useCustomAttenuation?: boolean;
  121540. /**
  121541. * Define the roll off factor of spatial sounds.
  121542. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121543. */
  121544. rolloffFactor?: number;
  121545. /**
  121546. * Define the reference distance the sound should be heard perfectly.
  121547. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121548. */
  121549. refDistance?: number;
  121550. /**
  121551. * Define the distance attenuation model the sound will follow.
  121552. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121553. */
  121554. distanceModel?: string;
  121555. /**
  121556. * Defines the playback speed (1 by default)
  121557. */
  121558. playbackRate?: number;
  121559. /**
  121560. * Defines if the sound is from a streaming source
  121561. */
  121562. streaming?: boolean;
  121563. /**
  121564. * Defines an optional length (in seconds) inside the sound file
  121565. */
  121566. length?: number;
  121567. /**
  121568. * Defines an optional offset (in seconds) inside the sound file
  121569. */
  121570. offset?: number;
  121571. /**
  121572. * If true, URLs will not be required to state the audio file codec to use.
  121573. */
  121574. skipCodecCheck?: boolean;
  121575. }
  121576. /**
  121577. * Defines a sound that can be played in the application.
  121578. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121579. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121580. */
  121581. export class Sound {
  121582. /**
  121583. * The name of the sound in the scene.
  121584. */
  121585. name: string;
  121586. /**
  121587. * Does the sound autoplay once loaded.
  121588. */
  121589. autoplay: boolean;
  121590. /**
  121591. * Does the sound loop after it finishes playing once.
  121592. */
  121593. loop: boolean;
  121594. /**
  121595. * Does the sound use a custom attenuation curve to simulate the falloff
  121596. * happening when the source gets further away from the camera.
  121597. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121598. */
  121599. useCustomAttenuation: boolean;
  121600. /**
  121601. * The sound track id this sound belongs to.
  121602. */
  121603. soundTrackId: number;
  121604. /**
  121605. * Is this sound currently played.
  121606. */
  121607. isPlaying: boolean;
  121608. /**
  121609. * Is this sound currently paused.
  121610. */
  121611. isPaused: boolean;
  121612. /**
  121613. * Does this sound enables spatial sound.
  121614. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121615. */
  121616. spatialSound: boolean;
  121617. /**
  121618. * Define the reference distance the sound should be heard perfectly.
  121619. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121620. */
  121621. refDistance: number;
  121622. /**
  121623. * Define the roll off factor of spatial sounds.
  121624. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121625. */
  121626. rolloffFactor: number;
  121627. /**
  121628. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121629. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121630. */
  121631. maxDistance: number;
  121632. /**
  121633. * Define the distance attenuation model the sound will follow.
  121634. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121635. */
  121636. distanceModel: string;
  121637. /**
  121638. * @hidden
  121639. * Back Compat
  121640. **/
  121641. onended: () => any;
  121642. /**
  121643. * Gets or sets an object used to store user defined information for the sound.
  121644. */
  121645. metadata: any;
  121646. /**
  121647. * Observable event when the current playing sound finishes.
  121648. */
  121649. onEndedObservable: Observable<Sound>;
  121650. private _panningModel;
  121651. private _playbackRate;
  121652. private _streaming;
  121653. private _startTime;
  121654. private _startOffset;
  121655. private _position;
  121656. /** @hidden */
  121657. _positionInEmitterSpace: boolean;
  121658. private _localDirection;
  121659. private _volume;
  121660. private _isReadyToPlay;
  121661. private _isDirectional;
  121662. private _readyToPlayCallback;
  121663. private _audioBuffer;
  121664. private _soundSource;
  121665. private _streamingSource;
  121666. private _soundPanner;
  121667. private _soundGain;
  121668. private _inputAudioNode;
  121669. private _outputAudioNode;
  121670. private _coneInnerAngle;
  121671. private _coneOuterAngle;
  121672. private _coneOuterGain;
  121673. private _scene;
  121674. private _connectedTransformNode;
  121675. private _customAttenuationFunction;
  121676. private _registerFunc;
  121677. private _isOutputConnected;
  121678. private _htmlAudioElement;
  121679. private _urlType;
  121680. private _length?;
  121681. private _offset?;
  121682. /** @hidden */
  121683. static _SceneComponentInitialization: (scene: Scene) => void;
  121684. /**
  121685. * Create a sound and attach it to a scene
  121686. * @param name Name of your sound
  121687. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  121688. * @param scene defines the scene the sound belongs to
  121689. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  121690. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  121691. */
  121692. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  121693. /**
  121694. * Release the sound and its associated resources
  121695. */
  121696. dispose(): void;
  121697. /**
  121698. * Gets if the sounds is ready to be played or not.
  121699. * @returns true if ready, otherwise false
  121700. */
  121701. isReady(): boolean;
  121702. private _soundLoaded;
  121703. /**
  121704. * Sets the data of the sound from an audiobuffer
  121705. * @param audioBuffer The audioBuffer containing the data
  121706. */
  121707. setAudioBuffer(audioBuffer: AudioBuffer): void;
  121708. /**
  121709. * Updates the current sounds options such as maxdistance, loop...
  121710. * @param options A JSON object containing values named as the object properties
  121711. */
  121712. updateOptions(options: ISoundOptions): void;
  121713. private _createSpatialParameters;
  121714. private _updateSpatialParameters;
  121715. /**
  121716. * Switch the panning model to HRTF:
  121717. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121719. */
  121720. switchPanningModelToHRTF(): void;
  121721. /**
  121722. * Switch the panning model to Equal Power:
  121723. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121724. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121725. */
  121726. switchPanningModelToEqualPower(): void;
  121727. private _switchPanningModel;
  121728. /**
  121729. * Connect this sound to a sound track audio node like gain...
  121730. * @param soundTrackAudioNode the sound track audio node to connect to
  121731. */
  121732. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  121733. /**
  121734. * Transform this sound into a directional source
  121735. * @param coneInnerAngle Size of the inner cone in degree
  121736. * @param coneOuterAngle Size of the outer cone in degree
  121737. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  121738. */
  121739. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  121740. /**
  121741. * Gets or sets the inner angle for the directional cone.
  121742. */
  121743. get directionalConeInnerAngle(): number;
  121744. /**
  121745. * Gets or sets the inner angle for the directional cone.
  121746. */
  121747. set directionalConeInnerAngle(value: number);
  121748. /**
  121749. * Gets or sets the outer angle for the directional cone.
  121750. */
  121751. get directionalConeOuterAngle(): number;
  121752. /**
  121753. * Gets or sets the outer angle for the directional cone.
  121754. */
  121755. set directionalConeOuterAngle(value: number);
  121756. /**
  121757. * Sets the position of the emitter if spatial sound is enabled
  121758. * @param newPosition Defines the new posisiton
  121759. */
  121760. setPosition(newPosition: Vector3): void;
  121761. /**
  121762. * Sets the local direction of the emitter if spatial sound is enabled
  121763. * @param newLocalDirection Defines the new local direction
  121764. */
  121765. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  121766. private _updateDirection;
  121767. /** @hidden */
  121768. updateDistanceFromListener(): void;
  121769. /**
  121770. * Sets a new custom attenuation function for the sound.
  121771. * @param callback Defines the function used for the attenuation
  121772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121773. */
  121774. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  121775. /**
  121776. * Play the sound
  121777. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  121778. * @param offset (optional) Start the sound at a specific time in seconds
  121779. * @param length (optional) Sound duration (in seconds)
  121780. */
  121781. play(time?: number, offset?: number, length?: number): void;
  121782. private _onended;
  121783. /**
  121784. * Stop the sound
  121785. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  121786. */
  121787. stop(time?: number): void;
  121788. /**
  121789. * Put the sound in pause
  121790. */
  121791. pause(): void;
  121792. /**
  121793. * Sets a dedicated volume for this sounds
  121794. * @param newVolume Define the new volume of the sound
  121795. * @param time Define time for gradual change to new volume
  121796. */
  121797. setVolume(newVolume: number, time?: number): void;
  121798. /**
  121799. * Set the sound play back rate
  121800. * @param newPlaybackRate Define the playback rate the sound should be played at
  121801. */
  121802. setPlaybackRate(newPlaybackRate: number): void;
  121803. /**
  121804. * Gets the volume of the sound.
  121805. * @returns the volume of the sound
  121806. */
  121807. getVolume(): number;
  121808. /**
  121809. * Attach the sound to a dedicated mesh
  121810. * @param transformNode The transform node to connect the sound with
  121811. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121812. */
  121813. attachToMesh(transformNode: TransformNode): void;
  121814. /**
  121815. * Detach the sound from the previously attached mesh
  121816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121817. */
  121818. detachFromMesh(): void;
  121819. private _onRegisterAfterWorldMatrixUpdate;
  121820. /**
  121821. * Clone the current sound in the scene.
  121822. * @returns the new sound clone
  121823. */
  121824. clone(): Nullable<Sound>;
  121825. /**
  121826. * Gets the current underlying audio buffer containing the data
  121827. * @returns the audio buffer
  121828. */
  121829. getAudioBuffer(): Nullable<AudioBuffer>;
  121830. /**
  121831. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  121832. * @returns the source node
  121833. */
  121834. getSoundSource(): Nullable<AudioBufferSourceNode>;
  121835. /**
  121836. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  121837. * @returns the gain node
  121838. */
  121839. getSoundGain(): Nullable<GainNode>;
  121840. /**
  121841. * Serializes the Sound in a JSON representation
  121842. * @returns the JSON representation of the sound
  121843. */
  121844. serialize(): any;
  121845. /**
  121846. * Parse a JSON representation of a sound to innstantiate in a given scene
  121847. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  121848. * @param scene Define the scene the new parsed sound should be created in
  121849. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  121850. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  121851. * @returns the newly parsed sound
  121852. */
  121853. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  121854. }
  121855. }
  121856. declare module BABYLON {
  121857. /**
  121858. * This defines an action helpful to play a defined sound on a triggered action.
  121859. */
  121860. export class PlaySoundAction extends Action {
  121861. private _sound;
  121862. /**
  121863. * Instantiate the action
  121864. * @param triggerOptions defines the trigger options
  121865. * @param sound defines the sound to play
  121866. * @param condition defines the trigger related conditions
  121867. */
  121868. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121869. /** @hidden */
  121870. _prepare(): void;
  121871. /**
  121872. * Execute the action and play the sound.
  121873. */
  121874. execute(): void;
  121875. /**
  121876. * Serializes the actions and its related information.
  121877. * @param parent defines the object to serialize in
  121878. * @returns the serialized object
  121879. */
  121880. serialize(parent: any): any;
  121881. }
  121882. /**
  121883. * This defines an action helpful to stop a defined sound on a triggered action.
  121884. */
  121885. export class StopSoundAction extends Action {
  121886. private _sound;
  121887. /**
  121888. * Instantiate the action
  121889. * @param triggerOptions defines the trigger options
  121890. * @param sound defines the sound to stop
  121891. * @param condition defines the trigger related conditions
  121892. */
  121893. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121894. /** @hidden */
  121895. _prepare(): void;
  121896. /**
  121897. * Execute the action and stop the sound.
  121898. */
  121899. execute(): void;
  121900. /**
  121901. * Serializes the actions and its related information.
  121902. * @param parent defines the object to serialize in
  121903. * @returns the serialized object
  121904. */
  121905. serialize(parent: any): any;
  121906. }
  121907. }
  121908. declare module BABYLON {
  121909. /**
  121910. * This defines an action responsible to change the value of a property
  121911. * by interpolating between its current value and the newly set one once triggered.
  121912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121913. */
  121914. export class InterpolateValueAction extends Action {
  121915. /**
  121916. * Defines the path of the property where the value should be interpolated
  121917. */
  121918. propertyPath: string;
  121919. /**
  121920. * Defines the target value at the end of the interpolation.
  121921. */
  121922. value: any;
  121923. /**
  121924. * Defines the time it will take for the property to interpolate to the value.
  121925. */
  121926. duration: number;
  121927. /**
  121928. * Defines if the other scene animations should be stopped when the action has been triggered
  121929. */
  121930. stopOtherAnimations?: boolean;
  121931. /**
  121932. * Defines a callback raised once the interpolation animation has been done.
  121933. */
  121934. onInterpolationDone?: () => void;
  121935. /**
  121936. * Observable triggered once the interpolation animation has been done.
  121937. */
  121938. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  121939. private _target;
  121940. private _effectiveTarget;
  121941. private _property;
  121942. /**
  121943. * Instantiate the action
  121944. * @param triggerOptions defines the trigger options
  121945. * @param target defines the object containing the value to interpolate
  121946. * @param propertyPath defines the path to the property in the target object
  121947. * @param value defines the target value at the end of the interpolation
  121948. * @param duration deines the time it will take for the property to interpolate to the value.
  121949. * @param condition defines the trigger related conditions
  121950. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  121951. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  121952. */
  121953. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  121954. /** @hidden */
  121955. _prepare(): void;
  121956. /**
  121957. * Execute the action starts the value interpolation.
  121958. */
  121959. execute(): void;
  121960. /**
  121961. * Serializes the actions and its related information.
  121962. * @param parent defines the object to serialize in
  121963. * @returns the serialized object
  121964. */
  121965. serialize(parent: any): any;
  121966. }
  121967. }
  121968. declare module BABYLON {
  121969. /**
  121970. * Options allowed during the creation of a sound track.
  121971. */
  121972. export interface ISoundTrackOptions {
  121973. /**
  121974. * The volume the sound track should take during creation
  121975. */
  121976. volume?: number;
  121977. /**
  121978. * Define if the sound track is the main sound track of the scene
  121979. */
  121980. mainTrack?: boolean;
  121981. }
  121982. /**
  121983. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  121984. * It will be also used in a future release to apply effects on a specific track.
  121985. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121986. */
  121987. export class SoundTrack {
  121988. /**
  121989. * The unique identifier of the sound track in the scene.
  121990. */
  121991. id: number;
  121992. /**
  121993. * The list of sounds included in the sound track.
  121994. */
  121995. soundCollection: Array<Sound>;
  121996. private _outputAudioNode;
  121997. private _scene;
  121998. private _connectedAnalyser;
  121999. private _options;
  122000. private _isInitialized;
  122001. /**
  122002. * Creates a new sound track.
  122003. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122004. * @param scene Define the scene the sound track belongs to
  122005. * @param options
  122006. */
  122007. constructor(scene: Scene, options?: ISoundTrackOptions);
  122008. private _initializeSoundTrackAudioGraph;
  122009. /**
  122010. * Release the sound track and its associated resources
  122011. */
  122012. dispose(): void;
  122013. /**
  122014. * Adds a sound to this sound track
  122015. * @param sound define the cound to add
  122016. * @ignoreNaming
  122017. */
  122018. AddSound(sound: Sound): void;
  122019. /**
  122020. * Removes a sound to this sound track
  122021. * @param sound define the cound to remove
  122022. * @ignoreNaming
  122023. */
  122024. RemoveSound(sound: Sound): void;
  122025. /**
  122026. * Set a global volume for the full sound track.
  122027. * @param newVolume Define the new volume of the sound track
  122028. */
  122029. setVolume(newVolume: number): void;
  122030. /**
  122031. * Switch the panning model to HRTF:
  122032. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122033. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122034. */
  122035. switchPanningModelToHRTF(): void;
  122036. /**
  122037. * Switch the panning model to Equal Power:
  122038. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122040. */
  122041. switchPanningModelToEqualPower(): void;
  122042. /**
  122043. * Connect the sound track to an audio analyser allowing some amazing
  122044. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122045. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122046. * @param analyser The analyser to connect to the engine
  122047. */
  122048. connectToAnalyser(analyser: Analyser): void;
  122049. }
  122050. }
  122051. declare module BABYLON {
  122052. interface AbstractScene {
  122053. /**
  122054. * The list of sounds used in the scene.
  122055. */
  122056. sounds: Nullable<Array<Sound>>;
  122057. }
  122058. interface Scene {
  122059. /**
  122060. * @hidden
  122061. * Backing field
  122062. */
  122063. _mainSoundTrack: SoundTrack;
  122064. /**
  122065. * The main sound track played by the scene.
  122066. * It cotains your primary collection of sounds.
  122067. */
  122068. mainSoundTrack: SoundTrack;
  122069. /**
  122070. * The list of sound tracks added to the scene
  122071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122072. */
  122073. soundTracks: Nullable<Array<SoundTrack>>;
  122074. /**
  122075. * Gets a sound using a given name
  122076. * @param name defines the name to search for
  122077. * @return the found sound or null if not found at all.
  122078. */
  122079. getSoundByName(name: string): Nullable<Sound>;
  122080. /**
  122081. * Gets or sets if audio support is enabled
  122082. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122083. */
  122084. audioEnabled: boolean;
  122085. /**
  122086. * Gets or sets if audio will be output to headphones
  122087. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122088. */
  122089. headphone: boolean;
  122090. /**
  122091. * Gets or sets custom audio listener position provider
  122092. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122093. */
  122094. audioListenerPositionProvider: Nullable<() => Vector3>;
  122095. /**
  122096. * Gets or sets a refresh rate when using 3D audio positioning
  122097. */
  122098. audioPositioningRefreshRate: number;
  122099. }
  122100. /**
  122101. * Defines the sound scene component responsible to manage any sounds
  122102. * in a given scene.
  122103. */
  122104. export class AudioSceneComponent implements ISceneSerializableComponent {
  122105. private static _CameraDirectionLH;
  122106. private static _CameraDirectionRH;
  122107. /**
  122108. * The component name helpfull to identify the component in the list of scene components.
  122109. */
  122110. readonly name: string;
  122111. /**
  122112. * The scene the component belongs to.
  122113. */
  122114. scene: Scene;
  122115. private _audioEnabled;
  122116. /**
  122117. * Gets whether audio is enabled or not.
  122118. * Please use related enable/disable method to switch state.
  122119. */
  122120. get audioEnabled(): boolean;
  122121. private _headphone;
  122122. /**
  122123. * Gets whether audio is outputing to headphone or not.
  122124. * Please use the according Switch methods to change output.
  122125. */
  122126. get headphone(): boolean;
  122127. /**
  122128. * Gets or sets a refresh rate when using 3D audio positioning
  122129. */
  122130. audioPositioningRefreshRate: number;
  122131. private _audioListenerPositionProvider;
  122132. /**
  122133. * Gets the current audio listener position provider
  122134. */
  122135. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122136. /**
  122137. * Sets a custom listener position for all sounds in the scene
  122138. * By default, this is the position of the first active camera
  122139. */
  122140. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122141. /**
  122142. * Creates a new instance of the component for the given scene
  122143. * @param scene Defines the scene to register the component in
  122144. */
  122145. constructor(scene: Scene);
  122146. /**
  122147. * Registers the component in a given scene
  122148. */
  122149. register(): void;
  122150. /**
  122151. * Rebuilds the elements related to this component in case of
  122152. * context lost for instance.
  122153. */
  122154. rebuild(): void;
  122155. /**
  122156. * Serializes the component data to the specified json object
  122157. * @param serializationObject The object to serialize to
  122158. */
  122159. serialize(serializationObject: any): void;
  122160. /**
  122161. * Adds all the elements from the container to the scene
  122162. * @param container the container holding the elements
  122163. */
  122164. addFromContainer(container: AbstractScene): void;
  122165. /**
  122166. * Removes all the elements in the container from the scene
  122167. * @param container contains the elements to remove
  122168. * @param dispose if the removed element should be disposed (default: false)
  122169. */
  122170. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122171. /**
  122172. * Disposes the component and the associated ressources.
  122173. */
  122174. dispose(): void;
  122175. /**
  122176. * Disables audio in the associated scene.
  122177. */
  122178. disableAudio(): void;
  122179. /**
  122180. * Enables audio in the associated scene.
  122181. */
  122182. enableAudio(): void;
  122183. /**
  122184. * Switch audio to headphone output.
  122185. */
  122186. switchAudioModeForHeadphones(): void;
  122187. /**
  122188. * Switch audio to normal speakers.
  122189. */
  122190. switchAudioModeForNormalSpeakers(): void;
  122191. private _cachedCameraDirection;
  122192. private _cachedCameraPosition;
  122193. private _lastCheck;
  122194. private _afterRender;
  122195. }
  122196. }
  122197. declare module BABYLON {
  122198. /**
  122199. * Wraps one or more Sound objects and selects one with random weight for playback.
  122200. */
  122201. export class WeightedSound {
  122202. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122203. loop: boolean;
  122204. private _coneInnerAngle;
  122205. private _coneOuterAngle;
  122206. private _volume;
  122207. /** A Sound is currently playing. */
  122208. isPlaying: boolean;
  122209. /** A Sound is currently paused. */
  122210. isPaused: boolean;
  122211. private _sounds;
  122212. private _weights;
  122213. private _currentIndex?;
  122214. /**
  122215. * Creates a new WeightedSound from the list of sounds given.
  122216. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122217. * @param sounds Array of Sounds that will be selected from.
  122218. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122219. */
  122220. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122221. /**
  122222. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122223. */
  122224. get directionalConeInnerAngle(): number;
  122225. /**
  122226. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122227. */
  122228. set directionalConeInnerAngle(value: number);
  122229. /**
  122230. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122231. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122232. */
  122233. get directionalConeOuterAngle(): number;
  122234. /**
  122235. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122236. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122237. */
  122238. set directionalConeOuterAngle(value: number);
  122239. /**
  122240. * Playback volume.
  122241. */
  122242. get volume(): number;
  122243. /**
  122244. * Playback volume.
  122245. */
  122246. set volume(value: number);
  122247. private _onended;
  122248. /**
  122249. * Suspend playback
  122250. */
  122251. pause(): void;
  122252. /**
  122253. * Stop playback
  122254. */
  122255. stop(): void;
  122256. /**
  122257. * Start playback.
  122258. * @param startOffset Position the clip head at a specific time in seconds.
  122259. */
  122260. play(startOffset?: number): void;
  122261. }
  122262. }
  122263. declare module BABYLON {
  122264. /**
  122265. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122266. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122267. */
  122268. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122269. /**
  122270. * Gets the name of the behavior.
  122271. */
  122272. get name(): string;
  122273. /**
  122274. * The easing function used by animations
  122275. */
  122276. static EasingFunction: BackEase;
  122277. /**
  122278. * The easing mode used by animations
  122279. */
  122280. static EasingMode: number;
  122281. /**
  122282. * The duration of the animation, in milliseconds
  122283. */
  122284. transitionDuration: number;
  122285. /**
  122286. * Length of the distance animated by the transition when lower radius is reached
  122287. */
  122288. lowerRadiusTransitionRange: number;
  122289. /**
  122290. * Length of the distance animated by the transition when upper radius is reached
  122291. */
  122292. upperRadiusTransitionRange: number;
  122293. private _autoTransitionRange;
  122294. /**
  122295. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122296. */
  122297. get autoTransitionRange(): boolean;
  122298. /**
  122299. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122300. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122301. */
  122302. set autoTransitionRange(value: boolean);
  122303. private _attachedCamera;
  122304. private _onAfterCheckInputsObserver;
  122305. private _onMeshTargetChangedObserver;
  122306. /**
  122307. * Initializes the behavior.
  122308. */
  122309. init(): void;
  122310. /**
  122311. * Attaches the behavior to its arc rotate camera.
  122312. * @param camera Defines the camera to attach the behavior to
  122313. */
  122314. attach(camera: ArcRotateCamera): void;
  122315. /**
  122316. * Detaches the behavior from its current arc rotate camera.
  122317. */
  122318. detach(): void;
  122319. private _radiusIsAnimating;
  122320. private _radiusBounceTransition;
  122321. private _animatables;
  122322. private _cachedWheelPrecision;
  122323. /**
  122324. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122325. * @param radiusLimit The limit to check against.
  122326. * @return Bool to indicate if at limit.
  122327. */
  122328. private _isRadiusAtLimit;
  122329. /**
  122330. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122331. * @param radiusDelta The delta by which to animate to. Can be negative.
  122332. */
  122333. private _applyBoundRadiusAnimation;
  122334. /**
  122335. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122336. */
  122337. protected _clearAnimationLocks(): void;
  122338. /**
  122339. * Stops and removes all animations that have been applied to the camera
  122340. */
  122341. stopAllAnimations(): void;
  122342. }
  122343. }
  122344. declare module BABYLON {
  122345. /**
  122346. * 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.
  122347. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122348. */
  122349. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122350. /**
  122351. * Gets the name of the behavior.
  122352. */
  122353. get name(): string;
  122354. private _mode;
  122355. private _radiusScale;
  122356. private _positionScale;
  122357. private _defaultElevation;
  122358. private _elevationReturnTime;
  122359. private _elevationReturnWaitTime;
  122360. private _zoomStopsAnimation;
  122361. private _framingTime;
  122362. /**
  122363. * The easing function used by animations
  122364. */
  122365. static EasingFunction: ExponentialEase;
  122366. /**
  122367. * The easing mode used by animations
  122368. */
  122369. static EasingMode: number;
  122370. /**
  122371. * Sets the current mode used by the behavior
  122372. */
  122373. set mode(mode: number);
  122374. /**
  122375. * Gets current mode used by the behavior.
  122376. */
  122377. get mode(): number;
  122378. /**
  122379. * Sets the scale applied to the radius (1 by default)
  122380. */
  122381. set radiusScale(radius: number);
  122382. /**
  122383. * Gets the scale applied to the radius
  122384. */
  122385. get radiusScale(): number;
  122386. /**
  122387. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122388. */
  122389. set positionScale(scale: number);
  122390. /**
  122391. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122392. */
  122393. get positionScale(): number;
  122394. /**
  122395. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122396. * behaviour is triggered, in radians.
  122397. */
  122398. set defaultElevation(elevation: number);
  122399. /**
  122400. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122401. * behaviour is triggered, in radians.
  122402. */
  122403. get defaultElevation(): number;
  122404. /**
  122405. * Sets the time (in milliseconds) taken to return to the default beta position.
  122406. * Negative value indicates camera should not return to default.
  122407. */
  122408. set elevationReturnTime(speed: number);
  122409. /**
  122410. * Gets the time (in milliseconds) taken to return to the default beta position.
  122411. * Negative value indicates camera should not return to default.
  122412. */
  122413. get elevationReturnTime(): number;
  122414. /**
  122415. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122416. */
  122417. set elevationReturnWaitTime(time: number);
  122418. /**
  122419. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122420. */
  122421. get elevationReturnWaitTime(): number;
  122422. /**
  122423. * Sets the flag that indicates if user zooming should stop animation.
  122424. */
  122425. set zoomStopsAnimation(flag: boolean);
  122426. /**
  122427. * Gets the flag that indicates if user zooming should stop animation.
  122428. */
  122429. get zoomStopsAnimation(): boolean;
  122430. /**
  122431. * Sets the transition time when framing the mesh, in milliseconds
  122432. */
  122433. set framingTime(time: number);
  122434. /**
  122435. * Gets the transition time when framing the mesh, in milliseconds
  122436. */
  122437. get framingTime(): number;
  122438. /**
  122439. * Define if the behavior should automatically change the configured
  122440. * camera limits and sensibilities.
  122441. */
  122442. autoCorrectCameraLimitsAndSensibility: boolean;
  122443. private _onPrePointerObservableObserver;
  122444. private _onAfterCheckInputsObserver;
  122445. private _onMeshTargetChangedObserver;
  122446. private _attachedCamera;
  122447. private _isPointerDown;
  122448. private _lastInteractionTime;
  122449. /**
  122450. * Initializes the behavior.
  122451. */
  122452. init(): void;
  122453. /**
  122454. * Attaches the behavior to its arc rotate camera.
  122455. * @param camera Defines the camera to attach the behavior to
  122456. */
  122457. attach(camera: ArcRotateCamera): void;
  122458. /**
  122459. * Detaches the behavior from its current arc rotate camera.
  122460. */
  122461. detach(): void;
  122462. private _animatables;
  122463. private _betaIsAnimating;
  122464. private _betaTransition;
  122465. private _radiusTransition;
  122466. private _vectorTransition;
  122467. /**
  122468. * Targets the given mesh and updates zoom level accordingly.
  122469. * @param mesh The mesh to target.
  122470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122472. */
  122473. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122474. /**
  122475. * Targets the given mesh with its children and updates zoom level accordingly.
  122476. * @param mesh The mesh to target.
  122477. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122478. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122479. */
  122480. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122481. /**
  122482. * Targets the given meshes with their children and updates zoom level accordingly.
  122483. * @param meshes The mesh to target.
  122484. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122485. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122486. */
  122487. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122488. /**
  122489. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122490. * @param minimumWorld Determines the smaller position of the bounding box extend
  122491. * @param maximumWorld Determines the bigger position of the bounding box extend
  122492. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122493. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122494. */
  122495. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122496. /**
  122497. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122498. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122499. * frustum width.
  122500. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122501. * to fully enclose the mesh in the viewing frustum.
  122502. */
  122503. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122504. /**
  122505. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122506. * is automatically returned to its default position (expected to be above ground plane).
  122507. */
  122508. private _maintainCameraAboveGround;
  122509. /**
  122510. * Returns the frustum slope based on the canvas ratio and camera FOV
  122511. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122512. */
  122513. private _getFrustumSlope;
  122514. /**
  122515. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122516. */
  122517. private _clearAnimationLocks;
  122518. /**
  122519. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122520. */
  122521. private _applyUserInteraction;
  122522. /**
  122523. * Stops and removes all animations that have been applied to the camera
  122524. */
  122525. stopAllAnimations(): void;
  122526. /**
  122527. * Gets a value indicating if the user is moving the camera
  122528. */
  122529. get isUserIsMoving(): boolean;
  122530. /**
  122531. * The camera can move all the way towards the mesh.
  122532. */
  122533. static IgnoreBoundsSizeMode: number;
  122534. /**
  122535. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122536. */
  122537. static FitFrustumSidesMode: number;
  122538. }
  122539. }
  122540. declare module BABYLON {
  122541. /**
  122542. * Base class for Camera Pointer Inputs.
  122543. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122544. * for example usage.
  122545. */
  122546. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122547. /**
  122548. * Defines the camera the input is attached to.
  122549. */
  122550. abstract camera: Camera;
  122551. /**
  122552. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122553. */
  122554. protected _altKey: boolean;
  122555. protected _ctrlKey: boolean;
  122556. protected _metaKey: boolean;
  122557. protected _shiftKey: boolean;
  122558. /**
  122559. * Which mouse buttons were pressed at time of last mouse event.
  122560. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122561. */
  122562. protected _buttonsPressed: number;
  122563. /**
  122564. * Defines the buttons associated with the input to handle camera move.
  122565. */
  122566. buttons: number[];
  122567. /**
  122568. * Attach the input controls to a specific dom element to get the input from.
  122569. * @param element Defines the element the controls should be listened from
  122570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122571. */
  122572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122573. /**
  122574. * Detach the current controls from the specified dom element.
  122575. * @param element Defines the element to stop listening the inputs from
  122576. */
  122577. detachControl(element: Nullable<HTMLElement>): void;
  122578. /**
  122579. * Gets the class name of the current input.
  122580. * @returns the class name
  122581. */
  122582. getClassName(): string;
  122583. /**
  122584. * Get the friendly name associated with the input class.
  122585. * @returns the input friendly name
  122586. */
  122587. getSimpleName(): string;
  122588. /**
  122589. * Called on pointer POINTERDOUBLETAP event.
  122590. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122591. */
  122592. protected onDoubleTap(type: string): void;
  122593. /**
  122594. * Called on pointer POINTERMOVE event if only a single touch is active.
  122595. * Override this method to provide functionality.
  122596. */
  122597. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122598. /**
  122599. * Called on pointer POINTERMOVE event if multiple touches are active.
  122600. * Override this method to provide functionality.
  122601. */
  122602. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122603. /**
  122604. * Called on JS contextmenu event.
  122605. * Override this method to provide functionality.
  122606. */
  122607. protected onContextMenu(evt: PointerEvent): void;
  122608. /**
  122609. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122610. * press.
  122611. * Override this method to provide functionality.
  122612. */
  122613. protected onButtonDown(evt: PointerEvent): void;
  122614. /**
  122615. * Called each time a new POINTERUP event occurs. Ie, for each button
  122616. * release.
  122617. * Override this method to provide functionality.
  122618. */
  122619. protected onButtonUp(evt: PointerEvent): void;
  122620. /**
  122621. * Called when window becomes inactive.
  122622. * Override this method to provide functionality.
  122623. */
  122624. protected onLostFocus(): void;
  122625. private _pointerInput;
  122626. private _observer;
  122627. private _onLostFocus;
  122628. private pointA;
  122629. private pointB;
  122630. }
  122631. }
  122632. declare module BABYLON {
  122633. /**
  122634. * Manage the pointers inputs to control an arc rotate camera.
  122635. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122636. */
  122637. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122638. /**
  122639. * Defines the camera the input is attached to.
  122640. */
  122641. camera: ArcRotateCamera;
  122642. /**
  122643. * Gets the class name of the current input.
  122644. * @returns the class name
  122645. */
  122646. getClassName(): string;
  122647. /**
  122648. * Defines the buttons associated with the input to handle camera move.
  122649. */
  122650. buttons: number[];
  122651. /**
  122652. * Defines the pointer angular sensibility along the X axis or how fast is
  122653. * the camera rotating.
  122654. */
  122655. angularSensibilityX: number;
  122656. /**
  122657. * Defines the pointer angular sensibility along the Y axis or how fast is
  122658. * the camera rotating.
  122659. */
  122660. angularSensibilityY: number;
  122661. /**
  122662. * Defines the pointer pinch precision or how fast is the camera zooming.
  122663. */
  122664. pinchPrecision: number;
  122665. /**
  122666. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122667. * from 0.
  122668. * It defines the percentage of current camera.radius to use as delta when
  122669. * pinch zoom is used.
  122670. */
  122671. pinchDeltaPercentage: number;
  122672. /**
  122673. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122674. * that any object in the plane at the camera's target point will scale
  122675. * perfectly with finger motion.
  122676. * Overrides pinchDeltaPercentage and pinchPrecision.
  122677. */
  122678. useNaturalPinchZoom: boolean;
  122679. /**
  122680. * Defines the pointer panning sensibility or how fast is the camera moving.
  122681. */
  122682. panningSensibility: number;
  122683. /**
  122684. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  122685. */
  122686. multiTouchPanning: boolean;
  122687. /**
  122688. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  122689. * zoom (pinch) through multitouch.
  122690. */
  122691. multiTouchPanAndZoom: boolean;
  122692. /**
  122693. * Revers pinch action direction.
  122694. */
  122695. pinchInwards: boolean;
  122696. private _isPanClick;
  122697. private _twoFingerActivityCount;
  122698. private _isPinching;
  122699. /**
  122700. * Called on pointer POINTERMOVE event if only a single touch is active.
  122701. */
  122702. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122703. /**
  122704. * Called on pointer POINTERDOUBLETAP event.
  122705. */
  122706. protected onDoubleTap(type: string): void;
  122707. /**
  122708. * Called on pointer POINTERMOVE event if multiple touches are active.
  122709. */
  122710. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122711. /**
  122712. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122713. * press.
  122714. */
  122715. protected onButtonDown(evt: PointerEvent): void;
  122716. /**
  122717. * Called each time a new POINTERUP event occurs. Ie, for each button
  122718. * release.
  122719. */
  122720. protected onButtonUp(evt: PointerEvent): void;
  122721. /**
  122722. * Called when window becomes inactive.
  122723. */
  122724. protected onLostFocus(): void;
  122725. }
  122726. }
  122727. declare module BABYLON {
  122728. /**
  122729. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  122730. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122731. */
  122732. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  122733. /**
  122734. * Defines the camera the input is attached to.
  122735. */
  122736. camera: ArcRotateCamera;
  122737. /**
  122738. * Defines the list of key codes associated with the up action (increase alpha)
  122739. */
  122740. keysUp: number[];
  122741. /**
  122742. * Defines the list of key codes associated with the down action (decrease alpha)
  122743. */
  122744. keysDown: number[];
  122745. /**
  122746. * Defines the list of key codes associated with the left action (increase beta)
  122747. */
  122748. keysLeft: number[];
  122749. /**
  122750. * Defines the list of key codes associated with the right action (decrease beta)
  122751. */
  122752. keysRight: number[];
  122753. /**
  122754. * Defines the list of key codes associated with the reset action.
  122755. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  122756. */
  122757. keysReset: number[];
  122758. /**
  122759. * Defines the panning sensibility of the inputs.
  122760. * (How fast is the camera panning)
  122761. */
  122762. panningSensibility: number;
  122763. /**
  122764. * Defines the zooming sensibility of the inputs.
  122765. * (How fast is the camera zooming)
  122766. */
  122767. zoomingSensibility: number;
  122768. /**
  122769. * Defines whether maintaining the alt key down switch the movement mode from
  122770. * orientation to zoom.
  122771. */
  122772. useAltToZoom: boolean;
  122773. /**
  122774. * Rotation speed of the camera
  122775. */
  122776. angularSpeed: number;
  122777. private _keys;
  122778. private _ctrlPressed;
  122779. private _altPressed;
  122780. private _onCanvasBlurObserver;
  122781. private _onKeyboardObserver;
  122782. private _engine;
  122783. private _scene;
  122784. /**
  122785. * Attach the input controls to a specific dom element to get the input from.
  122786. * @param element Defines the element the controls should be listened from
  122787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122788. */
  122789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122790. /**
  122791. * Detach the current controls from the specified dom element.
  122792. * @param element Defines the element to stop listening the inputs from
  122793. */
  122794. detachControl(element: Nullable<HTMLElement>): void;
  122795. /**
  122796. * Update the current camera state depending on the inputs that have been used this frame.
  122797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122798. */
  122799. checkInputs(): void;
  122800. /**
  122801. * Gets the class name of the current intput.
  122802. * @returns the class name
  122803. */
  122804. getClassName(): string;
  122805. /**
  122806. * Get the friendly name associated with the input class.
  122807. * @returns the input friendly name
  122808. */
  122809. getSimpleName(): string;
  122810. }
  122811. }
  122812. declare module BABYLON {
  122813. /**
  122814. * Manage the mouse wheel inputs to control an arc rotate camera.
  122815. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122816. */
  122817. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  122818. /**
  122819. * Defines the camera the input is attached to.
  122820. */
  122821. camera: ArcRotateCamera;
  122822. /**
  122823. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122824. */
  122825. wheelPrecision: number;
  122826. /**
  122827. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122828. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122829. */
  122830. wheelDeltaPercentage: number;
  122831. private _wheel;
  122832. private _observer;
  122833. private computeDeltaFromMouseWheelLegacyEvent;
  122834. /**
  122835. * Attach the input controls to a specific dom element to get the input from.
  122836. * @param element Defines the element the controls should be listened from
  122837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122838. */
  122839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122840. /**
  122841. * Detach the current controls from the specified dom element.
  122842. * @param element Defines the element to stop listening the inputs from
  122843. */
  122844. detachControl(element: Nullable<HTMLElement>): void;
  122845. /**
  122846. * Gets the class name of the current intput.
  122847. * @returns the class name
  122848. */
  122849. getClassName(): string;
  122850. /**
  122851. * Get the friendly name associated with the input class.
  122852. * @returns the input friendly name
  122853. */
  122854. getSimpleName(): string;
  122855. }
  122856. }
  122857. declare module BABYLON {
  122858. /**
  122859. * Default Inputs manager for the ArcRotateCamera.
  122860. * It groups all the default supported inputs for ease of use.
  122861. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122862. */
  122863. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  122864. /**
  122865. * Instantiates a new ArcRotateCameraInputsManager.
  122866. * @param camera Defines the camera the inputs belong to
  122867. */
  122868. constructor(camera: ArcRotateCamera);
  122869. /**
  122870. * Add mouse wheel input support to the input manager.
  122871. * @returns the current input manager
  122872. */
  122873. addMouseWheel(): ArcRotateCameraInputsManager;
  122874. /**
  122875. * Add pointers input support to the input manager.
  122876. * @returns the current input manager
  122877. */
  122878. addPointers(): ArcRotateCameraInputsManager;
  122879. /**
  122880. * Add keyboard input support to the input manager.
  122881. * @returns the current input manager
  122882. */
  122883. addKeyboard(): ArcRotateCameraInputsManager;
  122884. }
  122885. }
  122886. declare module BABYLON {
  122887. /**
  122888. * This represents an orbital type of camera.
  122889. *
  122890. * 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.
  122891. * 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.
  122892. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  122893. */
  122894. export class ArcRotateCamera extends TargetCamera {
  122895. /**
  122896. * Defines the rotation angle of the camera along the longitudinal axis.
  122897. */
  122898. alpha: number;
  122899. /**
  122900. * Defines the rotation angle of the camera along the latitudinal axis.
  122901. */
  122902. beta: number;
  122903. /**
  122904. * Defines the radius of the camera from it s target point.
  122905. */
  122906. radius: number;
  122907. protected _target: Vector3;
  122908. protected _targetHost: Nullable<AbstractMesh>;
  122909. /**
  122910. * Defines the target point of the camera.
  122911. * The camera looks towards it form the radius distance.
  122912. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  122913. */
  122914. get target(): Vector3;
  122915. set target(value: Vector3);
  122916. /**
  122917. * Define the current local position of the camera in the scene
  122918. */
  122919. get position(): Vector3;
  122920. set position(newPosition: Vector3);
  122921. protected _upToYMatrix: Matrix;
  122922. protected _YToUpMatrix: Matrix;
  122923. /**
  122924. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  122925. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  122926. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  122927. */
  122928. set upVector(vec: Vector3);
  122929. get upVector(): Vector3;
  122930. /**
  122931. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  122932. */
  122933. setMatUp(): void;
  122934. /**
  122935. * Current inertia value on the longitudinal axis.
  122936. * The bigger this number the longer it will take for the camera to stop.
  122937. */
  122938. inertialAlphaOffset: number;
  122939. /**
  122940. * Current inertia value on the latitudinal axis.
  122941. * The bigger this number the longer it will take for the camera to stop.
  122942. */
  122943. inertialBetaOffset: number;
  122944. /**
  122945. * Current inertia value on the radius axis.
  122946. * The bigger this number the longer it will take for the camera to stop.
  122947. */
  122948. inertialRadiusOffset: number;
  122949. /**
  122950. * Minimum allowed angle on the longitudinal axis.
  122951. * This can help limiting how the Camera is able to move in the scene.
  122952. */
  122953. lowerAlphaLimit: Nullable<number>;
  122954. /**
  122955. * Maximum allowed angle on the longitudinal axis.
  122956. * This can help limiting how the Camera is able to move in the scene.
  122957. */
  122958. upperAlphaLimit: Nullable<number>;
  122959. /**
  122960. * Minimum allowed angle on the latitudinal axis.
  122961. * This can help limiting how the Camera is able to move in the scene.
  122962. */
  122963. lowerBetaLimit: number;
  122964. /**
  122965. * Maximum allowed angle on the latitudinal axis.
  122966. * This can help limiting how the Camera is able to move in the scene.
  122967. */
  122968. upperBetaLimit: number;
  122969. /**
  122970. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  122971. * This can help limiting how the Camera is able to move in the scene.
  122972. */
  122973. lowerRadiusLimit: Nullable<number>;
  122974. /**
  122975. * Maximum allowed distance of the camera to the target (The camera can not get further).
  122976. * This can help limiting how the Camera is able to move in the scene.
  122977. */
  122978. upperRadiusLimit: Nullable<number>;
  122979. /**
  122980. * Defines the current inertia value used during panning of the camera along the X axis.
  122981. */
  122982. inertialPanningX: number;
  122983. /**
  122984. * Defines the current inertia value used during panning of the camera along the Y axis.
  122985. */
  122986. inertialPanningY: number;
  122987. /**
  122988. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  122989. * Basically if your fingers moves away from more than this distance you will be considered
  122990. * in pinch mode.
  122991. */
  122992. pinchToPanMaxDistance: number;
  122993. /**
  122994. * Defines the maximum distance the camera can pan.
  122995. * This could help keeping the cammera always in your scene.
  122996. */
  122997. panningDistanceLimit: Nullable<number>;
  122998. /**
  122999. * Defines the target of the camera before paning.
  123000. */
  123001. panningOriginTarget: Vector3;
  123002. /**
  123003. * Defines the value of the inertia used during panning.
  123004. * 0 would mean stop inertia and one would mean no decelleration at all.
  123005. */
  123006. panningInertia: number;
  123007. /**
  123008. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123009. */
  123010. get angularSensibilityX(): number;
  123011. set angularSensibilityX(value: number);
  123012. /**
  123013. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123014. */
  123015. get angularSensibilityY(): number;
  123016. set angularSensibilityY(value: number);
  123017. /**
  123018. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123019. */
  123020. get pinchPrecision(): number;
  123021. set pinchPrecision(value: number);
  123022. /**
  123023. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123024. * It will be used instead of pinchDeltaPrecision if different from 0.
  123025. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123026. */
  123027. get pinchDeltaPercentage(): number;
  123028. set pinchDeltaPercentage(value: number);
  123029. /**
  123030. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123031. * and pinch delta percentage.
  123032. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123033. * that any object in the plane at the camera's target point will scale
  123034. * perfectly with finger motion.
  123035. */
  123036. get useNaturalPinchZoom(): boolean;
  123037. set useNaturalPinchZoom(value: boolean);
  123038. /**
  123039. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123040. */
  123041. get panningSensibility(): number;
  123042. set panningSensibility(value: number);
  123043. /**
  123044. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123045. */
  123046. get keysUp(): number[];
  123047. set keysUp(value: number[]);
  123048. /**
  123049. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123050. */
  123051. get keysDown(): number[];
  123052. set keysDown(value: number[]);
  123053. /**
  123054. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123055. */
  123056. get keysLeft(): number[];
  123057. set keysLeft(value: number[]);
  123058. /**
  123059. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123060. */
  123061. get keysRight(): number[];
  123062. set keysRight(value: number[]);
  123063. /**
  123064. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123065. */
  123066. get wheelPrecision(): number;
  123067. set wheelPrecision(value: number);
  123068. /**
  123069. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123070. * It will be used instead of pinchDeltaPrecision if different from 0.
  123071. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123072. */
  123073. get wheelDeltaPercentage(): number;
  123074. set wheelDeltaPercentage(value: number);
  123075. /**
  123076. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123077. */
  123078. zoomOnFactor: number;
  123079. /**
  123080. * Defines a screen offset for the camera position.
  123081. */
  123082. targetScreenOffset: Vector2;
  123083. /**
  123084. * Allows the camera to be completely reversed.
  123085. * If false the camera can not arrive upside down.
  123086. */
  123087. allowUpsideDown: boolean;
  123088. /**
  123089. * Define if double tap/click is used to restore the previously saved state of the camera.
  123090. */
  123091. useInputToRestoreState: boolean;
  123092. /** @hidden */
  123093. _viewMatrix: Matrix;
  123094. /** @hidden */
  123095. _useCtrlForPanning: boolean;
  123096. /** @hidden */
  123097. _panningMouseButton: number;
  123098. /**
  123099. * Defines the input associated to the camera.
  123100. */
  123101. inputs: ArcRotateCameraInputsManager;
  123102. /** @hidden */
  123103. _reset: () => void;
  123104. /**
  123105. * Defines the allowed panning axis.
  123106. */
  123107. panningAxis: Vector3;
  123108. protected _localDirection: Vector3;
  123109. protected _transformedDirection: Vector3;
  123110. private _bouncingBehavior;
  123111. /**
  123112. * Gets the bouncing behavior of the camera if it has been enabled.
  123113. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123114. */
  123115. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123116. /**
  123117. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123118. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123119. */
  123120. get useBouncingBehavior(): boolean;
  123121. set useBouncingBehavior(value: boolean);
  123122. private _framingBehavior;
  123123. /**
  123124. * Gets the framing behavior of the camera if it has been enabled.
  123125. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123126. */
  123127. get framingBehavior(): Nullable<FramingBehavior>;
  123128. /**
  123129. * Defines if the framing behavior of the camera is enabled on the camera.
  123130. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123131. */
  123132. get useFramingBehavior(): boolean;
  123133. set useFramingBehavior(value: boolean);
  123134. private _autoRotationBehavior;
  123135. /**
  123136. * Gets the auto rotation behavior of the camera if it has been enabled.
  123137. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123138. */
  123139. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123140. /**
  123141. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123142. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123143. */
  123144. get useAutoRotationBehavior(): boolean;
  123145. set useAutoRotationBehavior(value: boolean);
  123146. /**
  123147. * Observable triggered when the mesh target has been changed on the camera.
  123148. */
  123149. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123150. /**
  123151. * Event raised when the camera is colliding with a mesh.
  123152. */
  123153. onCollide: (collidedMesh: AbstractMesh) => void;
  123154. /**
  123155. * Defines whether the camera should check collision with the objects oh the scene.
  123156. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123157. */
  123158. checkCollisions: boolean;
  123159. /**
  123160. * Defines the collision radius of the camera.
  123161. * This simulates a sphere around the camera.
  123162. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123163. */
  123164. collisionRadius: Vector3;
  123165. protected _collider: Collider;
  123166. protected _previousPosition: Vector3;
  123167. protected _collisionVelocity: Vector3;
  123168. protected _newPosition: Vector3;
  123169. protected _previousAlpha: number;
  123170. protected _previousBeta: number;
  123171. protected _previousRadius: number;
  123172. protected _collisionTriggered: boolean;
  123173. protected _targetBoundingCenter: Nullable<Vector3>;
  123174. private _computationVector;
  123175. /**
  123176. * Instantiates a new ArcRotateCamera in a given scene
  123177. * @param name Defines the name of the camera
  123178. * @param alpha Defines the camera rotation along the logitudinal axis
  123179. * @param beta Defines the camera rotation along the latitudinal axis
  123180. * @param radius Defines the camera distance from its target
  123181. * @param target Defines the camera target
  123182. * @param scene Defines the scene the camera belongs to
  123183. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123184. */
  123185. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123186. /** @hidden */
  123187. _initCache(): void;
  123188. /** @hidden */
  123189. _updateCache(ignoreParentClass?: boolean): void;
  123190. protected _getTargetPosition(): Vector3;
  123191. private _storedAlpha;
  123192. private _storedBeta;
  123193. private _storedRadius;
  123194. private _storedTarget;
  123195. private _storedTargetScreenOffset;
  123196. /**
  123197. * Stores the current state of the camera (alpha, beta, radius and target)
  123198. * @returns the camera itself
  123199. */
  123200. storeState(): Camera;
  123201. /**
  123202. * @hidden
  123203. * Restored camera state. You must call storeState() first
  123204. */
  123205. _restoreStateValues(): boolean;
  123206. /** @hidden */
  123207. _isSynchronizedViewMatrix(): boolean;
  123208. /**
  123209. * Attached controls to the current camera.
  123210. * @param element Defines the element the controls should be listened from
  123211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123212. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123213. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123214. */
  123215. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123216. /**
  123217. * Detach the current controls from the camera.
  123218. * The camera will stop reacting to inputs.
  123219. * @param element Defines the element to stop listening the inputs from
  123220. */
  123221. detachControl(element: HTMLElement): void;
  123222. /** @hidden */
  123223. _checkInputs(): void;
  123224. protected _checkLimits(): void;
  123225. /**
  123226. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123227. */
  123228. rebuildAnglesAndRadius(): void;
  123229. /**
  123230. * Use a position to define the current camera related information like alpha, beta and radius
  123231. * @param position Defines the position to set the camera at
  123232. */
  123233. setPosition(position: Vector3): void;
  123234. /**
  123235. * Defines the target the camera should look at.
  123236. * This will automatically adapt alpha beta and radius to fit within the new target.
  123237. * @param target Defines the new target as a Vector or a mesh
  123238. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123239. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123240. */
  123241. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123242. /** @hidden */
  123243. _getViewMatrix(): Matrix;
  123244. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123245. /**
  123246. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123247. * @param meshes Defines the mesh to zoom on
  123248. * @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)
  123249. */
  123250. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123251. /**
  123252. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123253. * The target will be changed but the radius
  123254. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123255. * @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)
  123256. */
  123257. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123258. min: Vector3;
  123259. max: Vector3;
  123260. distance: number;
  123261. }, doNotUpdateMaxZ?: boolean): void;
  123262. /**
  123263. * @override
  123264. * Override Camera.createRigCamera
  123265. */
  123266. createRigCamera(name: string, cameraIndex: number): Camera;
  123267. /**
  123268. * @hidden
  123269. * @override
  123270. * Override Camera._updateRigCameras
  123271. */
  123272. _updateRigCameras(): void;
  123273. /**
  123274. * Destroy the camera and release the current resources hold by it.
  123275. */
  123276. dispose(): void;
  123277. /**
  123278. * Gets the current object class name.
  123279. * @return the class name
  123280. */
  123281. getClassName(): string;
  123282. }
  123283. }
  123284. declare module BABYLON {
  123285. /**
  123286. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123287. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123288. */
  123289. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123290. /**
  123291. * Gets the name of the behavior.
  123292. */
  123293. get name(): string;
  123294. private _zoomStopsAnimation;
  123295. private _idleRotationSpeed;
  123296. private _idleRotationWaitTime;
  123297. private _idleRotationSpinupTime;
  123298. /**
  123299. * Sets the flag that indicates if user zooming should stop animation.
  123300. */
  123301. set zoomStopsAnimation(flag: boolean);
  123302. /**
  123303. * Gets the flag that indicates if user zooming should stop animation.
  123304. */
  123305. get zoomStopsAnimation(): boolean;
  123306. /**
  123307. * Sets the default speed at which the camera rotates around the model.
  123308. */
  123309. set idleRotationSpeed(speed: number);
  123310. /**
  123311. * Gets the default speed at which the camera rotates around the model.
  123312. */
  123313. get idleRotationSpeed(): number;
  123314. /**
  123315. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123316. */
  123317. set idleRotationWaitTime(time: number);
  123318. /**
  123319. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123320. */
  123321. get idleRotationWaitTime(): number;
  123322. /**
  123323. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123324. */
  123325. set idleRotationSpinupTime(time: number);
  123326. /**
  123327. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123328. */
  123329. get idleRotationSpinupTime(): number;
  123330. /**
  123331. * Gets a value indicating if the camera is currently rotating because of this behavior
  123332. */
  123333. get rotationInProgress(): boolean;
  123334. private _onPrePointerObservableObserver;
  123335. private _onAfterCheckInputsObserver;
  123336. private _attachedCamera;
  123337. private _isPointerDown;
  123338. private _lastFrameTime;
  123339. private _lastInteractionTime;
  123340. private _cameraRotationSpeed;
  123341. /**
  123342. * Initializes the behavior.
  123343. */
  123344. init(): void;
  123345. /**
  123346. * Attaches the behavior to its arc rotate camera.
  123347. * @param camera Defines the camera to attach the behavior to
  123348. */
  123349. attach(camera: ArcRotateCamera): void;
  123350. /**
  123351. * Detaches the behavior from its current arc rotate camera.
  123352. */
  123353. detach(): void;
  123354. /**
  123355. * Returns true if user is scrolling.
  123356. * @return true if user is scrolling.
  123357. */
  123358. private _userIsZooming;
  123359. private _lastFrameRadius;
  123360. private _shouldAnimationStopForInteraction;
  123361. /**
  123362. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123363. */
  123364. private _applyUserInteraction;
  123365. private _userIsMoving;
  123366. }
  123367. }
  123368. declare module BABYLON {
  123369. /**
  123370. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123371. */
  123372. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123373. private ui;
  123374. /**
  123375. * The name of the behavior
  123376. */
  123377. name: string;
  123378. /**
  123379. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123380. */
  123381. distanceAwayFromFace: number;
  123382. /**
  123383. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123384. */
  123385. distanceAwayFromBottomOfFace: number;
  123386. private _faceVectors;
  123387. private _target;
  123388. private _scene;
  123389. private _onRenderObserver;
  123390. private _tmpMatrix;
  123391. private _tmpVector;
  123392. /**
  123393. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123394. * @param ui The transform node that should be attched to the mesh
  123395. */
  123396. constructor(ui: TransformNode);
  123397. /**
  123398. * Initializes the behavior
  123399. */
  123400. init(): void;
  123401. private _closestFace;
  123402. private _zeroVector;
  123403. private _lookAtTmpMatrix;
  123404. private _lookAtToRef;
  123405. /**
  123406. * Attaches the AttachToBoxBehavior to the passed in mesh
  123407. * @param target The mesh that the specified node will be attached to
  123408. */
  123409. attach(target: Mesh): void;
  123410. /**
  123411. * Detaches the behavior from the mesh
  123412. */
  123413. detach(): void;
  123414. }
  123415. }
  123416. declare module BABYLON {
  123417. /**
  123418. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123419. */
  123420. export class FadeInOutBehavior implements Behavior<Mesh> {
  123421. /**
  123422. * Time in milliseconds to delay before fading in (Default: 0)
  123423. */
  123424. delay: number;
  123425. /**
  123426. * Time in milliseconds for the mesh to fade in (Default: 300)
  123427. */
  123428. fadeInTime: number;
  123429. private _millisecondsPerFrame;
  123430. private _hovered;
  123431. private _hoverValue;
  123432. private _ownerNode;
  123433. /**
  123434. * Instatiates the FadeInOutBehavior
  123435. */
  123436. constructor();
  123437. /**
  123438. * The name of the behavior
  123439. */
  123440. get name(): string;
  123441. /**
  123442. * Initializes the behavior
  123443. */
  123444. init(): void;
  123445. /**
  123446. * Attaches the fade behavior on the passed in mesh
  123447. * @param ownerNode The mesh that will be faded in/out once attached
  123448. */
  123449. attach(ownerNode: Mesh): void;
  123450. /**
  123451. * Detaches the behavior from the mesh
  123452. */
  123453. detach(): void;
  123454. /**
  123455. * Triggers the mesh to begin fading in or out
  123456. * @param value if the object should fade in or out (true to fade in)
  123457. */
  123458. fadeIn(value: boolean): void;
  123459. private _update;
  123460. private _setAllVisibility;
  123461. }
  123462. }
  123463. declare module BABYLON {
  123464. /**
  123465. * Class containing a set of static utilities functions for managing Pivots
  123466. * @hidden
  123467. */
  123468. export class PivotTools {
  123469. private static _PivotCached;
  123470. private static _OldPivotPoint;
  123471. private static _PivotTranslation;
  123472. private static _PivotTmpVector;
  123473. private static _PivotPostMultiplyPivotMatrix;
  123474. /** @hidden */
  123475. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123476. /** @hidden */
  123477. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123478. }
  123479. }
  123480. declare module BABYLON {
  123481. /**
  123482. * Class containing static functions to help procedurally build meshes
  123483. */
  123484. export class PlaneBuilder {
  123485. /**
  123486. * Creates a plane mesh
  123487. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123488. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123489. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123493. * @param name defines the name of the mesh
  123494. * @param options defines the options used to create the mesh
  123495. * @param scene defines the hosting scene
  123496. * @returns the plane mesh
  123497. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123498. */
  123499. static CreatePlane(name: string, options: {
  123500. size?: number;
  123501. width?: number;
  123502. height?: number;
  123503. sideOrientation?: number;
  123504. frontUVs?: Vector4;
  123505. backUVs?: Vector4;
  123506. updatable?: boolean;
  123507. sourcePlane?: Plane;
  123508. }, scene?: Nullable<Scene>): Mesh;
  123509. }
  123510. }
  123511. declare module BABYLON {
  123512. /**
  123513. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123514. */
  123515. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123516. private static _AnyMouseID;
  123517. /**
  123518. * Abstract mesh the behavior is set on
  123519. */
  123520. attachedNode: AbstractMesh;
  123521. private _dragPlane;
  123522. private _scene;
  123523. private _pointerObserver;
  123524. private _beforeRenderObserver;
  123525. private static _planeScene;
  123526. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123527. /**
  123528. * 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)
  123529. */
  123530. maxDragAngle: number;
  123531. /**
  123532. * @hidden
  123533. */
  123534. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123535. /**
  123536. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123537. */
  123538. currentDraggingPointerID: number;
  123539. /**
  123540. * The last position where the pointer hit the drag plane in world space
  123541. */
  123542. lastDragPosition: Vector3;
  123543. /**
  123544. * If the behavior is currently in a dragging state
  123545. */
  123546. dragging: boolean;
  123547. /**
  123548. * 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)
  123549. */
  123550. dragDeltaRatio: number;
  123551. /**
  123552. * If the drag plane orientation should be updated during the dragging (Default: true)
  123553. */
  123554. updateDragPlane: boolean;
  123555. private _debugMode;
  123556. private _moving;
  123557. /**
  123558. * Fires each time the attached mesh is dragged with the pointer
  123559. * * delta between last drag position and current drag position in world space
  123560. * * dragDistance along the drag axis
  123561. * * dragPlaneNormal normal of the current drag plane used during the drag
  123562. * * dragPlanePoint in world space where the drag intersects the drag plane
  123563. */
  123564. onDragObservable: Observable<{
  123565. delta: Vector3;
  123566. dragPlanePoint: Vector3;
  123567. dragPlaneNormal: Vector3;
  123568. dragDistance: number;
  123569. pointerId: number;
  123570. }>;
  123571. /**
  123572. * Fires each time a drag begins (eg. mouse down on mesh)
  123573. */
  123574. onDragStartObservable: Observable<{
  123575. dragPlanePoint: Vector3;
  123576. pointerId: number;
  123577. }>;
  123578. /**
  123579. * Fires each time a drag ends (eg. mouse release after drag)
  123580. */
  123581. onDragEndObservable: Observable<{
  123582. dragPlanePoint: Vector3;
  123583. pointerId: number;
  123584. }>;
  123585. /**
  123586. * If the attached mesh should be moved when dragged
  123587. */
  123588. moveAttached: boolean;
  123589. /**
  123590. * If the drag behavior will react to drag events (Default: true)
  123591. */
  123592. enabled: boolean;
  123593. /**
  123594. * If pointer events should start and release the drag (Default: true)
  123595. */
  123596. startAndReleaseDragOnPointerEvents: boolean;
  123597. /**
  123598. * If camera controls should be detached during the drag
  123599. */
  123600. detachCameraControls: boolean;
  123601. /**
  123602. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123603. */
  123604. useObjectOrientationForDragging: boolean;
  123605. private _options;
  123606. /**
  123607. * Gets the options used by the behavior
  123608. */
  123609. get options(): {
  123610. dragAxis?: Vector3;
  123611. dragPlaneNormal?: Vector3;
  123612. };
  123613. /**
  123614. * Sets the options used by the behavior
  123615. */
  123616. set options(options: {
  123617. dragAxis?: Vector3;
  123618. dragPlaneNormal?: Vector3;
  123619. });
  123620. /**
  123621. * Creates a pointer drag behavior that can be attached to a mesh
  123622. * @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)
  123623. */
  123624. constructor(options?: {
  123625. dragAxis?: Vector3;
  123626. dragPlaneNormal?: Vector3;
  123627. });
  123628. /**
  123629. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123630. */
  123631. validateDrag: (targetPosition: Vector3) => boolean;
  123632. /**
  123633. * The name of the behavior
  123634. */
  123635. get name(): string;
  123636. /**
  123637. * Initializes the behavior
  123638. */
  123639. init(): void;
  123640. private _tmpVector;
  123641. private _alternatePickedPoint;
  123642. private _worldDragAxis;
  123643. private _targetPosition;
  123644. private _attachedElement;
  123645. /**
  123646. * Attaches the drag behavior the passed in mesh
  123647. * @param ownerNode The mesh that will be dragged around once attached
  123648. * @param predicate Predicate to use for pick filtering
  123649. */
  123650. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123651. /**
  123652. * Force relase the drag action by code.
  123653. */
  123654. releaseDrag(): void;
  123655. private _startDragRay;
  123656. private _lastPointerRay;
  123657. /**
  123658. * Simulates the start of a pointer drag event on the behavior
  123659. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123660. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123661. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123662. */
  123663. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123664. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123665. private _dragDelta;
  123666. protected _moveDrag(ray: Ray): void;
  123667. private _pickWithRayOnDragPlane;
  123668. private _pointA;
  123669. private _pointC;
  123670. private _localAxis;
  123671. private _lookAt;
  123672. private _updateDragPlanePosition;
  123673. /**
  123674. * Detaches the behavior from the mesh
  123675. */
  123676. detach(): void;
  123677. }
  123678. }
  123679. declare module BABYLON {
  123680. /**
  123681. * A behavior that when attached to a mesh will allow the mesh to be scaled
  123682. */
  123683. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  123684. private _dragBehaviorA;
  123685. private _dragBehaviorB;
  123686. private _startDistance;
  123687. private _initialScale;
  123688. private _targetScale;
  123689. private _ownerNode;
  123690. private _sceneRenderObserver;
  123691. /**
  123692. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  123693. */
  123694. constructor();
  123695. /**
  123696. * The name of the behavior
  123697. */
  123698. get name(): string;
  123699. /**
  123700. * Initializes the behavior
  123701. */
  123702. init(): void;
  123703. private _getCurrentDistance;
  123704. /**
  123705. * Attaches the scale behavior the passed in mesh
  123706. * @param ownerNode The mesh that will be scaled around once attached
  123707. */
  123708. attach(ownerNode: Mesh): void;
  123709. /**
  123710. * Detaches the behavior from the mesh
  123711. */
  123712. detach(): void;
  123713. }
  123714. }
  123715. declare module BABYLON {
  123716. /**
  123717. * 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
  123718. */
  123719. export class SixDofDragBehavior implements Behavior<Mesh> {
  123720. private static _virtualScene;
  123721. private _ownerNode;
  123722. private _sceneRenderObserver;
  123723. private _scene;
  123724. private _targetPosition;
  123725. private _virtualOriginMesh;
  123726. private _virtualDragMesh;
  123727. private _pointerObserver;
  123728. private _moving;
  123729. private _startingOrientation;
  123730. private _attachedElement;
  123731. /**
  123732. * 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)
  123733. */
  123734. private zDragFactor;
  123735. /**
  123736. * If the object should rotate to face the drag origin
  123737. */
  123738. rotateDraggedObject: boolean;
  123739. /**
  123740. * If the behavior is currently in a dragging state
  123741. */
  123742. dragging: boolean;
  123743. /**
  123744. * 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)
  123745. */
  123746. dragDeltaRatio: number;
  123747. /**
  123748. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123749. */
  123750. currentDraggingPointerID: number;
  123751. /**
  123752. * If camera controls should be detached during the drag
  123753. */
  123754. detachCameraControls: boolean;
  123755. /**
  123756. * Fires each time a drag starts
  123757. */
  123758. onDragStartObservable: Observable<{}>;
  123759. /**
  123760. * Fires each time a drag ends (eg. mouse release after drag)
  123761. */
  123762. onDragEndObservable: Observable<{}>;
  123763. /**
  123764. * 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
  123765. */
  123766. constructor();
  123767. /**
  123768. * The name of the behavior
  123769. */
  123770. get name(): string;
  123771. /**
  123772. * Initializes the behavior
  123773. */
  123774. init(): void;
  123775. /**
  123776. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  123777. */
  123778. private get _pointerCamera();
  123779. /**
  123780. * Attaches the scale behavior the passed in mesh
  123781. * @param ownerNode The mesh that will be scaled around once attached
  123782. */
  123783. attach(ownerNode: Mesh): void;
  123784. /**
  123785. * Detaches the behavior from the mesh
  123786. */
  123787. detach(): void;
  123788. }
  123789. }
  123790. declare module BABYLON {
  123791. /**
  123792. * Class used to apply inverse kinematics to bones
  123793. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  123794. */
  123795. export class BoneIKController {
  123796. private static _tmpVecs;
  123797. private static _tmpQuat;
  123798. private static _tmpMats;
  123799. /**
  123800. * Gets or sets the target mesh
  123801. */
  123802. targetMesh: AbstractMesh;
  123803. /** Gets or sets the mesh used as pole */
  123804. poleTargetMesh: AbstractMesh;
  123805. /**
  123806. * Gets or sets the bone used as pole
  123807. */
  123808. poleTargetBone: Nullable<Bone>;
  123809. /**
  123810. * Gets or sets the target position
  123811. */
  123812. targetPosition: Vector3;
  123813. /**
  123814. * Gets or sets the pole target position
  123815. */
  123816. poleTargetPosition: Vector3;
  123817. /**
  123818. * Gets or sets the pole target local offset
  123819. */
  123820. poleTargetLocalOffset: Vector3;
  123821. /**
  123822. * Gets or sets the pole angle
  123823. */
  123824. poleAngle: number;
  123825. /**
  123826. * Gets or sets the mesh associated with the controller
  123827. */
  123828. mesh: AbstractMesh;
  123829. /**
  123830. * 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)
  123831. */
  123832. slerpAmount: number;
  123833. private _bone1Quat;
  123834. private _bone1Mat;
  123835. private _bone2Ang;
  123836. private _bone1;
  123837. private _bone2;
  123838. private _bone1Length;
  123839. private _bone2Length;
  123840. private _maxAngle;
  123841. private _maxReach;
  123842. private _rightHandedSystem;
  123843. private _bendAxis;
  123844. private _slerping;
  123845. private _adjustRoll;
  123846. /**
  123847. * Gets or sets maximum allowed angle
  123848. */
  123849. get maxAngle(): number;
  123850. set maxAngle(value: number);
  123851. /**
  123852. * Creates a new BoneIKController
  123853. * @param mesh defines the mesh to control
  123854. * @param bone defines the bone to control
  123855. * @param options defines options to set up the controller
  123856. */
  123857. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  123858. targetMesh?: AbstractMesh;
  123859. poleTargetMesh?: AbstractMesh;
  123860. poleTargetBone?: Bone;
  123861. poleTargetLocalOffset?: Vector3;
  123862. poleAngle?: number;
  123863. bendAxis?: Vector3;
  123864. maxAngle?: number;
  123865. slerpAmount?: number;
  123866. });
  123867. private _setMaxAngle;
  123868. /**
  123869. * Force the controller to update the bones
  123870. */
  123871. update(): void;
  123872. }
  123873. }
  123874. declare module BABYLON {
  123875. /**
  123876. * Class used to make a bone look toward a point in space
  123877. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  123878. */
  123879. export class BoneLookController {
  123880. private static _tmpVecs;
  123881. private static _tmpQuat;
  123882. private static _tmpMats;
  123883. /**
  123884. * The target Vector3 that the bone will look at
  123885. */
  123886. target: Vector3;
  123887. /**
  123888. * The mesh that the bone is attached to
  123889. */
  123890. mesh: AbstractMesh;
  123891. /**
  123892. * The bone that will be looking to the target
  123893. */
  123894. bone: Bone;
  123895. /**
  123896. * The up axis of the coordinate system that is used when the bone is rotated
  123897. */
  123898. upAxis: Vector3;
  123899. /**
  123900. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  123901. */
  123902. upAxisSpace: Space;
  123903. /**
  123904. * Used to make an adjustment to the yaw of the bone
  123905. */
  123906. adjustYaw: number;
  123907. /**
  123908. * Used to make an adjustment to the pitch of the bone
  123909. */
  123910. adjustPitch: number;
  123911. /**
  123912. * Used to make an adjustment to the roll of the bone
  123913. */
  123914. adjustRoll: number;
  123915. /**
  123916. * 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)
  123917. */
  123918. slerpAmount: number;
  123919. private _minYaw;
  123920. private _maxYaw;
  123921. private _minPitch;
  123922. private _maxPitch;
  123923. private _minYawSin;
  123924. private _minYawCos;
  123925. private _maxYawSin;
  123926. private _maxYawCos;
  123927. private _midYawConstraint;
  123928. private _minPitchTan;
  123929. private _maxPitchTan;
  123930. private _boneQuat;
  123931. private _slerping;
  123932. private _transformYawPitch;
  123933. private _transformYawPitchInv;
  123934. private _firstFrameSkipped;
  123935. private _yawRange;
  123936. private _fowardAxis;
  123937. /**
  123938. * Gets or sets the minimum yaw angle that the bone can look to
  123939. */
  123940. get minYaw(): number;
  123941. set minYaw(value: number);
  123942. /**
  123943. * Gets or sets the maximum yaw angle that the bone can look to
  123944. */
  123945. get maxYaw(): number;
  123946. set maxYaw(value: number);
  123947. /**
  123948. * Gets or sets the minimum pitch angle that the bone can look to
  123949. */
  123950. get minPitch(): number;
  123951. set minPitch(value: number);
  123952. /**
  123953. * Gets or sets the maximum pitch angle that the bone can look to
  123954. */
  123955. get maxPitch(): number;
  123956. set maxPitch(value: number);
  123957. /**
  123958. * Create a BoneLookController
  123959. * @param mesh the mesh that the bone belongs to
  123960. * @param bone the bone that will be looking to the target
  123961. * @param target the target Vector3 to look at
  123962. * @param options optional settings:
  123963. * * maxYaw: the maximum angle the bone will yaw to
  123964. * * minYaw: the minimum angle the bone will yaw to
  123965. * * maxPitch: the maximum angle the bone will pitch to
  123966. * * minPitch: the minimum angle the bone will yaw to
  123967. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  123968. * * upAxis: the up axis of the coordinate system
  123969. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  123970. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  123971. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  123972. * * adjustYaw: used to make an adjustment to the yaw of the bone
  123973. * * adjustPitch: used to make an adjustment to the pitch of the bone
  123974. * * adjustRoll: used to make an adjustment to the roll of the bone
  123975. **/
  123976. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  123977. maxYaw?: number;
  123978. minYaw?: number;
  123979. maxPitch?: number;
  123980. minPitch?: number;
  123981. slerpAmount?: number;
  123982. upAxis?: Vector3;
  123983. upAxisSpace?: Space;
  123984. yawAxis?: Vector3;
  123985. pitchAxis?: Vector3;
  123986. adjustYaw?: number;
  123987. adjustPitch?: number;
  123988. adjustRoll?: number;
  123989. });
  123990. /**
  123991. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  123992. */
  123993. update(): void;
  123994. private _getAngleDiff;
  123995. private _getAngleBetween;
  123996. private _isAngleBetween;
  123997. }
  123998. }
  123999. declare module BABYLON {
  124000. /**
  124001. * Manage the gamepad inputs to control an arc rotate camera.
  124002. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124003. */
  124004. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124005. /**
  124006. * Defines the camera the input is attached to.
  124007. */
  124008. camera: ArcRotateCamera;
  124009. /**
  124010. * Defines the gamepad the input is gathering event from.
  124011. */
  124012. gamepad: Nullable<Gamepad>;
  124013. /**
  124014. * Defines the gamepad rotation sensiblity.
  124015. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124016. */
  124017. gamepadRotationSensibility: number;
  124018. /**
  124019. * Defines the gamepad move sensiblity.
  124020. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124021. */
  124022. gamepadMoveSensibility: number;
  124023. private _yAxisScale;
  124024. /**
  124025. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124026. */
  124027. get invertYAxis(): boolean;
  124028. set invertYAxis(value: boolean);
  124029. private _onGamepadConnectedObserver;
  124030. private _onGamepadDisconnectedObserver;
  124031. /**
  124032. * Attach the input controls to a specific dom element to get the input from.
  124033. * @param element Defines the element the controls should be listened from
  124034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124035. */
  124036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124037. /**
  124038. * Detach the current controls from the specified dom element.
  124039. * @param element Defines the element to stop listening the inputs from
  124040. */
  124041. detachControl(element: Nullable<HTMLElement>): void;
  124042. /**
  124043. * Update the current camera state depending on the inputs that have been used this frame.
  124044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124045. */
  124046. checkInputs(): void;
  124047. /**
  124048. * Gets the class name of the current intput.
  124049. * @returns the class name
  124050. */
  124051. getClassName(): string;
  124052. /**
  124053. * Get the friendly name associated with the input class.
  124054. * @returns the input friendly name
  124055. */
  124056. getSimpleName(): string;
  124057. }
  124058. }
  124059. declare module BABYLON {
  124060. interface ArcRotateCameraInputsManager {
  124061. /**
  124062. * Add orientation input support to the input manager.
  124063. * @returns the current input manager
  124064. */
  124065. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124066. }
  124067. /**
  124068. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124069. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124070. */
  124071. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124072. /**
  124073. * Defines the camera the input is attached to.
  124074. */
  124075. camera: ArcRotateCamera;
  124076. /**
  124077. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124078. */
  124079. alphaCorrection: number;
  124080. /**
  124081. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124082. */
  124083. gammaCorrection: number;
  124084. private _alpha;
  124085. private _gamma;
  124086. private _dirty;
  124087. private _deviceOrientationHandler;
  124088. /**
  124089. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124090. */
  124091. constructor();
  124092. /**
  124093. * Attach the input controls to a specific dom element to get the input from.
  124094. * @param element Defines the element the controls should be listened from
  124095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124096. */
  124097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124098. /** @hidden */
  124099. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124100. /**
  124101. * Update the current camera state depending on the inputs that have been used this frame.
  124102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124103. */
  124104. checkInputs(): void;
  124105. /**
  124106. * Detach the current controls from the specified dom element.
  124107. * @param element Defines the element to stop listening the inputs from
  124108. */
  124109. detachControl(element: Nullable<HTMLElement>): void;
  124110. /**
  124111. * Gets the class name of the current intput.
  124112. * @returns the class name
  124113. */
  124114. getClassName(): string;
  124115. /**
  124116. * Get the friendly name associated with the input class.
  124117. * @returns the input friendly name
  124118. */
  124119. getSimpleName(): string;
  124120. }
  124121. }
  124122. declare module BABYLON {
  124123. /**
  124124. * Listen to mouse events to control the camera.
  124125. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124126. */
  124127. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124128. /**
  124129. * Defines the camera the input is attached to.
  124130. */
  124131. camera: FlyCamera;
  124132. /**
  124133. * Defines if touch is enabled. (Default is true.)
  124134. */
  124135. touchEnabled: boolean;
  124136. /**
  124137. * Defines the buttons associated with the input to handle camera rotation.
  124138. */
  124139. buttons: number[];
  124140. /**
  124141. * Assign buttons for Yaw control.
  124142. */
  124143. buttonsYaw: number[];
  124144. /**
  124145. * Assign buttons for Pitch control.
  124146. */
  124147. buttonsPitch: number[];
  124148. /**
  124149. * Assign buttons for Roll control.
  124150. */
  124151. buttonsRoll: number[];
  124152. /**
  124153. * Detect if any button is being pressed while mouse is moved.
  124154. * -1 = Mouse locked.
  124155. * 0 = Left button.
  124156. * 1 = Middle Button.
  124157. * 2 = Right Button.
  124158. */
  124159. activeButton: number;
  124160. /**
  124161. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124162. * Higher values reduce its sensitivity.
  124163. */
  124164. angularSensibility: number;
  124165. private _mousemoveCallback;
  124166. private _observer;
  124167. private _rollObserver;
  124168. private previousPosition;
  124169. private noPreventDefault;
  124170. private element;
  124171. /**
  124172. * Listen to mouse events to control the camera.
  124173. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124175. */
  124176. constructor(touchEnabled?: boolean);
  124177. /**
  124178. * Attach the mouse control to the HTML DOM element.
  124179. * @param element Defines the element that listens to the input events.
  124180. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124181. */
  124182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124183. /**
  124184. * Detach the current controls from the specified dom element.
  124185. * @param element Defines the element to stop listening the inputs from
  124186. */
  124187. detachControl(element: Nullable<HTMLElement>): void;
  124188. /**
  124189. * Gets the class name of the current input.
  124190. * @returns the class name.
  124191. */
  124192. getClassName(): string;
  124193. /**
  124194. * Get the friendly name associated with the input class.
  124195. * @returns the input's friendly name.
  124196. */
  124197. getSimpleName(): string;
  124198. private _pointerInput;
  124199. private _onMouseMove;
  124200. /**
  124201. * Rotate camera by mouse offset.
  124202. */
  124203. private rotateCamera;
  124204. }
  124205. }
  124206. declare module BABYLON {
  124207. /**
  124208. * Default Inputs manager for the FlyCamera.
  124209. * It groups all the default supported inputs for ease of use.
  124210. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124211. */
  124212. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124213. /**
  124214. * Instantiates a new FlyCameraInputsManager.
  124215. * @param camera Defines the camera the inputs belong to.
  124216. */
  124217. constructor(camera: FlyCamera);
  124218. /**
  124219. * Add keyboard input support to the input manager.
  124220. * @returns the new FlyCameraKeyboardMoveInput().
  124221. */
  124222. addKeyboard(): FlyCameraInputsManager;
  124223. /**
  124224. * Add mouse input support to the input manager.
  124225. * @param touchEnabled Enable touch screen support.
  124226. * @returns the new FlyCameraMouseInput().
  124227. */
  124228. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124229. }
  124230. }
  124231. declare module BABYLON {
  124232. /**
  124233. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124234. * such as in a 3D Space Shooter or a Flight Simulator.
  124235. */
  124236. export class FlyCamera extends TargetCamera {
  124237. /**
  124238. * Define the collision ellipsoid of the camera.
  124239. * This is helpful for simulating a camera body, like a player's body.
  124240. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124241. */
  124242. ellipsoid: Vector3;
  124243. /**
  124244. * Define an offset for the position of the ellipsoid around the camera.
  124245. * This can be helpful if the camera is attached away from the player's body center,
  124246. * such as at its head.
  124247. */
  124248. ellipsoidOffset: Vector3;
  124249. /**
  124250. * Enable or disable collisions of the camera with the rest of the scene objects.
  124251. */
  124252. checkCollisions: boolean;
  124253. /**
  124254. * Enable or disable gravity on the camera.
  124255. */
  124256. applyGravity: boolean;
  124257. /**
  124258. * Define the current direction the camera is moving to.
  124259. */
  124260. cameraDirection: Vector3;
  124261. /**
  124262. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124263. * This overrides and empties cameraRotation.
  124264. */
  124265. rotationQuaternion: Quaternion;
  124266. /**
  124267. * Track Roll to maintain the wanted Rolling when looking around.
  124268. */
  124269. _trackRoll: number;
  124270. /**
  124271. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124272. */
  124273. rollCorrect: number;
  124274. /**
  124275. * Mimic a banked turn, Rolling the camera when Yawing.
  124276. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124277. */
  124278. bankedTurn: boolean;
  124279. /**
  124280. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124281. */
  124282. bankedTurnLimit: number;
  124283. /**
  124284. * Value of 0 disables the banked Roll.
  124285. * Value of 1 is equal to the Yaw angle in radians.
  124286. */
  124287. bankedTurnMultiplier: number;
  124288. /**
  124289. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124290. */
  124291. inputs: FlyCameraInputsManager;
  124292. /**
  124293. * Gets the input sensibility for mouse input.
  124294. * Higher values reduce sensitivity.
  124295. */
  124296. get angularSensibility(): number;
  124297. /**
  124298. * Sets the input sensibility for a mouse input.
  124299. * Higher values reduce sensitivity.
  124300. */
  124301. set angularSensibility(value: number);
  124302. /**
  124303. * Get the keys for camera movement forward.
  124304. */
  124305. get keysForward(): number[];
  124306. /**
  124307. * Set the keys for camera movement forward.
  124308. */
  124309. set keysForward(value: number[]);
  124310. /**
  124311. * Get the keys for camera movement backward.
  124312. */
  124313. get keysBackward(): number[];
  124314. set keysBackward(value: number[]);
  124315. /**
  124316. * Get the keys for camera movement up.
  124317. */
  124318. get keysUp(): number[];
  124319. /**
  124320. * Set the keys for camera movement up.
  124321. */
  124322. set keysUp(value: number[]);
  124323. /**
  124324. * Get the keys for camera movement down.
  124325. */
  124326. get keysDown(): number[];
  124327. /**
  124328. * Set the keys for camera movement down.
  124329. */
  124330. set keysDown(value: number[]);
  124331. /**
  124332. * Get the keys for camera movement left.
  124333. */
  124334. get keysLeft(): number[];
  124335. /**
  124336. * Set the keys for camera movement left.
  124337. */
  124338. set keysLeft(value: number[]);
  124339. /**
  124340. * Set the keys for camera movement right.
  124341. */
  124342. get keysRight(): number[];
  124343. /**
  124344. * Set the keys for camera movement right.
  124345. */
  124346. set keysRight(value: number[]);
  124347. /**
  124348. * Event raised when the camera collides with a mesh in the scene.
  124349. */
  124350. onCollide: (collidedMesh: AbstractMesh) => void;
  124351. private _collider;
  124352. private _needMoveForGravity;
  124353. private _oldPosition;
  124354. private _diffPosition;
  124355. private _newPosition;
  124356. /** @hidden */
  124357. _localDirection: Vector3;
  124358. /** @hidden */
  124359. _transformedDirection: Vector3;
  124360. /**
  124361. * Instantiates a FlyCamera.
  124362. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124363. * such as in a 3D Space Shooter or a Flight Simulator.
  124364. * @param name Define the name of the camera in the scene.
  124365. * @param position Define the starting position of the camera in the scene.
  124366. * @param scene Define the scene the camera belongs to.
  124367. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124368. */
  124369. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124370. /**
  124371. * Attach a control to the HTML DOM element.
  124372. * @param element Defines the element that listens to the input events.
  124373. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124374. */
  124375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124376. /**
  124377. * Detach a control from the HTML DOM element.
  124378. * The camera will stop reacting to that input.
  124379. * @param element Defines the element that listens to the input events.
  124380. */
  124381. detachControl(element: HTMLElement): void;
  124382. private _collisionMask;
  124383. /**
  124384. * Get the mask that the camera ignores in collision events.
  124385. */
  124386. get collisionMask(): number;
  124387. /**
  124388. * Set the mask that the camera ignores in collision events.
  124389. */
  124390. set collisionMask(mask: number);
  124391. /** @hidden */
  124392. _collideWithWorld(displacement: Vector3): void;
  124393. /** @hidden */
  124394. private _onCollisionPositionChange;
  124395. /** @hidden */
  124396. _checkInputs(): void;
  124397. /** @hidden */
  124398. _decideIfNeedsToMove(): boolean;
  124399. /** @hidden */
  124400. _updatePosition(): void;
  124401. /**
  124402. * Restore the Roll to its target value at the rate specified.
  124403. * @param rate - Higher means slower restoring.
  124404. * @hidden
  124405. */
  124406. restoreRoll(rate: number): void;
  124407. /**
  124408. * Destroy the camera and release the current resources held by it.
  124409. */
  124410. dispose(): void;
  124411. /**
  124412. * Get the current object class name.
  124413. * @returns the class name.
  124414. */
  124415. getClassName(): string;
  124416. }
  124417. }
  124418. declare module BABYLON {
  124419. /**
  124420. * Listen to keyboard events to control the camera.
  124421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124422. */
  124423. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124424. /**
  124425. * Defines the camera the input is attached to.
  124426. */
  124427. camera: FlyCamera;
  124428. /**
  124429. * The list of keyboard keys used to control the forward move of the camera.
  124430. */
  124431. keysForward: number[];
  124432. /**
  124433. * The list of keyboard keys used to control the backward move of the camera.
  124434. */
  124435. keysBackward: number[];
  124436. /**
  124437. * The list of keyboard keys used to control the forward move of the camera.
  124438. */
  124439. keysUp: number[];
  124440. /**
  124441. * The list of keyboard keys used to control the backward move of the camera.
  124442. */
  124443. keysDown: number[];
  124444. /**
  124445. * The list of keyboard keys used to control the right strafe move of the camera.
  124446. */
  124447. keysRight: number[];
  124448. /**
  124449. * The list of keyboard keys used to control the left strafe move of the camera.
  124450. */
  124451. keysLeft: number[];
  124452. private _keys;
  124453. private _onCanvasBlurObserver;
  124454. private _onKeyboardObserver;
  124455. private _engine;
  124456. private _scene;
  124457. /**
  124458. * Attach the input controls to a specific dom element to get the input from.
  124459. * @param element Defines the element the controls should be listened from
  124460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124461. */
  124462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124463. /**
  124464. * Detach the current controls from the specified dom element.
  124465. * @param element Defines the element to stop listening the inputs from
  124466. */
  124467. detachControl(element: Nullable<HTMLElement>): void;
  124468. /**
  124469. * Gets the class name of the current intput.
  124470. * @returns the class name
  124471. */
  124472. getClassName(): string;
  124473. /** @hidden */
  124474. _onLostFocus(e: FocusEvent): void;
  124475. /**
  124476. * Get the friendly name associated with the input class.
  124477. * @returns the input friendly name
  124478. */
  124479. getSimpleName(): string;
  124480. /**
  124481. * Update the current camera state depending on the inputs that have been used this frame.
  124482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124483. */
  124484. checkInputs(): void;
  124485. }
  124486. }
  124487. declare module BABYLON {
  124488. /**
  124489. * Manage the mouse wheel inputs to control a follow camera.
  124490. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124491. */
  124492. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124493. /**
  124494. * Defines the camera the input is attached to.
  124495. */
  124496. camera: FollowCamera;
  124497. /**
  124498. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124499. */
  124500. axisControlRadius: boolean;
  124501. /**
  124502. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124503. */
  124504. axisControlHeight: boolean;
  124505. /**
  124506. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124507. */
  124508. axisControlRotation: boolean;
  124509. /**
  124510. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124511. * relation to mouseWheel events.
  124512. */
  124513. wheelPrecision: number;
  124514. /**
  124515. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124516. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124517. */
  124518. wheelDeltaPercentage: number;
  124519. private _wheel;
  124520. private _observer;
  124521. /**
  124522. * Attach the input controls to a specific dom element to get the input from.
  124523. * @param element Defines the element the controls should be listened from
  124524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124525. */
  124526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124527. /**
  124528. * Detach the current controls from the specified dom element.
  124529. * @param element Defines the element to stop listening the inputs from
  124530. */
  124531. detachControl(element: Nullable<HTMLElement>): void;
  124532. /**
  124533. * Gets the class name of the current intput.
  124534. * @returns the class name
  124535. */
  124536. getClassName(): string;
  124537. /**
  124538. * Get the friendly name associated with the input class.
  124539. * @returns the input friendly name
  124540. */
  124541. getSimpleName(): string;
  124542. }
  124543. }
  124544. declare module BABYLON {
  124545. /**
  124546. * Manage the pointers inputs to control an follow camera.
  124547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124548. */
  124549. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124550. /**
  124551. * Defines the camera the input is attached to.
  124552. */
  124553. camera: FollowCamera;
  124554. /**
  124555. * Gets the class name of the current input.
  124556. * @returns the class name
  124557. */
  124558. getClassName(): string;
  124559. /**
  124560. * Defines the pointer angular sensibility along the X axis or how fast is
  124561. * the camera rotating.
  124562. * A negative number will reverse the axis direction.
  124563. */
  124564. angularSensibilityX: number;
  124565. /**
  124566. * Defines the pointer angular sensibility along the Y axis or how fast is
  124567. * the camera rotating.
  124568. * A negative number will reverse the axis direction.
  124569. */
  124570. angularSensibilityY: number;
  124571. /**
  124572. * Defines the pointer pinch precision or how fast is the camera zooming.
  124573. * A negative number will reverse the axis direction.
  124574. */
  124575. pinchPrecision: number;
  124576. /**
  124577. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124578. * from 0.
  124579. * It defines the percentage of current camera.radius to use as delta when
  124580. * pinch zoom is used.
  124581. */
  124582. pinchDeltaPercentage: number;
  124583. /**
  124584. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124585. */
  124586. axisXControlRadius: boolean;
  124587. /**
  124588. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124589. */
  124590. axisXControlHeight: boolean;
  124591. /**
  124592. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124593. */
  124594. axisXControlRotation: boolean;
  124595. /**
  124596. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124597. */
  124598. axisYControlRadius: boolean;
  124599. /**
  124600. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124601. */
  124602. axisYControlHeight: boolean;
  124603. /**
  124604. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124605. */
  124606. axisYControlRotation: boolean;
  124607. /**
  124608. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124609. */
  124610. axisPinchControlRadius: boolean;
  124611. /**
  124612. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124613. */
  124614. axisPinchControlHeight: boolean;
  124615. /**
  124616. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124617. */
  124618. axisPinchControlRotation: boolean;
  124619. /**
  124620. * Log error messages if basic misconfiguration has occurred.
  124621. */
  124622. warningEnable: boolean;
  124623. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124624. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124625. private _warningCounter;
  124626. private _warning;
  124627. }
  124628. }
  124629. declare module BABYLON {
  124630. /**
  124631. * Default Inputs manager for the FollowCamera.
  124632. * It groups all the default supported inputs for ease of use.
  124633. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124634. */
  124635. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124636. /**
  124637. * Instantiates a new FollowCameraInputsManager.
  124638. * @param camera Defines the camera the inputs belong to
  124639. */
  124640. constructor(camera: FollowCamera);
  124641. /**
  124642. * Add keyboard input support to the input manager.
  124643. * @returns the current input manager
  124644. */
  124645. addKeyboard(): FollowCameraInputsManager;
  124646. /**
  124647. * Add mouse wheel input support to the input manager.
  124648. * @returns the current input manager
  124649. */
  124650. addMouseWheel(): FollowCameraInputsManager;
  124651. /**
  124652. * Add pointers input support to the input manager.
  124653. * @returns the current input manager
  124654. */
  124655. addPointers(): FollowCameraInputsManager;
  124656. /**
  124657. * Add orientation input support to the input manager.
  124658. * @returns the current input manager
  124659. */
  124660. addVRDeviceOrientation(): FollowCameraInputsManager;
  124661. }
  124662. }
  124663. declare module BABYLON {
  124664. /**
  124665. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124666. * an arc rotate version arcFollowCamera are available.
  124667. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124668. */
  124669. export class FollowCamera extends TargetCamera {
  124670. /**
  124671. * Distance the follow camera should follow an object at
  124672. */
  124673. radius: number;
  124674. /**
  124675. * Minimum allowed distance of the camera to the axis of rotation
  124676. * (The camera can not get closer).
  124677. * This can help limiting how the Camera is able to move in the scene.
  124678. */
  124679. lowerRadiusLimit: Nullable<number>;
  124680. /**
  124681. * Maximum allowed distance of the camera to the axis of rotation
  124682. * (The camera can not get further).
  124683. * This can help limiting how the Camera is able to move in the scene.
  124684. */
  124685. upperRadiusLimit: Nullable<number>;
  124686. /**
  124687. * Define a rotation offset between the camera and the object it follows
  124688. */
  124689. rotationOffset: number;
  124690. /**
  124691. * Minimum allowed angle to camera position relative to target object.
  124692. * This can help limiting how the Camera is able to move in the scene.
  124693. */
  124694. lowerRotationOffsetLimit: Nullable<number>;
  124695. /**
  124696. * Maximum allowed angle to camera position relative to target object.
  124697. * This can help limiting how the Camera is able to move in the scene.
  124698. */
  124699. upperRotationOffsetLimit: Nullable<number>;
  124700. /**
  124701. * Define a height offset between the camera and the object it follows.
  124702. * It can help following an object from the top (like a car chaing a plane)
  124703. */
  124704. heightOffset: number;
  124705. /**
  124706. * Minimum allowed height of camera position relative to target object.
  124707. * This can help limiting how the Camera is able to move in the scene.
  124708. */
  124709. lowerHeightOffsetLimit: Nullable<number>;
  124710. /**
  124711. * Maximum allowed height of camera position relative to target object.
  124712. * This can help limiting how the Camera is able to move in the scene.
  124713. */
  124714. upperHeightOffsetLimit: Nullable<number>;
  124715. /**
  124716. * Define how fast the camera can accelerate to follow it s target.
  124717. */
  124718. cameraAcceleration: number;
  124719. /**
  124720. * Define the speed limit of the camera following an object.
  124721. */
  124722. maxCameraSpeed: number;
  124723. /**
  124724. * Define the target of the camera.
  124725. */
  124726. lockedTarget: Nullable<AbstractMesh>;
  124727. /**
  124728. * Defines the input associated with the camera.
  124729. */
  124730. inputs: FollowCameraInputsManager;
  124731. /**
  124732. * Instantiates the follow camera.
  124733. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124734. * @param name Define the name of the camera in the scene
  124735. * @param position Define the position of the camera
  124736. * @param scene Define the scene the camera belong to
  124737. * @param lockedTarget Define the target of the camera
  124738. */
  124739. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  124740. private _follow;
  124741. /**
  124742. * Attached controls to the current camera.
  124743. * @param element Defines the element the controls should be listened from
  124744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124745. */
  124746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124747. /**
  124748. * Detach the current controls from the camera.
  124749. * The camera will stop reacting to inputs.
  124750. * @param element Defines the element to stop listening the inputs from
  124751. */
  124752. detachControl(element: HTMLElement): void;
  124753. /** @hidden */
  124754. _checkInputs(): void;
  124755. private _checkLimits;
  124756. /**
  124757. * Gets the camera class name.
  124758. * @returns the class name
  124759. */
  124760. getClassName(): string;
  124761. }
  124762. /**
  124763. * Arc Rotate version of the follow camera.
  124764. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  124765. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124766. */
  124767. export class ArcFollowCamera extends TargetCamera {
  124768. /** The longitudinal angle of the camera */
  124769. alpha: number;
  124770. /** The latitudinal angle of the camera */
  124771. beta: number;
  124772. /** The radius of the camera from its target */
  124773. radius: number;
  124774. private _cartesianCoordinates;
  124775. /** Define the camera target (the mesh it should follow) */
  124776. private _meshTarget;
  124777. /**
  124778. * Instantiates a new ArcFollowCamera
  124779. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124780. * @param name Define the name of the camera
  124781. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  124782. * @param beta Define the rotation angle of the camera around the elevation axis
  124783. * @param radius Define the radius of the camera from its target point
  124784. * @param target Define the target of the camera
  124785. * @param scene Define the scene the camera belongs to
  124786. */
  124787. constructor(name: string,
  124788. /** The longitudinal angle of the camera */
  124789. alpha: number,
  124790. /** The latitudinal angle of the camera */
  124791. beta: number,
  124792. /** The radius of the camera from its target */
  124793. radius: number,
  124794. /** Define the camera target (the mesh it should follow) */
  124795. target: Nullable<AbstractMesh>, scene: Scene);
  124796. private _follow;
  124797. /** @hidden */
  124798. _checkInputs(): void;
  124799. /**
  124800. * Returns the class name of the object.
  124801. * It is mostly used internally for serialization purposes.
  124802. */
  124803. getClassName(): string;
  124804. }
  124805. }
  124806. declare module BABYLON {
  124807. /**
  124808. * Manage the keyboard inputs to control the movement of a follow camera.
  124809. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124810. */
  124811. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  124812. /**
  124813. * Defines the camera the input is attached to.
  124814. */
  124815. camera: FollowCamera;
  124816. /**
  124817. * Defines the list of key codes associated with the up action (increase heightOffset)
  124818. */
  124819. keysHeightOffsetIncr: number[];
  124820. /**
  124821. * Defines the list of key codes associated with the down action (decrease heightOffset)
  124822. */
  124823. keysHeightOffsetDecr: number[];
  124824. /**
  124825. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  124826. */
  124827. keysHeightOffsetModifierAlt: boolean;
  124828. /**
  124829. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  124830. */
  124831. keysHeightOffsetModifierCtrl: boolean;
  124832. /**
  124833. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  124834. */
  124835. keysHeightOffsetModifierShift: boolean;
  124836. /**
  124837. * Defines the list of key codes associated with the left action (increase rotationOffset)
  124838. */
  124839. keysRotationOffsetIncr: number[];
  124840. /**
  124841. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  124842. */
  124843. keysRotationOffsetDecr: number[];
  124844. /**
  124845. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  124846. */
  124847. keysRotationOffsetModifierAlt: boolean;
  124848. /**
  124849. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  124850. */
  124851. keysRotationOffsetModifierCtrl: boolean;
  124852. /**
  124853. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  124854. */
  124855. keysRotationOffsetModifierShift: boolean;
  124856. /**
  124857. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  124858. */
  124859. keysRadiusIncr: number[];
  124860. /**
  124861. * Defines the list of key codes associated with the zoom-out action (increase radius)
  124862. */
  124863. keysRadiusDecr: number[];
  124864. /**
  124865. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  124866. */
  124867. keysRadiusModifierAlt: boolean;
  124868. /**
  124869. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  124870. */
  124871. keysRadiusModifierCtrl: boolean;
  124872. /**
  124873. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  124874. */
  124875. keysRadiusModifierShift: boolean;
  124876. /**
  124877. * Defines the rate of change of heightOffset.
  124878. */
  124879. heightSensibility: number;
  124880. /**
  124881. * Defines the rate of change of rotationOffset.
  124882. */
  124883. rotationSensibility: number;
  124884. /**
  124885. * Defines the rate of change of radius.
  124886. */
  124887. radiusSensibility: number;
  124888. private _keys;
  124889. private _ctrlPressed;
  124890. private _altPressed;
  124891. private _shiftPressed;
  124892. private _onCanvasBlurObserver;
  124893. private _onKeyboardObserver;
  124894. private _engine;
  124895. private _scene;
  124896. /**
  124897. * Attach the input controls to a specific dom element to get the input from.
  124898. * @param element Defines the element the controls should be listened from
  124899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124900. */
  124901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124902. /**
  124903. * Detach the current controls from the specified dom element.
  124904. * @param element Defines the element to stop listening the inputs from
  124905. */
  124906. detachControl(element: Nullable<HTMLElement>): void;
  124907. /**
  124908. * Update the current camera state depending on the inputs that have been used this frame.
  124909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124910. */
  124911. checkInputs(): void;
  124912. /**
  124913. * Gets the class name of the current input.
  124914. * @returns the class name
  124915. */
  124916. getClassName(): string;
  124917. /**
  124918. * Get the friendly name associated with the input class.
  124919. * @returns the input friendly name
  124920. */
  124921. getSimpleName(): string;
  124922. /**
  124923. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124924. * allow modification of the heightOffset value.
  124925. */
  124926. private _modifierHeightOffset;
  124927. /**
  124928. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124929. * allow modification of the rotationOffset value.
  124930. */
  124931. private _modifierRotationOffset;
  124932. /**
  124933. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124934. * allow modification of the radius value.
  124935. */
  124936. private _modifierRadius;
  124937. }
  124938. }
  124939. declare module BABYLON {
  124940. interface FreeCameraInputsManager {
  124941. /**
  124942. * @hidden
  124943. */
  124944. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  124945. /**
  124946. * Add orientation input support to the input manager.
  124947. * @returns the current input manager
  124948. */
  124949. addDeviceOrientation(): FreeCameraInputsManager;
  124950. }
  124951. /**
  124952. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  124953. * Screen rotation is taken into account.
  124954. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124955. */
  124956. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  124957. private _camera;
  124958. private _screenOrientationAngle;
  124959. private _constantTranform;
  124960. private _screenQuaternion;
  124961. private _alpha;
  124962. private _beta;
  124963. private _gamma;
  124964. /**
  124965. * Can be used to detect if a device orientation sensor is available on a device
  124966. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  124967. * @returns a promise that will resolve on orientation change
  124968. */
  124969. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  124970. /**
  124971. * @hidden
  124972. */
  124973. _onDeviceOrientationChangedObservable: Observable<void>;
  124974. /**
  124975. * Instantiates a new input
  124976. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124977. */
  124978. constructor();
  124979. /**
  124980. * Define the camera controlled by the input.
  124981. */
  124982. get camera(): FreeCamera;
  124983. set camera(camera: FreeCamera);
  124984. /**
  124985. * Attach the input controls to a specific dom element to get the input from.
  124986. * @param element Defines the element the controls should be listened from
  124987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124988. */
  124989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124990. private _orientationChanged;
  124991. private _deviceOrientation;
  124992. /**
  124993. * Detach the current controls from the specified dom element.
  124994. * @param element Defines the element to stop listening the inputs from
  124995. */
  124996. detachControl(element: Nullable<HTMLElement>): void;
  124997. /**
  124998. * Update the current camera state depending on the inputs that have been used this frame.
  124999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125000. */
  125001. checkInputs(): void;
  125002. /**
  125003. * Gets the class name of the current intput.
  125004. * @returns the class name
  125005. */
  125006. getClassName(): string;
  125007. /**
  125008. * Get the friendly name associated with the input class.
  125009. * @returns the input friendly name
  125010. */
  125011. getSimpleName(): string;
  125012. }
  125013. }
  125014. declare module BABYLON {
  125015. /**
  125016. * Manage the gamepad inputs to control a free camera.
  125017. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125018. */
  125019. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125020. /**
  125021. * Define the camera the input is attached to.
  125022. */
  125023. camera: FreeCamera;
  125024. /**
  125025. * Define the Gamepad controlling the input
  125026. */
  125027. gamepad: Nullable<Gamepad>;
  125028. /**
  125029. * Defines the gamepad rotation sensiblity.
  125030. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125031. */
  125032. gamepadAngularSensibility: number;
  125033. /**
  125034. * Defines the gamepad move sensiblity.
  125035. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125036. */
  125037. gamepadMoveSensibility: number;
  125038. private _yAxisScale;
  125039. /**
  125040. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125041. */
  125042. get invertYAxis(): boolean;
  125043. set invertYAxis(value: boolean);
  125044. private _onGamepadConnectedObserver;
  125045. private _onGamepadDisconnectedObserver;
  125046. private _cameraTransform;
  125047. private _deltaTransform;
  125048. private _vector3;
  125049. private _vector2;
  125050. /**
  125051. * Attach the input controls to a specific dom element to get the input from.
  125052. * @param element Defines the element the controls should be listened from
  125053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125054. */
  125055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125056. /**
  125057. * Detach the current controls from the specified dom element.
  125058. * @param element Defines the element to stop listening the inputs from
  125059. */
  125060. detachControl(element: Nullable<HTMLElement>): void;
  125061. /**
  125062. * Update the current camera state depending on the inputs that have been used this frame.
  125063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125064. */
  125065. checkInputs(): void;
  125066. /**
  125067. * Gets the class name of the current intput.
  125068. * @returns the class name
  125069. */
  125070. getClassName(): string;
  125071. /**
  125072. * Get the friendly name associated with the input class.
  125073. * @returns the input friendly name
  125074. */
  125075. getSimpleName(): string;
  125076. }
  125077. }
  125078. declare module BABYLON {
  125079. /**
  125080. * Defines the potential axis of a Joystick
  125081. */
  125082. export enum JoystickAxis {
  125083. /** X axis */
  125084. X = 0,
  125085. /** Y axis */
  125086. Y = 1,
  125087. /** Z axis */
  125088. Z = 2
  125089. }
  125090. /**
  125091. * Represents the different customization options available
  125092. * for VirtualJoystick
  125093. */
  125094. interface VirtualJoystickCustomizations {
  125095. /**
  125096. * Size of the joystick's puck
  125097. */
  125098. puckSize: number;
  125099. /**
  125100. * Size of the joystick's container
  125101. */
  125102. containerSize: number;
  125103. /**
  125104. * Color of the joystick && puck
  125105. */
  125106. color: string;
  125107. /**
  125108. * Image URL for the joystick's puck
  125109. */
  125110. puckImage?: string;
  125111. /**
  125112. * Image URL for the joystick's container
  125113. */
  125114. containerImage?: string;
  125115. /**
  125116. * Defines the unmoving position of the joystick container
  125117. */
  125118. position?: {
  125119. x: number;
  125120. y: number;
  125121. };
  125122. /**
  125123. * Defines whether or not the joystick container is always visible
  125124. */
  125125. alwaysVisible: boolean;
  125126. /**
  125127. * Defines whether or not to limit the movement of the puck to the joystick's container
  125128. */
  125129. limitToContainer: boolean;
  125130. }
  125131. /**
  125132. * Class used to define virtual joystick (used in touch mode)
  125133. */
  125134. export class VirtualJoystick {
  125135. /**
  125136. * Gets or sets a boolean indicating that left and right values must be inverted
  125137. */
  125138. reverseLeftRight: boolean;
  125139. /**
  125140. * Gets or sets a boolean indicating that up and down values must be inverted
  125141. */
  125142. reverseUpDown: boolean;
  125143. /**
  125144. * Gets the offset value for the position (ie. the change of the position value)
  125145. */
  125146. deltaPosition: Vector3;
  125147. /**
  125148. * Gets a boolean indicating if the virtual joystick was pressed
  125149. */
  125150. pressed: boolean;
  125151. /**
  125152. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125153. */
  125154. static Canvas: Nullable<HTMLCanvasElement>;
  125155. /**
  125156. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125157. */
  125158. limitToContainer: boolean;
  125159. private static _globalJoystickIndex;
  125160. private static _alwaysVisibleSticks;
  125161. private static vjCanvasContext;
  125162. private static vjCanvasWidth;
  125163. private static vjCanvasHeight;
  125164. private static halfWidth;
  125165. private static _GetDefaultOptions;
  125166. private _action;
  125167. private _axisTargetedByLeftAndRight;
  125168. private _axisTargetedByUpAndDown;
  125169. private _joystickSensibility;
  125170. private _inversedSensibility;
  125171. private _joystickPointerID;
  125172. private _joystickColor;
  125173. private _joystickPointerPos;
  125174. private _joystickPreviousPointerPos;
  125175. private _joystickPointerStartPos;
  125176. private _deltaJoystickVector;
  125177. private _leftJoystick;
  125178. private _touches;
  125179. private _joystickPosition;
  125180. private _alwaysVisible;
  125181. private _puckImage;
  125182. private _containerImage;
  125183. private _joystickPuckSize;
  125184. private _joystickContainerSize;
  125185. private _clearPuckSize;
  125186. private _clearContainerSize;
  125187. private _clearPuckSizeOffset;
  125188. private _clearContainerSizeOffset;
  125189. private _onPointerDownHandlerRef;
  125190. private _onPointerMoveHandlerRef;
  125191. private _onPointerUpHandlerRef;
  125192. private _onResize;
  125193. /**
  125194. * Creates a new virtual joystick
  125195. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125196. * @param customizations Defines the options we want to customize the VirtualJoystick
  125197. */
  125198. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125199. /**
  125200. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125201. * @param newJoystickSensibility defines the new sensibility
  125202. */
  125203. setJoystickSensibility(newJoystickSensibility: number): void;
  125204. private _onPointerDown;
  125205. private _onPointerMove;
  125206. private _onPointerUp;
  125207. /**
  125208. * Change the color of the virtual joystick
  125209. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125210. */
  125211. setJoystickColor(newColor: string): void;
  125212. /**
  125213. * Size of the joystick's container
  125214. */
  125215. set containerSize(newSize: number);
  125216. get containerSize(): number;
  125217. /**
  125218. * Size of the joystick's puck
  125219. */
  125220. set puckSize(newSize: number);
  125221. get puckSize(): number;
  125222. /**
  125223. * Clears the set position of the joystick
  125224. */
  125225. clearPosition(): void;
  125226. /**
  125227. * Defines whether or not the joystick container is always visible
  125228. */
  125229. set alwaysVisible(value: boolean);
  125230. get alwaysVisible(): boolean;
  125231. /**
  125232. * Sets the constant position of the Joystick container
  125233. * @param x X axis coordinate
  125234. * @param y Y axis coordinate
  125235. */
  125236. setPosition(x: number, y: number): void;
  125237. /**
  125238. * Defines a callback to call when the joystick is touched
  125239. * @param action defines the callback
  125240. */
  125241. setActionOnTouch(action: () => any): void;
  125242. /**
  125243. * Defines which axis you'd like to control for left & right
  125244. * @param axis defines the axis to use
  125245. */
  125246. setAxisForLeftRight(axis: JoystickAxis): void;
  125247. /**
  125248. * Defines which axis you'd like to control for up & down
  125249. * @param axis defines the axis to use
  125250. */
  125251. setAxisForUpDown(axis: JoystickAxis): void;
  125252. /**
  125253. * Clears the canvas from the previous puck / container draw
  125254. */
  125255. private _clearPreviousDraw;
  125256. /**
  125257. * Loads `urlPath` to be used for the container's image
  125258. * @param urlPath defines the urlPath of an image to use
  125259. */
  125260. setContainerImage(urlPath: string): void;
  125261. /**
  125262. * Loads `urlPath` to be used for the puck's image
  125263. * @param urlPath defines the urlPath of an image to use
  125264. */
  125265. setPuckImage(urlPath: string): void;
  125266. /**
  125267. * Draws the Virtual Joystick's container
  125268. */
  125269. private _drawContainer;
  125270. /**
  125271. * Draws the Virtual Joystick's puck
  125272. */
  125273. private _drawPuck;
  125274. private _drawVirtualJoystick;
  125275. /**
  125276. * Release internal HTML canvas
  125277. */
  125278. releaseCanvas(): void;
  125279. }
  125280. }
  125281. declare module BABYLON {
  125282. interface FreeCameraInputsManager {
  125283. /**
  125284. * Add virtual joystick input support to the input manager.
  125285. * @returns the current input manager
  125286. */
  125287. addVirtualJoystick(): FreeCameraInputsManager;
  125288. }
  125289. /**
  125290. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125291. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125292. */
  125293. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125294. /**
  125295. * Defines the camera the input is attached to.
  125296. */
  125297. camera: FreeCamera;
  125298. private _leftjoystick;
  125299. private _rightjoystick;
  125300. /**
  125301. * Gets the left stick of the virtual joystick.
  125302. * @returns The virtual Joystick
  125303. */
  125304. getLeftJoystick(): VirtualJoystick;
  125305. /**
  125306. * Gets the right stick of the virtual joystick.
  125307. * @returns The virtual Joystick
  125308. */
  125309. getRightJoystick(): VirtualJoystick;
  125310. /**
  125311. * Update the current camera state depending on the inputs that have been used this frame.
  125312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125313. */
  125314. checkInputs(): void;
  125315. /**
  125316. * Attach the input controls to a specific dom element to get the input from.
  125317. * @param element Defines the element the controls should be listened from
  125318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125319. */
  125320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125321. /**
  125322. * Detach the current controls from the specified dom element.
  125323. * @param element Defines the element to stop listening the inputs from
  125324. */
  125325. detachControl(element: Nullable<HTMLElement>): void;
  125326. /**
  125327. * Gets the class name of the current intput.
  125328. * @returns the class name
  125329. */
  125330. getClassName(): string;
  125331. /**
  125332. * Get the friendly name associated with the input class.
  125333. * @returns the input friendly name
  125334. */
  125335. getSimpleName(): string;
  125336. }
  125337. }
  125338. declare module BABYLON {
  125339. /**
  125340. * This represents a FPS type of camera controlled by touch.
  125341. * This is like a universal camera minus the Gamepad controls.
  125342. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125343. */
  125344. export class TouchCamera extends FreeCamera {
  125345. /**
  125346. * Defines the touch sensibility for rotation.
  125347. * The higher the faster.
  125348. */
  125349. get touchAngularSensibility(): number;
  125350. set touchAngularSensibility(value: number);
  125351. /**
  125352. * Defines the touch sensibility for move.
  125353. * The higher the faster.
  125354. */
  125355. get touchMoveSensibility(): number;
  125356. set touchMoveSensibility(value: number);
  125357. /**
  125358. * Instantiates a new touch camera.
  125359. * This represents a FPS type of camera controlled by touch.
  125360. * This is like a universal camera minus the Gamepad controls.
  125361. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125362. * @param name Define the name of the camera in the scene
  125363. * @param position Define the start position of the camera in the scene
  125364. * @param scene Define the scene the camera belongs to
  125365. */
  125366. constructor(name: string, position: Vector3, scene: Scene);
  125367. /**
  125368. * Gets the current object class name.
  125369. * @return the class name
  125370. */
  125371. getClassName(): string;
  125372. /** @hidden */
  125373. _setupInputs(): void;
  125374. }
  125375. }
  125376. declare module BABYLON {
  125377. /**
  125378. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125379. * being tilted forward or back and left or right.
  125380. */
  125381. export class DeviceOrientationCamera extends FreeCamera {
  125382. private _initialQuaternion;
  125383. private _quaternionCache;
  125384. private _tmpDragQuaternion;
  125385. private _disablePointerInputWhenUsingDeviceOrientation;
  125386. /**
  125387. * Creates a new device orientation camera
  125388. * @param name The name of the camera
  125389. * @param position The start position camera
  125390. * @param scene The scene the camera belongs to
  125391. */
  125392. constructor(name: string, position: Vector3, scene: Scene);
  125393. /**
  125394. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125395. */
  125396. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125397. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125398. private _dragFactor;
  125399. /**
  125400. * Enabled turning on the y axis when the orientation sensor is active
  125401. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125402. */
  125403. enableHorizontalDragging(dragFactor?: number): void;
  125404. /**
  125405. * Gets the current instance class name ("DeviceOrientationCamera").
  125406. * This helps avoiding instanceof at run time.
  125407. * @returns the class name
  125408. */
  125409. getClassName(): string;
  125410. /**
  125411. * @hidden
  125412. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125413. */
  125414. _checkInputs(): void;
  125415. /**
  125416. * Reset the camera to its default orientation on the specified axis only.
  125417. * @param axis The axis to reset
  125418. */
  125419. resetToCurrentRotation(axis?: Axis): void;
  125420. }
  125421. }
  125422. declare module BABYLON {
  125423. /**
  125424. * Defines supported buttons for XBox360 compatible gamepads
  125425. */
  125426. export enum Xbox360Button {
  125427. /** A */
  125428. A = 0,
  125429. /** B */
  125430. B = 1,
  125431. /** X */
  125432. X = 2,
  125433. /** Y */
  125434. Y = 3,
  125435. /** Left button */
  125436. LB = 4,
  125437. /** Right button */
  125438. RB = 5,
  125439. /** Back */
  125440. Back = 8,
  125441. /** Start */
  125442. Start = 9,
  125443. /** Left stick */
  125444. LeftStick = 10,
  125445. /** Right stick */
  125446. RightStick = 11
  125447. }
  125448. /** Defines values for XBox360 DPad */
  125449. export enum Xbox360Dpad {
  125450. /** Up */
  125451. Up = 12,
  125452. /** Down */
  125453. Down = 13,
  125454. /** Left */
  125455. Left = 14,
  125456. /** Right */
  125457. Right = 15
  125458. }
  125459. /**
  125460. * Defines a XBox360 gamepad
  125461. */
  125462. export class Xbox360Pad extends Gamepad {
  125463. private _leftTrigger;
  125464. private _rightTrigger;
  125465. private _onlefttriggerchanged;
  125466. private _onrighttriggerchanged;
  125467. private _onbuttondown;
  125468. private _onbuttonup;
  125469. private _ondpaddown;
  125470. private _ondpadup;
  125471. /** Observable raised when a button is pressed */
  125472. onButtonDownObservable: Observable<Xbox360Button>;
  125473. /** Observable raised when a button is released */
  125474. onButtonUpObservable: Observable<Xbox360Button>;
  125475. /** Observable raised when a pad is pressed */
  125476. onPadDownObservable: Observable<Xbox360Dpad>;
  125477. /** Observable raised when a pad is released */
  125478. onPadUpObservable: Observable<Xbox360Dpad>;
  125479. private _buttonA;
  125480. private _buttonB;
  125481. private _buttonX;
  125482. private _buttonY;
  125483. private _buttonBack;
  125484. private _buttonStart;
  125485. private _buttonLB;
  125486. private _buttonRB;
  125487. private _buttonLeftStick;
  125488. private _buttonRightStick;
  125489. private _dPadUp;
  125490. private _dPadDown;
  125491. private _dPadLeft;
  125492. private _dPadRight;
  125493. private _isXboxOnePad;
  125494. /**
  125495. * Creates a new XBox360 gamepad object
  125496. * @param id defines the id of this gamepad
  125497. * @param index defines its index
  125498. * @param gamepad defines the internal HTML gamepad object
  125499. * @param xboxOne defines if it is a XBox One gamepad
  125500. */
  125501. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125502. /**
  125503. * Defines the callback to call when left trigger is pressed
  125504. * @param callback defines the callback to use
  125505. */
  125506. onlefttriggerchanged(callback: (value: number) => void): void;
  125507. /**
  125508. * Defines the callback to call when right trigger is pressed
  125509. * @param callback defines the callback to use
  125510. */
  125511. onrighttriggerchanged(callback: (value: number) => void): void;
  125512. /**
  125513. * Gets the left trigger value
  125514. */
  125515. get leftTrigger(): number;
  125516. /**
  125517. * Sets the left trigger value
  125518. */
  125519. set leftTrigger(newValue: number);
  125520. /**
  125521. * Gets the right trigger value
  125522. */
  125523. get rightTrigger(): number;
  125524. /**
  125525. * Sets the right trigger value
  125526. */
  125527. set rightTrigger(newValue: number);
  125528. /**
  125529. * Defines the callback to call when a button is pressed
  125530. * @param callback defines the callback to use
  125531. */
  125532. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125533. /**
  125534. * Defines the callback to call when a button is released
  125535. * @param callback defines the callback to use
  125536. */
  125537. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125538. /**
  125539. * Defines the callback to call when a pad is pressed
  125540. * @param callback defines the callback to use
  125541. */
  125542. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125543. /**
  125544. * Defines the callback to call when a pad is released
  125545. * @param callback defines the callback to use
  125546. */
  125547. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125548. private _setButtonValue;
  125549. private _setDPadValue;
  125550. /**
  125551. * Gets the value of the `A` button
  125552. */
  125553. get buttonA(): number;
  125554. /**
  125555. * Sets the value of the `A` button
  125556. */
  125557. set buttonA(value: number);
  125558. /**
  125559. * Gets the value of the `B` button
  125560. */
  125561. get buttonB(): number;
  125562. /**
  125563. * Sets the value of the `B` button
  125564. */
  125565. set buttonB(value: number);
  125566. /**
  125567. * Gets the value of the `X` button
  125568. */
  125569. get buttonX(): number;
  125570. /**
  125571. * Sets the value of the `X` button
  125572. */
  125573. set buttonX(value: number);
  125574. /**
  125575. * Gets the value of the `Y` button
  125576. */
  125577. get buttonY(): number;
  125578. /**
  125579. * Sets the value of the `Y` button
  125580. */
  125581. set buttonY(value: number);
  125582. /**
  125583. * Gets the value of the `Start` button
  125584. */
  125585. get buttonStart(): number;
  125586. /**
  125587. * Sets the value of the `Start` button
  125588. */
  125589. set buttonStart(value: number);
  125590. /**
  125591. * Gets the value of the `Back` button
  125592. */
  125593. get buttonBack(): number;
  125594. /**
  125595. * Sets the value of the `Back` button
  125596. */
  125597. set buttonBack(value: number);
  125598. /**
  125599. * Gets the value of the `Left` button
  125600. */
  125601. get buttonLB(): number;
  125602. /**
  125603. * Sets the value of the `Left` button
  125604. */
  125605. set buttonLB(value: number);
  125606. /**
  125607. * Gets the value of the `Right` button
  125608. */
  125609. get buttonRB(): number;
  125610. /**
  125611. * Sets the value of the `Right` button
  125612. */
  125613. set buttonRB(value: number);
  125614. /**
  125615. * Gets the value of the Left joystick
  125616. */
  125617. get buttonLeftStick(): number;
  125618. /**
  125619. * Sets the value of the Left joystick
  125620. */
  125621. set buttonLeftStick(value: number);
  125622. /**
  125623. * Gets the value of the Right joystick
  125624. */
  125625. get buttonRightStick(): number;
  125626. /**
  125627. * Sets the value of the Right joystick
  125628. */
  125629. set buttonRightStick(value: number);
  125630. /**
  125631. * Gets the value of D-pad up
  125632. */
  125633. get dPadUp(): number;
  125634. /**
  125635. * Sets the value of D-pad up
  125636. */
  125637. set dPadUp(value: number);
  125638. /**
  125639. * Gets the value of D-pad down
  125640. */
  125641. get dPadDown(): number;
  125642. /**
  125643. * Sets the value of D-pad down
  125644. */
  125645. set dPadDown(value: number);
  125646. /**
  125647. * Gets the value of D-pad left
  125648. */
  125649. get dPadLeft(): number;
  125650. /**
  125651. * Sets the value of D-pad left
  125652. */
  125653. set dPadLeft(value: number);
  125654. /**
  125655. * Gets the value of D-pad right
  125656. */
  125657. get dPadRight(): number;
  125658. /**
  125659. * Sets the value of D-pad right
  125660. */
  125661. set dPadRight(value: number);
  125662. /**
  125663. * Force the gamepad to synchronize with device values
  125664. */
  125665. update(): void;
  125666. /**
  125667. * Disposes the gamepad
  125668. */
  125669. dispose(): void;
  125670. }
  125671. }
  125672. declare module BABYLON {
  125673. /**
  125674. * Defines supported buttons for DualShock compatible gamepads
  125675. */
  125676. export enum DualShockButton {
  125677. /** Cross */
  125678. Cross = 0,
  125679. /** Circle */
  125680. Circle = 1,
  125681. /** Square */
  125682. Square = 2,
  125683. /** Triangle */
  125684. Triangle = 3,
  125685. /** L1 */
  125686. L1 = 4,
  125687. /** R1 */
  125688. R1 = 5,
  125689. /** Share */
  125690. Share = 8,
  125691. /** Options */
  125692. Options = 9,
  125693. /** Left stick */
  125694. LeftStick = 10,
  125695. /** Right stick */
  125696. RightStick = 11
  125697. }
  125698. /** Defines values for DualShock DPad */
  125699. export enum DualShockDpad {
  125700. /** Up */
  125701. Up = 12,
  125702. /** Down */
  125703. Down = 13,
  125704. /** Left */
  125705. Left = 14,
  125706. /** Right */
  125707. Right = 15
  125708. }
  125709. /**
  125710. * Defines a DualShock gamepad
  125711. */
  125712. export class DualShockPad extends Gamepad {
  125713. private _leftTrigger;
  125714. private _rightTrigger;
  125715. private _onlefttriggerchanged;
  125716. private _onrighttriggerchanged;
  125717. private _onbuttondown;
  125718. private _onbuttonup;
  125719. private _ondpaddown;
  125720. private _ondpadup;
  125721. /** Observable raised when a button is pressed */
  125722. onButtonDownObservable: Observable<DualShockButton>;
  125723. /** Observable raised when a button is released */
  125724. onButtonUpObservable: Observable<DualShockButton>;
  125725. /** Observable raised when a pad is pressed */
  125726. onPadDownObservable: Observable<DualShockDpad>;
  125727. /** Observable raised when a pad is released */
  125728. onPadUpObservable: Observable<DualShockDpad>;
  125729. private _buttonCross;
  125730. private _buttonCircle;
  125731. private _buttonSquare;
  125732. private _buttonTriangle;
  125733. private _buttonShare;
  125734. private _buttonOptions;
  125735. private _buttonL1;
  125736. private _buttonR1;
  125737. private _buttonLeftStick;
  125738. private _buttonRightStick;
  125739. private _dPadUp;
  125740. private _dPadDown;
  125741. private _dPadLeft;
  125742. private _dPadRight;
  125743. /**
  125744. * Creates a new DualShock gamepad object
  125745. * @param id defines the id of this gamepad
  125746. * @param index defines its index
  125747. * @param gamepad defines the internal HTML gamepad object
  125748. */
  125749. constructor(id: string, index: number, gamepad: any);
  125750. /**
  125751. * Defines the callback to call when left trigger is pressed
  125752. * @param callback defines the callback to use
  125753. */
  125754. onlefttriggerchanged(callback: (value: number) => void): void;
  125755. /**
  125756. * Defines the callback to call when right trigger is pressed
  125757. * @param callback defines the callback to use
  125758. */
  125759. onrighttriggerchanged(callback: (value: number) => void): void;
  125760. /**
  125761. * Gets the left trigger value
  125762. */
  125763. get leftTrigger(): number;
  125764. /**
  125765. * Sets the left trigger value
  125766. */
  125767. set leftTrigger(newValue: number);
  125768. /**
  125769. * Gets the right trigger value
  125770. */
  125771. get rightTrigger(): number;
  125772. /**
  125773. * Sets the right trigger value
  125774. */
  125775. set rightTrigger(newValue: number);
  125776. /**
  125777. * Defines the callback to call when a button is pressed
  125778. * @param callback defines the callback to use
  125779. */
  125780. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  125781. /**
  125782. * Defines the callback to call when a button is released
  125783. * @param callback defines the callback to use
  125784. */
  125785. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  125786. /**
  125787. * Defines the callback to call when a pad is pressed
  125788. * @param callback defines the callback to use
  125789. */
  125790. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  125791. /**
  125792. * Defines the callback to call when a pad is released
  125793. * @param callback defines the callback to use
  125794. */
  125795. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  125796. private _setButtonValue;
  125797. private _setDPadValue;
  125798. /**
  125799. * Gets the value of the `Cross` button
  125800. */
  125801. get buttonCross(): number;
  125802. /**
  125803. * Sets the value of the `Cross` button
  125804. */
  125805. set buttonCross(value: number);
  125806. /**
  125807. * Gets the value of the `Circle` button
  125808. */
  125809. get buttonCircle(): number;
  125810. /**
  125811. * Sets the value of the `Circle` button
  125812. */
  125813. set buttonCircle(value: number);
  125814. /**
  125815. * Gets the value of the `Square` button
  125816. */
  125817. get buttonSquare(): number;
  125818. /**
  125819. * Sets the value of the `Square` button
  125820. */
  125821. set buttonSquare(value: number);
  125822. /**
  125823. * Gets the value of the `Triangle` button
  125824. */
  125825. get buttonTriangle(): number;
  125826. /**
  125827. * Sets the value of the `Triangle` button
  125828. */
  125829. set buttonTriangle(value: number);
  125830. /**
  125831. * Gets the value of the `Options` button
  125832. */
  125833. get buttonOptions(): number;
  125834. /**
  125835. * Sets the value of the `Options` button
  125836. */
  125837. set buttonOptions(value: number);
  125838. /**
  125839. * Gets the value of the `Share` button
  125840. */
  125841. get buttonShare(): number;
  125842. /**
  125843. * Sets the value of the `Share` button
  125844. */
  125845. set buttonShare(value: number);
  125846. /**
  125847. * Gets the value of the `L1` button
  125848. */
  125849. get buttonL1(): number;
  125850. /**
  125851. * Sets the value of the `L1` button
  125852. */
  125853. set buttonL1(value: number);
  125854. /**
  125855. * Gets the value of the `R1` button
  125856. */
  125857. get buttonR1(): number;
  125858. /**
  125859. * Sets the value of the `R1` button
  125860. */
  125861. set buttonR1(value: number);
  125862. /**
  125863. * Gets the value of the Left joystick
  125864. */
  125865. get buttonLeftStick(): number;
  125866. /**
  125867. * Sets the value of the Left joystick
  125868. */
  125869. set buttonLeftStick(value: number);
  125870. /**
  125871. * Gets the value of the Right joystick
  125872. */
  125873. get buttonRightStick(): number;
  125874. /**
  125875. * Sets the value of the Right joystick
  125876. */
  125877. set buttonRightStick(value: number);
  125878. /**
  125879. * Gets the value of D-pad up
  125880. */
  125881. get dPadUp(): number;
  125882. /**
  125883. * Sets the value of D-pad up
  125884. */
  125885. set dPadUp(value: number);
  125886. /**
  125887. * Gets the value of D-pad down
  125888. */
  125889. get dPadDown(): number;
  125890. /**
  125891. * Sets the value of D-pad down
  125892. */
  125893. set dPadDown(value: number);
  125894. /**
  125895. * Gets the value of D-pad left
  125896. */
  125897. get dPadLeft(): number;
  125898. /**
  125899. * Sets the value of D-pad left
  125900. */
  125901. set dPadLeft(value: number);
  125902. /**
  125903. * Gets the value of D-pad right
  125904. */
  125905. get dPadRight(): number;
  125906. /**
  125907. * Sets the value of D-pad right
  125908. */
  125909. set dPadRight(value: number);
  125910. /**
  125911. * Force the gamepad to synchronize with device values
  125912. */
  125913. update(): void;
  125914. /**
  125915. * Disposes the gamepad
  125916. */
  125917. dispose(): void;
  125918. }
  125919. }
  125920. declare module BABYLON {
  125921. /**
  125922. * Manager for handling gamepads
  125923. */
  125924. export class GamepadManager {
  125925. private _scene?;
  125926. private _babylonGamepads;
  125927. private _oneGamepadConnected;
  125928. /** @hidden */
  125929. _isMonitoring: boolean;
  125930. private _gamepadEventSupported;
  125931. private _gamepadSupport?;
  125932. /**
  125933. * observable to be triggered when the gamepad controller has been connected
  125934. */
  125935. onGamepadConnectedObservable: Observable<Gamepad>;
  125936. /**
  125937. * observable to be triggered when the gamepad controller has been disconnected
  125938. */
  125939. onGamepadDisconnectedObservable: Observable<Gamepad>;
  125940. private _onGamepadConnectedEvent;
  125941. private _onGamepadDisconnectedEvent;
  125942. /**
  125943. * Initializes the gamepad manager
  125944. * @param _scene BabylonJS scene
  125945. */
  125946. constructor(_scene?: Scene | undefined);
  125947. /**
  125948. * The gamepads in the game pad manager
  125949. */
  125950. get gamepads(): Gamepad[];
  125951. /**
  125952. * Get the gamepad controllers based on type
  125953. * @param type The type of gamepad controller
  125954. * @returns Nullable gamepad
  125955. */
  125956. getGamepadByType(type?: number): Nullable<Gamepad>;
  125957. /**
  125958. * Disposes the gamepad manager
  125959. */
  125960. dispose(): void;
  125961. private _addNewGamepad;
  125962. private _startMonitoringGamepads;
  125963. private _stopMonitoringGamepads;
  125964. /** @hidden */
  125965. _checkGamepadsStatus(): void;
  125966. private _updateGamepadObjects;
  125967. }
  125968. }
  125969. declare module BABYLON {
  125970. interface Scene {
  125971. /** @hidden */
  125972. _gamepadManager: Nullable<GamepadManager>;
  125973. /**
  125974. * Gets the gamepad manager associated with the scene
  125975. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  125976. */
  125977. gamepadManager: GamepadManager;
  125978. }
  125979. /**
  125980. * Interface representing a free camera inputs manager
  125981. */
  125982. interface FreeCameraInputsManager {
  125983. /**
  125984. * Adds gamepad input support to the FreeCameraInputsManager.
  125985. * @returns the FreeCameraInputsManager
  125986. */
  125987. addGamepad(): FreeCameraInputsManager;
  125988. }
  125989. /**
  125990. * Interface representing an arc rotate camera inputs manager
  125991. */
  125992. interface ArcRotateCameraInputsManager {
  125993. /**
  125994. * Adds gamepad input support to the ArcRotateCamera InputManager.
  125995. * @returns the camera inputs manager
  125996. */
  125997. addGamepad(): ArcRotateCameraInputsManager;
  125998. }
  125999. /**
  126000. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126001. */
  126002. export class GamepadSystemSceneComponent implements ISceneComponent {
  126003. /**
  126004. * The component name helpfull to identify the component in the list of scene components.
  126005. */
  126006. readonly name: string;
  126007. /**
  126008. * The scene the component belongs to.
  126009. */
  126010. scene: Scene;
  126011. /**
  126012. * Creates a new instance of the component for the given scene
  126013. * @param scene Defines the scene to register the component in
  126014. */
  126015. constructor(scene: Scene);
  126016. /**
  126017. * Registers the component in a given scene
  126018. */
  126019. register(): void;
  126020. /**
  126021. * Rebuilds the elements related to this component in case of
  126022. * context lost for instance.
  126023. */
  126024. rebuild(): void;
  126025. /**
  126026. * Disposes the component and the associated ressources
  126027. */
  126028. dispose(): void;
  126029. private _beforeCameraUpdate;
  126030. }
  126031. }
  126032. declare module BABYLON {
  126033. /**
  126034. * 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,
  126035. * which still works and will still be found in many Playgrounds.
  126036. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126037. */
  126038. export class UniversalCamera extends TouchCamera {
  126039. /**
  126040. * Defines the gamepad rotation sensiblity.
  126041. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126042. */
  126043. get gamepadAngularSensibility(): number;
  126044. set gamepadAngularSensibility(value: number);
  126045. /**
  126046. * Defines the gamepad move sensiblity.
  126047. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126048. */
  126049. get gamepadMoveSensibility(): number;
  126050. set gamepadMoveSensibility(value: number);
  126051. /**
  126052. * 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,
  126053. * which still works and will still be found in many Playgrounds.
  126054. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126055. * @param name Define the name of the camera in the scene
  126056. * @param position Define the start position of the camera in the scene
  126057. * @param scene Define the scene the camera belongs to
  126058. */
  126059. constructor(name: string, position: Vector3, scene: Scene);
  126060. /**
  126061. * Gets the current object class name.
  126062. * @return the class name
  126063. */
  126064. getClassName(): string;
  126065. }
  126066. }
  126067. declare module BABYLON {
  126068. /**
  126069. * This represents a FPS type of camera. This is only here for back compat purpose.
  126070. * Please use the UniversalCamera instead as both are identical.
  126071. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126072. */
  126073. export class GamepadCamera extends UniversalCamera {
  126074. /**
  126075. * Instantiates a new Gamepad Camera
  126076. * This represents a FPS type of camera. This is only here for back compat purpose.
  126077. * Please use the UniversalCamera instead as both are identical.
  126078. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126079. * @param name Define the name of the camera in the scene
  126080. * @param position Define the start position of the camera in the scene
  126081. * @param scene Define the scene the camera belongs to
  126082. */
  126083. constructor(name: string, position: Vector3, scene: Scene);
  126084. /**
  126085. * Gets the current object class name.
  126086. * @return the class name
  126087. */
  126088. getClassName(): string;
  126089. }
  126090. }
  126091. declare module BABYLON {
  126092. /** @hidden */
  126093. export var passPixelShader: {
  126094. name: string;
  126095. shader: string;
  126096. };
  126097. }
  126098. declare module BABYLON {
  126099. /** @hidden */
  126100. export var passCubePixelShader: {
  126101. name: string;
  126102. shader: string;
  126103. };
  126104. }
  126105. declare module BABYLON {
  126106. /**
  126107. * PassPostProcess which produces an output the same as it's input
  126108. */
  126109. export class PassPostProcess extends PostProcess {
  126110. /**
  126111. * Gets a string identifying the name of the class
  126112. * @returns "PassPostProcess" string
  126113. */
  126114. getClassName(): string;
  126115. /**
  126116. * Creates the PassPostProcess
  126117. * @param name The name of the effect.
  126118. * @param options The required width/height ratio to downsize to before computing the render pass.
  126119. * @param camera The camera to apply the render pass to.
  126120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126121. * @param engine The engine which the post process will be applied. (default: current engine)
  126122. * @param reusable If the post process can be reused on the same frame. (default: false)
  126123. * @param textureType The type of texture to be used when performing the post processing.
  126124. * @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)
  126125. */
  126126. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126127. /** @hidden */
  126128. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126129. }
  126130. /**
  126131. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126132. */
  126133. export class PassCubePostProcess extends PostProcess {
  126134. private _face;
  126135. /**
  126136. * Gets or sets the cube face to display.
  126137. * * 0 is +X
  126138. * * 1 is -X
  126139. * * 2 is +Y
  126140. * * 3 is -Y
  126141. * * 4 is +Z
  126142. * * 5 is -Z
  126143. */
  126144. get face(): number;
  126145. set face(value: number);
  126146. /**
  126147. * Gets a string identifying the name of the class
  126148. * @returns "PassCubePostProcess" string
  126149. */
  126150. getClassName(): string;
  126151. /**
  126152. * Creates the PassCubePostProcess
  126153. * @param name The name of the effect.
  126154. * @param options The required width/height ratio to downsize to before computing the render pass.
  126155. * @param camera The camera to apply the render pass to.
  126156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126157. * @param engine The engine which the post process will be applied. (default: current engine)
  126158. * @param reusable If the post process can be reused on the same frame. (default: false)
  126159. * @param textureType The type of texture to be used when performing the post processing.
  126160. * @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)
  126161. */
  126162. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126163. /** @hidden */
  126164. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126165. }
  126166. }
  126167. declare module BABYLON {
  126168. /** @hidden */
  126169. export var anaglyphPixelShader: {
  126170. name: string;
  126171. shader: string;
  126172. };
  126173. }
  126174. declare module BABYLON {
  126175. /**
  126176. * Postprocess used to generate anaglyphic rendering
  126177. */
  126178. export class AnaglyphPostProcess extends PostProcess {
  126179. private _passedProcess;
  126180. /**
  126181. * Gets a string identifying the name of the class
  126182. * @returns "AnaglyphPostProcess" string
  126183. */
  126184. getClassName(): string;
  126185. /**
  126186. * Creates a new AnaglyphPostProcess
  126187. * @param name defines postprocess name
  126188. * @param options defines creation options or target ratio scale
  126189. * @param rigCameras defines cameras using this postprocess
  126190. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126191. * @param engine defines hosting engine
  126192. * @param reusable defines if the postprocess will be reused multiple times per frame
  126193. */
  126194. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126195. }
  126196. }
  126197. declare module BABYLON {
  126198. /**
  126199. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126200. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126201. */
  126202. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126203. /**
  126204. * Creates a new AnaglyphArcRotateCamera
  126205. * @param name defines camera name
  126206. * @param alpha defines alpha angle (in radians)
  126207. * @param beta defines beta angle (in radians)
  126208. * @param radius defines radius
  126209. * @param target defines camera target
  126210. * @param interaxialDistance defines distance between each color axis
  126211. * @param scene defines the hosting scene
  126212. */
  126213. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126214. /**
  126215. * Gets camera class name
  126216. * @returns AnaglyphArcRotateCamera
  126217. */
  126218. getClassName(): string;
  126219. }
  126220. }
  126221. declare module BABYLON {
  126222. /**
  126223. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126224. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126225. */
  126226. export class AnaglyphFreeCamera extends FreeCamera {
  126227. /**
  126228. * Creates a new AnaglyphFreeCamera
  126229. * @param name defines camera name
  126230. * @param position defines initial position
  126231. * @param interaxialDistance defines distance between each color axis
  126232. * @param scene defines the hosting scene
  126233. */
  126234. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126235. /**
  126236. * Gets camera class name
  126237. * @returns AnaglyphFreeCamera
  126238. */
  126239. getClassName(): string;
  126240. }
  126241. }
  126242. declare module BABYLON {
  126243. /**
  126244. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126245. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126246. */
  126247. export class AnaglyphGamepadCamera extends GamepadCamera {
  126248. /**
  126249. * Creates a new AnaglyphGamepadCamera
  126250. * @param name defines camera name
  126251. * @param position defines initial position
  126252. * @param interaxialDistance defines distance between each color axis
  126253. * @param scene defines the hosting scene
  126254. */
  126255. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126256. /**
  126257. * Gets camera class name
  126258. * @returns AnaglyphGamepadCamera
  126259. */
  126260. getClassName(): string;
  126261. }
  126262. }
  126263. declare module BABYLON {
  126264. /**
  126265. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126266. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126267. */
  126268. export class AnaglyphUniversalCamera extends UniversalCamera {
  126269. /**
  126270. * Creates a new AnaglyphUniversalCamera
  126271. * @param name defines camera name
  126272. * @param position defines initial position
  126273. * @param interaxialDistance defines distance between each color axis
  126274. * @param scene defines the hosting scene
  126275. */
  126276. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126277. /**
  126278. * Gets camera class name
  126279. * @returns AnaglyphUniversalCamera
  126280. */
  126281. getClassName(): string;
  126282. }
  126283. }
  126284. declare module BABYLON {
  126285. /**
  126286. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126287. * @see https://doc.babylonjs.com/features/cameras
  126288. */
  126289. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126290. /**
  126291. * Creates a new StereoscopicArcRotateCamera
  126292. * @param name defines camera name
  126293. * @param alpha defines alpha angle (in radians)
  126294. * @param beta defines beta angle (in radians)
  126295. * @param radius defines radius
  126296. * @param target defines camera target
  126297. * @param interaxialDistance defines distance between each color axis
  126298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126299. * @param scene defines the hosting scene
  126300. */
  126301. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126302. /**
  126303. * Gets camera class name
  126304. * @returns StereoscopicArcRotateCamera
  126305. */
  126306. getClassName(): string;
  126307. }
  126308. }
  126309. declare module BABYLON {
  126310. /**
  126311. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126312. * @see https://doc.babylonjs.com/features/cameras
  126313. */
  126314. export class StereoscopicFreeCamera extends FreeCamera {
  126315. /**
  126316. * Creates a new StereoscopicFreeCamera
  126317. * @param name defines camera name
  126318. * @param position defines initial position
  126319. * @param interaxialDistance defines distance between each color axis
  126320. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126321. * @param scene defines the hosting scene
  126322. */
  126323. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126324. /**
  126325. * Gets camera class name
  126326. * @returns StereoscopicFreeCamera
  126327. */
  126328. getClassName(): string;
  126329. }
  126330. }
  126331. declare module BABYLON {
  126332. /**
  126333. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126334. * @see https://doc.babylonjs.com/features/cameras
  126335. */
  126336. export class StereoscopicGamepadCamera extends GamepadCamera {
  126337. /**
  126338. * Creates a new StereoscopicGamepadCamera
  126339. * @param name defines camera name
  126340. * @param position defines initial position
  126341. * @param interaxialDistance defines distance between each color axis
  126342. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126343. * @param scene defines the hosting scene
  126344. */
  126345. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126346. /**
  126347. * Gets camera class name
  126348. * @returns StereoscopicGamepadCamera
  126349. */
  126350. getClassName(): string;
  126351. }
  126352. }
  126353. declare module BABYLON {
  126354. /**
  126355. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126356. * @see https://doc.babylonjs.com/features/cameras
  126357. */
  126358. export class StereoscopicUniversalCamera extends UniversalCamera {
  126359. /**
  126360. * Creates a new StereoscopicUniversalCamera
  126361. * @param name defines camera name
  126362. * @param position defines initial position
  126363. * @param interaxialDistance defines distance between each color axis
  126364. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126365. * @param scene defines the hosting scene
  126366. */
  126367. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126368. /**
  126369. * Gets camera class name
  126370. * @returns StereoscopicUniversalCamera
  126371. */
  126372. getClassName(): string;
  126373. }
  126374. }
  126375. declare module BABYLON {
  126376. /**
  126377. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126378. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126379. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126380. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126381. */
  126382. export class VirtualJoysticksCamera extends FreeCamera {
  126383. /**
  126384. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126385. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126386. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126387. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126388. * @param name Define the name of the camera in the scene
  126389. * @param position Define the start position of the camera in the scene
  126390. * @param scene Define the scene the camera belongs to
  126391. */
  126392. constructor(name: string, position: Vector3, scene: Scene);
  126393. /**
  126394. * Gets the current object class name.
  126395. * @return the class name
  126396. */
  126397. getClassName(): string;
  126398. }
  126399. }
  126400. declare module BABYLON {
  126401. /**
  126402. * This represents all the required metrics to create a VR camera.
  126403. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126404. */
  126405. export class VRCameraMetrics {
  126406. /**
  126407. * Define the horizontal resolution off the screen.
  126408. */
  126409. hResolution: number;
  126410. /**
  126411. * Define the vertical resolution off the screen.
  126412. */
  126413. vResolution: number;
  126414. /**
  126415. * Define the horizontal screen size.
  126416. */
  126417. hScreenSize: number;
  126418. /**
  126419. * Define the vertical screen size.
  126420. */
  126421. vScreenSize: number;
  126422. /**
  126423. * Define the vertical screen center position.
  126424. */
  126425. vScreenCenter: number;
  126426. /**
  126427. * Define the distance of the eyes to the screen.
  126428. */
  126429. eyeToScreenDistance: number;
  126430. /**
  126431. * Define the distance between both lenses
  126432. */
  126433. lensSeparationDistance: number;
  126434. /**
  126435. * Define the distance between both viewer's eyes.
  126436. */
  126437. interpupillaryDistance: number;
  126438. /**
  126439. * Define the distortion factor of the VR postprocess.
  126440. * Please, touch with care.
  126441. */
  126442. distortionK: number[];
  126443. /**
  126444. * Define the chromatic aberration correction factors for the VR post process.
  126445. */
  126446. chromaAbCorrection: number[];
  126447. /**
  126448. * Define the scale factor of the post process.
  126449. * The smaller the better but the slower.
  126450. */
  126451. postProcessScaleFactor: number;
  126452. /**
  126453. * Define an offset for the lens center.
  126454. */
  126455. lensCenterOffset: number;
  126456. /**
  126457. * Define if the current vr camera should compensate the distortion of the lense or not.
  126458. */
  126459. compensateDistortion: boolean;
  126460. /**
  126461. * Defines if multiview should be enabled when rendering (Default: false)
  126462. */
  126463. multiviewEnabled: boolean;
  126464. /**
  126465. * Gets the rendering aspect ratio based on the provided resolutions.
  126466. */
  126467. get aspectRatio(): number;
  126468. /**
  126469. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126470. */
  126471. get aspectRatioFov(): number;
  126472. /**
  126473. * @hidden
  126474. */
  126475. get leftHMatrix(): Matrix;
  126476. /**
  126477. * @hidden
  126478. */
  126479. get rightHMatrix(): Matrix;
  126480. /**
  126481. * @hidden
  126482. */
  126483. get leftPreViewMatrix(): Matrix;
  126484. /**
  126485. * @hidden
  126486. */
  126487. get rightPreViewMatrix(): Matrix;
  126488. /**
  126489. * Get the default VRMetrics based on the most generic setup.
  126490. * @returns the default vr metrics
  126491. */
  126492. static GetDefault(): VRCameraMetrics;
  126493. }
  126494. }
  126495. declare module BABYLON {
  126496. /** @hidden */
  126497. export var vrDistortionCorrectionPixelShader: {
  126498. name: string;
  126499. shader: string;
  126500. };
  126501. }
  126502. declare module BABYLON {
  126503. /**
  126504. * VRDistortionCorrectionPostProcess used for mobile VR
  126505. */
  126506. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126507. private _isRightEye;
  126508. private _distortionFactors;
  126509. private _postProcessScaleFactor;
  126510. private _lensCenterOffset;
  126511. private _scaleIn;
  126512. private _scaleFactor;
  126513. private _lensCenter;
  126514. /**
  126515. * Gets a string identifying the name of the class
  126516. * @returns "VRDistortionCorrectionPostProcess" string
  126517. */
  126518. getClassName(): string;
  126519. /**
  126520. * Initializes the VRDistortionCorrectionPostProcess
  126521. * @param name The name of the effect.
  126522. * @param camera The camera to apply the render pass to.
  126523. * @param isRightEye If this is for the right eye distortion
  126524. * @param vrMetrics All the required metrics for the VR camera
  126525. */
  126526. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126527. }
  126528. }
  126529. declare module BABYLON {
  126530. /**
  126531. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126532. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126533. */
  126534. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126535. /**
  126536. * Creates a new VRDeviceOrientationArcRotateCamera
  126537. * @param name defines camera name
  126538. * @param alpha defines the camera rotation along the logitudinal axis
  126539. * @param beta defines the camera rotation along the latitudinal axis
  126540. * @param radius defines the camera distance from its target
  126541. * @param target defines the camera target
  126542. * @param scene defines the scene the camera belongs to
  126543. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126544. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126545. */
  126546. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126547. /**
  126548. * Gets camera class name
  126549. * @returns VRDeviceOrientationArcRotateCamera
  126550. */
  126551. getClassName(): string;
  126552. }
  126553. }
  126554. declare module BABYLON {
  126555. /**
  126556. * Camera used to simulate VR rendering (based on FreeCamera)
  126557. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126558. */
  126559. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126560. /**
  126561. * Creates a new VRDeviceOrientationFreeCamera
  126562. * @param name defines camera name
  126563. * @param position defines the start position of the camera
  126564. * @param scene defines the scene the camera belongs to
  126565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126567. */
  126568. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126569. /**
  126570. * Gets camera class name
  126571. * @returns VRDeviceOrientationFreeCamera
  126572. */
  126573. getClassName(): string;
  126574. }
  126575. }
  126576. declare module BABYLON {
  126577. /**
  126578. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126579. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126580. */
  126581. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126582. /**
  126583. * Creates a new VRDeviceOrientationGamepadCamera
  126584. * @param name defines camera name
  126585. * @param position defines the start position of the camera
  126586. * @param scene defines the scene the camera belongs to
  126587. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126588. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126589. */
  126590. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126591. /**
  126592. * Gets camera class name
  126593. * @returns VRDeviceOrientationGamepadCamera
  126594. */
  126595. getClassName(): string;
  126596. }
  126597. }
  126598. declare module BABYLON {
  126599. /**
  126600. * A class extending Texture allowing drawing on a texture
  126601. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126602. */
  126603. export class DynamicTexture extends Texture {
  126604. private _generateMipMaps;
  126605. private _canvas;
  126606. private _context;
  126607. /**
  126608. * Creates a DynamicTexture
  126609. * @param name defines the name of the texture
  126610. * @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
  126611. * @param scene defines the scene where you want the texture
  126612. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126613. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126614. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126615. */
  126616. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126617. /**
  126618. * Get the current class name of the texture useful for serialization or dynamic coding.
  126619. * @returns "DynamicTexture"
  126620. */
  126621. getClassName(): string;
  126622. /**
  126623. * Gets the current state of canRescale
  126624. */
  126625. get canRescale(): boolean;
  126626. private _recreate;
  126627. /**
  126628. * Scales the texture
  126629. * @param ratio the scale factor to apply to both width and height
  126630. */
  126631. scale(ratio: number): void;
  126632. /**
  126633. * Resizes the texture
  126634. * @param width the new width
  126635. * @param height the new height
  126636. */
  126637. scaleTo(width: number, height: number): void;
  126638. /**
  126639. * Gets the context of the canvas used by the texture
  126640. * @returns the canvas context of the dynamic texture
  126641. */
  126642. getContext(): CanvasRenderingContext2D;
  126643. /**
  126644. * Clears the texture
  126645. */
  126646. clear(): void;
  126647. /**
  126648. * Updates the texture
  126649. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126650. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126651. */
  126652. update(invertY?: boolean, premulAlpha?: boolean): void;
  126653. /**
  126654. * Draws text onto the texture
  126655. * @param text defines the text to be drawn
  126656. * @param x defines the placement of the text from the left
  126657. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126658. * @param font defines the font to be used with font-style, font-size, font-name
  126659. * @param color defines the color used for the text
  126660. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126661. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126662. * @param update defines whether texture is immediately update (default is true)
  126663. */
  126664. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126665. /**
  126666. * Clones the texture
  126667. * @returns the clone of the texture.
  126668. */
  126669. clone(): DynamicTexture;
  126670. /**
  126671. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  126672. * @returns a serialized dynamic texture object
  126673. */
  126674. serialize(): any;
  126675. private _IsCanvasElement;
  126676. /** @hidden */
  126677. _rebuild(): void;
  126678. }
  126679. }
  126680. declare module BABYLON {
  126681. /**
  126682. * Class containing static functions to help procedurally build meshes
  126683. */
  126684. export class GroundBuilder {
  126685. /**
  126686. * Creates a ground mesh
  126687. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126688. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126690. * @param name defines the name of the mesh
  126691. * @param options defines the options used to create the mesh
  126692. * @param scene defines the hosting scene
  126693. * @returns the ground mesh
  126694. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126695. */
  126696. static CreateGround(name: string, options: {
  126697. width?: number;
  126698. height?: number;
  126699. subdivisions?: number;
  126700. subdivisionsX?: number;
  126701. subdivisionsY?: number;
  126702. updatable?: boolean;
  126703. }, scene: any): Mesh;
  126704. /**
  126705. * Creates a tiled ground mesh
  126706. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126707. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126708. * * 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
  126709. * * 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
  126710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126711. * @param name defines the name of the mesh
  126712. * @param options defines the options used to create the mesh
  126713. * @param scene defines the hosting scene
  126714. * @returns the tiled ground mesh
  126715. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126716. */
  126717. static CreateTiledGround(name: string, options: {
  126718. xmin: number;
  126719. zmin: number;
  126720. xmax: number;
  126721. zmax: number;
  126722. subdivisions?: {
  126723. w: number;
  126724. h: number;
  126725. };
  126726. precision?: {
  126727. w: number;
  126728. h: number;
  126729. };
  126730. updatable?: boolean;
  126731. }, scene?: Nullable<Scene>): Mesh;
  126732. /**
  126733. * Creates a ground mesh from a height map
  126734. * * The parameter `url` sets the URL of the height map image resource.
  126735. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126736. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126737. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126738. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126739. * * 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.
  126740. * * 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).
  126741. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126743. * @param name defines the name of the mesh
  126744. * @param url defines the url to the height map
  126745. * @param options defines the options used to create the mesh
  126746. * @param scene defines the hosting scene
  126747. * @returns the ground mesh
  126748. * @see https://doc.babylonjs.com/babylon101/height_map
  126749. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126750. */
  126751. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126752. width?: number;
  126753. height?: number;
  126754. subdivisions?: number;
  126755. minHeight?: number;
  126756. maxHeight?: number;
  126757. colorFilter?: Color3;
  126758. alphaFilter?: number;
  126759. updatable?: boolean;
  126760. onReady?: (mesh: GroundMesh) => void;
  126761. }, scene?: Nullable<Scene>): GroundMesh;
  126762. }
  126763. }
  126764. declare module BABYLON {
  126765. /**
  126766. * Class containing static functions to help procedurally build meshes
  126767. */
  126768. export class TorusBuilder {
  126769. /**
  126770. * Creates a torus mesh
  126771. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126772. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126773. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126777. * @param name defines the name of the mesh
  126778. * @param options defines the options used to create the mesh
  126779. * @param scene defines the hosting scene
  126780. * @returns the torus mesh
  126781. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126782. */
  126783. static CreateTorus(name: string, options: {
  126784. diameter?: number;
  126785. thickness?: number;
  126786. tessellation?: number;
  126787. updatable?: boolean;
  126788. sideOrientation?: number;
  126789. frontUVs?: Vector4;
  126790. backUVs?: Vector4;
  126791. }, scene: any): Mesh;
  126792. }
  126793. }
  126794. declare module BABYLON {
  126795. /**
  126796. * Class containing static functions to help procedurally build meshes
  126797. */
  126798. export class CylinderBuilder {
  126799. /**
  126800. * Creates a cylinder or a cone mesh
  126801. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126802. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126803. * * 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.
  126804. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126805. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126806. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126807. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126808. * * 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).
  126809. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126810. * * 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).
  126811. * * 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
  126812. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126813. * * 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
  126814. * * 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.
  126815. * * If `enclose` is false, a ring surface is one element.
  126816. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126817. * * 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
  126818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126821. * @param name defines the name of the mesh
  126822. * @param options defines the options used to create the mesh
  126823. * @param scene defines the hosting scene
  126824. * @returns the cylinder mesh
  126825. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126826. */
  126827. static CreateCylinder(name: string, options: {
  126828. height?: number;
  126829. diameterTop?: number;
  126830. diameterBottom?: number;
  126831. diameter?: number;
  126832. tessellation?: number;
  126833. subdivisions?: number;
  126834. arc?: number;
  126835. faceColors?: Color4[];
  126836. faceUV?: Vector4[];
  126837. updatable?: boolean;
  126838. hasRings?: boolean;
  126839. enclose?: boolean;
  126840. cap?: number;
  126841. sideOrientation?: number;
  126842. frontUVs?: Vector4;
  126843. backUVs?: Vector4;
  126844. }, scene: any): Mesh;
  126845. }
  126846. }
  126847. declare module BABYLON {
  126848. /**
  126849. * States of the webXR experience
  126850. */
  126851. export enum WebXRState {
  126852. /**
  126853. * Transitioning to being in XR mode
  126854. */
  126855. ENTERING_XR = 0,
  126856. /**
  126857. * Transitioning to non XR mode
  126858. */
  126859. EXITING_XR = 1,
  126860. /**
  126861. * In XR mode and presenting
  126862. */
  126863. IN_XR = 2,
  126864. /**
  126865. * Not entered XR mode
  126866. */
  126867. NOT_IN_XR = 3
  126868. }
  126869. /**
  126870. * Abstraction of the XR render target
  126871. */
  126872. export interface WebXRRenderTarget extends IDisposable {
  126873. /**
  126874. * xrpresent context of the canvas which can be used to display/mirror xr content
  126875. */
  126876. canvasContext: WebGLRenderingContext;
  126877. /**
  126878. * xr layer for the canvas
  126879. */
  126880. xrLayer: Nullable<XRWebGLLayer>;
  126881. /**
  126882. * Initializes the xr layer for the session
  126883. * @param xrSession xr session
  126884. * @returns a promise that will resolve once the XR Layer has been created
  126885. */
  126886. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126887. }
  126888. }
  126889. declare module BABYLON {
  126890. /**
  126891. * COnfiguration object for WebXR output canvas
  126892. */
  126893. export class WebXRManagedOutputCanvasOptions {
  126894. /**
  126895. * An optional canvas in case you wish to create it yourself and provide it here.
  126896. * If not provided, a new canvas will be created
  126897. */
  126898. canvasElement?: HTMLCanvasElement;
  126899. /**
  126900. * Options for this XR Layer output
  126901. */
  126902. canvasOptions?: XRWebGLLayerOptions;
  126903. /**
  126904. * CSS styling for a newly created canvas (if not provided)
  126905. */
  126906. newCanvasCssStyle?: string;
  126907. /**
  126908. * Get the default values of the configuration object
  126909. * @param engine defines the engine to use (can be null)
  126910. * @returns default values of this configuration object
  126911. */
  126912. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  126913. }
  126914. /**
  126915. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  126916. */
  126917. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  126918. private _options;
  126919. private _canvas;
  126920. private _engine;
  126921. private _originalCanvasSize;
  126922. /**
  126923. * Rendering context of the canvas which can be used to display/mirror xr content
  126924. */
  126925. canvasContext: WebGLRenderingContext;
  126926. /**
  126927. * xr layer for the canvas
  126928. */
  126929. xrLayer: Nullable<XRWebGLLayer>;
  126930. /**
  126931. * Obseervers registered here will be triggered when the xr layer was initialized
  126932. */
  126933. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  126934. /**
  126935. * Initializes the canvas to be added/removed upon entering/exiting xr
  126936. * @param _xrSessionManager The XR Session manager
  126937. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  126938. */
  126939. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  126940. /**
  126941. * Disposes of the object
  126942. */
  126943. dispose(): void;
  126944. /**
  126945. * Initializes the xr layer for the session
  126946. * @param xrSession xr session
  126947. * @returns a promise that will resolve once the XR Layer has been created
  126948. */
  126949. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126950. private _addCanvas;
  126951. private _removeCanvas;
  126952. private _setCanvasSize;
  126953. private _setManagedOutputCanvas;
  126954. }
  126955. }
  126956. declare module BABYLON {
  126957. /**
  126958. * Manages an XRSession to work with Babylon's engine
  126959. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  126960. */
  126961. export class WebXRSessionManager implements IDisposable {
  126962. /** The scene which the session should be created for */
  126963. scene: Scene;
  126964. private _referenceSpace;
  126965. private _rttProvider;
  126966. private _sessionEnded;
  126967. private _xrNavigator;
  126968. private baseLayer;
  126969. /**
  126970. * The base reference space from which the session started. good if you want to reset your
  126971. * reference space
  126972. */
  126973. baseReferenceSpace: XRReferenceSpace;
  126974. /**
  126975. * Current XR frame
  126976. */
  126977. currentFrame: Nullable<XRFrame>;
  126978. /** WebXR timestamp updated every frame */
  126979. currentTimestamp: number;
  126980. /**
  126981. * Used just in case of a failure to initialize an immersive session.
  126982. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  126983. */
  126984. defaultHeightCompensation: number;
  126985. /**
  126986. * Fires every time a new xrFrame arrives which can be used to update the camera
  126987. */
  126988. onXRFrameObservable: Observable<XRFrame>;
  126989. /**
  126990. * Fires when the reference space changed
  126991. */
  126992. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  126993. /**
  126994. * Fires when the xr session is ended either by the device or manually done
  126995. */
  126996. onXRSessionEnded: Observable<any>;
  126997. /**
  126998. * Fires when the xr session is ended either by the device or manually done
  126999. */
  127000. onXRSessionInit: Observable<XRSession>;
  127001. /**
  127002. * Underlying xr session
  127003. */
  127004. session: XRSession;
  127005. /**
  127006. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127007. * or get the offset the player is currently at.
  127008. */
  127009. viewerReferenceSpace: XRReferenceSpace;
  127010. /**
  127011. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127012. * @param scene The scene which the session should be created for
  127013. */
  127014. constructor(
  127015. /** The scene which the session should be created for */
  127016. scene: Scene);
  127017. /**
  127018. * The current reference space used in this session. This reference space can constantly change!
  127019. * It is mainly used to offset the camera's position.
  127020. */
  127021. get referenceSpace(): XRReferenceSpace;
  127022. /**
  127023. * Set a new reference space and triggers the observable
  127024. */
  127025. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127026. /**
  127027. * Disposes of the session manager
  127028. */
  127029. dispose(): void;
  127030. /**
  127031. * Stops the xrSession and restores the render loop
  127032. * @returns Promise which resolves after it exits XR
  127033. */
  127034. exitXRAsync(): Promise<void>;
  127035. /**
  127036. * Gets the correct render target texture to be rendered this frame for this eye
  127037. * @param eye the eye for which to get the render target
  127038. * @returns the render target for the specified eye
  127039. */
  127040. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127041. /**
  127042. * Creates a WebXRRenderTarget object for the XR session
  127043. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127044. * @param options optional options to provide when creating a new render target
  127045. * @returns a WebXR render target to which the session can render
  127046. */
  127047. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127048. /**
  127049. * Initializes the manager
  127050. * After initialization enterXR can be called to start an XR session
  127051. * @returns Promise which resolves after it is initialized
  127052. */
  127053. initializeAsync(): Promise<void>;
  127054. /**
  127055. * Initializes an xr session
  127056. * @param xrSessionMode mode to initialize
  127057. * @param xrSessionInit defines optional and required values to pass to the session builder
  127058. * @returns a promise which will resolve once the session has been initialized
  127059. */
  127060. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127061. /**
  127062. * Checks if a session would be supported for the creation options specified
  127063. * @param sessionMode session mode to check if supported eg. immersive-vr
  127064. * @returns A Promise that resolves to true if supported and false if not
  127065. */
  127066. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127067. /**
  127068. * Resets the reference space to the one started the session
  127069. */
  127070. resetReferenceSpace(): void;
  127071. /**
  127072. * Starts rendering to the xr layer
  127073. */
  127074. runXRRenderLoop(): void;
  127075. /**
  127076. * Sets the reference space on the xr session
  127077. * @param referenceSpaceType space to set
  127078. * @returns a promise that will resolve once the reference space has been set
  127079. */
  127080. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127081. /**
  127082. * Updates the render state of the session
  127083. * @param state state to set
  127084. * @returns a promise that resolves once the render state has been updated
  127085. */
  127086. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127087. /**
  127088. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127089. * @param sessionMode defines the session to test
  127090. * @returns a promise with boolean as final value
  127091. */
  127092. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127093. private _createRenderTargetTexture;
  127094. }
  127095. }
  127096. declare module BABYLON {
  127097. /**
  127098. * WebXR Camera which holds the views for the xrSession
  127099. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127100. */
  127101. export class WebXRCamera extends FreeCamera {
  127102. private _xrSessionManager;
  127103. private _firstFrame;
  127104. private _referenceQuaternion;
  127105. private _referencedPosition;
  127106. private _xrInvPositionCache;
  127107. private _xrInvQuaternionCache;
  127108. /**
  127109. * Observable raised before camera teleportation
  127110. */
  127111. onBeforeCameraTeleport: Observable<Vector3>;
  127112. /**
  127113. * Observable raised after camera teleportation
  127114. */
  127115. onAfterCameraTeleport: Observable<Vector3>;
  127116. /**
  127117. * Should position compensation execute on first frame.
  127118. * This is used when copying the position from a native (non XR) camera
  127119. */
  127120. compensateOnFirstFrame: boolean;
  127121. /**
  127122. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127123. * @param name the name of the camera
  127124. * @param scene the scene to add the camera to
  127125. * @param _xrSessionManager a constructed xr session manager
  127126. */
  127127. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127128. /**
  127129. * Return the user's height, unrelated to the current ground.
  127130. * This will be the y position of this camera, when ground level is 0.
  127131. */
  127132. get realWorldHeight(): number;
  127133. /** @hidden */
  127134. _updateForDualEyeDebugging(): void;
  127135. /**
  127136. * Sets this camera's transformation based on a non-vr camera
  127137. * @param otherCamera the non-vr camera to copy the transformation from
  127138. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127139. */
  127140. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127141. /**
  127142. * Gets the current instance class name ("WebXRCamera").
  127143. * @returns the class name
  127144. */
  127145. getClassName(): string;
  127146. private _rotate180;
  127147. private _updateFromXRSession;
  127148. private _updateNumberOfRigCameras;
  127149. private _updateReferenceSpace;
  127150. private _updateReferenceSpaceOffset;
  127151. }
  127152. }
  127153. declare module BABYLON {
  127154. /**
  127155. * Defining the interface required for a (webxr) feature
  127156. */
  127157. export interface IWebXRFeature extends IDisposable {
  127158. /**
  127159. * Is this feature attached
  127160. */
  127161. attached: boolean;
  127162. /**
  127163. * Should auto-attach be disabled?
  127164. */
  127165. disableAutoAttach: boolean;
  127166. /**
  127167. * Attach the feature to the session
  127168. * Will usually be called by the features manager
  127169. *
  127170. * @param force should attachment be forced (even when already attached)
  127171. * @returns true if successful.
  127172. */
  127173. attach(force?: boolean): boolean;
  127174. /**
  127175. * Detach the feature from the session
  127176. * Will usually be called by the features manager
  127177. *
  127178. * @returns true if successful.
  127179. */
  127180. detach(): boolean;
  127181. /**
  127182. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127183. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127184. *
  127185. * @returns whether or not the feature is compatible in this environment
  127186. */
  127187. isCompatible(): boolean;
  127188. /**
  127189. * Was this feature disposed;
  127190. */
  127191. isDisposed: boolean;
  127192. /**
  127193. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127194. */
  127195. xrNativeFeatureName?: string;
  127196. /**
  127197. * A list of (Babylon WebXR) features this feature depends on
  127198. */
  127199. dependsOn?: string[];
  127200. }
  127201. /**
  127202. * A list of the currently available features without referencing them
  127203. */
  127204. export class WebXRFeatureName {
  127205. /**
  127206. * The name of the anchor system feature
  127207. */
  127208. static readonly ANCHOR_SYSTEM: string;
  127209. /**
  127210. * The name of the background remover feature
  127211. */
  127212. static readonly BACKGROUND_REMOVER: string;
  127213. /**
  127214. * The name of the hit test feature
  127215. */
  127216. static readonly HIT_TEST: string;
  127217. /**
  127218. * physics impostors for xr controllers feature
  127219. */
  127220. static readonly PHYSICS_CONTROLLERS: string;
  127221. /**
  127222. * The name of the plane detection feature
  127223. */
  127224. static readonly PLANE_DETECTION: string;
  127225. /**
  127226. * The name of the pointer selection feature
  127227. */
  127228. static readonly POINTER_SELECTION: string;
  127229. /**
  127230. * The name of the teleportation feature
  127231. */
  127232. static readonly TELEPORTATION: string;
  127233. /**
  127234. * The name of the feature points feature.
  127235. */
  127236. static readonly FEATURE_POINTS: string;
  127237. /**
  127238. * The name of the hand tracking feature.
  127239. */
  127240. static readonly HAND_TRACKING: string;
  127241. }
  127242. /**
  127243. * Defining the constructor of a feature. Used to register the modules.
  127244. */
  127245. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127246. /**
  127247. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127248. * It is mainly used in AR sessions.
  127249. *
  127250. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127251. */
  127252. export class WebXRFeaturesManager implements IDisposable {
  127253. private _xrSessionManager;
  127254. private static readonly _AvailableFeatures;
  127255. private _features;
  127256. /**
  127257. * constructs a new features manages.
  127258. *
  127259. * @param _xrSessionManager an instance of WebXRSessionManager
  127260. */
  127261. constructor(_xrSessionManager: WebXRSessionManager);
  127262. /**
  127263. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127264. * Mainly used internally.
  127265. *
  127266. * @param featureName the name of the feature to register
  127267. * @param constructorFunction the function used to construct the module
  127268. * @param version the (babylon) version of the module
  127269. * @param stable is that a stable version of this module
  127270. */
  127271. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127272. /**
  127273. * Returns a constructor of a specific feature.
  127274. *
  127275. * @param featureName the name of the feature to construct
  127276. * @param version the version of the feature to load
  127277. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127278. * @param options optional options provided to the module.
  127279. * @returns a function that, when called, will return a new instance of this feature
  127280. */
  127281. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127282. /**
  127283. * Can be used to return the list of features currently registered
  127284. *
  127285. * @returns an Array of available features
  127286. */
  127287. static GetAvailableFeatures(): string[];
  127288. /**
  127289. * Gets the versions available for a specific feature
  127290. * @param featureName the name of the feature
  127291. * @returns an array with the available versions
  127292. */
  127293. static GetAvailableVersions(featureName: string): string[];
  127294. /**
  127295. * Return the latest unstable version of this feature
  127296. * @param featureName the name of the feature to search
  127297. * @returns the version number. if not found will return -1
  127298. */
  127299. static GetLatestVersionOfFeature(featureName: string): number;
  127300. /**
  127301. * Return the latest stable version of this feature
  127302. * @param featureName the name of the feature to search
  127303. * @returns the version number. if not found will return -1
  127304. */
  127305. static GetStableVersionOfFeature(featureName: string): number;
  127306. /**
  127307. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127308. * Can be used during a session to start a feature
  127309. * @param featureName the name of feature to attach
  127310. */
  127311. attachFeature(featureName: string): void;
  127312. /**
  127313. * Can be used inside a session or when the session ends to detach a specific feature
  127314. * @param featureName the name of the feature to detach
  127315. */
  127316. detachFeature(featureName: string): void;
  127317. /**
  127318. * Used to disable an already-enabled feature
  127319. * The feature will be disposed and will be recreated once enabled.
  127320. * @param featureName the feature to disable
  127321. * @returns true if disable was successful
  127322. */
  127323. disableFeature(featureName: string | {
  127324. Name: string;
  127325. }): boolean;
  127326. /**
  127327. * dispose this features manager
  127328. */
  127329. dispose(): void;
  127330. /**
  127331. * 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.
  127332. * 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.
  127333. *
  127334. * @param featureName the name of the feature to load or the class of the feature
  127335. * @param version optional version to load. if not provided the latest version will be enabled
  127336. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127337. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127338. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127339. * @returns a new constructed feature or throws an error if feature not found.
  127340. */
  127341. enableFeature(featureName: string | {
  127342. Name: string;
  127343. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127344. /**
  127345. * get the implementation of an enabled feature.
  127346. * @param featureName the name of the feature to load
  127347. * @returns the feature class, if found
  127348. */
  127349. getEnabledFeature(featureName: string): IWebXRFeature;
  127350. /**
  127351. * Get the list of enabled features
  127352. * @returns an array of enabled features
  127353. */
  127354. getEnabledFeatures(): string[];
  127355. /**
  127356. * This function will exten the session creation configuration object with enabled features.
  127357. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127358. * according to the defined "required" variable, provided during enableFeature call
  127359. * @param xrSessionInit the xr Session init object to extend
  127360. *
  127361. * @returns an extended XRSessionInit object
  127362. */
  127363. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127364. }
  127365. }
  127366. declare module BABYLON {
  127367. /**
  127368. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127369. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127370. */
  127371. export class WebXRExperienceHelper implements IDisposable {
  127372. private scene;
  127373. private _nonVRCamera;
  127374. private _originalSceneAutoClear;
  127375. private _supported;
  127376. /**
  127377. * Camera used to render xr content
  127378. */
  127379. camera: WebXRCamera;
  127380. /** A features manager for this xr session */
  127381. featuresManager: WebXRFeaturesManager;
  127382. /**
  127383. * Observers registered here will be triggered after the camera's initial transformation is set
  127384. * This can be used to set a different ground level or an extra rotation.
  127385. *
  127386. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127387. * to the position set after this observable is done executing.
  127388. */
  127389. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127390. /**
  127391. * Fires when the state of the experience helper has changed
  127392. */
  127393. onStateChangedObservable: Observable<WebXRState>;
  127394. /** Session manager used to keep track of xr session */
  127395. sessionManager: WebXRSessionManager;
  127396. /**
  127397. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127398. */
  127399. state: WebXRState;
  127400. /**
  127401. * Creates a WebXRExperienceHelper
  127402. * @param scene The scene the helper should be created in
  127403. */
  127404. private constructor();
  127405. /**
  127406. * Creates the experience helper
  127407. * @param scene the scene to attach the experience helper to
  127408. * @returns a promise for the experience helper
  127409. */
  127410. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127411. /**
  127412. * Disposes of the experience helper
  127413. */
  127414. dispose(): void;
  127415. /**
  127416. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127417. * @param sessionMode options for the XR session
  127418. * @param referenceSpaceType frame of reference of the XR session
  127419. * @param renderTarget the output canvas that will be used to enter XR mode
  127420. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127421. * @returns promise that resolves after xr mode has entered
  127422. */
  127423. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127424. /**
  127425. * Exits XR mode and returns the scene to its original state
  127426. * @returns promise that resolves after xr mode has exited
  127427. */
  127428. exitXRAsync(): Promise<void>;
  127429. private _nonXRToXRCamera;
  127430. private _setState;
  127431. }
  127432. }
  127433. declare module BABYLON {
  127434. /**
  127435. * X-Y values for axes in WebXR
  127436. */
  127437. export interface IWebXRMotionControllerAxesValue {
  127438. /**
  127439. * The value of the x axis
  127440. */
  127441. x: number;
  127442. /**
  127443. * The value of the y-axis
  127444. */
  127445. y: number;
  127446. }
  127447. /**
  127448. * changed / previous values for the values of this component
  127449. */
  127450. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127451. /**
  127452. * current (this frame) value
  127453. */
  127454. current: T;
  127455. /**
  127456. * previous (last change) value
  127457. */
  127458. previous: T;
  127459. }
  127460. /**
  127461. * Represents changes in the component between current frame and last values recorded
  127462. */
  127463. export interface IWebXRMotionControllerComponentChanges {
  127464. /**
  127465. * will be populated with previous and current values if axes changed
  127466. */
  127467. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127468. /**
  127469. * will be populated with previous and current values if pressed changed
  127470. */
  127471. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127472. /**
  127473. * will be populated with previous and current values if touched changed
  127474. */
  127475. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127476. /**
  127477. * will be populated with previous and current values if value changed
  127478. */
  127479. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127480. }
  127481. /**
  127482. * This class represents a single component (for example button or thumbstick) of a motion controller
  127483. */
  127484. export class WebXRControllerComponent implements IDisposable {
  127485. /**
  127486. * the id of this component
  127487. */
  127488. id: string;
  127489. /**
  127490. * the type of the component
  127491. */
  127492. type: MotionControllerComponentType;
  127493. private _buttonIndex;
  127494. private _axesIndices;
  127495. private _axes;
  127496. private _changes;
  127497. private _currentValue;
  127498. private _hasChanges;
  127499. private _pressed;
  127500. private _touched;
  127501. /**
  127502. * button component type
  127503. */
  127504. static BUTTON_TYPE: MotionControllerComponentType;
  127505. /**
  127506. * squeeze component type
  127507. */
  127508. static SQUEEZE_TYPE: MotionControllerComponentType;
  127509. /**
  127510. * Thumbstick component type
  127511. */
  127512. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127513. /**
  127514. * Touchpad component type
  127515. */
  127516. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127517. /**
  127518. * trigger component type
  127519. */
  127520. static TRIGGER_TYPE: MotionControllerComponentType;
  127521. /**
  127522. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127523. * the axes data changes
  127524. */
  127525. onAxisValueChangedObservable: Observable<{
  127526. x: number;
  127527. y: number;
  127528. }>;
  127529. /**
  127530. * Observers registered here will be triggered when the state of a button changes
  127531. * State change is either pressed / touched / value
  127532. */
  127533. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127534. /**
  127535. * Creates a new component for a motion controller.
  127536. * It is created by the motion controller itself
  127537. *
  127538. * @param id the id of this component
  127539. * @param type the type of the component
  127540. * @param _buttonIndex index in the buttons array of the gamepad
  127541. * @param _axesIndices indices of the values in the axes array of the gamepad
  127542. */
  127543. constructor(
  127544. /**
  127545. * the id of this component
  127546. */
  127547. id: string,
  127548. /**
  127549. * the type of the component
  127550. */
  127551. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127552. /**
  127553. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127554. */
  127555. get axes(): IWebXRMotionControllerAxesValue;
  127556. /**
  127557. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127558. */
  127559. get changes(): IWebXRMotionControllerComponentChanges;
  127560. /**
  127561. * Return whether or not the component changed the last frame
  127562. */
  127563. get hasChanges(): boolean;
  127564. /**
  127565. * is the button currently pressed
  127566. */
  127567. get pressed(): boolean;
  127568. /**
  127569. * is the button currently touched
  127570. */
  127571. get touched(): boolean;
  127572. /**
  127573. * Get the current value of this component
  127574. */
  127575. get value(): number;
  127576. /**
  127577. * Dispose this component
  127578. */
  127579. dispose(): void;
  127580. /**
  127581. * Are there axes correlating to this component
  127582. * @return true is axes data is available
  127583. */
  127584. isAxes(): boolean;
  127585. /**
  127586. * Is this component a button (hence - pressable)
  127587. * @returns true if can be pressed
  127588. */
  127589. isButton(): boolean;
  127590. /**
  127591. * update this component using the gamepad object it is in. Called on every frame
  127592. * @param nativeController the native gamepad controller object
  127593. */
  127594. update(nativeController: IMinimalMotionControllerObject): void;
  127595. }
  127596. }
  127597. declare module BABYLON {
  127598. /**
  127599. * Interface used to represent data loading progression
  127600. */
  127601. export interface ISceneLoaderProgressEvent {
  127602. /**
  127603. * Defines if data length to load can be evaluated
  127604. */
  127605. readonly lengthComputable: boolean;
  127606. /**
  127607. * Defines the loaded data length
  127608. */
  127609. readonly loaded: number;
  127610. /**
  127611. * Defines the data length to load
  127612. */
  127613. readonly total: number;
  127614. }
  127615. /**
  127616. * Interface used by SceneLoader plugins to define supported file extensions
  127617. */
  127618. export interface ISceneLoaderPluginExtensions {
  127619. /**
  127620. * Defines the list of supported extensions
  127621. */
  127622. [extension: string]: {
  127623. isBinary: boolean;
  127624. };
  127625. }
  127626. /**
  127627. * Interface used by SceneLoader plugin factory
  127628. */
  127629. export interface ISceneLoaderPluginFactory {
  127630. /**
  127631. * Defines the name of the factory
  127632. */
  127633. name: string;
  127634. /**
  127635. * Function called to create a new plugin
  127636. * @return the new plugin
  127637. */
  127638. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127639. /**
  127640. * The callback that returns true if the data can be directly loaded.
  127641. * @param data string containing the file data
  127642. * @returns if the data can be loaded directly
  127643. */
  127644. canDirectLoad?(data: string): boolean;
  127645. }
  127646. /**
  127647. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127648. */
  127649. export interface ISceneLoaderPluginBase {
  127650. /**
  127651. * The friendly name of this plugin.
  127652. */
  127653. name: string;
  127654. /**
  127655. * The file extensions supported by this plugin.
  127656. */
  127657. extensions: string | ISceneLoaderPluginExtensions;
  127658. /**
  127659. * The callback called when loading from a url.
  127660. * @param scene scene loading this url
  127661. * @param url url to load
  127662. * @param onSuccess callback called when the file successfully loads
  127663. * @param onProgress callback called while file is loading (if the server supports this mode)
  127664. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127665. * @param onError callback called when the file fails to load
  127666. * @returns a file request object
  127667. */
  127668. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127669. /**
  127670. * The callback called when loading from a file object.
  127671. * @param scene scene loading this file
  127672. * @param file defines the file to load
  127673. * @param onSuccess defines the callback to call when data is loaded
  127674. * @param onProgress defines the callback to call during loading process
  127675. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127676. * @param onError defines the callback to call when an error occurs
  127677. * @returns a file request object
  127678. */
  127679. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127680. /**
  127681. * The callback that returns true if the data can be directly loaded.
  127682. * @param data string containing the file data
  127683. * @returns if the data can be loaded directly
  127684. */
  127685. canDirectLoad?(data: string): boolean;
  127686. /**
  127687. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  127688. * @param scene scene loading this data
  127689. * @param data string containing the data
  127690. * @returns data to pass to the plugin
  127691. */
  127692. directLoad?(scene: Scene, data: string): any;
  127693. /**
  127694. * The callback that allows custom handling of the root url based on the response url.
  127695. * @param rootUrl the original root url
  127696. * @param responseURL the response url if available
  127697. * @returns the new root url
  127698. */
  127699. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  127700. }
  127701. /**
  127702. * Interface used to define a SceneLoader plugin
  127703. */
  127704. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  127705. /**
  127706. * Import meshes into a scene.
  127707. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127708. * @param scene The scene to import into
  127709. * @param data The data to import
  127710. * @param rootUrl The root url for scene and resources
  127711. * @param meshes The meshes array to import into
  127712. * @param particleSystems The particle systems array to import into
  127713. * @param skeletons The skeletons array to import into
  127714. * @param onError The callback when import fails
  127715. * @returns True if successful or false otherwise
  127716. */
  127717. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  127718. /**
  127719. * Load into a scene.
  127720. * @param scene The scene to load into
  127721. * @param data The data to import
  127722. * @param rootUrl The root url for scene and resources
  127723. * @param onError The callback when import fails
  127724. * @returns True if successful or false otherwise
  127725. */
  127726. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  127727. /**
  127728. * Load into an asset container.
  127729. * @param scene The scene to load into
  127730. * @param data The data to import
  127731. * @param rootUrl The root url for scene and resources
  127732. * @param onError The callback when import fails
  127733. * @returns The loaded asset container
  127734. */
  127735. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  127736. }
  127737. /**
  127738. * Interface used to define an async SceneLoader plugin
  127739. */
  127740. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  127741. /**
  127742. * Import meshes into a scene.
  127743. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127744. * @param scene The scene to import into
  127745. * @param data The data to import
  127746. * @param rootUrl The root url for scene and resources
  127747. * @param onProgress The callback when the load progresses
  127748. * @param fileName Defines the name of the file to load
  127749. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  127750. */
  127751. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  127752. meshes: AbstractMesh[];
  127753. particleSystems: IParticleSystem[];
  127754. skeletons: Skeleton[];
  127755. animationGroups: AnimationGroup[];
  127756. }>;
  127757. /**
  127758. * Load into a scene.
  127759. * @param scene The scene to load into
  127760. * @param data The data to import
  127761. * @param rootUrl The root url for scene and resources
  127762. * @param onProgress The callback when the load progresses
  127763. * @param fileName Defines the name of the file to load
  127764. * @returns Nothing
  127765. */
  127766. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  127767. /**
  127768. * Load into an asset container.
  127769. * @param scene The scene to load into
  127770. * @param data The data to import
  127771. * @param rootUrl The root url for scene and resources
  127772. * @param onProgress The callback when the load progresses
  127773. * @param fileName Defines the name of the file to load
  127774. * @returns The loaded asset container
  127775. */
  127776. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  127777. }
  127778. /**
  127779. * Mode that determines how to handle old animation groups before loading new ones.
  127780. */
  127781. export enum SceneLoaderAnimationGroupLoadingMode {
  127782. /**
  127783. * Reset all old animations to initial state then dispose them.
  127784. */
  127785. Clean = 0,
  127786. /**
  127787. * Stop all old animations.
  127788. */
  127789. Stop = 1,
  127790. /**
  127791. * Restart old animations from first frame.
  127792. */
  127793. Sync = 2,
  127794. /**
  127795. * Old animations remains untouched.
  127796. */
  127797. NoSync = 3
  127798. }
  127799. /**
  127800. * Defines a plugin registered by the SceneLoader
  127801. */
  127802. interface IRegisteredPlugin {
  127803. /**
  127804. * Defines the plugin to use
  127805. */
  127806. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127807. /**
  127808. * Defines if the plugin supports binary data
  127809. */
  127810. isBinary: boolean;
  127811. }
  127812. /**
  127813. * Class used to load scene from various file formats using registered plugins
  127814. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  127815. */
  127816. export class SceneLoader {
  127817. /**
  127818. * No logging while loading
  127819. */
  127820. static readonly NO_LOGGING: number;
  127821. /**
  127822. * Minimal logging while loading
  127823. */
  127824. static readonly MINIMAL_LOGGING: number;
  127825. /**
  127826. * Summary logging while loading
  127827. */
  127828. static readonly SUMMARY_LOGGING: number;
  127829. /**
  127830. * Detailled logging while loading
  127831. */
  127832. static readonly DETAILED_LOGGING: number;
  127833. /**
  127834. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  127835. */
  127836. static get ForceFullSceneLoadingForIncremental(): boolean;
  127837. static set ForceFullSceneLoadingForIncremental(value: boolean);
  127838. /**
  127839. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  127840. */
  127841. static get ShowLoadingScreen(): boolean;
  127842. static set ShowLoadingScreen(value: boolean);
  127843. /**
  127844. * Defines the current logging level (while loading the scene)
  127845. * @ignorenaming
  127846. */
  127847. static get loggingLevel(): number;
  127848. static set loggingLevel(value: number);
  127849. /**
  127850. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  127851. */
  127852. static get CleanBoneMatrixWeights(): boolean;
  127853. static set CleanBoneMatrixWeights(value: boolean);
  127854. /**
  127855. * Event raised when a plugin is used to load a scene
  127856. */
  127857. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  127858. private static _registeredPlugins;
  127859. private static _showingLoadingScreen;
  127860. /**
  127861. * Gets the default plugin (used to load Babylon files)
  127862. * @returns the .babylon plugin
  127863. */
  127864. static GetDefaultPlugin(): IRegisteredPlugin;
  127865. private static _GetPluginForExtension;
  127866. private static _GetPluginForDirectLoad;
  127867. private static _GetPluginForFilename;
  127868. private static _GetDirectLoad;
  127869. private static _LoadData;
  127870. private static _GetFileInfo;
  127871. /**
  127872. * Gets a plugin that can load the given extension
  127873. * @param extension defines the extension to load
  127874. * @returns a plugin or null if none works
  127875. */
  127876. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127877. /**
  127878. * Gets a boolean indicating that the given extension can be loaded
  127879. * @param extension defines the extension to load
  127880. * @returns true if the extension is supported
  127881. */
  127882. static IsPluginForExtensionAvailable(extension: string): boolean;
  127883. /**
  127884. * Adds a new plugin to the list of registered plugins
  127885. * @param plugin defines the plugin to add
  127886. */
  127887. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  127888. /**
  127889. * Import meshes into a scene
  127890. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127891. * @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)
  127892. * @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)
  127893. * @param scene the instance of BABYLON.Scene to append to
  127894. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  127895. * @param onProgress a callback with a progress event for each file being loaded
  127896. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127897. * @param pluginExtension the extension used to determine the plugin
  127898. * @returns The loaded plugin
  127899. */
  127900. 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>;
  127901. /**
  127902. * Import meshes into a scene
  127903. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127904. * @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)
  127905. * @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)
  127906. * @param scene the instance of BABYLON.Scene to append to
  127907. * @param onProgress a callback with a progress event for each file being loaded
  127908. * @param pluginExtension the extension used to determine the plugin
  127909. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  127910. */
  127911. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  127912. meshes: AbstractMesh[];
  127913. particleSystems: IParticleSystem[];
  127914. skeletons: Skeleton[];
  127915. animationGroups: AnimationGroup[];
  127916. }>;
  127917. /**
  127918. * Load a scene
  127919. * @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)
  127920. * @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)
  127921. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127922. * @param onSuccess a callback with the scene when import succeeds
  127923. * @param onProgress a callback with a progress event for each file being loaded
  127924. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127925. * @param pluginExtension the extension used to determine the plugin
  127926. * @returns The loaded plugin
  127927. */
  127928. 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>;
  127929. /**
  127930. * Load a scene
  127931. * @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)
  127932. * @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)
  127933. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127934. * @param onProgress a callback with a progress event for each file being loaded
  127935. * @param pluginExtension the extension used to determine the plugin
  127936. * @returns The loaded scene
  127937. */
  127938. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127939. /**
  127940. * Append a scene
  127941. * @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)
  127942. * @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)
  127943. * @param scene is the instance of BABYLON.Scene to append to
  127944. * @param onSuccess a callback with the scene when import succeeds
  127945. * @param onProgress a callback with a progress event for each file being loaded
  127946. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127947. * @param pluginExtension the extension used to determine the plugin
  127948. * @returns The loaded plugin
  127949. */
  127950. 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>;
  127951. /**
  127952. * Append a scene
  127953. * @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)
  127954. * @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)
  127955. * @param scene is the instance of BABYLON.Scene to append to
  127956. * @param onProgress a callback with a progress event for each file being loaded
  127957. * @param pluginExtension the extension used to determine the plugin
  127958. * @returns The given scene
  127959. */
  127960. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127961. /**
  127962. * Load a scene into an asset container
  127963. * @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)
  127964. * @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)
  127965. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127966. * @param onSuccess a callback with the scene when import succeeds
  127967. * @param onProgress a callback with a progress event for each file being loaded
  127968. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127969. * @param pluginExtension the extension used to determine the plugin
  127970. * @returns The loaded plugin
  127971. */
  127972. 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>;
  127973. /**
  127974. * Load a scene into an asset container
  127975. * @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)
  127976. * @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)
  127977. * @param scene is the instance of Scene to append to
  127978. * @param onProgress a callback with a progress event for each file being loaded
  127979. * @param pluginExtension the extension used to determine the plugin
  127980. * @returns The loaded asset container
  127981. */
  127982. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  127983. /**
  127984. * Import animations from a file into a scene
  127985. * @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)
  127986. * @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)
  127987. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127988. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127989. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127990. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127991. * @param onSuccess a callback with the scene when import succeeds
  127992. * @param onProgress a callback with a progress event for each file being loaded
  127993. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127994. * @param pluginExtension the extension used to determine the plugin
  127995. */
  127996. 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;
  127997. /**
  127998. * Import animations from a file into a scene
  127999. * @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)
  128000. * @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)
  128001. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128002. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128003. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128004. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128005. * @param onSuccess a callback with the scene when import succeeds
  128006. * @param onProgress a callback with a progress event for each file being loaded
  128007. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128008. * @param pluginExtension the extension used to determine the plugin
  128009. * @returns the updated scene with imported animations
  128010. */
  128011. 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>;
  128012. }
  128013. }
  128014. declare module BABYLON {
  128015. /**
  128016. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128017. */
  128018. export type MotionControllerHandedness = "none" | "left" | "right";
  128019. /**
  128020. * The type of components available in motion controllers.
  128021. * This is not the name of the component.
  128022. */
  128023. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128024. /**
  128025. * The state of a controller component
  128026. */
  128027. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128028. /**
  128029. * The schema of motion controller layout.
  128030. * No object will be initialized using this interface
  128031. * This is used just to define the profile.
  128032. */
  128033. export interface IMotionControllerLayout {
  128034. /**
  128035. * Path to load the assets. Usually relative to the base path
  128036. */
  128037. assetPath: string;
  128038. /**
  128039. * Available components (unsorted)
  128040. */
  128041. components: {
  128042. /**
  128043. * A map of component Ids
  128044. */
  128045. [componentId: string]: {
  128046. /**
  128047. * The type of input the component outputs
  128048. */
  128049. type: MotionControllerComponentType;
  128050. /**
  128051. * The indices of this component in the gamepad object
  128052. */
  128053. gamepadIndices: {
  128054. /**
  128055. * Index of button
  128056. */
  128057. button?: number;
  128058. /**
  128059. * If available, index of x-axis
  128060. */
  128061. xAxis?: number;
  128062. /**
  128063. * If available, index of y-axis
  128064. */
  128065. yAxis?: number;
  128066. };
  128067. /**
  128068. * The mesh's root node name
  128069. */
  128070. rootNodeName: string;
  128071. /**
  128072. * Animation definitions for this model
  128073. */
  128074. visualResponses: {
  128075. [stateKey: string]: {
  128076. /**
  128077. * What property will be animated
  128078. */
  128079. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128080. /**
  128081. * What states influence this visual response
  128082. */
  128083. states: MotionControllerComponentStateType[];
  128084. /**
  128085. * Type of animation - movement or visibility
  128086. */
  128087. valueNodeProperty: "transform" | "visibility";
  128088. /**
  128089. * Base node name to move. Its position will be calculated according to the min and max nodes
  128090. */
  128091. valueNodeName?: string;
  128092. /**
  128093. * Minimum movement node
  128094. */
  128095. minNodeName?: string;
  128096. /**
  128097. * Max movement node
  128098. */
  128099. maxNodeName?: string;
  128100. };
  128101. };
  128102. /**
  128103. * If touch enabled, what is the name of node to display user feedback
  128104. */
  128105. touchPointNodeName?: string;
  128106. };
  128107. };
  128108. /**
  128109. * Is it xr standard mapping or not
  128110. */
  128111. gamepadMapping: "" | "xr-standard";
  128112. /**
  128113. * Base root node of this entire model
  128114. */
  128115. rootNodeName: string;
  128116. /**
  128117. * Defines the main button component id
  128118. */
  128119. selectComponentId: string;
  128120. }
  128121. /**
  128122. * A definition for the layout map in the input profile
  128123. */
  128124. export interface IMotionControllerLayoutMap {
  128125. /**
  128126. * Layouts with handedness type as a key
  128127. */
  128128. [handedness: string]: IMotionControllerLayout;
  128129. }
  128130. /**
  128131. * The XR Input profile schema
  128132. * Profiles can be found here:
  128133. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128134. */
  128135. export interface IMotionControllerProfile {
  128136. /**
  128137. * fallback profiles for this profileId
  128138. */
  128139. fallbackProfileIds: string[];
  128140. /**
  128141. * The layout map, with handedness as key
  128142. */
  128143. layouts: IMotionControllerLayoutMap;
  128144. /**
  128145. * The id of this profile
  128146. * correlates to the profile(s) in the xrInput.profiles array
  128147. */
  128148. profileId: string;
  128149. }
  128150. /**
  128151. * A helper-interface for the 3 meshes needed for controller button animation
  128152. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128153. */
  128154. export interface IMotionControllerButtonMeshMap {
  128155. /**
  128156. * the mesh that defines the pressed value mesh position.
  128157. * This is used to find the max-position of this button
  128158. */
  128159. pressedMesh: AbstractMesh;
  128160. /**
  128161. * the mesh that defines the unpressed value mesh position.
  128162. * This is used to find the min (or initial) position of this button
  128163. */
  128164. unpressedMesh: AbstractMesh;
  128165. /**
  128166. * The mesh that will be changed when value changes
  128167. */
  128168. valueMesh: AbstractMesh;
  128169. }
  128170. /**
  128171. * A helper-interface for the 3 meshes needed for controller axis animation.
  128172. * This will be expanded when touchpad animations are fully supported
  128173. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128174. */
  128175. export interface IMotionControllerMeshMap {
  128176. /**
  128177. * the mesh that defines the maximum value mesh position.
  128178. */
  128179. maxMesh?: AbstractMesh;
  128180. /**
  128181. * the mesh that defines the minimum value mesh position.
  128182. */
  128183. minMesh?: AbstractMesh;
  128184. /**
  128185. * The mesh that will be changed when axis value changes
  128186. */
  128187. valueMesh?: AbstractMesh;
  128188. }
  128189. /**
  128190. * The elements needed for change-detection of the gamepad objects in motion controllers
  128191. */
  128192. export interface IMinimalMotionControllerObject {
  128193. /**
  128194. * Available axes of this controller
  128195. */
  128196. axes: number[];
  128197. /**
  128198. * An array of available buttons
  128199. */
  128200. buttons: Array<{
  128201. /**
  128202. * Value of the button/trigger
  128203. */
  128204. value: number;
  128205. /**
  128206. * If the button/trigger is currently touched
  128207. */
  128208. touched: boolean;
  128209. /**
  128210. * If the button/trigger is currently pressed
  128211. */
  128212. pressed: boolean;
  128213. }>;
  128214. /**
  128215. * EXPERIMENTAL haptic support.
  128216. */
  128217. hapticActuators?: Array<{
  128218. pulse: (value: number, duration: number) => Promise<boolean>;
  128219. }>;
  128220. }
  128221. /**
  128222. * An Abstract Motion controller
  128223. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128224. * Each component has an observable to check for changes in value and state
  128225. */
  128226. export abstract class WebXRAbstractMotionController implements IDisposable {
  128227. protected scene: Scene;
  128228. protected layout: IMotionControllerLayout;
  128229. /**
  128230. * The gamepad object correlating to this controller
  128231. */
  128232. gamepadObject: IMinimalMotionControllerObject;
  128233. /**
  128234. * handedness (left/right/none) of this controller
  128235. */
  128236. handedness: MotionControllerHandedness;
  128237. private _initComponent;
  128238. private _modelReady;
  128239. /**
  128240. * A map of components (WebXRControllerComponent) in this motion controller
  128241. * Components have a ComponentType and can also have both button and axis definitions
  128242. */
  128243. readonly components: {
  128244. [id: string]: WebXRControllerComponent;
  128245. };
  128246. /**
  128247. * Disable the model's animation. Can be set at any time.
  128248. */
  128249. disableAnimation: boolean;
  128250. /**
  128251. * Observers registered here will be triggered when the model of this controller is done loading
  128252. */
  128253. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128254. /**
  128255. * The profile id of this motion controller
  128256. */
  128257. abstract profileId: string;
  128258. /**
  128259. * The root mesh of the model. It is null if the model was not yet initialized
  128260. */
  128261. rootMesh: Nullable<AbstractMesh>;
  128262. /**
  128263. * constructs a new abstract motion controller
  128264. * @param scene the scene to which the model of the controller will be added
  128265. * @param layout The profile layout to load
  128266. * @param gamepadObject The gamepad object correlating to this controller
  128267. * @param handedness handedness (left/right/none) of this controller
  128268. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128269. */
  128270. constructor(scene: Scene, layout: IMotionControllerLayout,
  128271. /**
  128272. * The gamepad object correlating to this controller
  128273. */
  128274. gamepadObject: IMinimalMotionControllerObject,
  128275. /**
  128276. * handedness (left/right/none) of this controller
  128277. */
  128278. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128279. /**
  128280. * Dispose this controller, the model mesh and all its components
  128281. */
  128282. dispose(): void;
  128283. /**
  128284. * Returns all components of specific type
  128285. * @param type the type to search for
  128286. * @return an array of components with this type
  128287. */
  128288. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128289. /**
  128290. * get a component based an its component id as defined in layout.components
  128291. * @param id the id of the component
  128292. * @returns the component correlates to the id or undefined if not found
  128293. */
  128294. getComponent(id: string): WebXRControllerComponent;
  128295. /**
  128296. * Get the list of components available in this motion controller
  128297. * @returns an array of strings correlating to available components
  128298. */
  128299. getComponentIds(): string[];
  128300. /**
  128301. * Get the first component of specific type
  128302. * @param type type of component to find
  128303. * @return a controller component or null if not found
  128304. */
  128305. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128306. /**
  128307. * Get the main (Select) component of this controller as defined in the layout
  128308. * @returns the main component of this controller
  128309. */
  128310. getMainComponent(): WebXRControllerComponent;
  128311. /**
  128312. * Loads the model correlating to this controller
  128313. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128314. * @returns A promise fulfilled with the result of the model loading
  128315. */
  128316. loadModel(): Promise<boolean>;
  128317. /**
  128318. * Update this model using the current XRFrame
  128319. * @param xrFrame the current xr frame to use and update the model
  128320. */
  128321. updateFromXRFrame(xrFrame: XRFrame): void;
  128322. /**
  128323. * Backwards compatibility due to a deeply-integrated typo
  128324. */
  128325. get handness(): XREye;
  128326. /**
  128327. * Pulse (vibrate) this controller
  128328. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128329. * Consecutive calls to this function will cancel the last pulse call
  128330. *
  128331. * @param value the strength of the pulse in 0.0...1.0 range
  128332. * @param duration Duration of the pulse in milliseconds
  128333. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128334. * @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
  128335. */
  128336. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128337. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128338. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128339. /**
  128340. * Moves the axis on the controller mesh based on its current state
  128341. * @param axis the index of the axis
  128342. * @param axisValue the value of the axis which determines the meshes new position
  128343. * @hidden
  128344. */
  128345. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128346. /**
  128347. * Update the model itself with the current frame data
  128348. * @param xrFrame the frame to use for updating the model mesh
  128349. */
  128350. protected updateModel(xrFrame: XRFrame): void;
  128351. /**
  128352. * Get the filename and path for this controller's model
  128353. * @returns a map of filename and path
  128354. */
  128355. protected abstract _getFilenameAndPath(): {
  128356. filename: string;
  128357. path: string;
  128358. };
  128359. /**
  128360. * This function is called before the mesh is loaded. It checks for loading constraints.
  128361. * For example, this function can check if the GLB loader is available
  128362. * If this function returns false, the generic controller will be loaded instead
  128363. * @returns Is the client ready to load the mesh
  128364. */
  128365. protected abstract _getModelLoadingConstraints(): boolean;
  128366. /**
  128367. * This function will be called after the model was successfully loaded and can be used
  128368. * for mesh transformations before it is available for the user
  128369. * @param meshes the loaded meshes
  128370. */
  128371. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128372. /**
  128373. * Set the root mesh for this controller. Important for the WebXR controller class
  128374. * @param meshes the loaded meshes
  128375. */
  128376. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128377. /**
  128378. * A function executed each frame that updates the mesh (if needed)
  128379. * @param xrFrame the current xrFrame
  128380. */
  128381. protected abstract _updateModel(xrFrame: XRFrame): void;
  128382. private _getGenericFilenameAndPath;
  128383. private _getGenericParentMesh;
  128384. }
  128385. }
  128386. declare module BABYLON {
  128387. /**
  128388. * A generic trigger-only motion controller for WebXR
  128389. */
  128390. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128391. /**
  128392. * Static version of the profile id of this controller
  128393. */
  128394. static ProfileId: string;
  128395. profileId: string;
  128396. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128397. protected _getFilenameAndPath(): {
  128398. filename: string;
  128399. path: string;
  128400. };
  128401. protected _getModelLoadingConstraints(): boolean;
  128402. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128403. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128404. protected _updateModel(): void;
  128405. }
  128406. }
  128407. declare module BABYLON {
  128408. /**
  128409. * Class containing static functions to help procedurally build meshes
  128410. */
  128411. export class SphereBuilder {
  128412. /**
  128413. * Creates a sphere mesh
  128414. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128415. * * 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`)
  128416. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128417. * * 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
  128418. * * 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)
  128419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128422. * @param name defines the name of the mesh
  128423. * @param options defines the options used to create the mesh
  128424. * @param scene defines the hosting scene
  128425. * @returns the sphere mesh
  128426. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128427. */
  128428. static CreateSphere(name: string, options: {
  128429. segments?: number;
  128430. diameter?: number;
  128431. diameterX?: number;
  128432. diameterY?: number;
  128433. diameterZ?: number;
  128434. arc?: number;
  128435. slice?: number;
  128436. sideOrientation?: number;
  128437. frontUVs?: Vector4;
  128438. backUVs?: Vector4;
  128439. updatable?: boolean;
  128440. }, scene?: Nullable<Scene>): Mesh;
  128441. }
  128442. }
  128443. declare module BABYLON {
  128444. /**
  128445. * A profiled motion controller has its profile loaded from an online repository.
  128446. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128447. */
  128448. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128449. private _repositoryUrl;
  128450. private _buttonMeshMapping;
  128451. private _touchDots;
  128452. /**
  128453. * The profile ID of this controller. Will be populated when the controller initializes.
  128454. */
  128455. profileId: string;
  128456. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128457. dispose(): void;
  128458. protected _getFilenameAndPath(): {
  128459. filename: string;
  128460. path: string;
  128461. };
  128462. protected _getModelLoadingConstraints(): boolean;
  128463. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128464. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128465. protected _updateModel(_xrFrame: XRFrame): void;
  128466. }
  128467. }
  128468. declare module BABYLON {
  128469. /**
  128470. * A construction function type to create a new controller based on an xrInput object
  128471. */
  128472. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128473. /**
  128474. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128475. *
  128476. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128477. * it should be replaced with auto-loaded controllers.
  128478. *
  128479. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128480. */
  128481. export class WebXRMotionControllerManager {
  128482. private static _AvailableControllers;
  128483. private static _Fallbacks;
  128484. private static _ProfileLoadingPromises;
  128485. private static _ProfilesList;
  128486. /**
  128487. * The base URL of the online controller repository. Can be changed at any time.
  128488. */
  128489. static BaseRepositoryUrl: string;
  128490. /**
  128491. * Which repository gets priority - local or online
  128492. */
  128493. static PrioritizeOnlineRepository: boolean;
  128494. /**
  128495. * Use the online repository, or use only locally-defined controllers
  128496. */
  128497. static UseOnlineRepository: boolean;
  128498. /**
  128499. * Clear the cache used for profile loading and reload when requested again
  128500. */
  128501. static ClearProfilesCache(): void;
  128502. /**
  128503. * Register the default fallbacks.
  128504. * This function is called automatically when this file is imported.
  128505. */
  128506. static DefaultFallbacks(): void;
  128507. /**
  128508. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128509. * @param profileId the profile to which a fallback needs to be found
  128510. * @return an array with corresponding fallback profiles
  128511. */
  128512. static FindFallbackWithProfileId(profileId: string): string[];
  128513. /**
  128514. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128515. * The order of search:
  128516. *
  128517. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128518. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128519. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128520. * 4) return the generic trigger controller if none were found
  128521. *
  128522. * @param xrInput the xrInput to which a new controller is initialized
  128523. * @param scene the scene to which the model will be added
  128524. * @param forceProfile force a certain profile for this controller
  128525. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128526. */
  128527. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128528. /**
  128529. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128530. *
  128531. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128532. *
  128533. * @param type the profile type to register
  128534. * @param constructFunction the function to be called when loading this profile
  128535. */
  128536. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128537. /**
  128538. * Register a fallback to a specific profile.
  128539. * @param profileId the profileId that will receive the fallbacks
  128540. * @param fallbacks A list of fallback profiles
  128541. */
  128542. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128543. /**
  128544. * Will update the list of profiles available in the repository
  128545. * @return a promise that resolves to a map of profiles available online
  128546. */
  128547. static UpdateProfilesList(): Promise<{
  128548. [profile: string]: string;
  128549. }>;
  128550. private static _LoadProfileFromRepository;
  128551. private static _LoadProfilesFromAvailableControllers;
  128552. }
  128553. }
  128554. declare module BABYLON {
  128555. /**
  128556. * Configuration options for the WebXR controller creation
  128557. */
  128558. export interface IWebXRControllerOptions {
  128559. /**
  128560. * Should the controller mesh be animated when a user interacts with it
  128561. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128562. */
  128563. disableMotionControllerAnimation?: boolean;
  128564. /**
  128565. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128566. */
  128567. doNotLoadControllerMesh?: boolean;
  128568. /**
  128569. * Force a specific controller type for this controller.
  128570. * This can be used when creating your own profile or when testing different controllers
  128571. */
  128572. forceControllerProfile?: string;
  128573. /**
  128574. * Defines a rendering group ID for meshes that will be loaded.
  128575. * This is for the default controllers only.
  128576. */
  128577. renderingGroupId?: number;
  128578. }
  128579. /**
  128580. * Represents an XR controller
  128581. */
  128582. export class WebXRInputSource {
  128583. private _scene;
  128584. /** The underlying input source for the controller */
  128585. inputSource: XRInputSource;
  128586. private _options;
  128587. private _tmpVector;
  128588. private _uniqueId;
  128589. private _disposed;
  128590. /**
  128591. * 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
  128592. */
  128593. grip?: AbstractMesh;
  128594. /**
  128595. * If available, this is the gamepad object related to this controller.
  128596. * Using this object it is possible to get click events and trackpad changes of the
  128597. * webxr controller that is currently being used.
  128598. */
  128599. motionController?: WebXRAbstractMotionController;
  128600. /**
  128601. * Event that fires when the controller is removed/disposed.
  128602. * The object provided as event data is this controller, after associated assets were disposed.
  128603. * uniqueId is still available.
  128604. */
  128605. onDisposeObservable: Observable<WebXRInputSource>;
  128606. /**
  128607. * Will be triggered when the mesh associated with the motion controller is done loading.
  128608. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128609. * A shortened version of controller -> motion controller -> on mesh loaded.
  128610. */
  128611. onMeshLoadedObservable: Observable<AbstractMesh>;
  128612. /**
  128613. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128614. */
  128615. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128616. /**
  128617. * Pointer which can be used to select objects or attach a visible laser to
  128618. */
  128619. pointer: AbstractMesh;
  128620. /**
  128621. * Creates the input source object
  128622. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128623. * @param _scene the scene which the controller should be associated to
  128624. * @param inputSource the underlying input source for the controller
  128625. * @param _options options for this controller creation
  128626. */
  128627. constructor(_scene: Scene,
  128628. /** The underlying input source for the controller */
  128629. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128630. /**
  128631. * Get this controllers unique id
  128632. */
  128633. get uniqueId(): string;
  128634. /**
  128635. * Disposes of the object
  128636. */
  128637. dispose(): void;
  128638. /**
  128639. * Gets a world space ray coming from the pointer or grip
  128640. * @param result the resulting ray
  128641. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128642. */
  128643. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128644. /**
  128645. * Updates the controller pose based on the given XRFrame
  128646. * @param xrFrame xr frame to update the pose with
  128647. * @param referenceSpace reference space to use
  128648. */
  128649. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128650. }
  128651. }
  128652. declare module BABYLON {
  128653. /**
  128654. * The schema for initialization options of the XR Input class
  128655. */
  128656. export interface IWebXRInputOptions {
  128657. /**
  128658. * If set to true no model will be automatically loaded
  128659. */
  128660. doNotLoadControllerMeshes?: boolean;
  128661. /**
  128662. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128663. * If not found, the xr input profile data will be used.
  128664. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128665. */
  128666. forceInputProfile?: string;
  128667. /**
  128668. * Do not send a request to the controller repository to load the profile.
  128669. *
  128670. * Instead, use the controllers available in babylon itself.
  128671. */
  128672. disableOnlineControllerRepository?: boolean;
  128673. /**
  128674. * A custom URL for the controllers repository
  128675. */
  128676. customControllersRepositoryURL?: string;
  128677. /**
  128678. * Should the controller model's components not move according to the user input
  128679. */
  128680. disableControllerAnimation?: boolean;
  128681. /**
  128682. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  128683. */
  128684. controllerOptions?: IWebXRControllerOptions;
  128685. }
  128686. /**
  128687. * XR input used to track XR inputs such as controllers/rays
  128688. */
  128689. export class WebXRInput implements IDisposable {
  128690. /**
  128691. * the xr session manager for this session
  128692. */
  128693. xrSessionManager: WebXRSessionManager;
  128694. /**
  128695. * the WebXR camera for this session. Mainly used for teleportation
  128696. */
  128697. xrCamera: WebXRCamera;
  128698. private readonly options;
  128699. /**
  128700. * XR controllers being tracked
  128701. */
  128702. controllers: Array<WebXRInputSource>;
  128703. private _frameObserver;
  128704. private _sessionEndedObserver;
  128705. private _sessionInitObserver;
  128706. /**
  128707. * Event when a controller has been connected/added
  128708. */
  128709. onControllerAddedObservable: Observable<WebXRInputSource>;
  128710. /**
  128711. * Event when a controller has been removed/disconnected
  128712. */
  128713. onControllerRemovedObservable: Observable<WebXRInputSource>;
  128714. /**
  128715. * Initializes the WebXRInput
  128716. * @param xrSessionManager the xr session manager for this session
  128717. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  128718. * @param options = initialization options for this xr input
  128719. */
  128720. constructor(
  128721. /**
  128722. * the xr session manager for this session
  128723. */
  128724. xrSessionManager: WebXRSessionManager,
  128725. /**
  128726. * the WebXR camera for this session. Mainly used for teleportation
  128727. */
  128728. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  128729. private _onInputSourcesChange;
  128730. private _addAndRemoveControllers;
  128731. /**
  128732. * Disposes of the object
  128733. */
  128734. dispose(): void;
  128735. }
  128736. }
  128737. declare module BABYLON {
  128738. /**
  128739. * This is the base class for all WebXR features.
  128740. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  128741. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  128742. */
  128743. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  128744. protected _xrSessionManager: WebXRSessionManager;
  128745. private _attached;
  128746. private _removeOnDetach;
  128747. /**
  128748. * Is this feature disposed?
  128749. */
  128750. isDisposed: boolean;
  128751. /**
  128752. * Should auto-attach be disabled?
  128753. */
  128754. disableAutoAttach: boolean;
  128755. /**
  128756. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  128757. */
  128758. xrNativeFeatureName: string;
  128759. /**
  128760. * Construct a new (abstract) WebXR feature
  128761. * @param _xrSessionManager the xr session manager for this feature
  128762. */
  128763. constructor(_xrSessionManager: WebXRSessionManager);
  128764. /**
  128765. * Is this feature attached
  128766. */
  128767. get attached(): boolean;
  128768. /**
  128769. * attach this feature
  128770. *
  128771. * @param force should attachment be forced (even when already attached)
  128772. * @returns true if successful, false is failed or already attached
  128773. */
  128774. attach(force?: boolean): boolean;
  128775. /**
  128776. * detach this feature.
  128777. *
  128778. * @returns true if successful, false if failed or already detached
  128779. */
  128780. detach(): boolean;
  128781. /**
  128782. * Dispose this feature and all of the resources attached
  128783. */
  128784. dispose(): void;
  128785. /**
  128786. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  128787. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  128788. *
  128789. * @returns whether or not the feature is compatible in this environment
  128790. */
  128791. isCompatible(): boolean;
  128792. /**
  128793. * This is used to register callbacks that will automatically be removed when detach is called.
  128794. * @param observable the observable to which the observer will be attached
  128795. * @param callback the callback to register
  128796. */
  128797. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  128798. /**
  128799. * Code in this function will be executed on each xrFrame received from the browser.
  128800. * This function will not execute after the feature is detached.
  128801. * @param _xrFrame the current frame
  128802. */
  128803. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  128804. }
  128805. }
  128806. declare module BABYLON {
  128807. /**
  128808. * Renders a layer on top of an existing scene
  128809. */
  128810. export class UtilityLayerRenderer implements IDisposable {
  128811. /** the original scene that will be rendered on top of */
  128812. originalScene: Scene;
  128813. private _pointerCaptures;
  128814. private _lastPointerEvents;
  128815. private static _DefaultUtilityLayer;
  128816. private static _DefaultKeepDepthUtilityLayer;
  128817. private _sharedGizmoLight;
  128818. private _renderCamera;
  128819. /**
  128820. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  128821. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  128822. * @returns the camera that is used when rendering the utility layer
  128823. */
  128824. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  128825. /**
  128826. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  128827. * @param cam the camera that should be used when rendering the utility layer
  128828. */
  128829. setRenderCamera(cam: Nullable<Camera>): void;
  128830. /**
  128831. * @hidden
  128832. * Light which used by gizmos to get light shading
  128833. */
  128834. _getSharedGizmoLight(): HemisphericLight;
  128835. /**
  128836. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128837. */
  128838. pickUtilitySceneFirst: boolean;
  128839. /**
  128840. * 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)
  128841. */
  128842. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  128843. /**
  128844. * 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)
  128845. */
  128846. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  128847. /**
  128848. * The scene that is rendered on top of the original scene
  128849. */
  128850. utilityLayerScene: Scene;
  128851. /**
  128852. * If the utility layer should automatically be rendered on top of existing scene
  128853. */
  128854. shouldRender: boolean;
  128855. /**
  128856. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128857. */
  128858. onlyCheckPointerDownEvents: boolean;
  128859. /**
  128860. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128861. */
  128862. processAllEvents: boolean;
  128863. /**
  128864. * Observable raised when the pointer move from the utility layer scene to the main scene
  128865. */
  128866. onPointerOutObservable: Observable<number>;
  128867. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  128868. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  128869. private _afterRenderObserver;
  128870. private _sceneDisposeObserver;
  128871. private _originalPointerObserver;
  128872. /**
  128873. * Instantiates a UtilityLayerRenderer
  128874. * @param originalScene the original scene that will be rendered on top of
  128875. * @param handleEvents boolean indicating if the utility layer should handle events
  128876. */
  128877. constructor(
  128878. /** the original scene that will be rendered on top of */
  128879. originalScene: Scene, handleEvents?: boolean);
  128880. private _notifyObservers;
  128881. /**
  128882. * Renders the utility layers scene on top of the original scene
  128883. */
  128884. render(): void;
  128885. /**
  128886. * Disposes of the renderer
  128887. */
  128888. dispose(): void;
  128889. private _updateCamera;
  128890. }
  128891. }
  128892. declare module BABYLON {
  128893. /**
  128894. * Options interface for the pointer selection module
  128895. */
  128896. export interface IWebXRControllerPointerSelectionOptions {
  128897. /**
  128898. * if provided, this scene will be used to render meshes.
  128899. */
  128900. customUtilityLayerScene?: Scene;
  128901. /**
  128902. * 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)
  128903. * If not disabled, the last picked point will be used to execute a pointer up event
  128904. * If disabled, pointer up event will be triggered right after the pointer down event.
  128905. * Used in screen and gaze target ray mode only
  128906. */
  128907. disablePointerUpOnTouchOut: boolean;
  128908. /**
  128909. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  128910. */
  128911. forceGazeMode: boolean;
  128912. /**
  128913. * 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
  128914. * to start a new countdown to the pointer down event.
  128915. * Defaults to 1.
  128916. */
  128917. gazeModePointerMovedFactor?: number;
  128918. /**
  128919. * Different button type to use instead of the main component
  128920. */
  128921. overrideButtonId?: string;
  128922. /**
  128923. * use this rendering group id for the meshes (optional)
  128924. */
  128925. renderingGroupId?: number;
  128926. /**
  128927. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  128928. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  128929. * 3000 means 3 seconds between pointing at something and selecting it
  128930. */
  128931. timeToSelect?: number;
  128932. /**
  128933. * Should meshes created here be added to a utility layer or the main scene
  128934. */
  128935. useUtilityLayer?: boolean;
  128936. /**
  128937. * Optional WebXR camera to be used for gaze selection
  128938. */
  128939. gazeCamera?: WebXRCamera;
  128940. /**
  128941. * the xr input to use with this pointer selection
  128942. */
  128943. xrInput: WebXRInput;
  128944. }
  128945. /**
  128946. * A module that will enable pointer selection for motion controllers of XR Input Sources
  128947. */
  128948. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  128949. private readonly _options;
  128950. private static _idCounter;
  128951. private _attachController;
  128952. private _controllers;
  128953. private _scene;
  128954. private _tmpVectorForPickCompare;
  128955. /**
  128956. * The module's name
  128957. */
  128958. static readonly Name: string;
  128959. /**
  128960. * The (Babylon) version of this module.
  128961. * This is an integer representing the implementation version.
  128962. * This number does not correspond to the WebXR specs version
  128963. */
  128964. static readonly Version: number;
  128965. /**
  128966. * Disable lighting on the laser pointer (so it will always be visible)
  128967. */
  128968. disablePointerLighting: boolean;
  128969. /**
  128970. * Disable lighting on the selection mesh (so it will always be visible)
  128971. */
  128972. disableSelectionMeshLighting: boolean;
  128973. /**
  128974. * Should the laser pointer be displayed
  128975. */
  128976. displayLaserPointer: boolean;
  128977. /**
  128978. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  128979. */
  128980. displaySelectionMesh: boolean;
  128981. /**
  128982. * This color will be set to the laser pointer when selection is triggered
  128983. */
  128984. laserPointerPickedColor: Color3;
  128985. /**
  128986. * Default color of the laser pointer
  128987. */
  128988. laserPointerDefaultColor: Color3;
  128989. /**
  128990. * default color of the selection ring
  128991. */
  128992. selectionMeshDefaultColor: Color3;
  128993. /**
  128994. * This color will be applied to the selection ring when selection is triggered
  128995. */
  128996. selectionMeshPickedColor: Color3;
  128997. /**
  128998. * Optional filter to be used for ray selection. This predicate shares behavior with
  128999. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129000. */
  129001. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129002. /**
  129003. * constructs a new background remover module
  129004. * @param _xrSessionManager the session manager for this module
  129005. * @param _options read-only options to be used in this module
  129006. */
  129007. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129008. /**
  129009. * attach this feature
  129010. * Will usually be called by the features manager
  129011. *
  129012. * @returns true if successful.
  129013. */
  129014. attach(): boolean;
  129015. /**
  129016. * detach this feature.
  129017. * Will usually be called by the features manager
  129018. *
  129019. * @returns true if successful.
  129020. */
  129021. detach(): boolean;
  129022. /**
  129023. * Will get the mesh under a specific pointer.
  129024. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129025. * @param controllerId the controllerId to check
  129026. * @returns The mesh under pointer or null if no mesh is under the pointer
  129027. */
  129028. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129029. /**
  129030. * Get the xr controller that correlates to the pointer id in the pointer event
  129031. *
  129032. * @param id the pointer id to search for
  129033. * @returns the controller that correlates to this id or null if not found
  129034. */
  129035. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129036. protected _onXRFrame(_xrFrame: XRFrame): void;
  129037. private _attachGazeMode;
  129038. private _attachScreenRayMode;
  129039. private _attachTrackedPointerRayMode;
  129040. private _convertNormalToDirectionOfRay;
  129041. private _detachController;
  129042. private _generateNewMeshPair;
  129043. private _pickingMoved;
  129044. private _updatePointerDistance;
  129045. /** @hidden */
  129046. get lasterPointerDefaultColor(): Color3;
  129047. }
  129048. }
  129049. declare module BABYLON {
  129050. /**
  129051. * Button which can be used to enter a different mode of XR
  129052. */
  129053. export class WebXREnterExitUIButton {
  129054. /** button element */
  129055. element: HTMLElement;
  129056. /** XR initialization options for the button */
  129057. sessionMode: XRSessionMode;
  129058. /** Reference space type */
  129059. referenceSpaceType: XRReferenceSpaceType;
  129060. /**
  129061. * Creates a WebXREnterExitUIButton
  129062. * @param element button element
  129063. * @param sessionMode XR initialization session mode
  129064. * @param referenceSpaceType the type of reference space to be used
  129065. */
  129066. constructor(
  129067. /** button element */
  129068. element: HTMLElement,
  129069. /** XR initialization options for the button */
  129070. sessionMode: XRSessionMode,
  129071. /** Reference space type */
  129072. referenceSpaceType: XRReferenceSpaceType);
  129073. /**
  129074. * Extendable function which can be used to update the button's visuals when the state changes
  129075. * @param activeButton the current active button in the UI
  129076. */
  129077. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129078. }
  129079. /**
  129080. * Options to create the webXR UI
  129081. */
  129082. export class WebXREnterExitUIOptions {
  129083. /**
  129084. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129085. */
  129086. customButtons?: Array<WebXREnterExitUIButton>;
  129087. /**
  129088. * A reference space type to use when creating the default button.
  129089. * Default is local-floor
  129090. */
  129091. referenceSpaceType?: XRReferenceSpaceType;
  129092. /**
  129093. * Context to enter xr with
  129094. */
  129095. renderTarget?: Nullable<WebXRRenderTarget>;
  129096. /**
  129097. * A session mode to use when creating the default button.
  129098. * Default is immersive-vr
  129099. */
  129100. sessionMode?: XRSessionMode;
  129101. /**
  129102. * A list of optional features to init the session with
  129103. */
  129104. optionalFeatures?: string[];
  129105. /**
  129106. * A list of optional features to init the session with
  129107. */
  129108. requiredFeatures?: string[];
  129109. }
  129110. /**
  129111. * UI to allow the user to enter/exit XR mode
  129112. */
  129113. export class WebXREnterExitUI implements IDisposable {
  129114. private scene;
  129115. /** version of the options passed to this UI */
  129116. options: WebXREnterExitUIOptions;
  129117. private _activeButton;
  129118. private _buttons;
  129119. /**
  129120. * The HTML Div Element to which buttons are added.
  129121. */
  129122. readonly overlay: HTMLDivElement;
  129123. /**
  129124. * Fired every time the active button is changed.
  129125. *
  129126. * When xr is entered via a button that launches xr that button will be the callback parameter
  129127. *
  129128. * When exiting xr the callback parameter will be null)
  129129. */
  129130. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129131. /**
  129132. *
  129133. * @param scene babylon scene object to use
  129134. * @param options (read-only) version of the options passed to this UI
  129135. */
  129136. private constructor();
  129137. /**
  129138. * Creates UI to allow the user to enter/exit XR mode
  129139. * @param scene the scene to add the ui to
  129140. * @param helper the xr experience helper to enter/exit xr with
  129141. * @param options options to configure the UI
  129142. * @returns the created ui
  129143. */
  129144. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129145. /**
  129146. * Disposes of the XR UI component
  129147. */
  129148. dispose(): void;
  129149. private _updateButtons;
  129150. }
  129151. }
  129152. declare module BABYLON {
  129153. /**
  129154. * Class containing static functions to help procedurally build meshes
  129155. */
  129156. export class LinesBuilder {
  129157. /**
  129158. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129159. * * 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
  129160. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129161. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129162. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129163. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129164. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129165. * * 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
  129166. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129169. * @param name defines the name of the new line system
  129170. * @param options defines the options used to create the line system
  129171. * @param scene defines the hosting scene
  129172. * @returns a new line system mesh
  129173. */
  129174. static CreateLineSystem(name: string, options: {
  129175. lines: Vector3[][];
  129176. updatable?: boolean;
  129177. instance?: Nullable<LinesMesh>;
  129178. colors?: Nullable<Color4[][]>;
  129179. useVertexAlpha?: boolean;
  129180. }, scene: Nullable<Scene>): LinesMesh;
  129181. /**
  129182. * Creates a line mesh
  129183. * 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
  129184. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129185. * * The parameter `points` is an array successive Vector3
  129186. * * 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
  129187. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129188. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129189. * * When updating an instance, remember that only point positions can change, not the number of points
  129190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129192. * @param name defines the name of the new line system
  129193. * @param options defines the options used to create the line system
  129194. * @param scene defines the hosting scene
  129195. * @returns a new line mesh
  129196. */
  129197. static CreateLines(name: string, options: {
  129198. points: Vector3[];
  129199. updatable?: boolean;
  129200. instance?: Nullable<LinesMesh>;
  129201. colors?: Color4[];
  129202. useVertexAlpha?: boolean;
  129203. }, scene?: Nullable<Scene>): LinesMesh;
  129204. /**
  129205. * Creates a dashed line mesh
  129206. * * 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
  129207. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129208. * * The parameter `points` is an array successive Vector3
  129209. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129210. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129211. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129212. * * 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
  129213. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129214. * * When updating an instance, remember that only point positions can change, not the number of points
  129215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129216. * @param name defines the name of the mesh
  129217. * @param options defines the options used to create the mesh
  129218. * @param scene defines the hosting scene
  129219. * @returns the dashed line mesh
  129220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129221. */
  129222. static CreateDashedLines(name: string, options: {
  129223. points: Vector3[];
  129224. dashSize?: number;
  129225. gapSize?: number;
  129226. dashNb?: number;
  129227. updatable?: boolean;
  129228. instance?: LinesMesh;
  129229. useVertexAlpha?: boolean;
  129230. }, scene?: Nullable<Scene>): LinesMesh;
  129231. }
  129232. }
  129233. declare module BABYLON {
  129234. /**
  129235. * Construction options for a timer
  129236. */
  129237. export interface ITimerOptions<T> {
  129238. /**
  129239. * Time-to-end
  129240. */
  129241. timeout: number;
  129242. /**
  129243. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129244. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129245. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129246. */
  129247. contextObservable: Observable<T>;
  129248. /**
  129249. * Optional parameters when adding an observer to the observable
  129250. */
  129251. observableParameters?: {
  129252. mask?: number;
  129253. insertFirst?: boolean;
  129254. scope?: any;
  129255. };
  129256. /**
  129257. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129258. */
  129259. breakCondition?: (data?: ITimerData<T>) => boolean;
  129260. /**
  129261. * Will be triggered when the time condition has met
  129262. */
  129263. onEnded?: (data: ITimerData<any>) => void;
  129264. /**
  129265. * Will be triggered when the break condition has met (prematurely ended)
  129266. */
  129267. onAborted?: (data: ITimerData<any>) => void;
  129268. /**
  129269. * Optional function to execute on each tick (or count)
  129270. */
  129271. onTick?: (data: ITimerData<any>) => void;
  129272. }
  129273. /**
  129274. * An interface defining the data sent by the timer
  129275. */
  129276. export interface ITimerData<T> {
  129277. /**
  129278. * When did it start
  129279. */
  129280. startTime: number;
  129281. /**
  129282. * Time now
  129283. */
  129284. currentTime: number;
  129285. /**
  129286. * Time passed since started
  129287. */
  129288. deltaTime: number;
  129289. /**
  129290. * How much is completed, in [0.0...1.0].
  129291. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129292. */
  129293. completeRate: number;
  129294. /**
  129295. * What the registered observable sent in the last count
  129296. */
  129297. payload: T;
  129298. }
  129299. /**
  129300. * The current state of the timer
  129301. */
  129302. export enum TimerState {
  129303. /**
  129304. * Timer initialized, not yet started
  129305. */
  129306. INIT = 0,
  129307. /**
  129308. * Timer started and counting
  129309. */
  129310. STARTED = 1,
  129311. /**
  129312. * Timer ended (whether aborted or time reached)
  129313. */
  129314. ENDED = 2
  129315. }
  129316. /**
  129317. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129318. *
  129319. * @param options options with which to initialize this timer
  129320. */
  129321. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129322. /**
  129323. * An advanced implementation of a timer class
  129324. */
  129325. export class AdvancedTimer<T = any> implements IDisposable {
  129326. /**
  129327. * Will notify each time the timer calculates the remaining time
  129328. */
  129329. onEachCountObservable: Observable<ITimerData<T>>;
  129330. /**
  129331. * Will trigger when the timer was aborted due to the break condition
  129332. */
  129333. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129334. /**
  129335. * Will trigger when the timer ended successfully
  129336. */
  129337. onTimerEndedObservable: Observable<ITimerData<T>>;
  129338. /**
  129339. * Will trigger when the timer state has changed
  129340. */
  129341. onStateChangedObservable: Observable<TimerState>;
  129342. private _observer;
  129343. private _contextObservable;
  129344. private _observableParameters;
  129345. private _startTime;
  129346. private _timer;
  129347. private _state;
  129348. private _breakCondition;
  129349. private _timeToEnd;
  129350. private _breakOnNextTick;
  129351. /**
  129352. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129353. * @param options construction options for this advanced timer
  129354. */
  129355. constructor(options: ITimerOptions<T>);
  129356. /**
  129357. * set a breaking condition for this timer. Default is to never break during count
  129358. * @param predicate the new break condition. Returns true to break, false otherwise
  129359. */
  129360. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129361. /**
  129362. * Reset ALL associated observables in this advanced timer
  129363. */
  129364. clearObservables(): void;
  129365. /**
  129366. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129367. *
  129368. * @param timeToEnd how much time to measure until timer ended
  129369. */
  129370. start(timeToEnd?: number): void;
  129371. /**
  129372. * Will force a stop on the next tick.
  129373. */
  129374. stop(): void;
  129375. /**
  129376. * Dispose this timer, clearing all resources
  129377. */
  129378. dispose(): void;
  129379. private _setState;
  129380. private _tick;
  129381. private _stop;
  129382. }
  129383. }
  129384. declare module BABYLON {
  129385. /**
  129386. * The options container for the teleportation module
  129387. */
  129388. export interface IWebXRTeleportationOptions {
  129389. /**
  129390. * if provided, this scene will be used to render meshes.
  129391. */
  129392. customUtilityLayerScene?: Scene;
  129393. /**
  129394. * Values to configure the default target mesh
  129395. */
  129396. defaultTargetMeshOptions?: {
  129397. /**
  129398. * Fill color of the teleportation area
  129399. */
  129400. teleportationFillColor?: string;
  129401. /**
  129402. * Border color for the teleportation area
  129403. */
  129404. teleportationBorderColor?: string;
  129405. /**
  129406. * Disable the mesh's animation sequence
  129407. */
  129408. disableAnimation?: boolean;
  129409. /**
  129410. * Disable lighting on the material or the ring and arrow
  129411. */
  129412. disableLighting?: boolean;
  129413. /**
  129414. * Override the default material of the torus and arrow
  129415. */
  129416. torusArrowMaterial?: Material;
  129417. };
  129418. /**
  129419. * A list of meshes to use as floor meshes.
  129420. * Meshes can be added and removed after initializing the feature using the
  129421. * addFloorMesh and removeFloorMesh functions
  129422. * If empty, rotation will still work
  129423. */
  129424. floorMeshes?: AbstractMesh[];
  129425. /**
  129426. * use this rendering group id for the meshes (optional)
  129427. */
  129428. renderingGroupId?: number;
  129429. /**
  129430. * Should teleportation move only to snap points
  129431. */
  129432. snapPointsOnly?: boolean;
  129433. /**
  129434. * An array of points to which the teleportation will snap to.
  129435. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129436. */
  129437. snapPositions?: Vector3[];
  129438. /**
  129439. * How close should the teleportation ray be in order to snap to position.
  129440. * Default to 0.8 units (meters)
  129441. */
  129442. snapToPositionRadius?: number;
  129443. /**
  129444. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129445. * If you want to support rotation, make sure your mesh has a direction indicator.
  129446. *
  129447. * When left untouched, the default mesh will be initialized.
  129448. */
  129449. teleportationTargetMesh?: AbstractMesh;
  129450. /**
  129451. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129452. */
  129453. timeToTeleport?: number;
  129454. /**
  129455. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129456. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129457. */
  129458. useMainComponentOnly?: boolean;
  129459. /**
  129460. * Should meshes created here be added to a utility layer or the main scene
  129461. */
  129462. useUtilityLayer?: boolean;
  129463. /**
  129464. * Babylon XR Input class for controller
  129465. */
  129466. xrInput: WebXRInput;
  129467. /**
  129468. * Meshes that the teleportation ray cannot go through
  129469. */
  129470. pickBlockerMeshes?: AbstractMesh[];
  129471. }
  129472. /**
  129473. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129474. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129475. * the input of the attached controllers.
  129476. */
  129477. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129478. private _options;
  129479. private _controllers;
  129480. private _currentTeleportationControllerId;
  129481. private _floorMeshes;
  129482. private _quadraticBezierCurve;
  129483. private _selectionFeature;
  129484. private _snapToPositions;
  129485. private _snappedToPoint;
  129486. private _teleportationRingMaterial?;
  129487. private _tmpRay;
  129488. private _tmpVector;
  129489. private _tmpQuaternion;
  129490. /**
  129491. * The module's name
  129492. */
  129493. static readonly Name: string;
  129494. /**
  129495. * The (Babylon) version of this module.
  129496. * This is an integer representing the implementation version.
  129497. * This number does not correspond to the webxr specs version
  129498. */
  129499. static readonly Version: number;
  129500. /**
  129501. * Is movement backwards enabled
  129502. */
  129503. backwardsMovementEnabled: boolean;
  129504. /**
  129505. * Distance to travel when moving backwards
  129506. */
  129507. backwardsTeleportationDistance: number;
  129508. /**
  129509. * The distance from the user to the inspection point in the direction of the controller
  129510. * A higher number will allow the user to move further
  129511. * defaults to 5 (meters, in xr units)
  129512. */
  129513. parabolicCheckRadius: number;
  129514. /**
  129515. * Should the module support parabolic ray on top of direct ray
  129516. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129517. * Very helpful when moving between floors / different heights
  129518. */
  129519. parabolicRayEnabled: boolean;
  129520. /**
  129521. * How much rotation should be applied when rotating right and left
  129522. */
  129523. rotationAngle: number;
  129524. /**
  129525. * Is rotation enabled when moving forward?
  129526. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129527. */
  129528. rotationEnabled: boolean;
  129529. /**
  129530. * constructs a new anchor system
  129531. * @param _xrSessionManager an instance of WebXRSessionManager
  129532. * @param _options configuration object for this feature
  129533. */
  129534. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129535. /**
  129536. * Get the snapPointsOnly flag
  129537. */
  129538. get snapPointsOnly(): boolean;
  129539. /**
  129540. * Sets the snapPointsOnly flag
  129541. * @param snapToPoints should teleportation be exclusively to snap points
  129542. */
  129543. set snapPointsOnly(snapToPoints: boolean);
  129544. /**
  129545. * Add a new mesh to the floor meshes array
  129546. * @param mesh the mesh to use as floor mesh
  129547. */
  129548. addFloorMesh(mesh: AbstractMesh): void;
  129549. /**
  129550. * Add a new snap-to point to fix teleportation to this position
  129551. * @param newSnapPoint The new Snap-To point
  129552. */
  129553. addSnapPoint(newSnapPoint: Vector3): void;
  129554. attach(): boolean;
  129555. detach(): boolean;
  129556. dispose(): void;
  129557. /**
  129558. * Remove a mesh from the floor meshes array
  129559. * @param mesh the mesh to remove
  129560. */
  129561. removeFloorMesh(mesh: AbstractMesh): void;
  129562. /**
  129563. * Remove a mesh from the floor meshes array using its name
  129564. * @param name the mesh name to remove
  129565. */
  129566. removeFloorMeshByName(name: string): void;
  129567. /**
  129568. * 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
  129569. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129570. * @returns was the point found and removed or not
  129571. */
  129572. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129573. /**
  129574. * This function sets a selection feature that will be disabled when
  129575. * the forward ray is shown and will be reattached when hidden.
  129576. * This is used to remove the selection rays when moving.
  129577. * @param selectionFeature the feature to disable when forward movement is enabled
  129578. */
  129579. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129580. protected _onXRFrame(_xrFrame: XRFrame): void;
  129581. private _attachController;
  129582. private _createDefaultTargetMesh;
  129583. private _detachController;
  129584. private _findClosestSnapPointWithRadius;
  129585. private _setTargetMeshPosition;
  129586. private _setTargetMeshVisibility;
  129587. private _showParabolicPath;
  129588. private _teleportForward;
  129589. }
  129590. }
  129591. declare module BABYLON {
  129592. /**
  129593. * Options for the default xr helper
  129594. */
  129595. export class WebXRDefaultExperienceOptions {
  129596. /**
  129597. * Enable or disable default UI to enter XR
  129598. */
  129599. disableDefaultUI?: boolean;
  129600. /**
  129601. * Should teleportation not initialize. defaults to false.
  129602. */
  129603. disableTeleportation?: boolean;
  129604. /**
  129605. * Floor meshes that will be used for teleport
  129606. */
  129607. floorMeshes?: Array<AbstractMesh>;
  129608. /**
  129609. * If set to true, the first frame will not be used to reset position
  129610. * The first frame is mainly used when copying transformation from the old camera
  129611. * Mainly used in AR
  129612. */
  129613. ignoreNativeCameraTransformation?: boolean;
  129614. /**
  129615. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129616. */
  129617. inputOptions?: IWebXRInputOptions;
  129618. /**
  129619. * optional configuration for the output canvas
  129620. */
  129621. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129622. /**
  129623. * optional UI options. This can be used among other to change session mode and reference space type
  129624. */
  129625. uiOptions?: WebXREnterExitUIOptions;
  129626. /**
  129627. * When loading teleportation and pointer select, use stable versions instead of latest.
  129628. */
  129629. useStablePlugins?: boolean;
  129630. /**
  129631. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129632. */
  129633. renderingGroupId?: number;
  129634. /**
  129635. * A list of optional features to init the session with
  129636. * If set to true, all features we support will be added
  129637. */
  129638. optionalFeatures?: boolean | string[];
  129639. }
  129640. /**
  129641. * Default experience which provides a similar setup to the previous webVRExperience
  129642. */
  129643. export class WebXRDefaultExperience {
  129644. /**
  129645. * Base experience
  129646. */
  129647. baseExperience: WebXRExperienceHelper;
  129648. /**
  129649. * Enables ui for entering/exiting xr
  129650. */
  129651. enterExitUI: WebXREnterExitUI;
  129652. /**
  129653. * Input experience extension
  129654. */
  129655. input: WebXRInput;
  129656. /**
  129657. * Enables laser pointer and selection
  129658. */
  129659. pointerSelection: WebXRControllerPointerSelection;
  129660. /**
  129661. * Default target xr should render to
  129662. */
  129663. renderTarget: WebXRRenderTarget;
  129664. /**
  129665. * Enables teleportation
  129666. */
  129667. teleportation: WebXRMotionControllerTeleportation;
  129668. private constructor();
  129669. /**
  129670. * Creates the default xr experience
  129671. * @param scene scene
  129672. * @param options options for basic configuration
  129673. * @returns resulting WebXRDefaultExperience
  129674. */
  129675. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129676. /**
  129677. * DIsposes of the experience helper
  129678. */
  129679. dispose(): void;
  129680. }
  129681. }
  129682. declare module BABYLON {
  129683. /**
  129684. * Options to modify the vr teleportation behavior.
  129685. */
  129686. export interface VRTeleportationOptions {
  129687. /**
  129688. * The name of the mesh which should be used as the teleportation floor. (default: null)
  129689. */
  129690. floorMeshName?: string;
  129691. /**
  129692. * A list of meshes to be used as the teleportation floor. (default: empty)
  129693. */
  129694. floorMeshes?: Mesh[];
  129695. /**
  129696. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  129697. */
  129698. teleportationMode?: number;
  129699. /**
  129700. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  129701. */
  129702. teleportationTime?: number;
  129703. /**
  129704. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  129705. */
  129706. teleportationSpeed?: number;
  129707. /**
  129708. * The easing function used in the animation or null for Linear. (default CircleEase)
  129709. */
  129710. easingFunction?: EasingFunction;
  129711. }
  129712. /**
  129713. * Options to modify the vr experience helper's behavior.
  129714. */
  129715. export interface VRExperienceHelperOptions extends WebVROptions {
  129716. /**
  129717. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  129718. */
  129719. createDeviceOrientationCamera?: boolean;
  129720. /**
  129721. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  129722. */
  129723. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  129724. /**
  129725. * Uses the main button on the controller to toggle the laser casted. (default: true)
  129726. */
  129727. laserToggle?: boolean;
  129728. /**
  129729. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  129730. */
  129731. floorMeshes?: Mesh[];
  129732. /**
  129733. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  129734. */
  129735. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  129736. /**
  129737. * Defines if WebXR should be used instead of WebVR (if available)
  129738. */
  129739. useXR?: boolean;
  129740. }
  129741. /**
  129742. * Event containing information after VR has been entered
  129743. */
  129744. export class OnAfterEnteringVRObservableEvent {
  129745. /**
  129746. * If entering vr was successful
  129747. */
  129748. success: boolean;
  129749. }
  129750. /**
  129751. * Helps to quickly add VR support to an existing scene.
  129752. * See https://doc.babylonjs.com/how_to/webvr_helper
  129753. */
  129754. export class VRExperienceHelper {
  129755. /** Options to modify the vr experience helper's behavior. */
  129756. webVROptions: VRExperienceHelperOptions;
  129757. private _scene;
  129758. private _position;
  129759. private _btnVR;
  129760. private _btnVRDisplayed;
  129761. private _webVRsupported;
  129762. private _webVRready;
  129763. private _webVRrequesting;
  129764. private _webVRpresenting;
  129765. private _hasEnteredVR;
  129766. private _fullscreenVRpresenting;
  129767. private _inputElement;
  129768. private _webVRCamera;
  129769. private _vrDeviceOrientationCamera;
  129770. private _deviceOrientationCamera;
  129771. private _existingCamera;
  129772. private _onKeyDown;
  129773. private _onVrDisplayPresentChange;
  129774. private _onVRDisplayChanged;
  129775. private _onVRRequestPresentStart;
  129776. private _onVRRequestPresentComplete;
  129777. /**
  129778. * 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)
  129779. */
  129780. enableGazeEvenWhenNoPointerLock: boolean;
  129781. /**
  129782. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  129783. */
  129784. exitVROnDoubleTap: boolean;
  129785. /**
  129786. * Observable raised right before entering VR.
  129787. */
  129788. onEnteringVRObservable: Observable<VRExperienceHelper>;
  129789. /**
  129790. * Observable raised when entering VR has completed.
  129791. */
  129792. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  129793. /**
  129794. * Observable raised when exiting VR.
  129795. */
  129796. onExitingVRObservable: Observable<VRExperienceHelper>;
  129797. /**
  129798. * Observable raised when controller mesh is loaded.
  129799. */
  129800. onControllerMeshLoadedObservable: Observable<WebVRController>;
  129801. /** Return this.onEnteringVRObservable
  129802. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  129803. */
  129804. get onEnteringVR(): Observable<VRExperienceHelper>;
  129805. /** Return this.onExitingVRObservable
  129806. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  129807. */
  129808. get onExitingVR(): Observable<VRExperienceHelper>;
  129809. /** Return this.onControllerMeshLoadedObservable
  129810. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  129811. */
  129812. get onControllerMeshLoaded(): Observable<WebVRController>;
  129813. private _rayLength;
  129814. private _useCustomVRButton;
  129815. private _teleportationRequested;
  129816. private _teleportActive;
  129817. private _floorMeshName;
  129818. private _floorMeshesCollection;
  129819. private _teleportationMode;
  129820. private _teleportationTime;
  129821. private _teleportationSpeed;
  129822. private _teleportationEasing;
  129823. private _rotationAllowed;
  129824. private _teleportBackwardsVector;
  129825. private _teleportationTarget;
  129826. private _isDefaultTeleportationTarget;
  129827. private _postProcessMove;
  129828. private _teleportationFillColor;
  129829. private _teleportationBorderColor;
  129830. private _rotationAngle;
  129831. private _haloCenter;
  129832. private _cameraGazer;
  129833. private _padSensibilityUp;
  129834. private _padSensibilityDown;
  129835. private _leftController;
  129836. private _rightController;
  129837. private _gazeColor;
  129838. private _laserColor;
  129839. private _pickedLaserColor;
  129840. private _pickedGazeColor;
  129841. /**
  129842. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  129843. */
  129844. onNewMeshSelected: Observable<AbstractMesh>;
  129845. /**
  129846. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  129847. * This observable will provide the mesh and the controller used to select the mesh
  129848. */
  129849. onMeshSelectedWithController: Observable<{
  129850. mesh: AbstractMesh;
  129851. controller: WebVRController;
  129852. }>;
  129853. /**
  129854. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  129855. */
  129856. onNewMeshPicked: Observable<PickingInfo>;
  129857. private _circleEase;
  129858. /**
  129859. * Observable raised before camera teleportation
  129860. */
  129861. onBeforeCameraTeleport: Observable<Vector3>;
  129862. /**
  129863. * Observable raised after camera teleportation
  129864. */
  129865. onAfterCameraTeleport: Observable<Vector3>;
  129866. /**
  129867. * Observable raised when current selected mesh gets unselected
  129868. */
  129869. onSelectedMeshUnselected: Observable<AbstractMesh>;
  129870. private _raySelectionPredicate;
  129871. /**
  129872. * To be optionaly changed by user to define custom ray selection
  129873. */
  129874. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129875. /**
  129876. * To be optionaly changed by user to define custom selection logic (after ray selection)
  129877. */
  129878. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  129879. /**
  129880. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  129881. */
  129882. teleportationEnabled: boolean;
  129883. private _defaultHeight;
  129884. private _teleportationInitialized;
  129885. private _interactionsEnabled;
  129886. private _interactionsRequested;
  129887. private _displayGaze;
  129888. private _displayLaserPointer;
  129889. /**
  129890. * The mesh used to display where the user is going to teleport.
  129891. */
  129892. get teleportationTarget(): Mesh;
  129893. /**
  129894. * Sets the mesh to be used to display where the user is going to teleport.
  129895. */
  129896. set teleportationTarget(value: Mesh);
  129897. /**
  129898. * 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
  129899. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  129900. * See https://doc.babylonjs.com/resources/baking_transformations
  129901. */
  129902. get gazeTrackerMesh(): Mesh;
  129903. set gazeTrackerMesh(value: Mesh);
  129904. /**
  129905. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  129906. */
  129907. updateGazeTrackerScale: boolean;
  129908. /**
  129909. * If the gaze trackers color should be updated when selecting meshes
  129910. */
  129911. updateGazeTrackerColor: boolean;
  129912. /**
  129913. * If the controller laser color should be updated when selecting meshes
  129914. */
  129915. updateControllerLaserColor: boolean;
  129916. /**
  129917. * The gaze tracking mesh corresponding to the left controller
  129918. */
  129919. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  129920. /**
  129921. * The gaze tracking mesh corresponding to the right controller
  129922. */
  129923. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  129924. /**
  129925. * If the ray of the gaze should be displayed.
  129926. */
  129927. get displayGaze(): boolean;
  129928. /**
  129929. * Sets if the ray of the gaze should be displayed.
  129930. */
  129931. set displayGaze(value: boolean);
  129932. /**
  129933. * If the ray of the LaserPointer should be displayed.
  129934. */
  129935. get displayLaserPointer(): boolean;
  129936. /**
  129937. * Sets if the ray of the LaserPointer should be displayed.
  129938. */
  129939. set displayLaserPointer(value: boolean);
  129940. /**
  129941. * The deviceOrientationCamera used as the camera when not in VR.
  129942. */
  129943. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  129944. /**
  129945. * Based on the current WebVR support, returns the current VR camera used.
  129946. */
  129947. get currentVRCamera(): Nullable<Camera>;
  129948. /**
  129949. * The webVRCamera which is used when in VR.
  129950. */
  129951. get webVRCamera(): WebVRFreeCamera;
  129952. /**
  129953. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  129954. */
  129955. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  129956. /**
  129957. * The html button that is used to trigger entering into VR.
  129958. */
  129959. get vrButton(): Nullable<HTMLButtonElement>;
  129960. private get _teleportationRequestInitiated();
  129961. /**
  129962. * Defines whether or not Pointer lock should be requested when switching to
  129963. * full screen.
  129964. */
  129965. requestPointerLockOnFullScreen: boolean;
  129966. /**
  129967. * If asking to force XR, this will be populated with the default xr experience
  129968. */
  129969. xr: WebXRDefaultExperience;
  129970. /**
  129971. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  129972. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  129973. */
  129974. xrTestDone: boolean;
  129975. /**
  129976. * Instantiates a VRExperienceHelper.
  129977. * Helps to quickly add VR support to an existing scene.
  129978. * @param scene The scene the VRExperienceHelper belongs to.
  129979. * @param webVROptions Options to modify the vr experience helper's behavior.
  129980. */
  129981. constructor(scene: Scene,
  129982. /** Options to modify the vr experience helper's behavior. */
  129983. webVROptions?: VRExperienceHelperOptions);
  129984. private completeVRInit;
  129985. private _onDefaultMeshLoaded;
  129986. private _onResize;
  129987. private _onFullscreenChange;
  129988. /**
  129989. * Gets a value indicating if we are currently in VR mode.
  129990. */
  129991. get isInVRMode(): boolean;
  129992. private onVrDisplayPresentChange;
  129993. private onVRDisplayChanged;
  129994. private moveButtonToBottomRight;
  129995. private displayVRButton;
  129996. private updateButtonVisibility;
  129997. private _cachedAngularSensibility;
  129998. /**
  129999. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130000. * Otherwise, will use the fullscreen API.
  130001. */
  130002. enterVR(): void;
  130003. /**
  130004. * Attempt to exit VR, or fullscreen.
  130005. */
  130006. exitVR(): void;
  130007. /**
  130008. * The position of the vr experience helper.
  130009. */
  130010. get position(): Vector3;
  130011. /**
  130012. * Sets the position of the vr experience helper.
  130013. */
  130014. set position(value: Vector3);
  130015. /**
  130016. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130017. */
  130018. enableInteractions(): void;
  130019. private get _noControllerIsActive();
  130020. private beforeRender;
  130021. private _isTeleportationFloor;
  130022. /**
  130023. * Adds a floor mesh to be used for teleportation.
  130024. * @param floorMesh the mesh to be used for teleportation.
  130025. */
  130026. addFloorMesh(floorMesh: Mesh): void;
  130027. /**
  130028. * Removes a floor mesh from being used for teleportation.
  130029. * @param floorMesh the mesh to be removed.
  130030. */
  130031. removeFloorMesh(floorMesh: Mesh): void;
  130032. /**
  130033. * Enables interactions and teleportation using the VR controllers and gaze.
  130034. * @param vrTeleportationOptions options to modify teleportation behavior.
  130035. */
  130036. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130037. private _onNewGamepadConnected;
  130038. private _tryEnableInteractionOnController;
  130039. private _onNewGamepadDisconnected;
  130040. private _enableInteractionOnController;
  130041. private _checkTeleportWithRay;
  130042. private _checkRotate;
  130043. private _checkTeleportBackwards;
  130044. private _enableTeleportationOnController;
  130045. private _createTeleportationCircles;
  130046. private _displayTeleportationTarget;
  130047. private _hideTeleportationTarget;
  130048. private _rotateCamera;
  130049. private _moveTeleportationSelectorTo;
  130050. private _workingVector;
  130051. private _workingQuaternion;
  130052. private _workingMatrix;
  130053. /**
  130054. * Time Constant Teleportation Mode
  130055. */
  130056. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130057. /**
  130058. * Speed Constant Teleportation Mode
  130059. */
  130060. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130061. /**
  130062. * Teleports the users feet to the desired location
  130063. * @param location The location where the user's feet should be placed
  130064. */
  130065. teleportCamera(location: Vector3): void;
  130066. private _convertNormalToDirectionOfRay;
  130067. private _castRayAndSelectObject;
  130068. private _notifySelectedMeshUnselected;
  130069. /**
  130070. * Permanently set new colors for the laser pointer
  130071. * @param color the new laser color
  130072. * @param pickedColor the new laser color when picked mesh detected
  130073. */
  130074. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130075. /**
  130076. * Set lighting enabled / disabled on the laser pointer of both controllers
  130077. * @param enabled should the lighting be enabled on the laser pointer
  130078. */
  130079. setLaserLightingState(enabled?: boolean): void;
  130080. /**
  130081. * Permanently set new colors for the gaze pointer
  130082. * @param color the new gaze color
  130083. * @param pickedColor the new gaze color when picked mesh detected
  130084. */
  130085. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130086. /**
  130087. * Sets the color of the laser ray from the vr controllers.
  130088. * @param color new color for the ray.
  130089. */
  130090. changeLaserColor(color: Color3): void;
  130091. /**
  130092. * Sets the color of the ray from the vr headsets gaze.
  130093. * @param color new color for the ray.
  130094. */
  130095. changeGazeColor(color: Color3): void;
  130096. /**
  130097. * Exits VR and disposes of the vr experience helper
  130098. */
  130099. dispose(): void;
  130100. /**
  130101. * Gets the name of the VRExperienceHelper class
  130102. * @returns "VRExperienceHelper"
  130103. */
  130104. getClassName(): string;
  130105. }
  130106. }
  130107. declare module BABYLON {
  130108. /**
  130109. * Contains an array of blocks representing the octree
  130110. */
  130111. export interface IOctreeContainer<T> {
  130112. /**
  130113. * Blocks within the octree
  130114. */
  130115. blocks: Array<OctreeBlock<T>>;
  130116. }
  130117. /**
  130118. * Class used to store a cell in an octree
  130119. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130120. */
  130121. export class OctreeBlock<T> {
  130122. /**
  130123. * Gets the content of the current block
  130124. */
  130125. entries: T[];
  130126. /**
  130127. * Gets the list of block children
  130128. */
  130129. blocks: Array<OctreeBlock<T>>;
  130130. private _depth;
  130131. private _maxDepth;
  130132. private _capacity;
  130133. private _minPoint;
  130134. private _maxPoint;
  130135. private _boundingVectors;
  130136. private _creationFunc;
  130137. /**
  130138. * Creates a new block
  130139. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130140. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130141. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130142. * @param depth defines the current depth of this block in the octree
  130143. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130144. * @param creationFunc defines a callback to call when an element is added to the block
  130145. */
  130146. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130147. /**
  130148. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130149. */
  130150. get capacity(): number;
  130151. /**
  130152. * Gets the minimum vector (in world space) of the block's bounding box
  130153. */
  130154. get minPoint(): Vector3;
  130155. /**
  130156. * Gets the maximum vector (in world space) of the block's bounding box
  130157. */
  130158. get maxPoint(): Vector3;
  130159. /**
  130160. * Add a new element to this block
  130161. * @param entry defines the element to add
  130162. */
  130163. addEntry(entry: T): void;
  130164. /**
  130165. * Remove an element from this block
  130166. * @param entry defines the element to remove
  130167. */
  130168. removeEntry(entry: T): void;
  130169. /**
  130170. * Add an array of elements to this block
  130171. * @param entries defines the array of elements to add
  130172. */
  130173. addEntries(entries: T[]): void;
  130174. /**
  130175. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130176. * @param frustumPlanes defines the frustum planes to test
  130177. * @param selection defines the array to store current content if selection is positive
  130178. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130179. */
  130180. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130181. /**
  130182. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130183. * @param sphereCenter defines the bounding sphere center
  130184. * @param sphereRadius defines the bounding sphere radius
  130185. * @param selection defines the array to store current content if selection is positive
  130186. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130187. */
  130188. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130189. /**
  130190. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130191. * @param ray defines the ray to test with
  130192. * @param selection defines the array to store current content if selection is positive
  130193. */
  130194. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130195. /**
  130196. * Subdivide the content into child blocks (this block will then be empty)
  130197. */
  130198. createInnerBlocks(): void;
  130199. /**
  130200. * @hidden
  130201. */
  130202. 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;
  130203. }
  130204. }
  130205. declare module BABYLON {
  130206. /**
  130207. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130208. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130209. */
  130210. export class Octree<T> {
  130211. /** 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.) */
  130212. maxDepth: number;
  130213. /**
  130214. * Blocks within the octree containing objects
  130215. */
  130216. blocks: Array<OctreeBlock<T>>;
  130217. /**
  130218. * Content stored in the octree
  130219. */
  130220. dynamicContent: T[];
  130221. private _maxBlockCapacity;
  130222. private _selectionContent;
  130223. private _creationFunc;
  130224. /**
  130225. * Creates a octree
  130226. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130227. * @param creationFunc function to be used to instatiate the octree
  130228. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130229. * @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.)
  130230. */
  130231. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130232. /** 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.) */
  130233. maxDepth?: number);
  130234. /**
  130235. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130236. * @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);
  130237. * @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);
  130238. * @param entries meshes to be added to the octree blocks
  130239. */
  130240. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130241. /**
  130242. * Adds a mesh to the octree
  130243. * @param entry Mesh to add to the octree
  130244. */
  130245. addMesh(entry: T): void;
  130246. /**
  130247. * Remove an element from the octree
  130248. * @param entry defines the element to remove
  130249. */
  130250. removeMesh(entry: T): void;
  130251. /**
  130252. * Selects an array of meshes within the frustum
  130253. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130254. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130255. * @returns array of meshes within the frustum
  130256. */
  130257. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130258. /**
  130259. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130260. * @param sphereCenter defines the bounding sphere center
  130261. * @param sphereRadius defines the bounding sphere radius
  130262. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130263. * @returns an array of objects that intersect the sphere
  130264. */
  130265. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130266. /**
  130267. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130268. * @param ray defines the ray to test with
  130269. * @returns array of intersected objects
  130270. */
  130271. intersectsRay(ray: Ray): SmartArray<T>;
  130272. /**
  130273. * Adds a mesh into the octree block if it intersects the block
  130274. */
  130275. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130276. /**
  130277. * Adds a submesh into the octree block if it intersects the block
  130278. */
  130279. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130280. }
  130281. }
  130282. declare module BABYLON {
  130283. interface Scene {
  130284. /**
  130285. * @hidden
  130286. * Backing Filed
  130287. */
  130288. _selectionOctree: Octree<AbstractMesh>;
  130289. /**
  130290. * Gets the octree used to boost mesh selection (picking)
  130291. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130292. */
  130293. selectionOctree: Octree<AbstractMesh>;
  130294. /**
  130295. * Creates or updates the octree used to boost selection (picking)
  130296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130297. * @param maxCapacity defines the maximum capacity per leaf
  130298. * @param maxDepth defines the maximum depth of the octree
  130299. * @returns an octree of AbstractMesh
  130300. */
  130301. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130302. }
  130303. interface AbstractMesh {
  130304. /**
  130305. * @hidden
  130306. * Backing Field
  130307. */
  130308. _submeshesOctree: Octree<SubMesh>;
  130309. /**
  130310. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130311. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130312. * @param maxCapacity defines the maximum size of each block (64 by default)
  130313. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130314. * @returns the new octree
  130315. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130316. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130317. */
  130318. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130319. }
  130320. /**
  130321. * Defines the octree scene component responsible to manage any octrees
  130322. * in a given scene.
  130323. */
  130324. export class OctreeSceneComponent {
  130325. /**
  130326. * The component name help to identify the component in the list of scene components.
  130327. */
  130328. readonly name: string;
  130329. /**
  130330. * The scene the component belongs to.
  130331. */
  130332. scene: Scene;
  130333. /**
  130334. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130335. */
  130336. readonly checksIsEnabled: boolean;
  130337. /**
  130338. * Creates a new instance of the component for the given scene
  130339. * @param scene Defines the scene to register the component in
  130340. */
  130341. constructor(scene: Scene);
  130342. /**
  130343. * Registers the component in a given scene
  130344. */
  130345. register(): void;
  130346. /**
  130347. * Return the list of active meshes
  130348. * @returns the list of active meshes
  130349. */
  130350. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130351. /**
  130352. * Return the list of active sub meshes
  130353. * @param mesh The mesh to get the candidates sub meshes from
  130354. * @returns the list of active sub meshes
  130355. */
  130356. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130357. private _tempRay;
  130358. /**
  130359. * Return the list of sub meshes intersecting with a given local ray
  130360. * @param mesh defines the mesh to find the submesh for
  130361. * @param localRay defines the ray in local space
  130362. * @returns the list of intersecting sub meshes
  130363. */
  130364. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130365. /**
  130366. * Return the list of sub meshes colliding with a collider
  130367. * @param mesh defines the mesh to find the submesh for
  130368. * @param collider defines the collider to evaluate the collision against
  130369. * @returns the list of colliding sub meshes
  130370. */
  130371. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130372. /**
  130373. * Rebuilds the elements related to this component in case of
  130374. * context lost for instance.
  130375. */
  130376. rebuild(): void;
  130377. /**
  130378. * Disposes the component and the associated ressources.
  130379. */
  130380. dispose(): void;
  130381. }
  130382. }
  130383. declare module BABYLON {
  130384. /**
  130385. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130386. */
  130387. export class Gizmo implements IDisposable {
  130388. /** The utility layer the gizmo will be added to */
  130389. gizmoLayer: UtilityLayerRenderer;
  130390. /**
  130391. * The root mesh of the gizmo
  130392. */
  130393. _rootMesh: Mesh;
  130394. private _attachedMesh;
  130395. private _attachedNode;
  130396. /**
  130397. * Ratio for the scale of the gizmo (Default: 1)
  130398. */
  130399. protected _scaleRatio: number;
  130400. /**
  130401. * Ratio for the scale of the gizmo (Default: 1)
  130402. */
  130403. set scaleRatio(value: number);
  130404. get scaleRatio(): number;
  130405. /**
  130406. * If a custom mesh has been set (Default: false)
  130407. */
  130408. protected _customMeshSet: boolean;
  130409. /**
  130410. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130411. * * When set, interactions will be enabled
  130412. */
  130413. get attachedMesh(): Nullable<AbstractMesh>;
  130414. set attachedMesh(value: Nullable<AbstractMesh>);
  130415. /**
  130416. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130417. * * When set, interactions will be enabled
  130418. */
  130419. get attachedNode(): Nullable<Node>;
  130420. set attachedNode(value: Nullable<Node>);
  130421. /**
  130422. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130423. * @param mesh The mesh to replace the default mesh of the gizmo
  130424. */
  130425. setCustomMesh(mesh: Mesh): void;
  130426. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130427. /**
  130428. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130429. */
  130430. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130431. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130432. /**
  130433. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130434. */
  130435. updateGizmoPositionToMatchAttachedMesh: boolean;
  130436. /**
  130437. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130438. */
  130439. updateScale: boolean;
  130440. protected _interactionsEnabled: boolean;
  130441. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130442. private _beforeRenderObserver;
  130443. private _tempQuaternion;
  130444. private _tempVector;
  130445. private _tempVector2;
  130446. private _tempMatrix1;
  130447. private _tempMatrix2;
  130448. private _rightHandtoLeftHandMatrix;
  130449. /**
  130450. * Creates a gizmo
  130451. * @param gizmoLayer The utility layer the gizmo will be added to
  130452. */
  130453. constructor(
  130454. /** The utility layer the gizmo will be added to */
  130455. gizmoLayer?: UtilityLayerRenderer);
  130456. /**
  130457. * Updates the gizmo to match the attached mesh's position/rotation
  130458. */
  130459. protected _update(): void;
  130460. /**
  130461. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130462. * @param value Node, TransformNode or mesh
  130463. */
  130464. protected _matrixChanged(): void;
  130465. /**
  130466. * Disposes of the gizmo
  130467. */
  130468. dispose(): void;
  130469. }
  130470. }
  130471. declare module BABYLON {
  130472. /**
  130473. * Single plane drag gizmo
  130474. */
  130475. export class PlaneDragGizmo extends Gizmo {
  130476. /**
  130477. * Drag behavior responsible for the gizmos dragging interactions
  130478. */
  130479. dragBehavior: PointerDragBehavior;
  130480. private _pointerObserver;
  130481. /**
  130482. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130483. */
  130484. snapDistance: number;
  130485. /**
  130486. * Event that fires each time the gizmo snaps to a new location.
  130487. * * snapDistance is the the change in distance
  130488. */
  130489. onSnapObservable: Observable<{
  130490. snapDistance: number;
  130491. }>;
  130492. private _plane;
  130493. private _coloredMaterial;
  130494. private _hoverMaterial;
  130495. private _isEnabled;
  130496. private _parent;
  130497. /** @hidden */
  130498. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130499. /** @hidden */
  130500. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130501. /**
  130502. * Creates a PlaneDragGizmo
  130503. * @param gizmoLayer The utility layer the gizmo will be added to
  130504. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130505. * @param color The color of the gizmo
  130506. */
  130507. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130508. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130509. /**
  130510. * If the gizmo is enabled
  130511. */
  130512. set isEnabled(value: boolean);
  130513. get isEnabled(): boolean;
  130514. /**
  130515. * Disposes of the gizmo
  130516. */
  130517. dispose(): void;
  130518. }
  130519. }
  130520. declare module BABYLON {
  130521. /**
  130522. * Gizmo that enables dragging a mesh along 3 axis
  130523. */
  130524. export class PositionGizmo extends Gizmo {
  130525. /**
  130526. * Internal gizmo used for interactions on the x axis
  130527. */
  130528. xGizmo: AxisDragGizmo;
  130529. /**
  130530. * Internal gizmo used for interactions on the y axis
  130531. */
  130532. yGizmo: AxisDragGizmo;
  130533. /**
  130534. * Internal gizmo used for interactions on the z axis
  130535. */
  130536. zGizmo: AxisDragGizmo;
  130537. /**
  130538. * Internal gizmo used for interactions on the yz plane
  130539. */
  130540. xPlaneGizmo: PlaneDragGizmo;
  130541. /**
  130542. * Internal gizmo used for interactions on the xz plane
  130543. */
  130544. yPlaneGizmo: PlaneDragGizmo;
  130545. /**
  130546. * Internal gizmo used for interactions on the xy plane
  130547. */
  130548. zPlaneGizmo: PlaneDragGizmo;
  130549. /**
  130550. * private variables
  130551. */
  130552. private _meshAttached;
  130553. private _nodeAttached;
  130554. private _snapDistance;
  130555. /** Fires an event when any of it's sub gizmos are dragged */
  130556. onDragStartObservable: Observable<unknown>;
  130557. /** Fires an event when any of it's sub gizmos are released from dragging */
  130558. onDragEndObservable: Observable<unknown>;
  130559. /**
  130560. * If set to true, planar drag is enabled
  130561. */
  130562. private _planarGizmoEnabled;
  130563. get attachedMesh(): Nullable<AbstractMesh>;
  130564. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130565. get attachedNode(): Nullable<Node>;
  130566. set attachedNode(node: Nullable<Node>);
  130567. /**
  130568. * Creates a PositionGizmo
  130569. * @param gizmoLayer The utility layer the gizmo will be added to
  130570. @param thickness display gizmo axis thickness
  130571. */
  130572. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130573. /**
  130574. * If the planar drag gizmo is enabled
  130575. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130576. */
  130577. set planarGizmoEnabled(value: boolean);
  130578. get planarGizmoEnabled(): boolean;
  130579. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130580. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130581. /**
  130582. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130583. */
  130584. set snapDistance(value: number);
  130585. get snapDistance(): number;
  130586. /**
  130587. * Ratio for the scale of the gizmo (Default: 1)
  130588. */
  130589. set scaleRatio(value: number);
  130590. get scaleRatio(): number;
  130591. /**
  130592. * Disposes of the gizmo
  130593. */
  130594. dispose(): void;
  130595. /**
  130596. * CustomMeshes are not supported by this gizmo
  130597. * @param mesh The mesh to replace the default mesh of the gizmo
  130598. */
  130599. setCustomMesh(mesh: Mesh): void;
  130600. }
  130601. }
  130602. declare module BABYLON {
  130603. /**
  130604. * Single axis drag gizmo
  130605. */
  130606. export class AxisDragGizmo extends Gizmo {
  130607. /**
  130608. * Drag behavior responsible for the gizmos dragging interactions
  130609. */
  130610. dragBehavior: PointerDragBehavior;
  130611. private _pointerObserver;
  130612. /**
  130613. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130614. */
  130615. snapDistance: number;
  130616. /**
  130617. * Event that fires each time the gizmo snaps to a new location.
  130618. * * snapDistance is the the change in distance
  130619. */
  130620. onSnapObservable: Observable<{
  130621. snapDistance: number;
  130622. }>;
  130623. private _isEnabled;
  130624. private _parent;
  130625. private _arrow;
  130626. private _coloredMaterial;
  130627. private _hoverMaterial;
  130628. /** @hidden */
  130629. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130630. /** @hidden */
  130631. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130632. /**
  130633. * Creates an AxisDragGizmo
  130634. * @param gizmoLayer The utility layer the gizmo will be added to
  130635. * @param dragAxis The axis which the gizmo will be able to drag on
  130636. * @param color The color of the gizmo
  130637. * @param thickness display gizmo axis thickness
  130638. */
  130639. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130640. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130641. /**
  130642. * If the gizmo is enabled
  130643. */
  130644. set isEnabled(value: boolean);
  130645. get isEnabled(): boolean;
  130646. /**
  130647. * Disposes of the gizmo
  130648. */
  130649. dispose(): void;
  130650. }
  130651. }
  130652. declare module BABYLON.Debug {
  130653. /**
  130654. * The Axes viewer will show 3 axes in a specific point in space
  130655. */
  130656. export class AxesViewer {
  130657. private _xAxis;
  130658. private _yAxis;
  130659. private _zAxis;
  130660. private _scaleLinesFactor;
  130661. private _instanced;
  130662. /**
  130663. * Gets the hosting scene
  130664. */
  130665. scene: Nullable<Scene>;
  130666. /**
  130667. * Gets or sets a number used to scale line length
  130668. */
  130669. scaleLines: number;
  130670. /** Gets the node hierarchy used to render x-axis */
  130671. get xAxis(): TransformNode;
  130672. /** Gets the node hierarchy used to render y-axis */
  130673. get yAxis(): TransformNode;
  130674. /** Gets the node hierarchy used to render z-axis */
  130675. get zAxis(): TransformNode;
  130676. /**
  130677. * Creates a new AxesViewer
  130678. * @param scene defines the hosting scene
  130679. * @param scaleLines defines a number used to scale line length (1 by default)
  130680. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  130681. * @param xAxis defines the node hierarchy used to render the x-axis
  130682. * @param yAxis defines the node hierarchy used to render the y-axis
  130683. * @param zAxis defines the node hierarchy used to render the z-axis
  130684. */
  130685. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  130686. /**
  130687. * Force the viewer to update
  130688. * @param position defines the position of the viewer
  130689. * @param xaxis defines the x axis of the viewer
  130690. * @param yaxis defines the y axis of the viewer
  130691. * @param zaxis defines the z axis of the viewer
  130692. */
  130693. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  130694. /**
  130695. * Creates an instance of this axes viewer.
  130696. * @returns a new axes viewer with instanced meshes
  130697. */
  130698. createInstance(): AxesViewer;
  130699. /** Releases resources */
  130700. dispose(): void;
  130701. private static _SetRenderingGroupId;
  130702. }
  130703. }
  130704. declare module BABYLON.Debug {
  130705. /**
  130706. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  130707. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  130708. */
  130709. export class BoneAxesViewer extends AxesViewer {
  130710. /**
  130711. * Gets or sets the target mesh where to display the axes viewer
  130712. */
  130713. mesh: Nullable<Mesh>;
  130714. /**
  130715. * Gets or sets the target bone where to display the axes viewer
  130716. */
  130717. bone: Nullable<Bone>;
  130718. /** Gets current position */
  130719. pos: Vector3;
  130720. /** Gets direction of X axis */
  130721. xaxis: Vector3;
  130722. /** Gets direction of Y axis */
  130723. yaxis: Vector3;
  130724. /** Gets direction of Z axis */
  130725. zaxis: Vector3;
  130726. /**
  130727. * Creates a new BoneAxesViewer
  130728. * @param scene defines the hosting scene
  130729. * @param bone defines the target bone
  130730. * @param mesh defines the target mesh
  130731. * @param scaleLines defines a scaling factor for line length (1 by default)
  130732. */
  130733. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  130734. /**
  130735. * Force the viewer to update
  130736. */
  130737. update(): void;
  130738. /** Releases resources */
  130739. dispose(): void;
  130740. }
  130741. }
  130742. declare module BABYLON {
  130743. /**
  130744. * Interface used to define scene explorer extensibility option
  130745. */
  130746. export interface IExplorerExtensibilityOption {
  130747. /**
  130748. * Define the option label
  130749. */
  130750. label: string;
  130751. /**
  130752. * Defines the action to execute on click
  130753. */
  130754. action: (entity: any) => void;
  130755. }
  130756. /**
  130757. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  130758. */
  130759. export interface IExplorerExtensibilityGroup {
  130760. /**
  130761. * Defines a predicate to test if a given type mut be extended
  130762. */
  130763. predicate: (entity: any) => boolean;
  130764. /**
  130765. * Gets the list of options added to a type
  130766. */
  130767. entries: IExplorerExtensibilityOption[];
  130768. }
  130769. /**
  130770. * Interface used to define the options to use to create the Inspector
  130771. */
  130772. export interface IInspectorOptions {
  130773. /**
  130774. * Display in overlay mode (default: false)
  130775. */
  130776. overlay?: boolean;
  130777. /**
  130778. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  130779. */
  130780. globalRoot?: HTMLElement;
  130781. /**
  130782. * Display the Scene explorer
  130783. */
  130784. showExplorer?: boolean;
  130785. /**
  130786. * Display the property inspector
  130787. */
  130788. showInspector?: boolean;
  130789. /**
  130790. * Display in embed mode (both panes on the right)
  130791. */
  130792. embedMode?: boolean;
  130793. /**
  130794. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  130795. */
  130796. handleResize?: boolean;
  130797. /**
  130798. * Allow the panes to popup (default: true)
  130799. */
  130800. enablePopup?: boolean;
  130801. /**
  130802. * Allow the panes to be closed by users (default: true)
  130803. */
  130804. enableClose?: boolean;
  130805. /**
  130806. * Optional list of extensibility entries
  130807. */
  130808. explorerExtensibility?: IExplorerExtensibilityGroup[];
  130809. /**
  130810. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  130811. */
  130812. inspectorURL?: string;
  130813. /**
  130814. * Optional initial tab (default to DebugLayerTab.Properties)
  130815. */
  130816. initialTab?: DebugLayerTab;
  130817. }
  130818. interface Scene {
  130819. /**
  130820. * @hidden
  130821. * Backing field
  130822. */
  130823. _debugLayer: DebugLayer;
  130824. /**
  130825. * Gets the debug layer (aka Inspector) associated with the scene
  130826. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130827. */
  130828. debugLayer: DebugLayer;
  130829. }
  130830. /**
  130831. * Enum of inspector action tab
  130832. */
  130833. export enum DebugLayerTab {
  130834. /**
  130835. * Properties tag (default)
  130836. */
  130837. Properties = 0,
  130838. /**
  130839. * Debug tab
  130840. */
  130841. Debug = 1,
  130842. /**
  130843. * Statistics tab
  130844. */
  130845. Statistics = 2,
  130846. /**
  130847. * Tools tab
  130848. */
  130849. Tools = 3,
  130850. /**
  130851. * Settings tab
  130852. */
  130853. Settings = 4
  130854. }
  130855. /**
  130856. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130857. * what is happening in your scene
  130858. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130859. */
  130860. export class DebugLayer {
  130861. /**
  130862. * Define the url to get the inspector script from.
  130863. * By default it uses the babylonjs CDN.
  130864. * @ignoreNaming
  130865. */
  130866. static InspectorURL: string;
  130867. private _scene;
  130868. private BJSINSPECTOR;
  130869. private _onPropertyChangedObservable?;
  130870. /**
  130871. * Observable triggered when a property is changed through the inspector.
  130872. */
  130873. get onPropertyChangedObservable(): any;
  130874. /**
  130875. * Instantiates a new debug layer.
  130876. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130877. * what is happening in your scene
  130878. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130879. * @param scene Defines the scene to inspect
  130880. */
  130881. constructor(scene: Scene);
  130882. /** Creates the inspector window. */
  130883. private _createInspector;
  130884. /**
  130885. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  130886. * @param entity defines the entity to select
  130887. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  130888. */
  130889. select(entity: any, lineContainerTitles?: string | string[]): void;
  130890. /** Get the inspector from bundle or global */
  130891. private _getGlobalInspector;
  130892. /**
  130893. * Get if the inspector is visible or not.
  130894. * @returns true if visible otherwise, false
  130895. */
  130896. isVisible(): boolean;
  130897. /**
  130898. * Hide the inspector and close its window.
  130899. */
  130900. hide(): void;
  130901. /**
  130902. * Update the scene in the inspector
  130903. */
  130904. setAsActiveScene(): void;
  130905. /**
  130906. * Launch the debugLayer.
  130907. * @param config Define the configuration of the inspector
  130908. * @return a promise fulfilled when the debug layer is visible
  130909. */
  130910. show(config?: IInspectorOptions): Promise<DebugLayer>;
  130911. }
  130912. }
  130913. declare module BABYLON {
  130914. /**
  130915. * Class containing static functions to help procedurally build meshes
  130916. */
  130917. export class BoxBuilder {
  130918. /**
  130919. * Creates a box mesh
  130920. * * The parameter `size` sets the size (float) of each box side (default 1)
  130921. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  130922. * * 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)
  130923. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130927. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  130928. * @param name defines the name of the mesh
  130929. * @param options defines the options used to create the mesh
  130930. * @param scene defines the hosting scene
  130931. * @returns the box mesh
  130932. */
  130933. static CreateBox(name: string, options: {
  130934. size?: number;
  130935. width?: number;
  130936. height?: number;
  130937. depth?: number;
  130938. faceUV?: Vector4[];
  130939. faceColors?: Color4[];
  130940. sideOrientation?: number;
  130941. frontUVs?: Vector4;
  130942. backUVs?: Vector4;
  130943. wrap?: boolean;
  130944. topBaseAt?: number;
  130945. bottomBaseAt?: number;
  130946. updatable?: boolean;
  130947. }, scene?: Nullable<Scene>): Mesh;
  130948. }
  130949. }
  130950. declare module BABYLON.Debug {
  130951. /**
  130952. * Used to show the physics impostor around the specific mesh
  130953. */
  130954. export class PhysicsViewer {
  130955. /** @hidden */
  130956. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  130957. /** @hidden */
  130958. protected _meshes: Array<Nullable<AbstractMesh>>;
  130959. /** @hidden */
  130960. protected _scene: Nullable<Scene>;
  130961. /** @hidden */
  130962. protected _numMeshes: number;
  130963. /** @hidden */
  130964. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  130965. private _renderFunction;
  130966. private _utilityLayer;
  130967. private _debugBoxMesh;
  130968. private _debugSphereMesh;
  130969. private _debugCylinderMesh;
  130970. private _debugMaterial;
  130971. private _debugMeshMeshes;
  130972. /**
  130973. * Creates a new PhysicsViewer
  130974. * @param scene defines the hosting scene
  130975. */
  130976. constructor(scene: Scene);
  130977. /** @hidden */
  130978. protected _updateDebugMeshes(): void;
  130979. /**
  130980. * Renders a specified physic impostor
  130981. * @param impostor defines the impostor to render
  130982. * @param targetMesh defines the mesh represented by the impostor
  130983. * @returns the new debug mesh used to render the impostor
  130984. */
  130985. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  130986. /**
  130987. * Hides a specified physic impostor
  130988. * @param impostor defines the impostor to hide
  130989. */
  130990. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  130991. private _getDebugMaterial;
  130992. private _getDebugBoxMesh;
  130993. private _getDebugSphereMesh;
  130994. private _getDebugCylinderMesh;
  130995. private _getDebugMeshMesh;
  130996. private _getDebugMesh;
  130997. /** Releases all resources */
  130998. dispose(): void;
  130999. }
  131000. }
  131001. declare module BABYLON {
  131002. /**
  131003. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131004. * in order to better appreciate the issue one might have.
  131005. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131006. */
  131007. export class RayHelper {
  131008. /**
  131009. * Defines the ray we are currently tryin to visualize.
  131010. */
  131011. ray: Nullable<Ray>;
  131012. private _renderPoints;
  131013. private _renderLine;
  131014. private _renderFunction;
  131015. private _scene;
  131016. private _onAfterRenderObserver;
  131017. private _onAfterStepObserver;
  131018. private _attachedToMesh;
  131019. private _meshSpaceDirection;
  131020. private _meshSpaceOrigin;
  131021. /**
  131022. * Helper function to create a colored helper in a scene in one line.
  131023. * @param ray Defines the ray we are currently tryin to visualize
  131024. * @param scene Defines the scene the ray is used in
  131025. * @param color Defines the color we want to see the ray in
  131026. * @returns The newly created ray helper.
  131027. */
  131028. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131029. /**
  131030. * Instantiate a new ray helper.
  131031. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131032. * in order to better appreciate the issue one might have.
  131033. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131034. * @param ray Defines the ray we are currently tryin to visualize
  131035. */
  131036. constructor(ray: Ray);
  131037. /**
  131038. * Shows the ray we are willing to debug.
  131039. * @param scene Defines the scene the ray needs to be rendered in
  131040. * @param color Defines the color the ray needs to be rendered in
  131041. */
  131042. show(scene: Scene, color?: Color3): void;
  131043. /**
  131044. * Hides the ray we are debugging.
  131045. */
  131046. hide(): void;
  131047. private _render;
  131048. /**
  131049. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131050. * @param mesh Defines the mesh we want the helper attached to
  131051. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131052. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131053. * @param length Defines the length of the ray
  131054. */
  131055. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131056. /**
  131057. * Detach the ray helper from the mesh it has previously been attached to.
  131058. */
  131059. detachFromMesh(): void;
  131060. private _updateToMesh;
  131061. /**
  131062. * Dispose the helper and release its associated resources.
  131063. */
  131064. dispose(): void;
  131065. }
  131066. }
  131067. declare module BABYLON {
  131068. /**
  131069. * Defines the options associated with the creation of a SkeletonViewer.
  131070. */
  131071. export interface ISkeletonViewerOptions {
  131072. /** Should the system pause animations before building the Viewer? */
  131073. pauseAnimations: boolean;
  131074. /** Should the system return the skeleton to rest before building? */
  131075. returnToRest: boolean;
  131076. /** public Display Mode of the Viewer */
  131077. displayMode: number;
  131078. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131079. displayOptions: ISkeletonViewerDisplayOptions;
  131080. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131081. computeBonesUsingShaders: boolean;
  131082. /** Flag ignore non weighted bones */
  131083. useAllBones: boolean;
  131084. }
  131085. /**
  131086. * Defines how to display the various bone meshes for the viewer.
  131087. */
  131088. export interface ISkeletonViewerDisplayOptions {
  131089. /** How far down to start tapering the bone spurs */
  131090. midStep?: number;
  131091. /** How big is the midStep? */
  131092. midStepFactor?: number;
  131093. /** Base for the Sphere Size */
  131094. sphereBaseSize?: number;
  131095. /** The ratio of the sphere to the longest bone in units */
  131096. sphereScaleUnit?: number;
  131097. /** Ratio for the Sphere Size */
  131098. sphereFactor?: number;
  131099. }
  131100. /**
  131101. * Defines the constructor options for the BoneWeight Shader.
  131102. */
  131103. export interface IBoneWeightShaderOptions {
  131104. /** Skeleton to Map */
  131105. skeleton: Skeleton;
  131106. /** Colors for Uninfluenced bones */
  131107. colorBase?: Color3;
  131108. /** Colors for 0.0-0.25 Weight bones */
  131109. colorZero?: Color3;
  131110. /** Color for 0.25-0.5 Weight Influence */
  131111. colorQuarter?: Color3;
  131112. /** Color for 0.5-0.75 Weight Influence */
  131113. colorHalf?: Color3;
  131114. /** Color for 0.75-1 Weight Influence */
  131115. colorFull?: Color3;
  131116. /** Color for Zero Weight Influence */
  131117. targetBoneIndex?: number;
  131118. }
  131119. /**
  131120. * Simple structure of the gradient steps for the Color Map.
  131121. */
  131122. export interface ISkeletonMapShaderColorMapKnot {
  131123. /** Color of the Knot */
  131124. color: Color3;
  131125. /** Location of the Knot */
  131126. location: number;
  131127. }
  131128. /**
  131129. * Defines the constructor options for the SkeletonMap Shader.
  131130. */
  131131. export interface ISkeletonMapShaderOptions {
  131132. /** Skeleton to Map */
  131133. skeleton: Skeleton;
  131134. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131135. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131136. }
  131137. }
  131138. declare module BABYLON {
  131139. /**
  131140. * Class containing static functions to help procedurally build meshes
  131141. */
  131142. export class RibbonBuilder {
  131143. /**
  131144. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131145. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131146. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131147. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131148. * * 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
  131149. * * 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
  131150. * * 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
  131151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131154. * * 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
  131155. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131156. * * 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
  131157. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131159. * @param name defines the name of the mesh
  131160. * @param options defines the options used to create the mesh
  131161. * @param scene defines the hosting scene
  131162. * @returns the ribbon mesh
  131163. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131164. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131165. */
  131166. static CreateRibbon(name: string, options: {
  131167. pathArray: Vector3[][];
  131168. closeArray?: boolean;
  131169. closePath?: boolean;
  131170. offset?: number;
  131171. updatable?: boolean;
  131172. sideOrientation?: number;
  131173. frontUVs?: Vector4;
  131174. backUVs?: Vector4;
  131175. instance?: Mesh;
  131176. invertUV?: boolean;
  131177. uvs?: Vector2[];
  131178. colors?: Color4[];
  131179. }, scene?: Nullable<Scene>): Mesh;
  131180. }
  131181. }
  131182. declare module BABYLON {
  131183. /**
  131184. * Class containing static functions to help procedurally build meshes
  131185. */
  131186. export class ShapeBuilder {
  131187. /**
  131188. * 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.
  131189. * * 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.
  131190. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131191. * * 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.
  131192. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131193. * * 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
  131194. * * 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
  131195. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131198. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131200. * @param name defines the name of the mesh
  131201. * @param options defines the options used to create the mesh
  131202. * @param scene defines the hosting scene
  131203. * @returns the extruded shape mesh
  131204. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131206. */
  131207. static ExtrudeShape(name: string, options: {
  131208. shape: Vector3[];
  131209. path: Vector3[];
  131210. scale?: number;
  131211. rotation?: number;
  131212. cap?: number;
  131213. updatable?: boolean;
  131214. sideOrientation?: number;
  131215. frontUVs?: Vector4;
  131216. backUVs?: Vector4;
  131217. instance?: Mesh;
  131218. invertUV?: boolean;
  131219. }, scene?: Nullable<Scene>): Mesh;
  131220. /**
  131221. * Creates an custom extruded shape mesh.
  131222. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131223. * * 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.
  131224. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131225. * * 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
  131226. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131227. * * 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
  131228. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131229. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131230. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131231. * * 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
  131232. * * 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
  131233. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131238. * @param name defines the name of the mesh
  131239. * @param options defines the options used to create the mesh
  131240. * @param scene defines the hosting scene
  131241. * @returns the custom extruded shape mesh
  131242. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131243. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131245. */
  131246. static ExtrudeShapeCustom(name: string, options: {
  131247. shape: Vector3[];
  131248. path: Vector3[];
  131249. scaleFunction?: any;
  131250. rotationFunction?: any;
  131251. ribbonCloseArray?: boolean;
  131252. ribbonClosePath?: boolean;
  131253. cap?: number;
  131254. updatable?: boolean;
  131255. sideOrientation?: number;
  131256. frontUVs?: Vector4;
  131257. backUVs?: Vector4;
  131258. instance?: Mesh;
  131259. invertUV?: boolean;
  131260. }, scene?: Nullable<Scene>): Mesh;
  131261. private static _ExtrudeShapeGeneric;
  131262. }
  131263. }
  131264. declare module BABYLON.Debug {
  131265. /**
  131266. * Class used to render a debug view of a given skeleton
  131267. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131268. */
  131269. export class SkeletonViewer {
  131270. /** defines the skeleton to render */
  131271. skeleton: Skeleton;
  131272. /** defines the mesh attached to the skeleton */
  131273. mesh: AbstractMesh;
  131274. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131275. autoUpdateBonesMatrices: boolean;
  131276. /** defines the rendering group id to use with the viewer */
  131277. renderingGroupId: number;
  131278. /** is the options for the viewer */
  131279. options: Partial<ISkeletonViewerOptions>;
  131280. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131281. static readonly DISPLAY_LINES: number;
  131282. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131283. static readonly DISPLAY_SPHERES: number;
  131284. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131285. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131286. /** public static method to create a BoneWeight Shader
  131287. * @param options The constructor options
  131288. * @param scene The scene that the shader is scoped to
  131289. * @returns The created ShaderMaterial
  131290. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131291. */
  131292. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131293. /** public static method to create a BoneWeight Shader
  131294. * @param options The constructor options
  131295. * @param scene The scene that the shader is scoped to
  131296. * @returns The created ShaderMaterial
  131297. */
  131298. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131299. /** private static method to create a BoneWeight Shader
  131300. * @param size The size of the buffer to create (usually the bone count)
  131301. * @param colorMap The gradient data to generate
  131302. * @param scene The scene that the shader is scoped to
  131303. * @returns an Array of floats from the color gradient values
  131304. */
  131305. private static _CreateBoneMapColorBuffer;
  131306. /** If SkeletonViewer scene scope. */
  131307. private _scene;
  131308. /** Gets or sets the color used to render the skeleton */
  131309. color: Color3;
  131310. /** Array of the points of the skeleton fo the line view. */
  131311. private _debugLines;
  131312. /** The SkeletonViewers Mesh. */
  131313. private _debugMesh;
  131314. /** If SkeletonViewer is enabled. */
  131315. private _isEnabled;
  131316. /** If SkeletonViewer is ready. */
  131317. private _ready;
  131318. /** SkeletonViewer render observable. */
  131319. private _obs;
  131320. /** The Utility Layer to render the gizmos in. */
  131321. private _utilityLayer;
  131322. private _boneIndices;
  131323. /** Gets the Scene. */
  131324. get scene(): Scene;
  131325. /** Gets the utilityLayer. */
  131326. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131327. /** Checks Ready Status. */
  131328. get isReady(): Boolean;
  131329. /** Sets Ready Status. */
  131330. set ready(value: boolean);
  131331. /** Gets the debugMesh */
  131332. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131333. /** Sets the debugMesh */
  131334. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131335. /** Gets the displayMode */
  131336. get displayMode(): number;
  131337. /** Sets the displayMode */
  131338. set displayMode(value: number);
  131339. /**
  131340. * Creates a new SkeletonViewer
  131341. * @param skeleton defines the skeleton to render
  131342. * @param mesh defines the mesh attached to the skeleton
  131343. * @param scene defines the hosting scene
  131344. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131345. * @param renderingGroupId defines the rendering group id to use with the viewer
  131346. * @param options All of the extra constructor options for the SkeletonViewer
  131347. */
  131348. constructor(
  131349. /** defines the skeleton to render */
  131350. skeleton: Skeleton,
  131351. /** defines the mesh attached to the skeleton */
  131352. mesh: AbstractMesh,
  131353. /** The Scene scope*/
  131354. scene: Scene,
  131355. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131356. autoUpdateBonesMatrices?: boolean,
  131357. /** defines the rendering group id to use with the viewer */
  131358. renderingGroupId?: number,
  131359. /** is the options for the viewer */
  131360. options?: Partial<ISkeletonViewerOptions>);
  131361. /** The Dynamic bindings for the update functions */
  131362. private _bindObs;
  131363. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131364. update(): void;
  131365. /** Gets or sets a boolean indicating if the viewer is enabled */
  131366. set isEnabled(value: boolean);
  131367. get isEnabled(): boolean;
  131368. private _getBonePosition;
  131369. private _getLinesForBonesWithLength;
  131370. private _getLinesForBonesNoLength;
  131371. /** function to revert the mesh and scene back to the initial state. */
  131372. private _revert;
  131373. /** function to build and bind sphere joint points and spur bone representations. */
  131374. private _buildSpheresAndSpurs;
  131375. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131376. private _displayLinesUpdate;
  131377. /** Changes the displayMode of the skeleton viewer
  131378. * @param mode The displayMode numerical value
  131379. */
  131380. changeDisplayMode(mode: number): void;
  131381. /** Changes the displayMode of the skeleton viewer
  131382. * @param option String of the option name
  131383. * @param value The numerical option value
  131384. */
  131385. changeDisplayOptions(option: string, value: number): void;
  131386. /** Release associated resources */
  131387. dispose(): void;
  131388. }
  131389. }
  131390. declare module BABYLON {
  131391. /**
  131392. * Enum for Device Types
  131393. */
  131394. export enum DeviceType {
  131395. /** Generic */
  131396. Generic = 0,
  131397. /** Keyboard */
  131398. Keyboard = 1,
  131399. /** Mouse */
  131400. Mouse = 2,
  131401. /** Touch Pointers */
  131402. Touch = 3,
  131403. /** PS4 Dual Shock */
  131404. DualShock = 4,
  131405. /** Xbox */
  131406. Xbox = 5,
  131407. /** Switch Controller */
  131408. Switch = 6
  131409. }
  131410. /**
  131411. * Enum for All Pointers (Touch/Mouse)
  131412. */
  131413. export enum PointerInput {
  131414. /** Horizontal Axis */
  131415. Horizontal = 0,
  131416. /** Vertical Axis */
  131417. Vertical = 1,
  131418. /** Left Click or Touch */
  131419. LeftClick = 2,
  131420. /** Middle Click */
  131421. MiddleClick = 3,
  131422. /** Right Click */
  131423. RightClick = 4,
  131424. /** Browser Back */
  131425. BrowserBack = 5,
  131426. /** Browser Forward */
  131427. BrowserForward = 6
  131428. }
  131429. /**
  131430. * Enum for Dual Shock Gamepad
  131431. */
  131432. export enum DualShockInput {
  131433. /** Cross */
  131434. Cross = 0,
  131435. /** Circle */
  131436. Circle = 1,
  131437. /** Square */
  131438. Square = 2,
  131439. /** Triangle */
  131440. Triangle = 3,
  131441. /** L1 */
  131442. L1 = 4,
  131443. /** R1 */
  131444. R1 = 5,
  131445. /** L2 */
  131446. L2 = 6,
  131447. /** R2 */
  131448. R2 = 7,
  131449. /** Share */
  131450. Share = 8,
  131451. /** Options */
  131452. Options = 9,
  131453. /** L3 */
  131454. L3 = 10,
  131455. /** R3 */
  131456. R3 = 11,
  131457. /** DPadUp */
  131458. DPadUp = 12,
  131459. /** DPadDown */
  131460. DPadDown = 13,
  131461. /** DPadLeft */
  131462. DPadLeft = 14,
  131463. /** DRight */
  131464. DPadRight = 15,
  131465. /** Home */
  131466. Home = 16,
  131467. /** TouchPad */
  131468. TouchPad = 17,
  131469. /** LStickXAxis */
  131470. LStickXAxis = 18,
  131471. /** LStickYAxis */
  131472. LStickYAxis = 19,
  131473. /** RStickXAxis */
  131474. RStickXAxis = 20,
  131475. /** RStickYAxis */
  131476. RStickYAxis = 21
  131477. }
  131478. /**
  131479. * Enum for Xbox Gamepad
  131480. */
  131481. export enum XboxInput {
  131482. /** A */
  131483. A = 0,
  131484. /** B */
  131485. B = 1,
  131486. /** X */
  131487. X = 2,
  131488. /** Y */
  131489. Y = 3,
  131490. /** LB */
  131491. LB = 4,
  131492. /** RB */
  131493. RB = 5,
  131494. /** LT */
  131495. LT = 6,
  131496. /** RT */
  131497. RT = 7,
  131498. /** Back */
  131499. Back = 8,
  131500. /** Start */
  131501. Start = 9,
  131502. /** LS */
  131503. LS = 10,
  131504. /** RS */
  131505. RS = 11,
  131506. /** DPadUp */
  131507. DPadUp = 12,
  131508. /** DPadDown */
  131509. DPadDown = 13,
  131510. /** DPadLeft */
  131511. DPadLeft = 14,
  131512. /** DRight */
  131513. DPadRight = 15,
  131514. /** Home */
  131515. Home = 16,
  131516. /** LStickXAxis */
  131517. LStickXAxis = 17,
  131518. /** LStickYAxis */
  131519. LStickYAxis = 18,
  131520. /** RStickXAxis */
  131521. RStickXAxis = 19,
  131522. /** RStickYAxis */
  131523. RStickYAxis = 20
  131524. }
  131525. /**
  131526. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131527. */
  131528. export enum SwitchInput {
  131529. /** B */
  131530. B = 0,
  131531. /** A */
  131532. A = 1,
  131533. /** Y */
  131534. Y = 2,
  131535. /** X */
  131536. X = 3,
  131537. /** L */
  131538. L = 4,
  131539. /** R */
  131540. R = 5,
  131541. /** ZL */
  131542. ZL = 6,
  131543. /** ZR */
  131544. ZR = 7,
  131545. /** Minus */
  131546. Minus = 8,
  131547. /** Plus */
  131548. Plus = 9,
  131549. /** LS */
  131550. LS = 10,
  131551. /** RS */
  131552. RS = 11,
  131553. /** DPadUp */
  131554. DPadUp = 12,
  131555. /** DPadDown */
  131556. DPadDown = 13,
  131557. /** DPadLeft */
  131558. DPadLeft = 14,
  131559. /** DRight */
  131560. DPadRight = 15,
  131561. /** Home */
  131562. Home = 16,
  131563. /** Capture */
  131564. Capture = 17,
  131565. /** LStickXAxis */
  131566. LStickXAxis = 18,
  131567. /** LStickYAxis */
  131568. LStickYAxis = 19,
  131569. /** RStickXAxis */
  131570. RStickXAxis = 20,
  131571. /** RStickYAxis */
  131572. RStickYAxis = 21
  131573. }
  131574. }
  131575. declare module BABYLON {
  131576. /**
  131577. * This class will take all inputs from Keyboard, Pointer, and
  131578. * any Gamepads and provide a polling system that all devices
  131579. * will use. This class assumes that there will only be one
  131580. * pointer device and one keyboard.
  131581. */
  131582. export class DeviceInputSystem implements IDisposable {
  131583. /**
  131584. * Callback to be triggered when a device is connected
  131585. */
  131586. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131587. /**
  131588. * Callback to be triggered when a device is disconnected
  131589. */
  131590. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131591. /**
  131592. * Callback to be triggered when event driven input is updated
  131593. */
  131594. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131595. private _inputs;
  131596. private _gamepads;
  131597. private _keyboardActive;
  131598. private _pointerActive;
  131599. private _elementToAttachTo;
  131600. private _keyboardDownEvent;
  131601. private _keyboardUpEvent;
  131602. private _pointerMoveEvent;
  131603. private _pointerDownEvent;
  131604. private _pointerUpEvent;
  131605. private _gamepadConnectedEvent;
  131606. private _gamepadDisconnectedEvent;
  131607. private static _MAX_KEYCODES;
  131608. private static _MAX_POINTER_INPUTS;
  131609. private constructor();
  131610. /**
  131611. * Creates a new DeviceInputSystem instance
  131612. * @param engine Engine to pull input element from
  131613. * @returns The new instance
  131614. */
  131615. static Create(engine: Engine): DeviceInputSystem;
  131616. /**
  131617. * Checks for current device input value, given an id and input index
  131618. * @param deviceName Id of connected device
  131619. * @param inputIndex Index of device input
  131620. * @returns Current value of input
  131621. */
  131622. /**
  131623. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131624. * @param deviceType Enum specifiying device type
  131625. * @param deviceSlot "Slot" or index that device is referenced in
  131626. * @param inputIndex Id of input to be checked
  131627. * @returns Current value of input
  131628. */
  131629. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131630. /**
  131631. * Dispose of all the eventlisteners
  131632. */
  131633. dispose(): void;
  131634. /**
  131635. * Add device and inputs to device array
  131636. * @param deviceType Enum specifiying device type
  131637. * @param deviceSlot "Slot" or index that device is referenced in
  131638. * @param numberOfInputs Number of input entries to create for given device
  131639. */
  131640. private _registerDevice;
  131641. /**
  131642. * Given a specific device name, remove that device from the device map
  131643. * @param deviceType Enum specifiying device type
  131644. * @param deviceSlot "Slot" or index that device is referenced in
  131645. */
  131646. private _unregisterDevice;
  131647. /**
  131648. * Handle all actions that come from keyboard interaction
  131649. */
  131650. private _handleKeyActions;
  131651. /**
  131652. * Handle all actions that come from pointer interaction
  131653. */
  131654. private _handlePointerActions;
  131655. /**
  131656. * Handle all actions that come from gamepad interaction
  131657. */
  131658. private _handleGamepadActions;
  131659. /**
  131660. * Update all non-event based devices with each frame
  131661. * @param deviceType Enum specifiying device type
  131662. * @param deviceSlot "Slot" or index that device is referenced in
  131663. * @param inputIndex Id of input to be checked
  131664. */
  131665. private _updateDevice;
  131666. /**
  131667. * Gets DeviceType from the device name
  131668. * @param deviceName Name of Device from DeviceInputSystem
  131669. * @returns DeviceType enum value
  131670. */
  131671. private _getGamepadDeviceType;
  131672. }
  131673. }
  131674. declare module BABYLON {
  131675. /**
  131676. * Type to handle enforcement of inputs
  131677. */
  131678. 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;
  131679. }
  131680. declare module BABYLON {
  131681. /**
  131682. * Class that handles all input for a specific device
  131683. */
  131684. export class DeviceSource<T extends DeviceType> {
  131685. /** Type of device */
  131686. readonly deviceType: DeviceType;
  131687. /** "Slot" or index that device is referenced in */
  131688. readonly deviceSlot: number;
  131689. /**
  131690. * Observable to handle device input changes per device
  131691. */
  131692. readonly onInputChangedObservable: Observable<{
  131693. inputIndex: DeviceInput<T>;
  131694. previousState: Nullable<number>;
  131695. currentState: Nullable<number>;
  131696. }>;
  131697. private readonly _deviceInputSystem;
  131698. /**
  131699. * Default Constructor
  131700. * @param deviceInputSystem Reference to DeviceInputSystem
  131701. * @param deviceType Type of device
  131702. * @param deviceSlot "Slot" or index that device is referenced in
  131703. */
  131704. constructor(deviceInputSystem: DeviceInputSystem,
  131705. /** Type of device */
  131706. deviceType: DeviceType,
  131707. /** "Slot" or index that device is referenced in */
  131708. deviceSlot?: number);
  131709. /**
  131710. * Get input for specific input
  131711. * @param inputIndex index of specific input on device
  131712. * @returns Input value from DeviceInputSystem
  131713. */
  131714. getInput(inputIndex: DeviceInput<T>): number;
  131715. }
  131716. /**
  131717. * Class to keep track of devices
  131718. */
  131719. export class DeviceSourceManager implements IDisposable {
  131720. /**
  131721. * Observable to be triggered when before a device is connected
  131722. */
  131723. readonly onBeforeDeviceConnectedObservable: Observable<{
  131724. deviceType: DeviceType;
  131725. deviceSlot: number;
  131726. }>;
  131727. /**
  131728. * Observable to be triggered when before a device is disconnected
  131729. */
  131730. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  131731. deviceType: DeviceType;
  131732. deviceSlot: number;
  131733. }>;
  131734. /**
  131735. * Observable to be triggered when after a device is connected
  131736. */
  131737. readonly onAfterDeviceConnectedObservable: Observable<{
  131738. deviceType: DeviceType;
  131739. deviceSlot: number;
  131740. }>;
  131741. /**
  131742. * Observable to be triggered when after a device is disconnected
  131743. */
  131744. readonly onAfterDeviceDisconnectedObservable: Observable<{
  131745. deviceType: DeviceType;
  131746. deviceSlot: number;
  131747. }>;
  131748. private readonly _devices;
  131749. private readonly _firstDevice;
  131750. private readonly _deviceInputSystem;
  131751. /**
  131752. * Default Constructor
  131753. * @param engine engine to pull input element from
  131754. */
  131755. constructor(engine: Engine);
  131756. /**
  131757. * Gets a DeviceSource, given a type and slot
  131758. * @param deviceType Enum specifying device type
  131759. * @param deviceSlot "Slot" or index that device is referenced in
  131760. * @returns DeviceSource object
  131761. */
  131762. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  131763. /**
  131764. * Gets an array of DeviceSource objects for a given device type
  131765. * @param deviceType Enum specifying device type
  131766. * @returns Array of DeviceSource objects
  131767. */
  131768. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  131769. /**
  131770. * Dispose of DeviceInputSystem and other parts
  131771. */
  131772. dispose(): void;
  131773. /**
  131774. * Function to add device name to device list
  131775. * @param deviceType Enum specifying device type
  131776. * @param deviceSlot "Slot" or index that device is referenced in
  131777. */
  131778. private _addDevice;
  131779. /**
  131780. * Function to remove device name to device list
  131781. * @param deviceType Enum specifying device type
  131782. * @param deviceSlot "Slot" or index that device is referenced in
  131783. */
  131784. private _removeDevice;
  131785. /**
  131786. * Updates array storing first connected device of each type
  131787. * @param type Type of Device
  131788. */
  131789. private _updateFirstDevices;
  131790. }
  131791. }
  131792. declare module BABYLON {
  131793. /**
  131794. * Options to create the null engine
  131795. */
  131796. export class NullEngineOptions {
  131797. /**
  131798. * Render width (Default: 512)
  131799. */
  131800. renderWidth: number;
  131801. /**
  131802. * Render height (Default: 256)
  131803. */
  131804. renderHeight: number;
  131805. /**
  131806. * Texture size (Default: 512)
  131807. */
  131808. textureSize: number;
  131809. /**
  131810. * If delta time between frames should be constant
  131811. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131812. */
  131813. deterministicLockstep: boolean;
  131814. /**
  131815. * Maximum about of steps between frames (Default: 4)
  131816. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131817. */
  131818. lockstepMaxSteps: number;
  131819. /**
  131820. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  131821. */
  131822. useHighPrecisionMatrix?: boolean;
  131823. }
  131824. /**
  131825. * The null engine class provides support for headless version of babylon.js.
  131826. * This can be used in server side scenario or for testing purposes
  131827. */
  131828. export class NullEngine extends Engine {
  131829. private _options;
  131830. /**
  131831. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  131832. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131833. * @returns true if engine is in deterministic lock step mode
  131834. */
  131835. isDeterministicLockStep(): boolean;
  131836. /**
  131837. * Gets the max steps when engine is running in deterministic lock step
  131838. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131839. * @returns the max steps
  131840. */
  131841. getLockstepMaxSteps(): number;
  131842. /**
  131843. * Gets the current hardware scaling level.
  131844. * By default the hardware scaling level is computed from the window device ratio.
  131845. * 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.
  131846. * @returns a number indicating the current hardware scaling level
  131847. */
  131848. getHardwareScalingLevel(): number;
  131849. constructor(options?: NullEngineOptions);
  131850. /**
  131851. * Creates a vertex buffer
  131852. * @param vertices the data for the vertex buffer
  131853. * @returns the new WebGL static buffer
  131854. */
  131855. createVertexBuffer(vertices: FloatArray): DataBuffer;
  131856. /**
  131857. * Creates a new index buffer
  131858. * @param indices defines the content of the index buffer
  131859. * @param updatable defines if the index buffer must be updatable
  131860. * @returns a new webGL buffer
  131861. */
  131862. createIndexBuffer(indices: IndicesArray): DataBuffer;
  131863. /**
  131864. * Clear the current render buffer or the current render target (if any is set up)
  131865. * @param color defines the color to use
  131866. * @param backBuffer defines if the back buffer must be cleared
  131867. * @param depth defines if the depth buffer must be cleared
  131868. * @param stencil defines if the stencil buffer must be cleared
  131869. */
  131870. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131871. /**
  131872. * Gets the current render width
  131873. * @param useScreen defines if screen size must be used (or the current render target if any)
  131874. * @returns a number defining the current render width
  131875. */
  131876. getRenderWidth(useScreen?: boolean): number;
  131877. /**
  131878. * Gets the current render height
  131879. * @param useScreen defines if screen size must be used (or the current render target if any)
  131880. * @returns a number defining the current render height
  131881. */
  131882. getRenderHeight(useScreen?: boolean): number;
  131883. /**
  131884. * Set the WebGL's viewport
  131885. * @param viewport defines the viewport element to be used
  131886. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  131887. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  131888. */
  131889. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  131890. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  131891. /**
  131892. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  131893. * @param pipelineContext defines the pipeline context to use
  131894. * @param uniformsNames defines the list of uniform names
  131895. * @returns an array of webGL uniform locations
  131896. */
  131897. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  131898. /**
  131899. * Gets the lsit of active attributes for a given webGL program
  131900. * @param pipelineContext defines the pipeline context to use
  131901. * @param attributesNames defines the list of attribute names to get
  131902. * @returns an array of indices indicating the offset of each attribute
  131903. */
  131904. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131905. /**
  131906. * Binds an effect to the webGL context
  131907. * @param effect defines the effect to bind
  131908. */
  131909. bindSamplers(effect: Effect): void;
  131910. /**
  131911. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  131912. * @param effect defines the effect to activate
  131913. */
  131914. enableEffect(effect: Effect): void;
  131915. /**
  131916. * Set various states to the webGL context
  131917. * @param culling defines backface culling state
  131918. * @param zOffset defines the value to apply to zOffset (0 by default)
  131919. * @param force defines if states must be applied even if cache is up to date
  131920. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  131921. */
  131922. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131923. /**
  131924. * Set the value of an uniform to an array of int32
  131925. * @param uniform defines the webGL uniform location where to store the value
  131926. * @param array defines the array of int32 to store
  131927. */
  131928. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131929. /**
  131930. * Set the value of an uniform to an array of int32 (stored as vec2)
  131931. * @param uniform defines the webGL uniform location where to store the value
  131932. * @param array defines the array of int32 to store
  131933. */
  131934. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131935. /**
  131936. * Set the value of an uniform to an array of int32 (stored as vec3)
  131937. * @param uniform defines the webGL uniform location where to store the value
  131938. * @param array defines the array of int32 to store
  131939. */
  131940. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131941. /**
  131942. * Set the value of an uniform to an array of int32 (stored as vec4)
  131943. * @param uniform defines the webGL uniform location where to store the value
  131944. * @param array defines the array of int32 to store
  131945. */
  131946. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131947. /**
  131948. * Set the value of an uniform to an array of float32
  131949. * @param uniform defines the webGL uniform location where to store the value
  131950. * @param array defines the array of float32 to store
  131951. */
  131952. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131953. /**
  131954. * Set the value of an uniform to an array of float32 (stored as vec2)
  131955. * @param uniform defines the webGL uniform location where to store the value
  131956. * @param array defines the array of float32 to store
  131957. */
  131958. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131959. /**
  131960. * Set the value of an uniform to an array of float32 (stored as vec3)
  131961. * @param uniform defines the webGL uniform location where to store the value
  131962. * @param array defines the array of float32 to store
  131963. */
  131964. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131965. /**
  131966. * Set the value of an uniform to an array of float32 (stored as vec4)
  131967. * @param uniform defines the webGL uniform location where to store the value
  131968. * @param array defines the array of float32 to store
  131969. */
  131970. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131971. /**
  131972. * Set the value of an uniform to an array of number
  131973. * @param uniform defines the webGL uniform location where to store the value
  131974. * @param array defines the array of number to store
  131975. */
  131976. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131977. /**
  131978. * Set the value of an uniform to an array of number (stored as vec2)
  131979. * @param uniform defines the webGL uniform location where to store the value
  131980. * @param array defines the array of number to store
  131981. */
  131982. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131983. /**
  131984. * Set the value of an uniform to an array of number (stored as vec3)
  131985. * @param uniform defines the webGL uniform location where to store the value
  131986. * @param array defines the array of number to store
  131987. */
  131988. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131989. /**
  131990. * Set the value of an uniform to an array of number (stored as vec4)
  131991. * @param uniform defines the webGL uniform location where to store the value
  131992. * @param array defines the array of number to store
  131993. */
  131994. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131995. /**
  131996. * Set the value of an uniform to an array of float32 (stored as matrices)
  131997. * @param uniform defines the webGL uniform location where to store the value
  131998. * @param matrices defines the array of float32 to store
  131999. */
  132000. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  132001. /**
  132002. * Set the value of an uniform to a matrix (3x3)
  132003. * @param uniform defines the webGL uniform location where to store the value
  132004. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132005. */
  132006. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132007. /**
  132008. * Set the value of an uniform to a matrix (2x2)
  132009. * @param uniform defines the webGL uniform location where to store the value
  132010. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132011. */
  132012. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132013. /**
  132014. * Set the value of an uniform to a number (float)
  132015. * @param uniform defines the webGL uniform location where to store the value
  132016. * @param value defines the float number to store
  132017. */
  132018. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132019. /**
  132020. * Set the value of an uniform to a vec2
  132021. * @param uniform defines the webGL uniform location where to store the value
  132022. * @param x defines the 1st component of the value
  132023. * @param y defines the 2nd component of the value
  132024. */
  132025. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132026. /**
  132027. * Set the value of an uniform to a vec3
  132028. * @param uniform defines the webGL uniform location where to store the value
  132029. * @param x defines the 1st component of the value
  132030. * @param y defines the 2nd component of the value
  132031. * @param z defines the 3rd component of the value
  132032. */
  132033. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132034. /**
  132035. * Set the value of an uniform to a boolean
  132036. * @param uniform defines the webGL uniform location where to store the value
  132037. * @param bool defines the boolean to store
  132038. */
  132039. setBool(uniform: WebGLUniformLocation, bool: number): void;
  132040. /**
  132041. * Set the value of an uniform to a vec4
  132042. * @param uniform defines the webGL uniform location where to store the value
  132043. * @param x defines the 1st component of the value
  132044. * @param y defines the 2nd component of the value
  132045. * @param z defines the 3rd component of the value
  132046. * @param w defines the 4th component of the value
  132047. */
  132048. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132049. /**
  132050. * Sets the current alpha mode
  132051. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132052. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132053. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132054. */
  132055. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132056. /**
  132057. * Bind webGl buffers directly to the webGL context
  132058. * @param vertexBuffers defines the vertex buffer to bind
  132059. * @param indexBuffer defines the index buffer to bind
  132060. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132061. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132062. * @param effect defines the effect associated with the vertex buffer
  132063. */
  132064. bindBuffers(vertexBuffers: {
  132065. [key: string]: VertexBuffer;
  132066. }, indexBuffer: DataBuffer, effect: Effect): void;
  132067. /**
  132068. * Force the entire cache to be cleared
  132069. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132070. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132071. */
  132072. wipeCaches(bruteForce?: boolean): void;
  132073. /**
  132074. * Send a draw order
  132075. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132076. * @param indexStart defines the starting index
  132077. * @param indexCount defines the number of index to draw
  132078. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132079. */
  132080. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132081. /**
  132082. * Draw a list of indexed primitives
  132083. * @param fillMode defines the primitive to use
  132084. * @param indexStart defines the starting index
  132085. * @param indexCount defines the number of index to draw
  132086. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132087. */
  132088. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132089. /**
  132090. * Draw a list of unindexed primitives
  132091. * @param fillMode defines the primitive to use
  132092. * @param verticesStart defines the index of first vertex to draw
  132093. * @param verticesCount defines the count of vertices to draw
  132094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132095. */
  132096. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132097. /** @hidden */
  132098. _createTexture(): WebGLTexture;
  132099. /** @hidden */
  132100. _releaseTexture(texture: InternalTexture): void;
  132101. /**
  132102. * Usually called from Texture.ts.
  132103. * Passed information to create a WebGLTexture
  132104. * @param urlArg defines a value which contains one of the following:
  132105. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132106. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132107. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132108. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132109. * @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)
  132110. * @param scene needed for loading to the correct scene
  132111. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132112. * @param onLoad optional callback to be called upon successful completion
  132113. * @param onError optional callback to be called upon failure
  132114. * @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
  132115. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132116. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132117. * @param forcedExtension defines the extension to use to pick the right loader
  132118. * @param mimeType defines an optional mime type
  132119. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132120. */
  132121. 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;
  132122. /**
  132123. * Creates a new render target texture
  132124. * @param size defines the size of the texture
  132125. * @param options defines the options used to create the texture
  132126. * @returns a new render target texture stored in an InternalTexture
  132127. */
  132128. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132129. /**
  132130. * Update the sampling mode of a given texture
  132131. * @param samplingMode defines the required sampling mode
  132132. * @param texture defines the texture to update
  132133. */
  132134. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132135. /**
  132136. * Binds the frame buffer to the specified texture.
  132137. * @param texture The texture to render to or null for the default canvas
  132138. * @param faceIndex The face of the texture to render to in case of cube texture
  132139. * @param requiredWidth The width of the target to render to
  132140. * @param requiredHeight The height of the target to render to
  132141. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132142. * @param lodLevel defines le lod level to bind to the frame buffer
  132143. */
  132144. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132145. /**
  132146. * Unbind the current render target texture from the webGL context
  132147. * @param texture defines the render target texture to unbind
  132148. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132149. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132150. */
  132151. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132152. /**
  132153. * Creates a dynamic vertex buffer
  132154. * @param vertices the data for the dynamic vertex buffer
  132155. * @returns the new WebGL dynamic buffer
  132156. */
  132157. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132158. /**
  132159. * Update the content of a dynamic texture
  132160. * @param texture defines the texture to update
  132161. * @param canvas defines the canvas containing the source
  132162. * @param invertY defines if data must be stored with Y axis inverted
  132163. * @param premulAlpha defines if alpha is stored as premultiplied
  132164. * @param format defines the format of the data
  132165. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132166. */
  132167. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132168. /**
  132169. * Gets a boolean indicating if all created effects are ready
  132170. * @returns true if all effects are ready
  132171. */
  132172. areAllEffectsReady(): boolean;
  132173. /**
  132174. * @hidden
  132175. * Get the current error code of the webGL context
  132176. * @returns the error code
  132177. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132178. */
  132179. getError(): number;
  132180. /** @hidden */
  132181. _getUnpackAlignement(): number;
  132182. /** @hidden */
  132183. _unpackFlipY(value: boolean): void;
  132184. /**
  132185. * Update a dynamic index buffer
  132186. * @param indexBuffer defines the target index buffer
  132187. * @param indices defines the data to update
  132188. * @param offset defines the offset in the target index buffer where update should start
  132189. */
  132190. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132191. /**
  132192. * Updates a dynamic vertex buffer.
  132193. * @param vertexBuffer the vertex buffer to update
  132194. * @param vertices the data used to update the vertex buffer
  132195. * @param byteOffset the byte offset of the data (optional)
  132196. * @param byteLength the byte length of the data (optional)
  132197. */
  132198. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132199. /** @hidden */
  132200. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132201. /** @hidden */
  132202. _bindTexture(channel: number, texture: InternalTexture): void;
  132203. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132204. /**
  132205. * 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
  132206. */
  132207. releaseEffects(): void;
  132208. displayLoadingUI(): void;
  132209. hideLoadingUI(): void;
  132210. /** @hidden */
  132211. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132212. /** @hidden */
  132213. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132214. /** @hidden */
  132215. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132216. /** @hidden */
  132217. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132218. }
  132219. }
  132220. declare module BABYLON {
  132221. /**
  132222. * @hidden
  132223. **/
  132224. export class _TimeToken {
  132225. _startTimeQuery: Nullable<WebGLQuery>;
  132226. _endTimeQuery: Nullable<WebGLQuery>;
  132227. _timeElapsedQuery: Nullable<WebGLQuery>;
  132228. _timeElapsedQueryEnded: boolean;
  132229. }
  132230. }
  132231. declare module BABYLON {
  132232. /** @hidden */
  132233. export class _OcclusionDataStorage {
  132234. /** @hidden */
  132235. occlusionInternalRetryCounter: number;
  132236. /** @hidden */
  132237. isOcclusionQueryInProgress: boolean;
  132238. /** @hidden */
  132239. isOccluded: boolean;
  132240. /** @hidden */
  132241. occlusionRetryCount: number;
  132242. /** @hidden */
  132243. occlusionType: number;
  132244. /** @hidden */
  132245. occlusionQueryAlgorithmType: number;
  132246. }
  132247. interface Engine {
  132248. /**
  132249. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132250. * @return the new query
  132251. */
  132252. createQuery(): WebGLQuery;
  132253. /**
  132254. * Delete and release a webGL query
  132255. * @param query defines the query to delete
  132256. * @return the current engine
  132257. */
  132258. deleteQuery(query: WebGLQuery): Engine;
  132259. /**
  132260. * Check if a given query has resolved and got its value
  132261. * @param query defines the query to check
  132262. * @returns true if the query got its value
  132263. */
  132264. isQueryResultAvailable(query: WebGLQuery): boolean;
  132265. /**
  132266. * Gets the value of a given query
  132267. * @param query defines the query to check
  132268. * @returns the value of the query
  132269. */
  132270. getQueryResult(query: WebGLQuery): number;
  132271. /**
  132272. * Initiates an occlusion query
  132273. * @param algorithmType defines the algorithm to use
  132274. * @param query defines the query to use
  132275. * @returns the current engine
  132276. * @see https://doc.babylonjs.com/features/occlusionquery
  132277. */
  132278. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132279. /**
  132280. * Ends an occlusion query
  132281. * @see https://doc.babylonjs.com/features/occlusionquery
  132282. * @param algorithmType defines the algorithm to use
  132283. * @returns the current engine
  132284. */
  132285. endOcclusionQuery(algorithmType: number): Engine;
  132286. /**
  132287. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132288. * Please note that only one query can be issued at a time
  132289. * @returns a time token used to track the time span
  132290. */
  132291. startTimeQuery(): Nullable<_TimeToken>;
  132292. /**
  132293. * Ends a time query
  132294. * @param token defines the token used to measure the time span
  132295. * @returns the time spent (in ns)
  132296. */
  132297. endTimeQuery(token: _TimeToken): int;
  132298. /** @hidden */
  132299. _currentNonTimestampToken: Nullable<_TimeToken>;
  132300. /** @hidden */
  132301. _createTimeQuery(): WebGLQuery;
  132302. /** @hidden */
  132303. _deleteTimeQuery(query: WebGLQuery): void;
  132304. /** @hidden */
  132305. _getGlAlgorithmType(algorithmType: number): number;
  132306. /** @hidden */
  132307. _getTimeQueryResult(query: WebGLQuery): any;
  132308. /** @hidden */
  132309. _getTimeQueryAvailability(query: WebGLQuery): any;
  132310. }
  132311. interface AbstractMesh {
  132312. /**
  132313. * Backing filed
  132314. * @hidden
  132315. */
  132316. __occlusionDataStorage: _OcclusionDataStorage;
  132317. /**
  132318. * Access property
  132319. * @hidden
  132320. */
  132321. _occlusionDataStorage: _OcclusionDataStorage;
  132322. /**
  132323. * 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.
  132324. * The default value is -1 which means don't break the query and wait till the result
  132325. * @see https://doc.babylonjs.com/features/occlusionquery
  132326. */
  132327. occlusionRetryCount: number;
  132328. /**
  132329. * 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:
  132330. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132331. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132332. * * 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.
  132333. * @see https://doc.babylonjs.com/features/occlusionquery
  132334. */
  132335. occlusionType: number;
  132336. /**
  132337. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132338. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132339. * * 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.
  132340. * @see https://doc.babylonjs.com/features/occlusionquery
  132341. */
  132342. occlusionQueryAlgorithmType: number;
  132343. /**
  132344. * 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
  132345. * @see https://doc.babylonjs.com/features/occlusionquery
  132346. */
  132347. isOccluded: boolean;
  132348. /**
  132349. * Flag to check the progress status of the query
  132350. * @see https://doc.babylonjs.com/features/occlusionquery
  132351. */
  132352. isOcclusionQueryInProgress: boolean;
  132353. }
  132354. }
  132355. declare module BABYLON {
  132356. /** @hidden */
  132357. export var _forceTransformFeedbackToBundle: boolean;
  132358. interface Engine {
  132359. /**
  132360. * Creates a webGL transform feedback object
  132361. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132362. * @returns the webGL transform feedback object
  132363. */
  132364. createTransformFeedback(): WebGLTransformFeedback;
  132365. /**
  132366. * Delete a webGL transform feedback object
  132367. * @param value defines the webGL transform feedback object to delete
  132368. */
  132369. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132370. /**
  132371. * Bind a webGL transform feedback object to the webgl context
  132372. * @param value defines the webGL transform feedback object to bind
  132373. */
  132374. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132375. /**
  132376. * Begins a transform feedback operation
  132377. * @param usePoints defines if points or triangles must be used
  132378. */
  132379. beginTransformFeedback(usePoints: boolean): void;
  132380. /**
  132381. * Ends a transform feedback operation
  132382. */
  132383. endTransformFeedback(): void;
  132384. /**
  132385. * Specify the varyings to use with transform feedback
  132386. * @param program defines the associated webGL program
  132387. * @param value defines the list of strings representing the varying names
  132388. */
  132389. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132390. /**
  132391. * Bind a webGL buffer for a transform feedback operation
  132392. * @param value defines the webGL buffer to bind
  132393. */
  132394. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132395. }
  132396. }
  132397. declare module BABYLON {
  132398. /**
  132399. * Class used to define an additional view for the engine
  132400. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132401. */
  132402. export class EngineView {
  132403. /** Defines the canvas where to render the view */
  132404. target: HTMLCanvasElement;
  132405. /** Defines an optional camera used to render the view (will use active camera else) */
  132406. camera?: Camera;
  132407. }
  132408. interface Engine {
  132409. /**
  132410. * Gets or sets the HTML element to use for attaching events
  132411. */
  132412. inputElement: Nullable<HTMLElement>;
  132413. /**
  132414. * Gets the current engine view
  132415. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132416. */
  132417. activeView: Nullable<EngineView>;
  132418. /** Gets or sets the list of views */
  132419. views: EngineView[];
  132420. /**
  132421. * Register a new child canvas
  132422. * @param canvas defines the canvas to register
  132423. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132424. * @returns the associated view
  132425. */
  132426. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132427. /**
  132428. * Remove a registered child canvas
  132429. * @param canvas defines the canvas to remove
  132430. * @returns the current engine
  132431. */
  132432. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132433. }
  132434. }
  132435. declare module BABYLON {
  132436. interface Engine {
  132437. /** @hidden */
  132438. _excludedCompressedTextures: string[];
  132439. /** @hidden */
  132440. _textureFormatInUse: string;
  132441. /**
  132442. * Gets the list of texture formats supported
  132443. */
  132444. readonly texturesSupported: Array<string>;
  132445. /**
  132446. * Gets the texture format in use
  132447. */
  132448. readonly textureFormatInUse: Nullable<string>;
  132449. /**
  132450. * Set the compressed texture extensions or file names to skip.
  132451. *
  132452. * @param skippedFiles defines the list of those texture files you want to skip
  132453. * Example: [".dds", ".env", "myfile.png"]
  132454. */
  132455. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132456. /**
  132457. * Set the compressed texture format to use, based on the formats you have, and the formats
  132458. * supported by the hardware / browser.
  132459. *
  132460. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132461. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132462. * to API arguments needed to compressed textures. This puts the burden on the container
  132463. * generator to house the arcane code for determining these for current & future formats.
  132464. *
  132465. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132466. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132467. *
  132468. * Note: The result of this call is not taken into account when a texture is base64.
  132469. *
  132470. * @param formatsAvailable defines the list of those format families you have created
  132471. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132472. *
  132473. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132474. * @returns The extension selected.
  132475. */
  132476. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132477. }
  132478. }
  132479. declare module BABYLON {
  132480. /**
  132481. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132482. */
  132483. export interface CubeMapInfo {
  132484. /**
  132485. * The pixel array for the front face.
  132486. * This is stored in format, left to right, up to down format.
  132487. */
  132488. front: Nullable<ArrayBufferView>;
  132489. /**
  132490. * The pixel array for the back face.
  132491. * This is stored in format, left to right, up to down format.
  132492. */
  132493. back: Nullable<ArrayBufferView>;
  132494. /**
  132495. * The pixel array for the left face.
  132496. * This is stored in format, left to right, up to down format.
  132497. */
  132498. left: Nullable<ArrayBufferView>;
  132499. /**
  132500. * The pixel array for the right face.
  132501. * This is stored in format, left to right, up to down format.
  132502. */
  132503. right: Nullable<ArrayBufferView>;
  132504. /**
  132505. * The pixel array for the up face.
  132506. * This is stored in format, left to right, up to down format.
  132507. */
  132508. up: Nullable<ArrayBufferView>;
  132509. /**
  132510. * The pixel array for the down face.
  132511. * This is stored in format, left to right, up to down format.
  132512. */
  132513. down: Nullable<ArrayBufferView>;
  132514. /**
  132515. * The size of the cubemap stored.
  132516. *
  132517. * Each faces will be size * size pixels.
  132518. */
  132519. size: number;
  132520. /**
  132521. * The format of the texture.
  132522. *
  132523. * RGBA, RGB.
  132524. */
  132525. format: number;
  132526. /**
  132527. * The type of the texture data.
  132528. *
  132529. * UNSIGNED_INT, FLOAT.
  132530. */
  132531. type: number;
  132532. /**
  132533. * Specifies whether the texture is in gamma space.
  132534. */
  132535. gammaSpace: boolean;
  132536. }
  132537. /**
  132538. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132539. */
  132540. export class PanoramaToCubeMapTools {
  132541. private static FACE_LEFT;
  132542. private static FACE_RIGHT;
  132543. private static FACE_FRONT;
  132544. private static FACE_BACK;
  132545. private static FACE_DOWN;
  132546. private static FACE_UP;
  132547. /**
  132548. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132549. *
  132550. * @param float32Array The source data.
  132551. * @param inputWidth The width of the input panorama.
  132552. * @param inputHeight The height of the input panorama.
  132553. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132554. * @return The cubemap data
  132555. */
  132556. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132557. private static CreateCubemapTexture;
  132558. private static CalcProjectionSpherical;
  132559. }
  132560. }
  132561. declare module BABYLON {
  132562. /**
  132563. * Helper class dealing with the extraction of spherical polynomial dataArray
  132564. * from a cube map.
  132565. */
  132566. export class CubeMapToSphericalPolynomialTools {
  132567. private static FileFaces;
  132568. /**
  132569. * Converts a texture to the according Spherical Polynomial data.
  132570. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132571. *
  132572. * @param texture The texture to extract the information from.
  132573. * @return The Spherical Polynomial data.
  132574. */
  132575. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132576. /**
  132577. * Converts a cubemap to the according Spherical Polynomial data.
  132578. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132579. *
  132580. * @param cubeInfo The Cube map to extract the information from.
  132581. * @return The Spherical Polynomial data.
  132582. */
  132583. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132584. }
  132585. }
  132586. declare module BABYLON {
  132587. interface BaseTexture {
  132588. /**
  132589. * Get the polynomial representation of the texture data.
  132590. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132591. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132592. */
  132593. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132594. }
  132595. }
  132596. declare module BABYLON {
  132597. /** @hidden */
  132598. export var rgbdEncodePixelShader: {
  132599. name: string;
  132600. shader: string;
  132601. };
  132602. }
  132603. declare module BABYLON {
  132604. /** @hidden */
  132605. export var rgbdDecodePixelShader: {
  132606. name: string;
  132607. shader: string;
  132608. };
  132609. }
  132610. declare module BABYLON {
  132611. /**
  132612. * Raw texture data and descriptor sufficient for WebGL texture upload
  132613. */
  132614. export interface EnvironmentTextureInfo {
  132615. /**
  132616. * Version of the environment map
  132617. */
  132618. version: number;
  132619. /**
  132620. * Width of image
  132621. */
  132622. width: number;
  132623. /**
  132624. * Irradiance information stored in the file.
  132625. */
  132626. irradiance: any;
  132627. /**
  132628. * Specular information stored in the file.
  132629. */
  132630. specular: any;
  132631. }
  132632. /**
  132633. * Defines One Image in the file. It requires only the position in the file
  132634. * as well as the length.
  132635. */
  132636. interface BufferImageData {
  132637. /**
  132638. * Length of the image data.
  132639. */
  132640. length: number;
  132641. /**
  132642. * Position of the data from the null terminator delimiting the end of the JSON.
  132643. */
  132644. position: number;
  132645. }
  132646. /**
  132647. * Defines the specular data enclosed in the file.
  132648. * This corresponds to the version 1 of the data.
  132649. */
  132650. export interface EnvironmentTextureSpecularInfoV1 {
  132651. /**
  132652. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  132653. */
  132654. specularDataPosition?: number;
  132655. /**
  132656. * This contains all the images data needed to reconstruct the cubemap.
  132657. */
  132658. mipmaps: Array<BufferImageData>;
  132659. /**
  132660. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  132661. */
  132662. lodGenerationScale: number;
  132663. }
  132664. /**
  132665. * Sets of helpers addressing the serialization and deserialization of environment texture
  132666. * stored in a BabylonJS env file.
  132667. * Those files are usually stored as .env files.
  132668. */
  132669. export class EnvironmentTextureTools {
  132670. /**
  132671. * Magic number identifying the env file.
  132672. */
  132673. private static _MagicBytes;
  132674. /**
  132675. * Gets the environment info from an env file.
  132676. * @param data The array buffer containing the .env bytes.
  132677. * @returns the environment file info (the json header) if successfully parsed.
  132678. */
  132679. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  132680. /**
  132681. * Creates an environment texture from a loaded cube texture.
  132682. * @param texture defines the cube texture to convert in env file
  132683. * @return a promise containing the environment data if succesfull.
  132684. */
  132685. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  132686. /**
  132687. * Creates a JSON representation of the spherical data.
  132688. * @param texture defines the texture containing the polynomials
  132689. * @return the JSON representation of the spherical info
  132690. */
  132691. private static _CreateEnvTextureIrradiance;
  132692. /**
  132693. * Creates the ArrayBufferViews used for initializing environment texture image data.
  132694. * @param data the image data
  132695. * @param info parameters that determine what views will be created for accessing the underlying buffer
  132696. * @return the views described by info providing access to the underlying buffer
  132697. */
  132698. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  132699. /**
  132700. * Uploads the texture info contained in the env file to the GPU.
  132701. * @param texture defines the internal texture to upload to
  132702. * @param data defines the data to load
  132703. * @param info defines the texture info retrieved through the GetEnvInfo method
  132704. * @returns a promise
  132705. */
  132706. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  132707. private static _OnImageReadyAsync;
  132708. /**
  132709. * Uploads the levels of image data to the GPU.
  132710. * @param texture defines the internal texture to upload to
  132711. * @param imageData defines the array buffer views of image data [mipmap][face]
  132712. * @returns a promise
  132713. */
  132714. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  132715. /**
  132716. * Uploads spherical polynomials information to the texture.
  132717. * @param texture defines the texture we are trying to upload the information to
  132718. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  132719. */
  132720. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  132721. /** @hidden */
  132722. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132723. }
  132724. }
  132725. declare module BABYLON {
  132726. /**
  132727. * Class used to inline functions in shader code
  132728. */
  132729. export class ShaderCodeInliner {
  132730. private static readonly _RegexpFindFunctionNameAndType;
  132731. private _sourceCode;
  132732. private _functionDescr;
  132733. private _numMaxIterations;
  132734. /** Gets or sets the token used to mark the functions to inline */
  132735. inlineToken: string;
  132736. /** Gets or sets the debug mode */
  132737. debug: boolean;
  132738. /** Gets the code after the inlining process */
  132739. get code(): string;
  132740. /**
  132741. * Initializes the inliner
  132742. * @param sourceCode shader code source to inline
  132743. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  132744. */
  132745. constructor(sourceCode: string, numMaxIterations?: number);
  132746. /**
  132747. * Start the processing of the shader code
  132748. */
  132749. processCode(): void;
  132750. private _collectFunctions;
  132751. private _processInlining;
  132752. private _extractBetweenMarkers;
  132753. private _skipWhitespaces;
  132754. private _removeComments;
  132755. private _replaceFunctionCallsByCode;
  132756. private _findBackward;
  132757. private _escapeRegExp;
  132758. private _replaceNames;
  132759. }
  132760. }
  132761. declare module BABYLON {
  132762. /**
  132763. * Container for accessors for natively-stored mesh data buffers.
  132764. */
  132765. class NativeDataBuffer extends DataBuffer {
  132766. /**
  132767. * Accessor value used to identify/retrieve a natively-stored index buffer.
  132768. */
  132769. nativeIndexBuffer?: any;
  132770. /**
  132771. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  132772. */
  132773. nativeVertexBuffer?: any;
  132774. }
  132775. /** @hidden */
  132776. class NativeTexture extends InternalTexture {
  132777. getInternalTexture(): InternalTexture;
  132778. getViewCount(): number;
  132779. }
  132780. /** @hidden */
  132781. export class NativeEngine extends Engine {
  132782. private readonly _native;
  132783. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  132784. private readonly INVALID_HANDLE;
  132785. private _boundBuffersVertexArray;
  132786. getHardwareScalingLevel(): number;
  132787. constructor();
  132788. dispose(): void;
  132789. /**
  132790. * Can be used to override the current requestAnimationFrame requester.
  132791. * @hidden
  132792. */
  132793. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  132794. /**
  132795. * Override default engine behavior.
  132796. * @param color
  132797. * @param backBuffer
  132798. * @param depth
  132799. * @param stencil
  132800. */
  132801. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  132802. /**
  132803. * Gets host document
  132804. * @returns the host document object
  132805. */
  132806. getHostDocument(): Nullable<Document>;
  132807. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132808. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  132809. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  132810. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  132811. [key: string]: VertexBuffer;
  132812. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132813. bindBuffers(vertexBuffers: {
  132814. [key: string]: VertexBuffer;
  132815. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132816. recordVertexArrayObject(vertexBuffers: {
  132817. [key: string]: VertexBuffer;
  132818. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  132819. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132820. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132821. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132822. /**
  132823. * Draw a list of indexed primitives
  132824. * @param fillMode defines the primitive to use
  132825. * @param indexStart defines the starting index
  132826. * @param indexCount defines the number of index to draw
  132827. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132828. */
  132829. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132830. /**
  132831. * Draw a list of unindexed primitives
  132832. * @param fillMode defines the primitive to use
  132833. * @param verticesStart defines the index of first vertex to draw
  132834. * @param verticesCount defines the count of vertices to draw
  132835. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132836. */
  132837. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132838. createPipelineContext(): IPipelineContext;
  132839. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  132840. /** @hidden */
  132841. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  132842. /** @hidden */
  132843. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  132844. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132845. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132846. protected _setProgram(program: WebGLProgram): void;
  132847. _releaseEffect(effect: Effect): void;
  132848. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  132849. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  132850. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  132851. bindSamplers(effect: Effect): void;
  132852. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  132853. getRenderWidth(useScreen?: boolean): number;
  132854. getRenderHeight(useScreen?: boolean): number;
  132855. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  132856. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132857. /**
  132858. * Set the z offset to apply to current rendering
  132859. * @param value defines the offset to apply
  132860. */
  132861. setZOffset(value: number): void;
  132862. /**
  132863. * Gets the current value of the zOffset
  132864. * @returns the current zOffset state
  132865. */
  132866. getZOffset(): number;
  132867. /**
  132868. * Enable or disable depth buffering
  132869. * @param enable defines the state to set
  132870. */
  132871. setDepthBuffer(enable: boolean): void;
  132872. /**
  132873. * Gets a boolean indicating if depth writing is enabled
  132874. * @returns the current depth writing state
  132875. */
  132876. getDepthWrite(): boolean;
  132877. /**
  132878. * Enable or disable depth writing
  132879. * @param enable defines the state to set
  132880. */
  132881. setDepthWrite(enable: boolean): void;
  132882. /**
  132883. * Enable or disable color writing
  132884. * @param enable defines the state to set
  132885. */
  132886. setColorWrite(enable: boolean): void;
  132887. /**
  132888. * Gets a boolean indicating if color writing is enabled
  132889. * @returns the current color writing state
  132890. */
  132891. getColorWrite(): boolean;
  132892. /**
  132893. * Sets alpha constants used by some alpha blending modes
  132894. * @param r defines the red component
  132895. * @param g defines the green component
  132896. * @param b defines the blue component
  132897. * @param a defines the alpha component
  132898. */
  132899. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  132900. /**
  132901. * Sets the current alpha mode
  132902. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  132903. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132904. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132905. */
  132906. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132907. /**
  132908. * Gets the current alpha mode
  132909. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132910. * @returns the current alpha mode
  132911. */
  132912. getAlphaMode(): number;
  132913. setInt(uniform: WebGLUniformLocation, int: number): void;
  132914. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  132915. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  132916. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  132917. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  132918. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  132919. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  132920. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  132921. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  132922. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  132923. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  132924. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  132925. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  132926. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  132927. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132928. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132929. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132930. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132931. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132932. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132933. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  132934. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  132935. wipeCaches(bruteForce?: boolean): void;
  132936. _createTexture(): WebGLTexture;
  132937. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  132938. /**
  132939. * Usually called from Texture.ts.
  132940. * Passed information to create a WebGLTexture
  132941. * @param url defines a value which contains one of the following:
  132942. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132943. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132944. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132945. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132946. * @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)
  132947. * @param scene needed for loading to the correct scene
  132948. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132949. * @param onLoad optional callback to be called upon successful completion
  132950. * @param onError optional callback to be called upon failure
  132951. * @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
  132952. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132953. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132954. * @param forcedExtension defines the extension to use to pick the right loader
  132955. * @param mimeType defines an optional mime type
  132956. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132957. */
  132958. 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;
  132959. /**
  132960. * Creates a cube texture
  132961. * @param rootUrl defines the url where the files to load is located
  132962. * @param scene defines the current scene
  132963. * @param files defines the list of files to load (1 per face)
  132964. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  132965. * @param onLoad defines an optional callback raised when the texture is loaded
  132966. * @param onError defines an optional callback raised if there is an issue to load the texture
  132967. * @param format defines the format of the data
  132968. * @param forcedExtension defines the extension to use to pick the right loader
  132969. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  132970. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132971. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132972. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  132973. * @returns the cube texture as an InternalTexture
  132974. */
  132975. 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;
  132976. private _getSamplingFilter;
  132977. private static _GetNativeTextureFormat;
  132978. createRenderTargetTexture(size: number | {
  132979. width: number;
  132980. height: number;
  132981. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  132982. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132983. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132984. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132985. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  132986. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  132987. /**
  132988. * Updates a dynamic vertex buffer.
  132989. * @param vertexBuffer the vertex buffer to update
  132990. * @param data the data used to update the vertex buffer
  132991. * @param byteOffset the byte offset of the data (optional)
  132992. * @param byteLength the byte length of the data (optional)
  132993. */
  132994. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  132995. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  132996. private _updateAnisotropicLevel;
  132997. private _getAddressMode;
  132998. /** @hidden */
  132999. _bindTexture(channel: number, texture: InternalTexture): void;
  133000. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133001. releaseEffects(): void;
  133002. /** @hidden */
  133003. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133004. /** @hidden */
  133005. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133006. /** @hidden */
  133007. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133008. /** @hidden */
  133009. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133010. }
  133011. }
  133012. declare module BABYLON {
  133013. /**
  133014. * Gather the list of clipboard event types as constants.
  133015. */
  133016. export class ClipboardEventTypes {
  133017. /**
  133018. * The clipboard event is fired when a copy command is active (pressed).
  133019. */
  133020. static readonly COPY: number;
  133021. /**
  133022. * The clipboard event is fired when a cut command is active (pressed).
  133023. */
  133024. static readonly CUT: number;
  133025. /**
  133026. * The clipboard event is fired when a paste command is active (pressed).
  133027. */
  133028. static readonly PASTE: number;
  133029. }
  133030. /**
  133031. * This class is used to store clipboard related info for the onClipboardObservable event.
  133032. */
  133033. export class ClipboardInfo {
  133034. /**
  133035. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133036. */
  133037. type: number;
  133038. /**
  133039. * Defines the related dom event
  133040. */
  133041. event: ClipboardEvent;
  133042. /**
  133043. *Creates an instance of ClipboardInfo.
  133044. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133045. * @param event Defines the related dom event
  133046. */
  133047. constructor(
  133048. /**
  133049. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133050. */
  133051. type: number,
  133052. /**
  133053. * Defines the related dom event
  133054. */
  133055. event: ClipboardEvent);
  133056. /**
  133057. * Get the clipboard event's type from the keycode.
  133058. * @param keyCode Defines the keyCode for the current keyboard event.
  133059. * @return {number}
  133060. */
  133061. static GetTypeFromCharacter(keyCode: number): number;
  133062. }
  133063. }
  133064. declare module BABYLON {
  133065. /**
  133066. * Google Daydream controller
  133067. */
  133068. export class DaydreamController extends WebVRController {
  133069. /**
  133070. * Base Url for the controller model.
  133071. */
  133072. static MODEL_BASE_URL: string;
  133073. /**
  133074. * File name for the controller model.
  133075. */
  133076. static MODEL_FILENAME: string;
  133077. /**
  133078. * Gamepad Id prefix used to identify Daydream Controller.
  133079. */
  133080. static readonly GAMEPAD_ID_PREFIX: string;
  133081. /**
  133082. * Creates a new DaydreamController from a gamepad
  133083. * @param vrGamepad the gamepad that the controller should be created from
  133084. */
  133085. constructor(vrGamepad: any);
  133086. /**
  133087. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133088. * @param scene scene in which to add meshes
  133089. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133090. */
  133091. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133092. /**
  133093. * Called once for each button that changed state since the last frame
  133094. * @param buttonIdx Which button index changed
  133095. * @param state New state of the button
  133096. * @param changes Which properties on the state changed since last frame
  133097. */
  133098. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133099. }
  133100. }
  133101. declare module BABYLON {
  133102. /**
  133103. * Gear VR Controller
  133104. */
  133105. export class GearVRController extends WebVRController {
  133106. /**
  133107. * Base Url for the controller model.
  133108. */
  133109. static MODEL_BASE_URL: string;
  133110. /**
  133111. * File name for the controller model.
  133112. */
  133113. static MODEL_FILENAME: string;
  133114. /**
  133115. * Gamepad Id prefix used to identify this controller.
  133116. */
  133117. static readonly GAMEPAD_ID_PREFIX: string;
  133118. private readonly _buttonIndexToObservableNameMap;
  133119. /**
  133120. * Creates a new GearVRController from a gamepad
  133121. * @param vrGamepad the gamepad that the controller should be created from
  133122. */
  133123. constructor(vrGamepad: any);
  133124. /**
  133125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133126. * @param scene scene in which to add meshes
  133127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133128. */
  133129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133130. /**
  133131. * Called once for each button that changed state since the last frame
  133132. * @param buttonIdx Which button index changed
  133133. * @param state New state of the button
  133134. * @param changes Which properties on the state changed since last frame
  133135. */
  133136. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133137. }
  133138. }
  133139. declare module BABYLON {
  133140. /**
  133141. * Generic Controller
  133142. */
  133143. export class GenericController extends WebVRController {
  133144. /**
  133145. * Base Url for the controller model.
  133146. */
  133147. static readonly MODEL_BASE_URL: string;
  133148. /**
  133149. * File name for the controller model.
  133150. */
  133151. static readonly MODEL_FILENAME: string;
  133152. /**
  133153. * Creates a new GenericController from a gamepad
  133154. * @param vrGamepad the gamepad that the controller should be created from
  133155. */
  133156. constructor(vrGamepad: any);
  133157. /**
  133158. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133159. * @param scene scene in which to add meshes
  133160. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133161. */
  133162. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133163. /**
  133164. * Called once for each button that changed state since the last frame
  133165. * @param buttonIdx Which button index changed
  133166. * @param state New state of the button
  133167. * @param changes Which properties on the state changed since last frame
  133168. */
  133169. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133170. }
  133171. }
  133172. declare module BABYLON {
  133173. /**
  133174. * Oculus Touch Controller
  133175. */
  133176. export class OculusTouchController extends WebVRController {
  133177. /**
  133178. * Base Url for the controller model.
  133179. */
  133180. static MODEL_BASE_URL: string;
  133181. /**
  133182. * File name for the left controller model.
  133183. */
  133184. static MODEL_LEFT_FILENAME: string;
  133185. /**
  133186. * File name for the right controller model.
  133187. */
  133188. static MODEL_RIGHT_FILENAME: string;
  133189. /**
  133190. * Base Url for the Quest controller model.
  133191. */
  133192. static QUEST_MODEL_BASE_URL: string;
  133193. /**
  133194. * @hidden
  133195. * If the controllers are running on a device that needs the updated Quest controller models
  133196. */
  133197. static _IsQuest: boolean;
  133198. /**
  133199. * Fired when the secondary trigger on this controller is modified
  133200. */
  133201. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133202. /**
  133203. * Fired when the thumb rest on this controller is modified
  133204. */
  133205. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133206. /**
  133207. * Creates a new OculusTouchController from a gamepad
  133208. * @param vrGamepad the gamepad that the controller should be created from
  133209. */
  133210. constructor(vrGamepad: any);
  133211. /**
  133212. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133213. * @param scene scene in which to add meshes
  133214. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133215. */
  133216. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133217. /**
  133218. * Fired when the A button on this controller is modified
  133219. */
  133220. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133221. /**
  133222. * Fired when the B button on this controller is modified
  133223. */
  133224. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133225. /**
  133226. * Fired when the X button on this controller is modified
  133227. */
  133228. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133229. /**
  133230. * Fired when the Y button on this controller is modified
  133231. */
  133232. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133233. /**
  133234. * Called once for each button that changed state since the last frame
  133235. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133236. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133237. * 2) secondary trigger (same)
  133238. * 3) A (right) X (left), touch, pressed = value
  133239. * 4) B / Y
  133240. * 5) thumb rest
  133241. * @param buttonIdx Which button index changed
  133242. * @param state New state of the button
  133243. * @param changes Which properties on the state changed since last frame
  133244. */
  133245. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133246. }
  133247. }
  133248. declare module BABYLON {
  133249. /**
  133250. * Vive Controller
  133251. */
  133252. export class ViveController extends WebVRController {
  133253. /**
  133254. * Base Url for the controller model.
  133255. */
  133256. static MODEL_BASE_URL: string;
  133257. /**
  133258. * File name for the controller model.
  133259. */
  133260. static MODEL_FILENAME: string;
  133261. /**
  133262. * Creates a new ViveController from a gamepad
  133263. * @param vrGamepad the gamepad that the controller should be created from
  133264. */
  133265. constructor(vrGamepad: any);
  133266. /**
  133267. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133268. * @param scene scene in which to add meshes
  133269. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133270. */
  133271. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133272. /**
  133273. * Fired when the left button on this controller is modified
  133274. */
  133275. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133276. /**
  133277. * Fired when the right button on this controller is modified
  133278. */
  133279. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133280. /**
  133281. * Fired when the menu button on this controller is modified
  133282. */
  133283. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133284. /**
  133285. * Called once for each button that changed state since the last frame
  133286. * Vive mapping:
  133287. * 0: touchpad
  133288. * 1: trigger
  133289. * 2: left AND right buttons
  133290. * 3: menu button
  133291. * @param buttonIdx Which button index changed
  133292. * @param state New state of the button
  133293. * @param changes Which properties on the state changed since last frame
  133294. */
  133295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133296. }
  133297. }
  133298. declare module BABYLON {
  133299. /**
  133300. * Defines the WindowsMotionController object that the state of the windows motion controller
  133301. */
  133302. export class WindowsMotionController extends WebVRController {
  133303. /**
  133304. * The base url used to load the left and right controller models
  133305. */
  133306. static MODEL_BASE_URL: string;
  133307. /**
  133308. * The name of the left controller model file
  133309. */
  133310. static MODEL_LEFT_FILENAME: string;
  133311. /**
  133312. * The name of the right controller model file
  133313. */
  133314. static MODEL_RIGHT_FILENAME: string;
  133315. /**
  133316. * The controller name prefix for this controller type
  133317. */
  133318. static readonly GAMEPAD_ID_PREFIX: string;
  133319. /**
  133320. * The controller id pattern for this controller type
  133321. */
  133322. private static readonly GAMEPAD_ID_PATTERN;
  133323. private _loadedMeshInfo;
  133324. protected readonly _mapping: {
  133325. buttons: string[];
  133326. buttonMeshNames: {
  133327. trigger: string;
  133328. menu: string;
  133329. grip: string;
  133330. thumbstick: string;
  133331. trackpad: string;
  133332. };
  133333. buttonObservableNames: {
  133334. trigger: string;
  133335. menu: string;
  133336. grip: string;
  133337. thumbstick: string;
  133338. trackpad: string;
  133339. };
  133340. axisMeshNames: string[];
  133341. pointingPoseMeshName: string;
  133342. };
  133343. /**
  133344. * Fired when the trackpad on this controller is clicked
  133345. */
  133346. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133347. /**
  133348. * Fired when the trackpad on this controller is modified
  133349. */
  133350. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133351. /**
  133352. * The current x and y values of this controller's trackpad
  133353. */
  133354. trackpad: StickValues;
  133355. /**
  133356. * Creates a new WindowsMotionController from a gamepad
  133357. * @param vrGamepad the gamepad that the controller should be created from
  133358. */
  133359. constructor(vrGamepad: any);
  133360. /**
  133361. * Fired when the trigger on this controller is modified
  133362. */
  133363. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133364. /**
  133365. * Fired when the menu button on this controller is modified
  133366. */
  133367. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133368. /**
  133369. * Fired when the grip button on this controller is modified
  133370. */
  133371. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133372. /**
  133373. * Fired when the thumbstick button on this controller is modified
  133374. */
  133375. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133376. /**
  133377. * Fired when the touchpad button on this controller is modified
  133378. */
  133379. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133380. /**
  133381. * Fired when the touchpad values on this controller are modified
  133382. */
  133383. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133384. protected _updateTrackpad(): void;
  133385. /**
  133386. * Called once per frame by the engine.
  133387. */
  133388. update(): void;
  133389. /**
  133390. * Called once for each button that changed state since the last frame
  133391. * @param buttonIdx Which button index changed
  133392. * @param state New state of the button
  133393. * @param changes Which properties on the state changed since last frame
  133394. */
  133395. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133396. /**
  133397. * Moves the buttons on the controller mesh based on their current state
  133398. * @param buttonName the name of the button to move
  133399. * @param buttonValue the value of the button which determines the buttons new position
  133400. */
  133401. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133402. /**
  133403. * Moves the axis on the controller mesh based on its current state
  133404. * @param axis the index of the axis
  133405. * @param axisValue the value of the axis which determines the meshes new position
  133406. * @hidden
  133407. */
  133408. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133409. /**
  133410. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133411. * @param scene scene in which to add meshes
  133412. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133413. */
  133414. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133415. /**
  133416. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133417. * can be transformed by button presses and axes values, based on this._mapping.
  133418. *
  133419. * @param scene scene in which the meshes exist
  133420. * @param meshes list of meshes that make up the controller model to process
  133421. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133422. */
  133423. private processModel;
  133424. private createMeshInfo;
  133425. /**
  133426. * Gets the ray of the controller in the direction the controller is pointing
  133427. * @param length the length the resulting ray should be
  133428. * @returns a ray in the direction the controller is pointing
  133429. */
  133430. getForwardRay(length?: number): Ray;
  133431. /**
  133432. * Disposes of the controller
  133433. */
  133434. dispose(): void;
  133435. }
  133436. /**
  133437. * This class represents a new windows motion controller in XR.
  133438. */
  133439. export class XRWindowsMotionController extends WindowsMotionController {
  133440. /**
  133441. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133442. */
  133443. protected readonly _mapping: {
  133444. buttons: string[];
  133445. buttonMeshNames: {
  133446. trigger: string;
  133447. menu: string;
  133448. grip: string;
  133449. thumbstick: string;
  133450. trackpad: string;
  133451. };
  133452. buttonObservableNames: {
  133453. trigger: string;
  133454. menu: string;
  133455. grip: string;
  133456. thumbstick: string;
  133457. trackpad: string;
  133458. };
  133459. axisMeshNames: string[];
  133460. pointingPoseMeshName: string;
  133461. };
  133462. /**
  133463. * Construct a new XR-Based windows motion controller
  133464. *
  133465. * @param gamepadInfo the gamepad object from the browser
  133466. */
  133467. constructor(gamepadInfo: any);
  133468. /**
  133469. * holds the thumbstick values (X,Y)
  133470. */
  133471. thumbstickValues: StickValues;
  133472. /**
  133473. * Fired when the thumbstick on this controller is clicked
  133474. */
  133475. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133476. /**
  133477. * Fired when the thumbstick on this controller is modified
  133478. */
  133479. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133480. /**
  133481. * Fired when the touchpad button on this controller is modified
  133482. */
  133483. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133484. /**
  133485. * Fired when the touchpad values on this controller are modified
  133486. */
  133487. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133488. /**
  133489. * Fired when the thumbstick button on this controller is modified
  133490. * here to prevent breaking changes
  133491. */
  133492. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133493. /**
  133494. * updating the thumbstick(!) and not the trackpad.
  133495. * This is named this way due to the difference between WebVR and XR and to avoid
  133496. * changing the parent class.
  133497. */
  133498. protected _updateTrackpad(): void;
  133499. /**
  133500. * Disposes the class with joy
  133501. */
  133502. dispose(): void;
  133503. }
  133504. }
  133505. declare module BABYLON {
  133506. /**
  133507. * Class containing static functions to help procedurally build meshes
  133508. */
  133509. export class PolyhedronBuilder {
  133510. /**
  133511. * Creates a polyhedron mesh
  133512. * * 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
  133513. * * The parameter `size` (positive float, default 1) sets the polygon size
  133514. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133515. * * 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`
  133516. * * 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
  133517. * * 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)`)
  133518. * * 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
  133519. * * 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
  133520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133521. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133523. * @param name defines the name of the mesh
  133524. * @param options defines the options used to create the mesh
  133525. * @param scene defines the hosting scene
  133526. * @returns the polyhedron mesh
  133527. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133528. */
  133529. static CreatePolyhedron(name: string, options: {
  133530. type?: number;
  133531. size?: number;
  133532. sizeX?: number;
  133533. sizeY?: number;
  133534. sizeZ?: number;
  133535. custom?: any;
  133536. faceUV?: Vector4[];
  133537. faceColors?: Color4[];
  133538. flat?: boolean;
  133539. updatable?: boolean;
  133540. sideOrientation?: number;
  133541. frontUVs?: Vector4;
  133542. backUVs?: Vector4;
  133543. }, scene?: Nullable<Scene>): Mesh;
  133544. }
  133545. }
  133546. declare module BABYLON {
  133547. /**
  133548. * Gizmo that enables scaling a mesh along 3 axis
  133549. */
  133550. export class ScaleGizmo extends Gizmo {
  133551. /**
  133552. * Internal gizmo used for interactions on the x axis
  133553. */
  133554. xGizmo: AxisScaleGizmo;
  133555. /**
  133556. * Internal gizmo used for interactions on the y axis
  133557. */
  133558. yGizmo: AxisScaleGizmo;
  133559. /**
  133560. * Internal gizmo used for interactions on the z axis
  133561. */
  133562. zGizmo: AxisScaleGizmo;
  133563. /**
  133564. * Internal gizmo used to scale all axis equally
  133565. */
  133566. uniformScaleGizmo: AxisScaleGizmo;
  133567. private _meshAttached;
  133568. private _nodeAttached;
  133569. private _snapDistance;
  133570. private _uniformScalingMesh;
  133571. private _octahedron;
  133572. private _sensitivity;
  133573. /** Fires an event when any of it's sub gizmos are dragged */
  133574. onDragStartObservable: Observable<unknown>;
  133575. /** Fires an event when any of it's sub gizmos are released from dragging */
  133576. onDragEndObservable: Observable<unknown>;
  133577. get attachedMesh(): Nullable<AbstractMesh>;
  133578. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133579. get attachedNode(): Nullable<Node>;
  133580. set attachedNode(node: Nullable<Node>);
  133581. /**
  133582. * Creates a ScaleGizmo
  133583. * @param gizmoLayer The utility layer the gizmo will be added to
  133584. * @param thickness display gizmo axis thickness
  133585. */
  133586. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133587. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133588. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133589. /**
  133590. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133591. */
  133592. set snapDistance(value: number);
  133593. get snapDistance(): number;
  133594. /**
  133595. * Ratio for the scale of the gizmo (Default: 1)
  133596. */
  133597. set scaleRatio(value: number);
  133598. get scaleRatio(): number;
  133599. /**
  133600. * Sensitivity factor for dragging (Default: 1)
  133601. */
  133602. set sensitivity(value: number);
  133603. get sensitivity(): number;
  133604. /**
  133605. * Disposes of the gizmo
  133606. */
  133607. dispose(): void;
  133608. }
  133609. }
  133610. declare module BABYLON {
  133611. /**
  133612. * Single axis scale gizmo
  133613. */
  133614. export class AxisScaleGizmo extends Gizmo {
  133615. /**
  133616. * Drag behavior responsible for the gizmos dragging interactions
  133617. */
  133618. dragBehavior: PointerDragBehavior;
  133619. private _pointerObserver;
  133620. /**
  133621. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133622. */
  133623. snapDistance: number;
  133624. /**
  133625. * Event that fires each time the gizmo snaps to a new location.
  133626. * * snapDistance is the the change in distance
  133627. */
  133628. onSnapObservable: Observable<{
  133629. snapDistance: number;
  133630. }>;
  133631. /**
  133632. * If the scaling operation should be done on all axis (default: false)
  133633. */
  133634. uniformScaling: boolean;
  133635. /**
  133636. * Custom sensitivity value for the drag strength
  133637. */
  133638. sensitivity: number;
  133639. private _isEnabled;
  133640. private _parent;
  133641. private _arrow;
  133642. private _coloredMaterial;
  133643. private _hoverMaterial;
  133644. /**
  133645. * Creates an AxisScaleGizmo
  133646. * @param gizmoLayer The utility layer the gizmo will be added to
  133647. * @param dragAxis The axis which the gizmo will be able to scale on
  133648. * @param color The color of the gizmo
  133649. * @param thickness display gizmo axis thickness
  133650. */
  133651. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  133652. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133653. /**
  133654. * If the gizmo is enabled
  133655. */
  133656. set isEnabled(value: boolean);
  133657. get isEnabled(): boolean;
  133658. /**
  133659. * Disposes of the gizmo
  133660. */
  133661. dispose(): void;
  133662. /**
  133663. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133664. * @param mesh The mesh to replace the default mesh of the gizmo
  133665. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  133666. */
  133667. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  133668. }
  133669. }
  133670. declare module BABYLON {
  133671. /**
  133672. * Bounding box gizmo
  133673. */
  133674. export class BoundingBoxGizmo extends Gizmo {
  133675. private _lineBoundingBox;
  133676. private _rotateSpheresParent;
  133677. private _scaleBoxesParent;
  133678. private _boundingDimensions;
  133679. private _renderObserver;
  133680. private _pointerObserver;
  133681. private _scaleDragSpeed;
  133682. private _tmpQuaternion;
  133683. private _tmpVector;
  133684. private _tmpRotationMatrix;
  133685. /**
  133686. * 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)
  133687. */
  133688. ignoreChildren: boolean;
  133689. /**
  133690. * 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)
  133691. */
  133692. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  133693. /**
  133694. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  133695. */
  133696. rotationSphereSize: number;
  133697. /**
  133698. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  133699. */
  133700. scaleBoxSize: number;
  133701. /**
  133702. * 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)
  133703. */
  133704. fixedDragMeshScreenSize: boolean;
  133705. /**
  133706. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  133707. */
  133708. fixedDragMeshScreenSizeDistanceFactor: number;
  133709. /**
  133710. * Fired when a rotation sphere or scale box is dragged
  133711. */
  133712. onDragStartObservable: Observable<{}>;
  133713. /**
  133714. * Fired when a scale box is dragged
  133715. */
  133716. onScaleBoxDragObservable: Observable<{}>;
  133717. /**
  133718. * Fired when a scale box drag is ended
  133719. */
  133720. onScaleBoxDragEndObservable: Observable<{}>;
  133721. /**
  133722. * Fired when a rotation sphere is dragged
  133723. */
  133724. onRotationSphereDragObservable: Observable<{}>;
  133725. /**
  133726. * Fired when a rotation sphere drag is ended
  133727. */
  133728. onRotationSphereDragEndObservable: Observable<{}>;
  133729. /**
  133730. * 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)
  133731. */
  133732. scalePivot: Nullable<Vector3>;
  133733. /**
  133734. * Mesh used as a pivot to rotate the attached node
  133735. */
  133736. private _anchorMesh;
  133737. private _existingMeshScale;
  133738. private _dragMesh;
  133739. private pointerDragBehavior;
  133740. private coloredMaterial;
  133741. private hoverColoredMaterial;
  133742. /**
  133743. * Sets the color of the bounding box gizmo
  133744. * @param color the color to set
  133745. */
  133746. setColor(color: Color3): void;
  133747. /**
  133748. * Creates an BoundingBoxGizmo
  133749. * @param gizmoLayer The utility layer the gizmo will be added to
  133750. * @param color The color of the gizmo
  133751. */
  133752. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  133753. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  133754. private _selectNode;
  133755. /**
  133756. * Updates the bounding box information for the Gizmo
  133757. */
  133758. updateBoundingBox(): void;
  133759. private _updateRotationSpheres;
  133760. private _updateScaleBoxes;
  133761. /**
  133762. * Enables rotation on the specified axis and disables rotation on the others
  133763. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  133764. */
  133765. setEnabledRotationAxis(axis: string): void;
  133766. /**
  133767. * Enables/disables scaling
  133768. * @param enable if scaling should be enabled
  133769. * @param homogeneousScaling defines if scaling should only be homogeneous
  133770. */
  133771. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  133772. private _updateDummy;
  133773. /**
  133774. * Enables a pointer drag behavior on the bounding box of the gizmo
  133775. */
  133776. enableDragBehavior(): void;
  133777. /**
  133778. * Disposes of the gizmo
  133779. */
  133780. dispose(): void;
  133781. /**
  133782. * 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)
  133783. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  133784. * @returns the bounding box mesh with the passed in mesh as a child
  133785. */
  133786. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  133787. /**
  133788. * CustomMeshes are not supported by this gizmo
  133789. * @param mesh The mesh to replace the default mesh of the gizmo
  133790. */
  133791. setCustomMesh(mesh: Mesh): void;
  133792. }
  133793. }
  133794. declare module BABYLON {
  133795. /**
  133796. * Single plane rotation gizmo
  133797. */
  133798. export class PlaneRotationGizmo extends Gizmo {
  133799. /**
  133800. * Drag behavior responsible for the gizmos dragging interactions
  133801. */
  133802. dragBehavior: PointerDragBehavior;
  133803. private _pointerObserver;
  133804. /**
  133805. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  133806. */
  133807. snapDistance: number;
  133808. /**
  133809. * Event that fires each time the gizmo snaps to a new location.
  133810. * * snapDistance is the the change in distance
  133811. */
  133812. onSnapObservable: Observable<{
  133813. snapDistance: number;
  133814. }>;
  133815. private _isEnabled;
  133816. private _parent;
  133817. /**
  133818. * Creates a PlaneRotationGizmo
  133819. * @param gizmoLayer The utility layer the gizmo will be added to
  133820. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  133821. * @param color The color of the gizmo
  133822. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133823. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133824. * @param thickness display gizmo axis thickness
  133825. */
  133826. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  133827. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133828. /**
  133829. * If the gizmo is enabled
  133830. */
  133831. set isEnabled(value: boolean);
  133832. get isEnabled(): boolean;
  133833. /**
  133834. * Disposes of the gizmo
  133835. */
  133836. dispose(): void;
  133837. }
  133838. }
  133839. declare module BABYLON {
  133840. /**
  133841. * Gizmo that enables rotating a mesh along 3 axis
  133842. */
  133843. export class RotationGizmo extends Gizmo {
  133844. /**
  133845. * Internal gizmo used for interactions on the x axis
  133846. */
  133847. xGizmo: PlaneRotationGizmo;
  133848. /**
  133849. * Internal gizmo used for interactions on the y axis
  133850. */
  133851. yGizmo: PlaneRotationGizmo;
  133852. /**
  133853. * Internal gizmo used for interactions on the z axis
  133854. */
  133855. zGizmo: PlaneRotationGizmo;
  133856. /** Fires an event when any of it's sub gizmos are dragged */
  133857. onDragStartObservable: Observable<unknown>;
  133858. /** Fires an event when any of it's sub gizmos are released from dragging */
  133859. onDragEndObservable: Observable<unknown>;
  133860. private _meshAttached;
  133861. private _nodeAttached;
  133862. get attachedMesh(): Nullable<AbstractMesh>;
  133863. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133864. get attachedNode(): Nullable<Node>;
  133865. set attachedNode(node: Nullable<Node>);
  133866. /**
  133867. * Creates a RotationGizmo
  133868. * @param gizmoLayer The utility layer the gizmo will be added to
  133869. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133870. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133871. * @param thickness display gizmo axis thickness
  133872. */
  133873. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  133874. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133875. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133876. /**
  133877. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133878. */
  133879. set snapDistance(value: number);
  133880. get snapDistance(): number;
  133881. /**
  133882. * Ratio for the scale of the gizmo (Default: 1)
  133883. */
  133884. set scaleRatio(value: number);
  133885. get scaleRatio(): number;
  133886. /**
  133887. * Disposes of the gizmo
  133888. */
  133889. dispose(): void;
  133890. /**
  133891. * CustomMeshes are not supported by this gizmo
  133892. * @param mesh The mesh to replace the default mesh of the gizmo
  133893. */
  133894. setCustomMesh(mesh: Mesh): void;
  133895. }
  133896. }
  133897. declare module BABYLON {
  133898. /**
  133899. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  133900. */
  133901. export class GizmoManager implements IDisposable {
  133902. private scene;
  133903. /**
  133904. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  133905. */
  133906. gizmos: {
  133907. positionGizmo: Nullable<PositionGizmo>;
  133908. rotationGizmo: Nullable<RotationGizmo>;
  133909. scaleGizmo: Nullable<ScaleGizmo>;
  133910. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  133911. };
  133912. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  133913. clearGizmoOnEmptyPointerEvent: boolean;
  133914. /** Fires an event when the manager is attached to a mesh */
  133915. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  133916. /** Fires an event when the manager is attached to a node */
  133917. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  133918. private _gizmosEnabled;
  133919. private _pointerObserver;
  133920. private _attachedMesh;
  133921. private _attachedNode;
  133922. private _boundingBoxColor;
  133923. private _defaultUtilityLayer;
  133924. private _defaultKeepDepthUtilityLayer;
  133925. private _thickness;
  133926. /**
  133927. * When bounding box gizmo is enabled, this can be used to track drag/end events
  133928. */
  133929. boundingBoxDragBehavior: SixDofDragBehavior;
  133930. /**
  133931. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  133932. */
  133933. attachableMeshes: Nullable<Array<AbstractMesh>>;
  133934. /**
  133935. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  133936. */
  133937. attachableNodes: Nullable<Array<Node>>;
  133938. /**
  133939. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  133940. */
  133941. usePointerToAttachGizmos: boolean;
  133942. /**
  133943. * Utility layer that the bounding box gizmo belongs to
  133944. */
  133945. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  133946. /**
  133947. * Utility layer that all gizmos besides bounding box belong to
  133948. */
  133949. get utilityLayer(): UtilityLayerRenderer;
  133950. /**
  133951. * Instatiates a gizmo manager
  133952. * @param scene the scene to overlay the gizmos on top of
  133953. * @param thickness display gizmo axis thickness
  133954. */
  133955. constructor(scene: Scene, thickness?: number);
  133956. /**
  133957. * Attaches a set of gizmos to the specified mesh
  133958. * @param mesh The mesh the gizmo's should be attached to
  133959. */
  133960. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  133961. /**
  133962. * Attaches a set of gizmos to the specified node
  133963. * @param node The node the gizmo's should be attached to
  133964. */
  133965. attachToNode(node: Nullable<Node>): void;
  133966. /**
  133967. * If the position gizmo is enabled
  133968. */
  133969. set positionGizmoEnabled(value: boolean);
  133970. get positionGizmoEnabled(): boolean;
  133971. /**
  133972. * If the rotation gizmo is enabled
  133973. */
  133974. set rotationGizmoEnabled(value: boolean);
  133975. get rotationGizmoEnabled(): boolean;
  133976. /**
  133977. * If the scale gizmo is enabled
  133978. */
  133979. set scaleGizmoEnabled(value: boolean);
  133980. get scaleGizmoEnabled(): boolean;
  133981. /**
  133982. * If the boundingBox gizmo is enabled
  133983. */
  133984. set boundingBoxGizmoEnabled(value: boolean);
  133985. get boundingBoxGizmoEnabled(): boolean;
  133986. /**
  133987. * Disposes of the gizmo manager
  133988. */
  133989. dispose(): void;
  133990. }
  133991. }
  133992. declare module BABYLON {
  133993. /**
  133994. * A directional light is defined by a direction (what a surprise!).
  133995. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  133996. * 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.
  133997. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133998. */
  133999. export class DirectionalLight extends ShadowLight {
  134000. private _shadowFrustumSize;
  134001. /**
  134002. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134003. */
  134004. get shadowFrustumSize(): number;
  134005. /**
  134006. * Specifies a fix frustum size for the shadow generation.
  134007. */
  134008. set shadowFrustumSize(value: number);
  134009. private _shadowOrthoScale;
  134010. /**
  134011. * Gets the shadow projection scale against the optimal computed one.
  134012. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134013. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134014. */
  134015. get shadowOrthoScale(): number;
  134016. /**
  134017. * Sets the shadow projection scale against the optimal computed one.
  134018. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134019. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134020. */
  134021. set shadowOrthoScale(value: number);
  134022. /**
  134023. * Automatically compute the projection matrix to best fit (including all the casters)
  134024. * on each frame.
  134025. */
  134026. autoUpdateExtends: boolean;
  134027. /**
  134028. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134029. * on each frame. autoUpdateExtends must be set to true for this to work
  134030. */
  134031. autoCalcShadowZBounds: boolean;
  134032. private _orthoLeft;
  134033. private _orthoRight;
  134034. private _orthoTop;
  134035. private _orthoBottom;
  134036. /**
  134037. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134038. * The directional light is emitted from everywhere in the given direction.
  134039. * It can cast shadows.
  134040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134041. * @param name The friendly name of the light
  134042. * @param direction The direction of the light
  134043. * @param scene The scene the light belongs to
  134044. */
  134045. constructor(name: string, direction: Vector3, scene: Scene);
  134046. /**
  134047. * Returns the string "DirectionalLight".
  134048. * @return The class name
  134049. */
  134050. getClassName(): string;
  134051. /**
  134052. * Returns the integer 1.
  134053. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134054. */
  134055. getTypeID(): number;
  134056. /**
  134057. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134058. * Returns the DirectionalLight Shadow projection matrix.
  134059. */
  134060. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134061. /**
  134062. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134063. * Returns the DirectionalLight Shadow projection matrix.
  134064. */
  134065. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134066. /**
  134067. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134068. * Returns the DirectionalLight Shadow projection matrix.
  134069. */
  134070. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134071. protected _buildUniformLayout(): void;
  134072. /**
  134073. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134074. * @param effect The effect to update
  134075. * @param lightIndex The index of the light in the effect to update
  134076. * @returns The directional light
  134077. */
  134078. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134079. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134080. /**
  134081. * Gets the minZ used for shadow according to both the scene and the light.
  134082. *
  134083. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134084. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134085. * @param activeCamera The camera we are returning the min for
  134086. * @returns the depth min z
  134087. */
  134088. getDepthMinZ(activeCamera: Camera): number;
  134089. /**
  134090. * Gets the maxZ used for shadow according to both the scene and the light.
  134091. *
  134092. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134093. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134094. * @param activeCamera The camera we are returning the max for
  134095. * @returns the depth max z
  134096. */
  134097. getDepthMaxZ(activeCamera: Camera): number;
  134098. /**
  134099. * Prepares the list of defines specific to the light type.
  134100. * @param defines the list of defines
  134101. * @param lightIndex defines the index of the light for the effect
  134102. */
  134103. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134104. }
  134105. }
  134106. declare module BABYLON {
  134107. /**
  134108. * Class containing static functions to help procedurally build meshes
  134109. */
  134110. export class HemisphereBuilder {
  134111. /**
  134112. * Creates a hemisphere mesh
  134113. * @param name defines the name of the mesh
  134114. * @param options defines the options used to create the mesh
  134115. * @param scene defines the hosting scene
  134116. * @returns the hemisphere mesh
  134117. */
  134118. static CreateHemisphere(name: string, options: {
  134119. segments?: number;
  134120. diameter?: number;
  134121. sideOrientation?: number;
  134122. }, scene: any): Mesh;
  134123. }
  134124. }
  134125. declare module BABYLON {
  134126. /**
  134127. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134128. * These values define a cone of light starting from the position, emitting toward the direction.
  134129. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134130. * and the exponent defines the speed of the decay of the light with distance (reach).
  134131. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134132. */
  134133. export class SpotLight extends ShadowLight {
  134134. private _angle;
  134135. private _innerAngle;
  134136. private _cosHalfAngle;
  134137. private _lightAngleScale;
  134138. private _lightAngleOffset;
  134139. /**
  134140. * Gets the cone angle of the spot light in Radians.
  134141. */
  134142. get angle(): number;
  134143. /**
  134144. * Sets the cone angle of the spot light in Radians.
  134145. */
  134146. set angle(value: number);
  134147. /**
  134148. * Only used in gltf falloff mode, this defines the angle where
  134149. * the directional falloff will start before cutting at angle which could be seen
  134150. * as outer angle.
  134151. */
  134152. get innerAngle(): number;
  134153. /**
  134154. * Only used in gltf falloff mode, this defines the angle where
  134155. * the directional falloff will start before cutting at angle which could be seen
  134156. * as outer angle.
  134157. */
  134158. set innerAngle(value: number);
  134159. private _shadowAngleScale;
  134160. /**
  134161. * Allows scaling the angle of the light for shadow generation only.
  134162. */
  134163. get shadowAngleScale(): number;
  134164. /**
  134165. * Allows scaling the angle of the light for shadow generation only.
  134166. */
  134167. set shadowAngleScale(value: number);
  134168. /**
  134169. * The light decay speed with the distance from the emission spot.
  134170. */
  134171. exponent: number;
  134172. private _projectionTextureMatrix;
  134173. /**
  134174. * Allows reading the projecton texture
  134175. */
  134176. get projectionTextureMatrix(): Matrix;
  134177. protected _projectionTextureLightNear: number;
  134178. /**
  134179. * Gets the near clip of the Spotlight for texture projection.
  134180. */
  134181. get projectionTextureLightNear(): number;
  134182. /**
  134183. * Sets the near clip of the Spotlight for texture projection.
  134184. */
  134185. set projectionTextureLightNear(value: number);
  134186. protected _projectionTextureLightFar: number;
  134187. /**
  134188. * Gets the far clip of the Spotlight for texture projection.
  134189. */
  134190. get projectionTextureLightFar(): number;
  134191. /**
  134192. * Sets the far clip of the Spotlight for texture projection.
  134193. */
  134194. set projectionTextureLightFar(value: number);
  134195. protected _projectionTextureUpDirection: Vector3;
  134196. /**
  134197. * Gets the Up vector of the Spotlight for texture projection.
  134198. */
  134199. get projectionTextureUpDirection(): Vector3;
  134200. /**
  134201. * Sets the Up vector of the Spotlight for texture projection.
  134202. */
  134203. set projectionTextureUpDirection(value: Vector3);
  134204. private _projectionTexture;
  134205. /**
  134206. * Gets the projection texture of the light.
  134207. */
  134208. get projectionTexture(): Nullable<BaseTexture>;
  134209. /**
  134210. * Sets the projection texture of the light.
  134211. */
  134212. set projectionTexture(value: Nullable<BaseTexture>);
  134213. private _projectionTextureViewLightDirty;
  134214. private _projectionTextureProjectionLightDirty;
  134215. private _projectionTextureDirty;
  134216. private _projectionTextureViewTargetVector;
  134217. private _projectionTextureViewLightMatrix;
  134218. private _projectionTextureProjectionLightMatrix;
  134219. private _projectionTextureScalingMatrix;
  134220. /**
  134221. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134222. * It can cast shadows.
  134223. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134224. * @param name The light friendly name
  134225. * @param position The position of the spot light in the scene
  134226. * @param direction The direction of the light in the scene
  134227. * @param angle The cone angle of the light in Radians
  134228. * @param exponent The light decay speed with the distance from the emission spot
  134229. * @param scene The scene the lights belongs to
  134230. */
  134231. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134232. /**
  134233. * Returns the string "SpotLight".
  134234. * @returns the class name
  134235. */
  134236. getClassName(): string;
  134237. /**
  134238. * Returns the integer 2.
  134239. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134240. */
  134241. getTypeID(): number;
  134242. /**
  134243. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134244. */
  134245. protected _setDirection(value: Vector3): void;
  134246. /**
  134247. * Overrides the position setter to recompute the projection texture view light Matrix.
  134248. */
  134249. protected _setPosition(value: Vector3): void;
  134250. /**
  134251. * 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.
  134252. * Returns the SpotLight.
  134253. */
  134254. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134255. protected _computeProjectionTextureViewLightMatrix(): void;
  134256. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134257. /**
  134258. * Main function for light texture projection matrix computing.
  134259. */
  134260. protected _computeProjectionTextureMatrix(): void;
  134261. protected _buildUniformLayout(): void;
  134262. private _computeAngleValues;
  134263. /**
  134264. * Sets the passed Effect "effect" with the Light textures.
  134265. * @param effect The effect to update
  134266. * @param lightIndex The index of the light in the effect to update
  134267. * @returns The light
  134268. */
  134269. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134270. /**
  134271. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134272. * @param effect The effect to update
  134273. * @param lightIndex The index of the light in the effect to update
  134274. * @returns The spot light
  134275. */
  134276. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134277. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134278. /**
  134279. * Disposes the light and the associated resources.
  134280. */
  134281. dispose(): void;
  134282. /**
  134283. * Prepares the list of defines specific to the light type.
  134284. * @param defines the list of defines
  134285. * @param lightIndex defines the index of the light for the effect
  134286. */
  134287. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134288. }
  134289. }
  134290. declare module BABYLON {
  134291. /**
  134292. * Gizmo that enables viewing a light
  134293. */
  134294. export class LightGizmo extends Gizmo {
  134295. private _lightMesh;
  134296. private _material;
  134297. private _cachedPosition;
  134298. private _cachedForward;
  134299. private _attachedMeshParent;
  134300. private _pointerObserver;
  134301. /**
  134302. * Event that fires each time the gizmo is clicked
  134303. */
  134304. onClickedObservable: Observable<Light>;
  134305. /**
  134306. * Creates a LightGizmo
  134307. * @param gizmoLayer The utility layer the gizmo will be added to
  134308. */
  134309. constructor(gizmoLayer?: UtilityLayerRenderer);
  134310. private _light;
  134311. /**
  134312. * The light that the gizmo is attached to
  134313. */
  134314. set light(light: Nullable<Light>);
  134315. get light(): Nullable<Light>;
  134316. /**
  134317. * Gets the material used to render the light gizmo
  134318. */
  134319. get material(): StandardMaterial;
  134320. /**
  134321. * @hidden
  134322. * Updates the gizmo to match the attached mesh's position/rotation
  134323. */
  134324. protected _update(): void;
  134325. private static _Scale;
  134326. /**
  134327. * Creates the lines for a light mesh
  134328. */
  134329. private static _CreateLightLines;
  134330. /**
  134331. * Disposes of the light gizmo
  134332. */
  134333. dispose(): void;
  134334. private static _CreateHemisphericLightMesh;
  134335. private static _CreatePointLightMesh;
  134336. private static _CreateSpotLightMesh;
  134337. private static _CreateDirectionalLightMesh;
  134338. }
  134339. }
  134340. declare module BABYLON {
  134341. /**
  134342. * Gizmo that enables viewing a camera
  134343. */
  134344. export class CameraGizmo extends Gizmo {
  134345. private _cameraMesh;
  134346. private _cameraLinesMesh;
  134347. private _material;
  134348. private _pointerObserver;
  134349. /**
  134350. * Event that fires each time the gizmo is clicked
  134351. */
  134352. onClickedObservable: Observable<Camera>;
  134353. /**
  134354. * Creates a CameraGizmo
  134355. * @param gizmoLayer The utility layer the gizmo will be added to
  134356. */
  134357. constructor(gizmoLayer?: UtilityLayerRenderer);
  134358. private _camera;
  134359. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134360. get displayFrustum(): boolean;
  134361. set displayFrustum(value: boolean);
  134362. /**
  134363. * The camera that the gizmo is attached to
  134364. */
  134365. set camera(camera: Nullable<Camera>);
  134366. get camera(): Nullable<Camera>;
  134367. /**
  134368. * Gets the material used to render the camera gizmo
  134369. */
  134370. get material(): StandardMaterial;
  134371. /**
  134372. * @hidden
  134373. * Updates the gizmo to match the attached mesh's position/rotation
  134374. */
  134375. protected _update(): void;
  134376. private static _Scale;
  134377. private _invProjection;
  134378. /**
  134379. * Disposes of the camera gizmo
  134380. */
  134381. dispose(): void;
  134382. private static _CreateCameraMesh;
  134383. private static _CreateCameraFrustum;
  134384. }
  134385. }
  134386. declare module BABYLON {
  134387. /** @hidden */
  134388. export var backgroundFragmentDeclaration: {
  134389. name: string;
  134390. shader: string;
  134391. };
  134392. }
  134393. declare module BABYLON {
  134394. /** @hidden */
  134395. export var backgroundUboDeclaration: {
  134396. name: string;
  134397. shader: string;
  134398. };
  134399. }
  134400. declare module BABYLON {
  134401. /** @hidden */
  134402. export var backgroundPixelShader: {
  134403. name: string;
  134404. shader: string;
  134405. };
  134406. }
  134407. declare module BABYLON {
  134408. /** @hidden */
  134409. export var backgroundVertexDeclaration: {
  134410. name: string;
  134411. shader: string;
  134412. };
  134413. }
  134414. declare module BABYLON {
  134415. /** @hidden */
  134416. export var backgroundVertexShader: {
  134417. name: string;
  134418. shader: string;
  134419. };
  134420. }
  134421. declare module BABYLON {
  134422. /**
  134423. * Background material used to create an efficient environement around your scene.
  134424. */
  134425. export class BackgroundMaterial extends PushMaterial {
  134426. /**
  134427. * Standard reflectance value at parallel view angle.
  134428. */
  134429. static StandardReflectance0: number;
  134430. /**
  134431. * Standard reflectance value at grazing angle.
  134432. */
  134433. static StandardReflectance90: number;
  134434. protected _primaryColor: Color3;
  134435. /**
  134436. * Key light Color (multiply against the environement texture)
  134437. */
  134438. primaryColor: Color3;
  134439. protected __perceptualColor: Nullable<Color3>;
  134440. /**
  134441. * Experimental Internal Use Only.
  134442. *
  134443. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134444. * This acts as a helper to set the primary color to a more "human friendly" value.
  134445. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134446. * output color as close as possible from the chosen value.
  134447. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134448. * part of lighting setup.)
  134449. */
  134450. get _perceptualColor(): Nullable<Color3>;
  134451. set _perceptualColor(value: Nullable<Color3>);
  134452. protected _primaryColorShadowLevel: float;
  134453. /**
  134454. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134455. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134456. */
  134457. get primaryColorShadowLevel(): float;
  134458. set primaryColorShadowLevel(value: float);
  134459. protected _primaryColorHighlightLevel: float;
  134460. /**
  134461. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134462. * The primary color is used at the level chosen to define what the white area would look.
  134463. */
  134464. get primaryColorHighlightLevel(): float;
  134465. set primaryColorHighlightLevel(value: float);
  134466. protected _reflectionTexture: Nullable<BaseTexture>;
  134467. /**
  134468. * Reflection Texture used in the material.
  134469. * Should be author in a specific way for the best result (refer to the documentation).
  134470. */
  134471. reflectionTexture: Nullable<BaseTexture>;
  134472. protected _reflectionBlur: float;
  134473. /**
  134474. * Reflection Texture level of blur.
  134475. *
  134476. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134477. * texture twice.
  134478. */
  134479. reflectionBlur: float;
  134480. protected _diffuseTexture: Nullable<BaseTexture>;
  134481. /**
  134482. * Diffuse Texture used in the material.
  134483. * Should be author in a specific way for the best result (refer to the documentation).
  134484. */
  134485. diffuseTexture: Nullable<BaseTexture>;
  134486. protected _shadowLights: Nullable<IShadowLight[]>;
  134487. /**
  134488. * Specify the list of lights casting shadow on the material.
  134489. * All scene shadow lights will be included if null.
  134490. */
  134491. shadowLights: Nullable<IShadowLight[]>;
  134492. protected _shadowLevel: float;
  134493. /**
  134494. * Helps adjusting the shadow to a softer level if required.
  134495. * 0 means black shadows and 1 means no shadows.
  134496. */
  134497. shadowLevel: float;
  134498. protected _sceneCenter: Vector3;
  134499. /**
  134500. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134501. * It is usually zero but might be interesting to modify according to your setup.
  134502. */
  134503. sceneCenter: Vector3;
  134504. protected _opacityFresnel: boolean;
  134505. /**
  134506. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134507. * This helps ensuring a nice transition when the camera goes under the ground.
  134508. */
  134509. opacityFresnel: boolean;
  134510. protected _reflectionFresnel: boolean;
  134511. /**
  134512. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134513. * This helps adding a mirror texture on the ground.
  134514. */
  134515. reflectionFresnel: boolean;
  134516. protected _reflectionFalloffDistance: number;
  134517. /**
  134518. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134519. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134520. */
  134521. reflectionFalloffDistance: number;
  134522. protected _reflectionAmount: number;
  134523. /**
  134524. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134525. */
  134526. reflectionAmount: number;
  134527. protected _reflectionReflectance0: number;
  134528. /**
  134529. * This specifies the weight of the reflection at grazing angle.
  134530. */
  134531. reflectionReflectance0: number;
  134532. protected _reflectionReflectance90: number;
  134533. /**
  134534. * This specifies the weight of the reflection at a perpendicular point of view.
  134535. */
  134536. reflectionReflectance90: number;
  134537. /**
  134538. * Sets the reflection reflectance fresnel values according to the default standard
  134539. * empirically know to work well :-)
  134540. */
  134541. set reflectionStandardFresnelWeight(value: number);
  134542. protected _useRGBColor: boolean;
  134543. /**
  134544. * Helps to directly use the maps channels instead of their level.
  134545. */
  134546. useRGBColor: boolean;
  134547. protected _enableNoise: boolean;
  134548. /**
  134549. * This helps reducing the banding effect that could occur on the background.
  134550. */
  134551. enableNoise: boolean;
  134552. /**
  134553. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134554. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134555. * Recommended to be keep at 1.0 except for special cases.
  134556. */
  134557. get fovMultiplier(): number;
  134558. set fovMultiplier(value: number);
  134559. private _fovMultiplier;
  134560. /**
  134561. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134562. */
  134563. useEquirectangularFOV: boolean;
  134564. private _maxSimultaneousLights;
  134565. /**
  134566. * Number of Simultaneous lights allowed on the material.
  134567. */
  134568. maxSimultaneousLights: int;
  134569. private _shadowOnly;
  134570. /**
  134571. * Make the material only render shadows
  134572. */
  134573. shadowOnly: boolean;
  134574. /**
  134575. * Default configuration related to image processing available in the Background Material.
  134576. */
  134577. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134578. /**
  134579. * Keep track of the image processing observer to allow dispose and replace.
  134580. */
  134581. private _imageProcessingObserver;
  134582. /**
  134583. * Attaches a new image processing configuration to the PBR Material.
  134584. * @param configuration (if null the scene configuration will be use)
  134585. */
  134586. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134587. /**
  134588. * Gets the image processing configuration used either in this material.
  134589. */
  134590. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134591. /**
  134592. * Sets the Default image processing configuration used either in the this material.
  134593. *
  134594. * If sets to null, the scene one is in use.
  134595. */
  134596. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134597. /**
  134598. * Gets wether the color curves effect is enabled.
  134599. */
  134600. get cameraColorCurvesEnabled(): boolean;
  134601. /**
  134602. * Sets wether the color curves effect is enabled.
  134603. */
  134604. set cameraColorCurvesEnabled(value: boolean);
  134605. /**
  134606. * Gets wether the color grading effect is enabled.
  134607. */
  134608. get cameraColorGradingEnabled(): boolean;
  134609. /**
  134610. * Gets wether the color grading effect is enabled.
  134611. */
  134612. set cameraColorGradingEnabled(value: boolean);
  134613. /**
  134614. * Gets wether tonemapping is enabled or not.
  134615. */
  134616. get cameraToneMappingEnabled(): boolean;
  134617. /**
  134618. * Sets wether tonemapping is enabled or not
  134619. */
  134620. set cameraToneMappingEnabled(value: boolean);
  134621. /**
  134622. * The camera exposure used on this material.
  134623. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134624. * This corresponds to a photographic exposure.
  134625. */
  134626. get cameraExposure(): float;
  134627. /**
  134628. * The camera exposure used on this material.
  134629. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134630. * This corresponds to a photographic exposure.
  134631. */
  134632. set cameraExposure(value: float);
  134633. /**
  134634. * Gets The camera contrast used on this material.
  134635. */
  134636. get cameraContrast(): float;
  134637. /**
  134638. * Sets The camera contrast used on this material.
  134639. */
  134640. set cameraContrast(value: float);
  134641. /**
  134642. * Gets the Color Grading 2D Lookup Texture.
  134643. */
  134644. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134645. /**
  134646. * Sets the Color Grading 2D Lookup Texture.
  134647. */
  134648. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134649. /**
  134650. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134651. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134652. * 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;
  134653. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134654. */
  134655. get cameraColorCurves(): Nullable<ColorCurves>;
  134656. /**
  134657. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134658. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134659. * 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;
  134660. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134661. */
  134662. set cameraColorCurves(value: Nullable<ColorCurves>);
  134663. /**
  134664. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  134665. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  134666. */
  134667. switchToBGR: boolean;
  134668. private _renderTargets;
  134669. private _reflectionControls;
  134670. private _white;
  134671. private _primaryShadowColor;
  134672. private _primaryHighlightColor;
  134673. /**
  134674. * Instantiates a Background Material in the given scene
  134675. * @param name The friendly name of the material
  134676. * @param scene The scene to add the material to
  134677. */
  134678. constructor(name: string, scene: Scene);
  134679. /**
  134680. * Gets a boolean indicating that current material needs to register RTT
  134681. */
  134682. get hasRenderTargetTextures(): boolean;
  134683. /**
  134684. * The entire material has been created in order to prevent overdraw.
  134685. * @returns false
  134686. */
  134687. needAlphaTesting(): boolean;
  134688. /**
  134689. * The entire material has been created in order to prevent overdraw.
  134690. * @returns true if blending is enable
  134691. */
  134692. needAlphaBlending(): boolean;
  134693. /**
  134694. * Checks wether the material is ready to be rendered for a given mesh.
  134695. * @param mesh The mesh to render
  134696. * @param subMesh The submesh to check against
  134697. * @param useInstances Specify wether or not the material is used with instances
  134698. * @returns true if all the dependencies are ready (Textures, Effects...)
  134699. */
  134700. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134701. /**
  134702. * Compute the primary color according to the chosen perceptual color.
  134703. */
  134704. private _computePrimaryColorFromPerceptualColor;
  134705. /**
  134706. * Compute the highlights and shadow colors according to their chosen levels.
  134707. */
  134708. private _computePrimaryColors;
  134709. /**
  134710. * Build the uniform buffer used in the material.
  134711. */
  134712. buildUniformLayout(): void;
  134713. /**
  134714. * Unbind the material.
  134715. */
  134716. unbind(): void;
  134717. /**
  134718. * Bind only the world matrix to the material.
  134719. * @param world The world matrix to bind.
  134720. */
  134721. bindOnlyWorldMatrix(world: Matrix): void;
  134722. /**
  134723. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  134724. * @param world The world matrix to bind.
  134725. * @param subMesh The submesh to bind for.
  134726. */
  134727. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134728. /**
  134729. * Checks to see if a texture is used in the material.
  134730. * @param texture - Base texture to use.
  134731. * @returns - Boolean specifying if a texture is used in the material.
  134732. */
  134733. hasTexture(texture: BaseTexture): boolean;
  134734. /**
  134735. * Dispose the material.
  134736. * @param forceDisposeEffect Force disposal of the associated effect.
  134737. * @param forceDisposeTextures Force disposal of the associated textures.
  134738. */
  134739. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134740. /**
  134741. * Clones the material.
  134742. * @param name The cloned name.
  134743. * @returns The cloned material.
  134744. */
  134745. clone(name: string): BackgroundMaterial;
  134746. /**
  134747. * Serializes the current material to its JSON representation.
  134748. * @returns The JSON representation.
  134749. */
  134750. serialize(): any;
  134751. /**
  134752. * Gets the class name of the material
  134753. * @returns "BackgroundMaterial"
  134754. */
  134755. getClassName(): string;
  134756. /**
  134757. * Parse a JSON input to create back a background material.
  134758. * @param source The JSON data to parse
  134759. * @param scene The scene to create the parsed material in
  134760. * @param rootUrl The root url of the assets the material depends upon
  134761. * @returns the instantiated BackgroundMaterial.
  134762. */
  134763. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  134764. }
  134765. }
  134766. declare module BABYLON {
  134767. /**
  134768. * Represents the different options available during the creation of
  134769. * a Environment helper.
  134770. *
  134771. * This can control the default ground, skybox and image processing setup of your scene.
  134772. */
  134773. export interface IEnvironmentHelperOptions {
  134774. /**
  134775. * Specifies whether or not to create a ground.
  134776. * True by default.
  134777. */
  134778. createGround: boolean;
  134779. /**
  134780. * Specifies the ground size.
  134781. * 15 by default.
  134782. */
  134783. groundSize: number;
  134784. /**
  134785. * The texture used on the ground for the main color.
  134786. * Comes from the BabylonJS CDN by default.
  134787. *
  134788. * Remarks: Can be either a texture or a url.
  134789. */
  134790. groundTexture: string | BaseTexture;
  134791. /**
  134792. * The color mixed in the ground texture by default.
  134793. * BabylonJS clearColor by default.
  134794. */
  134795. groundColor: Color3;
  134796. /**
  134797. * Specifies the ground opacity.
  134798. * 1 by default.
  134799. */
  134800. groundOpacity: number;
  134801. /**
  134802. * Enables the ground to receive shadows.
  134803. * True by default.
  134804. */
  134805. enableGroundShadow: boolean;
  134806. /**
  134807. * Helps preventing the shadow to be fully black on the ground.
  134808. * 0.5 by default.
  134809. */
  134810. groundShadowLevel: number;
  134811. /**
  134812. * Creates a mirror texture attach to the ground.
  134813. * false by default.
  134814. */
  134815. enableGroundMirror: boolean;
  134816. /**
  134817. * Specifies the ground mirror size ratio.
  134818. * 0.3 by default as the default kernel is 64.
  134819. */
  134820. groundMirrorSizeRatio: number;
  134821. /**
  134822. * Specifies the ground mirror blur kernel size.
  134823. * 64 by default.
  134824. */
  134825. groundMirrorBlurKernel: number;
  134826. /**
  134827. * Specifies the ground mirror visibility amount.
  134828. * 1 by default
  134829. */
  134830. groundMirrorAmount: number;
  134831. /**
  134832. * Specifies the ground mirror reflectance weight.
  134833. * This uses the standard weight of the background material to setup the fresnel effect
  134834. * of the mirror.
  134835. * 1 by default.
  134836. */
  134837. groundMirrorFresnelWeight: number;
  134838. /**
  134839. * Specifies the ground mirror Falloff distance.
  134840. * This can helps reducing the size of the reflection.
  134841. * 0 by Default.
  134842. */
  134843. groundMirrorFallOffDistance: number;
  134844. /**
  134845. * Specifies the ground mirror texture type.
  134846. * Unsigned Int by Default.
  134847. */
  134848. groundMirrorTextureType: number;
  134849. /**
  134850. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  134851. * the shown objects.
  134852. */
  134853. groundYBias: number;
  134854. /**
  134855. * Specifies whether or not to create a skybox.
  134856. * True by default.
  134857. */
  134858. createSkybox: boolean;
  134859. /**
  134860. * Specifies the skybox size.
  134861. * 20 by default.
  134862. */
  134863. skyboxSize: number;
  134864. /**
  134865. * The texture used on the skybox for the main color.
  134866. * Comes from the BabylonJS CDN by default.
  134867. *
  134868. * Remarks: Can be either a texture or a url.
  134869. */
  134870. skyboxTexture: string | BaseTexture;
  134871. /**
  134872. * The color mixed in the skybox texture by default.
  134873. * BabylonJS clearColor by default.
  134874. */
  134875. skyboxColor: Color3;
  134876. /**
  134877. * The background rotation around the Y axis of the scene.
  134878. * This helps aligning the key lights of your scene with the background.
  134879. * 0 by default.
  134880. */
  134881. backgroundYRotation: number;
  134882. /**
  134883. * Compute automatically the size of the elements to best fit with the scene.
  134884. */
  134885. sizeAuto: boolean;
  134886. /**
  134887. * Default position of the rootMesh if autoSize is not true.
  134888. */
  134889. rootPosition: Vector3;
  134890. /**
  134891. * Sets up the image processing in the scene.
  134892. * true by default.
  134893. */
  134894. setupImageProcessing: boolean;
  134895. /**
  134896. * The texture used as your environment texture in the scene.
  134897. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  134898. *
  134899. * Remarks: Can be either a texture or a url.
  134900. */
  134901. environmentTexture: string | BaseTexture;
  134902. /**
  134903. * The value of the exposure to apply to the scene.
  134904. * 0.6 by default if setupImageProcessing is true.
  134905. */
  134906. cameraExposure: number;
  134907. /**
  134908. * The value of the contrast to apply to the scene.
  134909. * 1.6 by default if setupImageProcessing is true.
  134910. */
  134911. cameraContrast: number;
  134912. /**
  134913. * Specifies whether or not tonemapping should be enabled in the scene.
  134914. * true by default if setupImageProcessing is true.
  134915. */
  134916. toneMappingEnabled: boolean;
  134917. }
  134918. /**
  134919. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  134920. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  134921. * It also helps with the default setup of your imageProcessing configuration.
  134922. */
  134923. export class EnvironmentHelper {
  134924. /**
  134925. * Default ground texture URL.
  134926. */
  134927. private static _groundTextureCDNUrl;
  134928. /**
  134929. * Default skybox texture URL.
  134930. */
  134931. private static _skyboxTextureCDNUrl;
  134932. /**
  134933. * Default environment texture URL.
  134934. */
  134935. private static _environmentTextureCDNUrl;
  134936. /**
  134937. * Creates the default options for the helper.
  134938. */
  134939. private static _getDefaultOptions;
  134940. private _rootMesh;
  134941. /**
  134942. * Gets the root mesh created by the helper.
  134943. */
  134944. get rootMesh(): Mesh;
  134945. private _skybox;
  134946. /**
  134947. * Gets the skybox created by the helper.
  134948. */
  134949. get skybox(): Nullable<Mesh>;
  134950. private _skyboxTexture;
  134951. /**
  134952. * Gets the skybox texture created by the helper.
  134953. */
  134954. get skyboxTexture(): Nullable<BaseTexture>;
  134955. private _skyboxMaterial;
  134956. /**
  134957. * Gets the skybox material created by the helper.
  134958. */
  134959. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  134960. private _ground;
  134961. /**
  134962. * Gets the ground mesh created by the helper.
  134963. */
  134964. get ground(): Nullable<Mesh>;
  134965. private _groundTexture;
  134966. /**
  134967. * Gets the ground texture created by the helper.
  134968. */
  134969. get groundTexture(): Nullable<BaseTexture>;
  134970. private _groundMirror;
  134971. /**
  134972. * Gets the ground mirror created by the helper.
  134973. */
  134974. get groundMirror(): Nullable<MirrorTexture>;
  134975. /**
  134976. * Gets the ground mirror render list to helps pushing the meshes
  134977. * you wish in the ground reflection.
  134978. */
  134979. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  134980. private _groundMaterial;
  134981. /**
  134982. * Gets the ground material created by the helper.
  134983. */
  134984. get groundMaterial(): Nullable<BackgroundMaterial>;
  134985. /**
  134986. * Stores the creation options.
  134987. */
  134988. private readonly _scene;
  134989. private _options;
  134990. /**
  134991. * This observable will be notified with any error during the creation of the environment,
  134992. * mainly texture creation errors.
  134993. */
  134994. onErrorObservable: Observable<{
  134995. message?: string;
  134996. exception?: any;
  134997. }>;
  134998. /**
  134999. * constructor
  135000. * @param options Defines the options we want to customize the helper
  135001. * @param scene The scene to add the material to
  135002. */
  135003. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135004. /**
  135005. * Updates the background according to the new options
  135006. * @param options
  135007. */
  135008. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135009. /**
  135010. * Sets the primary color of all the available elements.
  135011. * @param color the main color to affect to the ground and the background
  135012. */
  135013. setMainColor(color: Color3): void;
  135014. /**
  135015. * Setup the image processing according to the specified options.
  135016. */
  135017. private _setupImageProcessing;
  135018. /**
  135019. * Setup the environment texture according to the specified options.
  135020. */
  135021. private _setupEnvironmentTexture;
  135022. /**
  135023. * Setup the background according to the specified options.
  135024. */
  135025. private _setupBackground;
  135026. /**
  135027. * Get the scene sizes according to the setup.
  135028. */
  135029. private _getSceneSize;
  135030. /**
  135031. * Setup the ground according to the specified options.
  135032. */
  135033. private _setupGround;
  135034. /**
  135035. * Setup the ground material according to the specified options.
  135036. */
  135037. private _setupGroundMaterial;
  135038. /**
  135039. * Setup the ground diffuse texture according to the specified options.
  135040. */
  135041. private _setupGroundDiffuseTexture;
  135042. /**
  135043. * Setup the ground mirror texture according to the specified options.
  135044. */
  135045. private _setupGroundMirrorTexture;
  135046. /**
  135047. * Setup the ground to receive the mirror texture.
  135048. */
  135049. private _setupMirrorInGroundMaterial;
  135050. /**
  135051. * Setup the skybox according to the specified options.
  135052. */
  135053. private _setupSkybox;
  135054. /**
  135055. * Setup the skybox material according to the specified options.
  135056. */
  135057. private _setupSkyboxMaterial;
  135058. /**
  135059. * Setup the skybox reflection texture according to the specified options.
  135060. */
  135061. private _setupSkyboxReflectionTexture;
  135062. private _errorHandler;
  135063. /**
  135064. * Dispose all the elements created by the Helper.
  135065. */
  135066. dispose(): void;
  135067. }
  135068. }
  135069. declare module BABYLON {
  135070. /**
  135071. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135072. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135073. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135074. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135075. */
  135076. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135077. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135078. /**
  135079. * Define the source as a Monoscopic panoramic 360/180.
  135080. */
  135081. static readonly MODE_MONOSCOPIC: number;
  135082. /**
  135083. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135084. */
  135085. static readonly MODE_TOPBOTTOM: number;
  135086. /**
  135087. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135088. */
  135089. static readonly MODE_SIDEBYSIDE: number;
  135090. private _halfDome;
  135091. protected _useDirectMapping: boolean;
  135092. /**
  135093. * The texture being displayed on the sphere
  135094. */
  135095. protected _texture: T;
  135096. /**
  135097. * Gets the texture being displayed on the sphere
  135098. */
  135099. get texture(): T;
  135100. /**
  135101. * Sets the texture being displayed on the sphere
  135102. */
  135103. set texture(newTexture: T);
  135104. /**
  135105. * The skybox material
  135106. */
  135107. protected _material: BackgroundMaterial;
  135108. /**
  135109. * The surface used for the dome
  135110. */
  135111. protected _mesh: Mesh;
  135112. /**
  135113. * Gets the mesh used for the dome.
  135114. */
  135115. get mesh(): Mesh;
  135116. /**
  135117. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135118. */
  135119. private _halfDomeMask;
  135120. /**
  135121. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135122. * Also see the options.resolution property.
  135123. */
  135124. get fovMultiplier(): number;
  135125. set fovMultiplier(value: number);
  135126. protected _textureMode: number;
  135127. /**
  135128. * Gets or set the current texture mode for the texture. It can be:
  135129. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135130. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135131. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135132. */
  135133. get textureMode(): number;
  135134. /**
  135135. * Sets the current texture mode for the texture. It can be:
  135136. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135137. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135138. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135139. */
  135140. set textureMode(value: number);
  135141. /**
  135142. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135143. */
  135144. get halfDome(): boolean;
  135145. /**
  135146. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135147. */
  135148. set halfDome(enabled: boolean);
  135149. /**
  135150. * Oberserver used in Stereoscopic VR Mode.
  135151. */
  135152. private _onBeforeCameraRenderObserver;
  135153. /**
  135154. * Observable raised when an error occured while loading the 360 image
  135155. */
  135156. onLoadErrorObservable: Observable<string>;
  135157. /**
  135158. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135159. * @param name Element's name, child elements will append suffixes for their own names.
  135160. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135161. * @param options An object containing optional or exposed sub element properties
  135162. */
  135163. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135164. resolution?: number;
  135165. clickToPlay?: boolean;
  135166. autoPlay?: boolean;
  135167. loop?: boolean;
  135168. size?: number;
  135169. poster?: string;
  135170. faceForward?: boolean;
  135171. useDirectMapping?: boolean;
  135172. halfDomeMode?: boolean;
  135173. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135174. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135175. protected _changeTextureMode(value: number): void;
  135176. /**
  135177. * Releases resources associated with this node.
  135178. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135179. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135180. */
  135181. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135182. }
  135183. }
  135184. declare module BABYLON {
  135185. /**
  135186. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135187. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135188. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135189. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135190. */
  135191. export class PhotoDome extends TextureDome<Texture> {
  135192. /**
  135193. * Define the image as a Monoscopic panoramic 360 image.
  135194. */
  135195. static readonly MODE_MONOSCOPIC: number;
  135196. /**
  135197. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135198. */
  135199. static readonly MODE_TOPBOTTOM: number;
  135200. /**
  135201. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135202. */
  135203. static readonly MODE_SIDEBYSIDE: number;
  135204. /**
  135205. * Gets or sets the texture being displayed on the sphere
  135206. */
  135207. get photoTexture(): Texture;
  135208. /**
  135209. * sets the texture being displayed on the sphere
  135210. */
  135211. set photoTexture(value: Texture);
  135212. /**
  135213. * Gets the current video mode for the video. It can be:
  135214. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135215. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135216. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135217. */
  135218. get imageMode(): number;
  135219. /**
  135220. * Sets the current video mode for the video. It can be:
  135221. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135222. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135223. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135224. */
  135225. set imageMode(value: number);
  135226. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135227. }
  135228. }
  135229. declare module BABYLON {
  135230. /**
  135231. * Class used to host RGBD texture specific utilities
  135232. */
  135233. export class RGBDTextureTools {
  135234. /**
  135235. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135236. * @param texture the texture to expand.
  135237. */
  135238. static ExpandRGBDTexture(texture: Texture): void;
  135239. }
  135240. }
  135241. declare module BABYLON {
  135242. /**
  135243. * Class used to host texture specific utilities
  135244. */
  135245. export class BRDFTextureTools {
  135246. /**
  135247. * Prevents texture cache collision
  135248. */
  135249. private static _instanceNumber;
  135250. /**
  135251. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135252. * @param scene defines the hosting scene
  135253. * @returns the environment BRDF texture
  135254. */
  135255. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135256. private static _environmentBRDFBase64Texture;
  135257. }
  135258. }
  135259. declare module BABYLON {
  135260. /**
  135261. * @hidden
  135262. */
  135263. export interface IMaterialClearCoatDefines {
  135264. CLEARCOAT: boolean;
  135265. CLEARCOAT_DEFAULTIOR: boolean;
  135266. CLEARCOAT_TEXTURE: boolean;
  135267. CLEARCOAT_TEXTUREDIRECTUV: number;
  135268. CLEARCOAT_BUMP: boolean;
  135269. CLEARCOAT_BUMPDIRECTUV: number;
  135270. CLEARCOAT_TINT: boolean;
  135271. CLEARCOAT_TINT_TEXTURE: boolean;
  135272. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135273. /** @hidden */
  135274. _areTexturesDirty: boolean;
  135275. }
  135276. /**
  135277. * Define the code related to the clear coat parameters of the pbr material.
  135278. */
  135279. export class PBRClearCoatConfiguration {
  135280. /**
  135281. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135282. * The default fits with a polyurethane material.
  135283. */
  135284. private static readonly _DefaultIndexOfRefraction;
  135285. private _isEnabled;
  135286. /**
  135287. * Defines if the clear coat is enabled in the material.
  135288. */
  135289. isEnabled: boolean;
  135290. /**
  135291. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135292. */
  135293. intensity: number;
  135294. /**
  135295. * Defines the clear coat layer roughness.
  135296. */
  135297. roughness: number;
  135298. private _indexOfRefraction;
  135299. /**
  135300. * Defines the index of refraction of the clear coat.
  135301. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135302. * The default fits with a polyurethane material.
  135303. * Changing the default value is more performance intensive.
  135304. */
  135305. indexOfRefraction: number;
  135306. private _texture;
  135307. /**
  135308. * Stores the clear coat values in a texture.
  135309. */
  135310. texture: Nullable<BaseTexture>;
  135311. private _bumpTexture;
  135312. /**
  135313. * Define the clear coat specific bump texture.
  135314. */
  135315. bumpTexture: Nullable<BaseTexture>;
  135316. private _isTintEnabled;
  135317. /**
  135318. * Defines if the clear coat tint is enabled in the material.
  135319. */
  135320. isTintEnabled: boolean;
  135321. /**
  135322. * Defines the clear coat tint of the material.
  135323. * This is only use if tint is enabled
  135324. */
  135325. tintColor: Color3;
  135326. /**
  135327. * Defines the distance at which the tint color should be found in the
  135328. * clear coat media.
  135329. * This is only use if tint is enabled
  135330. */
  135331. tintColorAtDistance: number;
  135332. /**
  135333. * Defines the clear coat layer thickness.
  135334. * This is only use if tint is enabled
  135335. */
  135336. tintThickness: number;
  135337. private _tintTexture;
  135338. /**
  135339. * Stores the clear tint values in a texture.
  135340. * rgb is tint
  135341. * a is a thickness factor
  135342. */
  135343. tintTexture: Nullable<BaseTexture>;
  135344. /** @hidden */
  135345. private _internalMarkAllSubMeshesAsTexturesDirty;
  135346. /** @hidden */
  135347. _markAllSubMeshesAsTexturesDirty(): void;
  135348. /**
  135349. * Instantiate a new istance of clear coat configuration.
  135350. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135351. */
  135352. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135353. /**
  135354. * Gets wehter the submesh is ready to be used or not.
  135355. * @param defines the list of "defines" to update.
  135356. * @param scene defines the scene the material belongs to.
  135357. * @param engine defines the engine the material belongs to.
  135358. * @param disableBumpMap defines wether the material disables bump or not.
  135359. * @returns - boolean indicating that the submesh is ready or not.
  135360. */
  135361. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135362. /**
  135363. * Checks to see if a texture is used in the material.
  135364. * @param defines the list of "defines" to update.
  135365. * @param scene defines the scene to the material belongs to.
  135366. */
  135367. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135368. /**
  135369. * Binds the material data.
  135370. * @param uniformBuffer defines the Uniform buffer to fill in.
  135371. * @param scene defines the scene the material belongs to.
  135372. * @param engine defines the engine the material belongs to.
  135373. * @param disableBumpMap defines wether the material disables bump or not.
  135374. * @param isFrozen defines wether the material is frozen or not.
  135375. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135376. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135377. */
  135378. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135379. /**
  135380. * Checks to see if a texture is used in the material.
  135381. * @param texture - Base texture to use.
  135382. * @returns - Boolean specifying if a texture is used in the material.
  135383. */
  135384. hasTexture(texture: BaseTexture): boolean;
  135385. /**
  135386. * Returns an array of the actively used textures.
  135387. * @param activeTextures Array of BaseTextures
  135388. */
  135389. getActiveTextures(activeTextures: BaseTexture[]): void;
  135390. /**
  135391. * Returns the animatable textures.
  135392. * @param animatables Array of animatable textures.
  135393. */
  135394. getAnimatables(animatables: IAnimatable[]): void;
  135395. /**
  135396. * Disposes the resources of the material.
  135397. * @param forceDisposeTextures - Forces the disposal of all textures.
  135398. */
  135399. dispose(forceDisposeTextures?: boolean): void;
  135400. /**
  135401. * Get the current class name of the texture useful for serialization or dynamic coding.
  135402. * @returns "PBRClearCoatConfiguration"
  135403. */
  135404. getClassName(): string;
  135405. /**
  135406. * Add fallbacks to the effect fallbacks list.
  135407. * @param defines defines the Base texture to use.
  135408. * @param fallbacks defines the current fallback list.
  135409. * @param currentRank defines the current fallback rank.
  135410. * @returns the new fallback rank.
  135411. */
  135412. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135413. /**
  135414. * Add the required uniforms to the current list.
  135415. * @param uniforms defines the current uniform list.
  135416. */
  135417. static AddUniforms(uniforms: string[]): void;
  135418. /**
  135419. * Add the required samplers to the current list.
  135420. * @param samplers defines the current sampler list.
  135421. */
  135422. static AddSamplers(samplers: string[]): void;
  135423. /**
  135424. * Add the required uniforms to the current buffer.
  135425. * @param uniformBuffer defines the current uniform buffer.
  135426. */
  135427. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135428. /**
  135429. * Makes a duplicate of the current configuration into another one.
  135430. * @param clearCoatConfiguration define the config where to copy the info
  135431. */
  135432. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135433. /**
  135434. * Serializes this clear coat configuration.
  135435. * @returns - An object with the serialized config.
  135436. */
  135437. serialize(): any;
  135438. /**
  135439. * Parses a anisotropy Configuration from a serialized object.
  135440. * @param source - Serialized object.
  135441. * @param scene Defines the scene we are parsing for
  135442. * @param rootUrl Defines the rootUrl to load from
  135443. */
  135444. parse(source: any, scene: Scene, rootUrl: string): void;
  135445. }
  135446. }
  135447. declare module BABYLON {
  135448. /**
  135449. * @hidden
  135450. */
  135451. export interface IMaterialAnisotropicDefines {
  135452. ANISOTROPIC: boolean;
  135453. ANISOTROPIC_TEXTURE: boolean;
  135454. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135455. MAINUV1: boolean;
  135456. _areTexturesDirty: boolean;
  135457. _needUVs: boolean;
  135458. }
  135459. /**
  135460. * Define the code related to the anisotropic parameters of the pbr material.
  135461. */
  135462. export class PBRAnisotropicConfiguration {
  135463. private _isEnabled;
  135464. /**
  135465. * Defines if the anisotropy is enabled in the material.
  135466. */
  135467. isEnabled: boolean;
  135468. /**
  135469. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135470. */
  135471. intensity: number;
  135472. /**
  135473. * Defines if the effect is along the tangents, bitangents or in between.
  135474. * By default, the effect is "strectching" the highlights along the tangents.
  135475. */
  135476. direction: Vector2;
  135477. private _texture;
  135478. /**
  135479. * Stores the anisotropy values in a texture.
  135480. * rg is direction (like normal from -1 to 1)
  135481. * b is a intensity
  135482. */
  135483. texture: Nullable<BaseTexture>;
  135484. /** @hidden */
  135485. private _internalMarkAllSubMeshesAsTexturesDirty;
  135486. /** @hidden */
  135487. _markAllSubMeshesAsTexturesDirty(): void;
  135488. /**
  135489. * Instantiate a new istance of anisotropy configuration.
  135490. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135491. */
  135492. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135493. /**
  135494. * Specifies that the submesh is ready to be used.
  135495. * @param defines the list of "defines" to update.
  135496. * @param scene defines the scene the material belongs to.
  135497. * @returns - boolean indicating that the submesh is ready or not.
  135498. */
  135499. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135500. /**
  135501. * Checks to see if a texture is used in the material.
  135502. * @param defines the list of "defines" to update.
  135503. * @param mesh the mesh we are preparing the defines for.
  135504. * @param scene defines the scene the material belongs to.
  135505. */
  135506. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135507. /**
  135508. * Binds the material data.
  135509. * @param uniformBuffer defines the Uniform buffer to fill in.
  135510. * @param scene defines the scene the material belongs to.
  135511. * @param isFrozen defines wether the material is frozen or not.
  135512. */
  135513. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135514. /**
  135515. * Checks to see if a texture is used in the material.
  135516. * @param texture - Base texture to use.
  135517. * @returns - Boolean specifying if a texture is used in the material.
  135518. */
  135519. hasTexture(texture: BaseTexture): boolean;
  135520. /**
  135521. * Returns an array of the actively used textures.
  135522. * @param activeTextures Array of BaseTextures
  135523. */
  135524. getActiveTextures(activeTextures: BaseTexture[]): void;
  135525. /**
  135526. * Returns the animatable textures.
  135527. * @param animatables Array of animatable textures.
  135528. */
  135529. getAnimatables(animatables: IAnimatable[]): void;
  135530. /**
  135531. * Disposes the resources of the material.
  135532. * @param forceDisposeTextures - Forces the disposal of all textures.
  135533. */
  135534. dispose(forceDisposeTextures?: boolean): void;
  135535. /**
  135536. * Get the current class name of the texture useful for serialization or dynamic coding.
  135537. * @returns "PBRAnisotropicConfiguration"
  135538. */
  135539. getClassName(): string;
  135540. /**
  135541. * Add fallbacks to the effect fallbacks list.
  135542. * @param defines defines the Base texture to use.
  135543. * @param fallbacks defines the current fallback list.
  135544. * @param currentRank defines the current fallback rank.
  135545. * @returns the new fallback rank.
  135546. */
  135547. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135548. /**
  135549. * Add the required uniforms to the current list.
  135550. * @param uniforms defines the current uniform list.
  135551. */
  135552. static AddUniforms(uniforms: string[]): void;
  135553. /**
  135554. * Add the required uniforms to the current buffer.
  135555. * @param uniformBuffer defines the current uniform buffer.
  135556. */
  135557. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135558. /**
  135559. * Add the required samplers to the current list.
  135560. * @param samplers defines the current sampler list.
  135561. */
  135562. static AddSamplers(samplers: string[]): void;
  135563. /**
  135564. * Makes a duplicate of the current configuration into another one.
  135565. * @param anisotropicConfiguration define the config where to copy the info
  135566. */
  135567. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135568. /**
  135569. * Serializes this anisotropy configuration.
  135570. * @returns - An object with the serialized config.
  135571. */
  135572. serialize(): any;
  135573. /**
  135574. * Parses a anisotropy Configuration from a serialized object.
  135575. * @param source - Serialized object.
  135576. * @param scene Defines the scene we are parsing for
  135577. * @param rootUrl Defines the rootUrl to load from
  135578. */
  135579. parse(source: any, scene: Scene, rootUrl: string): void;
  135580. }
  135581. }
  135582. declare module BABYLON {
  135583. /**
  135584. * @hidden
  135585. */
  135586. export interface IMaterialBRDFDefines {
  135587. BRDF_V_HEIGHT_CORRELATED: boolean;
  135588. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135589. SPHERICAL_HARMONICS: boolean;
  135590. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135591. /** @hidden */
  135592. _areMiscDirty: boolean;
  135593. }
  135594. /**
  135595. * Define the code related to the BRDF parameters of the pbr material.
  135596. */
  135597. export class PBRBRDFConfiguration {
  135598. /**
  135599. * Default value used for the energy conservation.
  135600. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135601. */
  135602. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135603. /**
  135604. * Default value used for the Smith Visibility Height Correlated mode.
  135605. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135606. */
  135607. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  135608. /**
  135609. * Default value used for the IBL diffuse part.
  135610. * This can help switching back to the polynomials mode globally which is a tiny bit
  135611. * less GPU intensive at the drawback of a lower quality.
  135612. */
  135613. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  135614. /**
  135615. * Default value used for activating energy conservation for the specular workflow.
  135616. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135617. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135618. */
  135619. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  135620. private _useEnergyConservation;
  135621. /**
  135622. * Defines if the material uses energy conservation.
  135623. */
  135624. useEnergyConservation: boolean;
  135625. private _useSmithVisibilityHeightCorrelated;
  135626. /**
  135627. * LEGACY Mode set to false
  135628. * Defines if the material uses height smith correlated visibility term.
  135629. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  135630. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  135631. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  135632. * Not relying on height correlated will also disable energy conservation.
  135633. */
  135634. useSmithVisibilityHeightCorrelated: boolean;
  135635. private _useSphericalHarmonics;
  135636. /**
  135637. * LEGACY Mode set to false
  135638. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  135639. * diffuse part of the IBL.
  135640. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  135641. * to the ground truth.
  135642. */
  135643. useSphericalHarmonics: boolean;
  135644. private _useSpecularGlossinessInputEnergyConservation;
  135645. /**
  135646. * Defines if the material uses energy conservation, when the specular workflow is active.
  135647. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135648. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135649. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  135650. */
  135651. useSpecularGlossinessInputEnergyConservation: boolean;
  135652. /** @hidden */
  135653. private _internalMarkAllSubMeshesAsMiscDirty;
  135654. /** @hidden */
  135655. _markAllSubMeshesAsMiscDirty(): void;
  135656. /**
  135657. * Instantiate a new istance of clear coat configuration.
  135658. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  135659. */
  135660. constructor(markAllSubMeshesAsMiscDirty: () => void);
  135661. /**
  135662. * Checks to see if a texture is used in the material.
  135663. * @param defines the list of "defines" to update.
  135664. */
  135665. prepareDefines(defines: IMaterialBRDFDefines): void;
  135666. /**
  135667. * Get the current class name of the texture useful for serialization or dynamic coding.
  135668. * @returns "PBRClearCoatConfiguration"
  135669. */
  135670. getClassName(): string;
  135671. /**
  135672. * Makes a duplicate of the current configuration into another one.
  135673. * @param brdfConfiguration define the config where to copy the info
  135674. */
  135675. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  135676. /**
  135677. * Serializes this BRDF configuration.
  135678. * @returns - An object with the serialized config.
  135679. */
  135680. serialize(): any;
  135681. /**
  135682. * Parses a anisotropy Configuration from a serialized object.
  135683. * @param source - Serialized object.
  135684. * @param scene Defines the scene we are parsing for
  135685. * @param rootUrl Defines the rootUrl to load from
  135686. */
  135687. parse(source: any, scene: Scene, rootUrl: string): void;
  135688. }
  135689. }
  135690. declare module BABYLON {
  135691. /**
  135692. * @hidden
  135693. */
  135694. export interface IMaterialSheenDefines {
  135695. SHEEN: boolean;
  135696. SHEEN_TEXTURE: boolean;
  135697. SHEEN_TEXTUREDIRECTUV: number;
  135698. SHEEN_LINKWITHALBEDO: boolean;
  135699. SHEEN_ROUGHNESS: boolean;
  135700. SHEEN_ALBEDOSCALING: boolean;
  135701. /** @hidden */
  135702. _areTexturesDirty: boolean;
  135703. }
  135704. /**
  135705. * Define the code related to the Sheen parameters of the pbr material.
  135706. */
  135707. export class PBRSheenConfiguration {
  135708. private _isEnabled;
  135709. /**
  135710. * Defines if the material uses sheen.
  135711. */
  135712. isEnabled: boolean;
  135713. private _linkSheenWithAlbedo;
  135714. /**
  135715. * Defines if the sheen is linked to the sheen color.
  135716. */
  135717. linkSheenWithAlbedo: boolean;
  135718. /**
  135719. * Defines the sheen intensity.
  135720. */
  135721. intensity: number;
  135722. /**
  135723. * Defines the sheen color.
  135724. */
  135725. color: Color3;
  135726. private _texture;
  135727. /**
  135728. * Stores the sheen tint values in a texture.
  135729. * rgb is tint
  135730. * a is a intensity or roughness if roughness has been defined
  135731. */
  135732. texture: Nullable<BaseTexture>;
  135733. private _roughness;
  135734. /**
  135735. * Defines the sheen roughness.
  135736. * It is not taken into account if linkSheenWithAlbedo is true.
  135737. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  135738. */
  135739. roughness: Nullable<number>;
  135740. private _albedoScaling;
  135741. /**
  135742. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  135743. * It allows the strength of the sheen effect to not depend on the base color of the material,
  135744. * making it easier to setup and tweak the effect
  135745. */
  135746. albedoScaling: boolean;
  135747. /** @hidden */
  135748. private _internalMarkAllSubMeshesAsTexturesDirty;
  135749. /** @hidden */
  135750. _markAllSubMeshesAsTexturesDirty(): void;
  135751. /**
  135752. * Instantiate a new istance of clear coat configuration.
  135753. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135754. */
  135755. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135756. /**
  135757. * Specifies that the submesh is ready to be used.
  135758. * @param defines the list of "defines" to update.
  135759. * @param scene defines the scene the material belongs to.
  135760. * @returns - boolean indicating that the submesh is ready or not.
  135761. */
  135762. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  135763. /**
  135764. * Checks to see if a texture is used in the material.
  135765. * @param defines the list of "defines" to update.
  135766. * @param scene defines the scene the material belongs to.
  135767. */
  135768. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  135769. /**
  135770. * Binds the material data.
  135771. * @param uniformBuffer defines the Uniform buffer to fill in.
  135772. * @param scene defines the scene the material belongs to.
  135773. * @param isFrozen defines wether the material is frozen or not.
  135774. */
  135775. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135776. /**
  135777. * Checks to see if a texture is used in the material.
  135778. * @param texture - Base texture to use.
  135779. * @returns - Boolean specifying if a texture is used in the material.
  135780. */
  135781. hasTexture(texture: BaseTexture): boolean;
  135782. /**
  135783. * Returns an array of the actively used textures.
  135784. * @param activeTextures Array of BaseTextures
  135785. */
  135786. getActiveTextures(activeTextures: BaseTexture[]): void;
  135787. /**
  135788. * Returns the animatable textures.
  135789. * @param animatables Array of animatable textures.
  135790. */
  135791. getAnimatables(animatables: IAnimatable[]): void;
  135792. /**
  135793. * Disposes the resources of the material.
  135794. * @param forceDisposeTextures - Forces the disposal of all textures.
  135795. */
  135796. dispose(forceDisposeTextures?: boolean): void;
  135797. /**
  135798. * Get the current class name of the texture useful for serialization or dynamic coding.
  135799. * @returns "PBRSheenConfiguration"
  135800. */
  135801. getClassName(): string;
  135802. /**
  135803. * Add fallbacks to the effect fallbacks list.
  135804. * @param defines defines the Base texture to use.
  135805. * @param fallbacks defines the current fallback list.
  135806. * @param currentRank defines the current fallback rank.
  135807. * @returns the new fallback rank.
  135808. */
  135809. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135810. /**
  135811. * Add the required uniforms to the current list.
  135812. * @param uniforms defines the current uniform list.
  135813. */
  135814. static AddUniforms(uniforms: string[]): void;
  135815. /**
  135816. * Add the required uniforms to the current buffer.
  135817. * @param uniformBuffer defines the current uniform buffer.
  135818. */
  135819. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135820. /**
  135821. * Add the required samplers to the current list.
  135822. * @param samplers defines the current sampler list.
  135823. */
  135824. static AddSamplers(samplers: string[]): void;
  135825. /**
  135826. * Makes a duplicate of the current configuration into another one.
  135827. * @param sheenConfiguration define the config where to copy the info
  135828. */
  135829. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  135830. /**
  135831. * Serializes this BRDF configuration.
  135832. * @returns - An object with the serialized config.
  135833. */
  135834. serialize(): any;
  135835. /**
  135836. * Parses a anisotropy Configuration from a serialized object.
  135837. * @param source - Serialized object.
  135838. * @param scene Defines the scene we are parsing for
  135839. * @param rootUrl Defines the rootUrl to load from
  135840. */
  135841. parse(source: any, scene: Scene, rootUrl: string): void;
  135842. }
  135843. }
  135844. declare module BABYLON {
  135845. /**
  135846. * @hidden
  135847. */
  135848. export interface IMaterialSubSurfaceDefines {
  135849. SUBSURFACE: boolean;
  135850. SS_REFRACTION: boolean;
  135851. SS_TRANSLUCENCY: boolean;
  135852. SS_SCATTERING: boolean;
  135853. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135854. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135855. SS_REFRACTIONMAP_3D: boolean;
  135856. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135857. SS_LODINREFRACTIONALPHA: boolean;
  135858. SS_GAMMAREFRACTION: boolean;
  135859. SS_RGBDREFRACTION: boolean;
  135860. SS_LINEARSPECULARREFRACTION: boolean;
  135861. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135862. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135863. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135864. /** @hidden */
  135865. _areTexturesDirty: boolean;
  135866. }
  135867. /**
  135868. * Define the code related to the sub surface parameters of the pbr material.
  135869. */
  135870. export class PBRSubSurfaceConfiguration {
  135871. private _isRefractionEnabled;
  135872. /**
  135873. * Defines if the refraction is enabled in the material.
  135874. */
  135875. isRefractionEnabled: boolean;
  135876. private _isTranslucencyEnabled;
  135877. /**
  135878. * Defines if the translucency is enabled in the material.
  135879. */
  135880. isTranslucencyEnabled: boolean;
  135881. private _isScatteringEnabled;
  135882. /**
  135883. * Defines if the sub surface scattering is enabled in the material.
  135884. */
  135885. isScatteringEnabled: boolean;
  135886. private _scatteringDiffusionProfileIndex;
  135887. /**
  135888. * Diffusion profile for subsurface scattering.
  135889. * Useful for better scattering in the skins or foliages.
  135890. */
  135891. get scatteringDiffusionProfile(): Nullable<Color3>;
  135892. set scatteringDiffusionProfile(c: Nullable<Color3>);
  135893. /**
  135894. * Defines the refraction intensity of the material.
  135895. * The refraction when enabled replaces the Diffuse part of the material.
  135896. * The intensity helps transitionning between diffuse and refraction.
  135897. */
  135898. refractionIntensity: number;
  135899. /**
  135900. * Defines the translucency intensity of the material.
  135901. * When translucency has been enabled, this defines how much of the "translucency"
  135902. * is addded to the diffuse part of the material.
  135903. */
  135904. translucencyIntensity: number;
  135905. /**
  135906. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  135907. */
  135908. useAlbedoToTintRefraction: boolean;
  135909. private _thicknessTexture;
  135910. /**
  135911. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  135912. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  135913. * 0 would mean minimumThickness
  135914. * 1 would mean maximumThickness
  135915. * The other channels might be use as a mask to vary the different effects intensity.
  135916. */
  135917. thicknessTexture: Nullable<BaseTexture>;
  135918. private _refractionTexture;
  135919. /**
  135920. * Defines the texture to use for refraction.
  135921. */
  135922. refractionTexture: Nullable<BaseTexture>;
  135923. private _indexOfRefraction;
  135924. /**
  135925. * Index of refraction of the material base layer.
  135926. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135927. *
  135928. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135929. *
  135930. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135931. */
  135932. indexOfRefraction: number;
  135933. private _volumeIndexOfRefraction;
  135934. /**
  135935. * Index of refraction of the material's volume.
  135936. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135937. *
  135938. * This ONLY impacts refraction. If not provided or given a non-valid value,
  135939. * the volume will use the same IOR as the surface.
  135940. */
  135941. get volumeIndexOfRefraction(): number;
  135942. set volumeIndexOfRefraction(value: number);
  135943. private _invertRefractionY;
  135944. /**
  135945. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135946. */
  135947. invertRefractionY: boolean;
  135948. private _linkRefractionWithTransparency;
  135949. /**
  135950. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135951. * Materials half opaque for instance using refraction could benefit from this control.
  135952. */
  135953. linkRefractionWithTransparency: boolean;
  135954. /**
  135955. * Defines the minimum thickness stored in the thickness map.
  135956. * If no thickness map is defined, this value will be used to simulate thickness.
  135957. */
  135958. minimumThickness: number;
  135959. /**
  135960. * Defines the maximum thickness stored in the thickness map.
  135961. */
  135962. maximumThickness: number;
  135963. /**
  135964. * Defines the volume tint of the material.
  135965. * This is used for both translucency and scattering.
  135966. */
  135967. tintColor: Color3;
  135968. /**
  135969. * Defines the distance at which the tint color should be found in the media.
  135970. * This is used for refraction only.
  135971. */
  135972. tintColorAtDistance: number;
  135973. /**
  135974. * Defines how far each channel transmit through the media.
  135975. * It is defined as a color to simplify it selection.
  135976. */
  135977. diffusionDistance: Color3;
  135978. private _useMaskFromThicknessTexture;
  135979. /**
  135980. * Stores the intensity of the different subsurface effects in the thickness texture.
  135981. * * the green channel is the translucency intensity.
  135982. * * the blue channel is the scattering intensity.
  135983. * * the alpha channel is the refraction intensity.
  135984. */
  135985. useMaskFromThicknessTexture: boolean;
  135986. private _scene;
  135987. /** @hidden */
  135988. private _internalMarkAllSubMeshesAsTexturesDirty;
  135989. private _internalMarkScenePrePassDirty;
  135990. /** @hidden */
  135991. _markAllSubMeshesAsTexturesDirty(): void;
  135992. /** @hidden */
  135993. _markScenePrePassDirty(): void;
  135994. /**
  135995. * Instantiate a new istance of sub surface configuration.
  135996. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135997. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  135998. * @param scene The scene
  135999. */
  136000. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136001. /**
  136002. * Gets wehter the submesh is ready to be used or not.
  136003. * @param defines the list of "defines" to update.
  136004. * @param scene defines the scene the material belongs to.
  136005. * @returns - boolean indicating that the submesh is ready or not.
  136006. */
  136007. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136008. /**
  136009. * Checks to see if a texture is used in the material.
  136010. * @param defines the list of "defines" to update.
  136011. * @param scene defines the scene to the material belongs to.
  136012. */
  136013. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136014. /**
  136015. * Binds the material data.
  136016. * @param uniformBuffer defines the Uniform buffer to fill in.
  136017. * @param scene defines the scene the material belongs to.
  136018. * @param engine defines the engine the material belongs to.
  136019. * @param isFrozen defines whether the material is frozen or not.
  136020. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136021. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136022. */
  136023. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136024. /**
  136025. * Unbinds the material from the mesh.
  136026. * @param activeEffect defines the effect that should be unbound from.
  136027. * @returns true if unbound, otherwise false
  136028. */
  136029. unbind(activeEffect: Effect): boolean;
  136030. /**
  136031. * Returns the texture used for refraction or null if none is used.
  136032. * @param scene defines the scene the material belongs to.
  136033. * @returns - Refraction texture if present. If no refraction texture and refraction
  136034. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136035. */
  136036. private _getRefractionTexture;
  136037. /**
  136038. * Returns true if alpha blending should be disabled.
  136039. */
  136040. get disableAlphaBlending(): boolean;
  136041. /**
  136042. * Fills the list of render target textures.
  136043. * @param renderTargets the list of render targets to update
  136044. */
  136045. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136046. /**
  136047. * Checks to see if a texture is used in the material.
  136048. * @param texture - Base texture to use.
  136049. * @returns - Boolean specifying if a texture is used in the material.
  136050. */
  136051. hasTexture(texture: BaseTexture): boolean;
  136052. /**
  136053. * Gets a boolean indicating that current material needs to register RTT
  136054. * @returns true if this uses a render target otherwise false.
  136055. */
  136056. hasRenderTargetTextures(): boolean;
  136057. /**
  136058. * Returns an array of the actively used textures.
  136059. * @param activeTextures Array of BaseTextures
  136060. */
  136061. getActiveTextures(activeTextures: BaseTexture[]): void;
  136062. /**
  136063. * Returns the animatable textures.
  136064. * @param animatables Array of animatable textures.
  136065. */
  136066. getAnimatables(animatables: IAnimatable[]): void;
  136067. /**
  136068. * Disposes the resources of the material.
  136069. * @param forceDisposeTextures - Forces the disposal of all textures.
  136070. */
  136071. dispose(forceDisposeTextures?: boolean): void;
  136072. /**
  136073. * Get the current class name of the texture useful for serialization or dynamic coding.
  136074. * @returns "PBRSubSurfaceConfiguration"
  136075. */
  136076. getClassName(): string;
  136077. /**
  136078. * Add fallbacks to the effect fallbacks list.
  136079. * @param defines defines the Base texture to use.
  136080. * @param fallbacks defines the current fallback list.
  136081. * @param currentRank defines the current fallback rank.
  136082. * @returns the new fallback rank.
  136083. */
  136084. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136085. /**
  136086. * Add the required uniforms to the current list.
  136087. * @param uniforms defines the current uniform list.
  136088. */
  136089. static AddUniforms(uniforms: string[]): void;
  136090. /**
  136091. * Add the required samplers to the current list.
  136092. * @param samplers defines the current sampler list.
  136093. */
  136094. static AddSamplers(samplers: string[]): void;
  136095. /**
  136096. * Add the required uniforms to the current buffer.
  136097. * @param uniformBuffer defines the current uniform buffer.
  136098. */
  136099. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136100. /**
  136101. * Makes a duplicate of the current configuration into another one.
  136102. * @param configuration define the config where to copy the info
  136103. */
  136104. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136105. /**
  136106. * Serializes this Sub Surface configuration.
  136107. * @returns - An object with the serialized config.
  136108. */
  136109. serialize(): any;
  136110. /**
  136111. * Parses a anisotropy Configuration from a serialized object.
  136112. * @param source - Serialized object.
  136113. * @param scene Defines the scene we are parsing for
  136114. * @param rootUrl Defines the rootUrl to load from
  136115. */
  136116. parse(source: any, scene: Scene, rootUrl: string): void;
  136117. }
  136118. }
  136119. declare module BABYLON {
  136120. /** @hidden */
  136121. export var pbrFragmentDeclaration: {
  136122. name: string;
  136123. shader: string;
  136124. };
  136125. }
  136126. declare module BABYLON {
  136127. /** @hidden */
  136128. export var pbrUboDeclaration: {
  136129. name: string;
  136130. shader: string;
  136131. };
  136132. }
  136133. declare module BABYLON {
  136134. /** @hidden */
  136135. export var pbrFragmentExtraDeclaration: {
  136136. name: string;
  136137. shader: string;
  136138. };
  136139. }
  136140. declare module BABYLON {
  136141. /** @hidden */
  136142. export var pbrFragmentSamplersDeclaration: {
  136143. name: string;
  136144. shader: string;
  136145. };
  136146. }
  136147. declare module BABYLON {
  136148. /** @hidden */
  136149. export var importanceSampling: {
  136150. name: string;
  136151. shader: string;
  136152. };
  136153. }
  136154. declare module BABYLON {
  136155. /** @hidden */
  136156. export var pbrHelperFunctions: {
  136157. name: string;
  136158. shader: string;
  136159. };
  136160. }
  136161. declare module BABYLON {
  136162. /** @hidden */
  136163. export var harmonicsFunctions: {
  136164. name: string;
  136165. shader: string;
  136166. };
  136167. }
  136168. declare module BABYLON {
  136169. /** @hidden */
  136170. export var pbrDirectLightingSetupFunctions: {
  136171. name: string;
  136172. shader: string;
  136173. };
  136174. }
  136175. declare module BABYLON {
  136176. /** @hidden */
  136177. export var pbrDirectLightingFalloffFunctions: {
  136178. name: string;
  136179. shader: string;
  136180. };
  136181. }
  136182. declare module BABYLON {
  136183. /** @hidden */
  136184. export var pbrBRDFFunctions: {
  136185. name: string;
  136186. shader: string;
  136187. };
  136188. }
  136189. declare module BABYLON {
  136190. /** @hidden */
  136191. export var hdrFilteringFunctions: {
  136192. name: string;
  136193. shader: string;
  136194. };
  136195. }
  136196. declare module BABYLON {
  136197. /** @hidden */
  136198. export var pbrDirectLightingFunctions: {
  136199. name: string;
  136200. shader: string;
  136201. };
  136202. }
  136203. declare module BABYLON {
  136204. /** @hidden */
  136205. export var pbrIBLFunctions: {
  136206. name: string;
  136207. shader: string;
  136208. };
  136209. }
  136210. declare module BABYLON {
  136211. /** @hidden */
  136212. export var pbrBlockAlbedoOpacity: {
  136213. name: string;
  136214. shader: string;
  136215. };
  136216. }
  136217. declare module BABYLON {
  136218. /** @hidden */
  136219. export var pbrBlockReflectivity: {
  136220. name: string;
  136221. shader: string;
  136222. };
  136223. }
  136224. declare module BABYLON {
  136225. /** @hidden */
  136226. export var pbrBlockAmbientOcclusion: {
  136227. name: string;
  136228. shader: string;
  136229. };
  136230. }
  136231. declare module BABYLON {
  136232. /** @hidden */
  136233. export var pbrBlockAlphaFresnel: {
  136234. name: string;
  136235. shader: string;
  136236. };
  136237. }
  136238. declare module BABYLON {
  136239. /** @hidden */
  136240. export var pbrBlockAnisotropic: {
  136241. name: string;
  136242. shader: string;
  136243. };
  136244. }
  136245. declare module BABYLON {
  136246. /** @hidden */
  136247. export var pbrBlockReflection: {
  136248. name: string;
  136249. shader: string;
  136250. };
  136251. }
  136252. declare module BABYLON {
  136253. /** @hidden */
  136254. export var pbrBlockSheen: {
  136255. name: string;
  136256. shader: string;
  136257. };
  136258. }
  136259. declare module BABYLON {
  136260. /** @hidden */
  136261. export var pbrBlockClearcoat: {
  136262. name: string;
  136263. shader: string;
  136264. };
  136265. }
  136266. declare module BABYLON {
  136267. /** @hidden */
  136268. export var pbrBlockSubSurface: {
  136269. name: string;
  136270. shader: string;
  136271. };
  136272. }
  136273. declare module BABYLON {
  136274. /** @hidden */
  136275. export var pbrBlockNormalGeometric: {
  136276. name: string;
  136277. shader: string;
  136278. };
  136279. }
  136280. declare module BABYLON {
  136281. /** @hidden */
  136282. export var pbrBlockNormalFinal: {
  136283. name: string;
  136284. shader: string;
  136285. };
  136286. }
  136287. declare module BABYLON {
  136288. /** @hidden */
  136289. export var pbrBlockLightmapInit: {
  136290. name: string;
  136291. shader: string;
  136292. };
  136293. }
  136294. declare module BABYLON {
  136295. /** @hidden */
  136296. export var pbrBlockGeometryInfo: {
  136297. name: string;
  136298. shader: string;
  136299. };
  136300. }
  136301. declare module BABYLON {
  136302. /** @hidden */
  136303. export var pbrBlockReflectance0: {
  136304. name: string;
  136305. shader: string;
  136306. };
  136307. }
  136308. declare module BABYLON {
  136309. /** @hidden */
  136310. export var pbrBlockReflectance: {
  136311. name: string;
  136312. shader: string;
  136313. };
  136314. }
  136315. declare module BABYLON {
  136316. /** @hidden */
  136317. export var pbrBlockDirectLighting: {
  136318. name: string;
  136319. shader: string;
  136320. };
  136321. }
  136322. declare module BABYLON {
  136323. /** @hidden */
  136324. export var pbrBlockFinalLitComponents: {
  136325. name: string;
  136326. shader: string;
  136327. };
  136328. }
  136329. declare module BABYLON {
  136330. /** @hidden */
  136331. export var pbrBlockFinalUnlitComponents: {
  136332. name: string;
  136333. shader: string;
  136334. };
  136335. }
  136336. declare module BABYLON {
  136337. /** @hidden */
  136338. export var pbrBlockFinalColorComposition: {
  136339. name: string;
  136340. shader: string;
  136341. };
  136342. }
  136343. declare module BABYLON {
  136344. /** @hidden */
  136345. export var pbrBlockImageProcessing: {
  136346. name: string;
  136347. shader: string;
  136348. };
  136349. }
  136350. declare module BABYLON {
  136351. /** @hidden */
  136352. export var pbrDebug: {
  136353. name: string;
  136354. shader: string;
  136355. };
  136356. }
  136357. declare module BABYLON {
  136358. /** @hidden */
  136359. export var pbrPixelShader: {
  136360. name: string;
  136361. shader: string;
  136362. };
  136363. }
  136364. declare module BABYLON {
  136365. /** @hidden */
  136366. export var pbrVertexDeclaration: {
  136367. name: string;
  136368. shader: string;
  136369. };
  136370. }
  136371. declare module BABYLON {
  136372. /** @hidden */
  136373. export var pbrVertexShader: {
  136374. name: string;
  136375. shader: string;
  136376. };
  136377. }
  136378. declare module BABYLON {
  136379. /**
  136380. * Manages the defines for the PBR Material.
  136381. * @hidden
  136382. */
  136383. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136384. PBR: boolean;
  136385. NUM_SAMPLES: string;
  136386. REALTIME_FILTERING: boolean;
  136387. MAINUV1: boolean;
  136388. MAINUV2: boolean;
  136389. UV1: boolean;
  136390. UV2: boolean;
  136391. ALBEDO: boolean;
  136392. GAMMAALBEDO: boolean;
  136393. ALBEDODIRECTUV: number;
  136394. VERTEXCOLOR: boolean;
  136395. DETAIL: boolean;
  136396. DETAILDIRECTUV: number;
  136397. DETAIL_NORMALBLENDMETHOD: number;
  136398. AMBIENT: boolean;
  136399. AMBIENTDIRECTUV: number;
  136400. AMBIENTINGRAYSCALE: boolean;
  136401. OPACITY: boolean;
  136402. VERTEXALPHA: boolean;
  136403. OPACITYDIRECTUV: number;
  136404. OPACITYRGB: boolean;
  136405. ALPHATEST: boolean;
  136406. DEPTHPREPASS: boolean;
  136407. ALPHABLEND: boolean;
  136408. ALPHAFROMALBEDO: boolean;
  136409. ALPHATESTVALUE: string;
  136410. SPECULAROVERALPHA: boolean;
  136411. RADIANCEOVERALPHA: boolean;
  136412. ALPHAFRESNEL: boolean;
  136413. LINEARALPHAFRESNEL: boolean;
  136414. PREMULTIPLYALPHA: boolean;
  136415. EMISSIVE: boolean;
  136416. EMISSIVEDIRECTUV: number;
  136417. REFLECTIVITY: boolean;
  136418. REFLECTIVITYDIRECTUV: number;
  136419. SPECULARTERM: boolean;
  136420. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136421. MICROSURFACEAUTOMATIC: boolean;
  136422. LODBASEDMICROSFURACE: boolean;
  136423. MICROSURFACEMAP: boolean;
  136424. MICROSURFACEMAPDIRECTUV: number;
  136425. METALLICWORKFLOW: boolean;
  136426. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136427. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136428. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136429. AOSTOREINMETALMAPRED: boolean;
  136430. METALLIC_REFLECTANCE: boolean;
  136431. METALLIC_REFLECTANCEDIRECTUV: number;
  136432. ENVIRONMENTBRDF: boolean;
  136433. ENVIRONMENTBRDF_RGBD: boolean;
  136434. NORMAL: boolean;
  136435. TANGENT: boolean;
  136436. BUMP: boolean;
  136437. BUMPDIRECTUV: number;
  136438. OBJECTSPACE_NORMALMAP: boolean;
  136439. PARALLAX: boolean;
  136440. PARALLAXOCCLUSION: boolean;
  136441. NORMALXYSCALE: boolean;
  136442. LIGHTMAP: boolean;
  136443. LIGHTMAPDIRECTUV: number;
  136444. USELIGHTMAPASSHADOWMAP: boolean;
  136445. GAMMALIGHTMAP: boolean;
  136446. RGBDLIGHTMAP: boolean;
  136447. REFLECTION: boolean;
  136448. REFLECTIONMAP_3D: boolean;
  136449. REFLECTIONMAP_SPHERICAL: boolean;
  136450. REFLECTIONMAP_PLANAR: boolean;
  136451. REFLECTIONMAP_CUBIC: boolean;
  136452. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136453. REFLECTIONMAP_PROJECTION: boolean;
  136454. REFLECTIONMAP_SKYBOX: boolean;
  136455. REFLECTIONMAP_EXPLICIT: boolean;
  136456. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136457. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136458. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136459. INVERTCUBICMAP: boolean;
  136460. USESPHERICALFROMREFLECTIONMAP: boolean;
  136461. USEIRRADIANCEMAP: boolean;
  136462. SPHERICAL_HARMONICS: boolean;
  136463. USESPHERICALINVERTEX: boolean;
  136464. REFLECTIONMAP_OPPOSITEZ: boolean;
  136465. LODINREFLECTIONALPHA: boolean;
  136466. GAMMAREFLECTION: boolean;
  136467. RGBDREFLECTION: boolean;
  136468. LINEARSPECULARREFLECTION: boolean;
  136469. RADIANCEOCCLUSION: boolean;
  136470. HORIZONOCCLUSION: boolean;
  136471. INSTANCES: boolean;
  136472. THIN_INSTANCES: boolean;
  136473. PREPASS: boolean;
  136474. SCENE_MRT_COUNT: number;
  136475. NUM_BONE_INFLUENCERS: number;
  136476. BonesPerMesh: number;
  136477. BONETEXTURE: boolean;
  136478. NONUNIFORMSCALING: boolean;
  136479. MORPHTARGETS: boolean;
  136480. MORPHTARGETS_NORMAL: boolean;
  136481. MORPHTARGETS_TANGENT: boolean;
  136482. MORPHTARGETS_UV: boolean;
  136483. NUM_MORPH_INFLUENCERS: number;
  136484. IMAGEPROCESSING: boolean;
  136485. VIGNETTE: boolean;
  136486. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136487. VIGNETTEBLENDMODEOPAQUE: boolean;
  136488. TONEMAPPING: boolean;
  136489. TONEMAPPING_ACES: boolean;
  136490. CONTRAST: boolean;
  136491. COLORCURVES: boolean;
  136492. COLORGRADING: boolean;
  136493. COLORGRADING3D: boolean;
  136494. SAMPLER3DGREENDEPTH: boolean;
  136495. SAMPLER3DBGRMAP: boolean;
  136496. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136497. EXPOSURE: boolean;
  136498. MULTIVIEW: boolean;
  136499. USEPHYSICALLIGHTFALLOFF: boolean;
  136500. USEGLTFLIGHTFALLOFF: boolean;
  136501. TWOSIDEDLIGHTING: boolean;
  136502. SHADOWFLOAT: boolean;
  136503. CLIPPLANE: boolean;
  136504. CLIPPLANE2: boolean;
  136505. CLIPPLANE3: boolean;
  136506. CLIPPLANE4: boolean;
  136507. CLIPPLANE5: boolean;
  136508. CLIPPLANE6: boolean;
  136509. POINTSIZE: boolean;
  136510. FOG: boolean;
  136511. LOGARITHMICDEPTH: boolean;
  136512. FORCENORMALFORWARD: boolean;
  136513. SPECULARAA: boolean;
  136514. CLEARCOAT: boolean;
  136515. CLEARCOAT_DEFAULTIOR: boolean;
  136516. CLEARCOAT_TEXTURE: boolean;
  136517. CLEARCOAT_TEXTUREDIRECTUV: number;
  136518. CLEARCOAT_BUMP: boolean;
  136519. CLEARCOAT_BUMPDIRECTUV: number;
  136520. CLEARCOAT_TINT: boolean;
  136521. CLEARCOAT_TINT_TEXTURE: boolean;
  136522. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136523. ANISOTROPIC: boolean;
  136524. ANISOTROPIC_TEXTURE: boolean;
  136525. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136526. BRDF_V_HEIGHT_CORRELATED: boolean;
  136527. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136528. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136529. SHEEN: boolean;
  136530. SHEEN_TEXTURE: boolean;
  136531. SHEEN_TEXTUREDIRECTUV: number;
  136532. SHEEN_LINKWITHALBEDO: boolean;
  136533. SHEEN_ROUGHNESS: boolean;
  136534. SHEEN_ALBEDOSCALING: boolean;
  136535. SUBSURFACE: boolean;
  136536. SS_REFRACTION: boolean;
  136537. SS_TRANSLUCENCY: boolean;
  136538. SS_SCATTERING: boolean;
  136539. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136540. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136541. SS_REFRACTIONMAP_3D: boolean;
  136542. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136543. SS_LODINREFRACTIONALPHA: boolean;
  136544. SS_GAMMAREFRACTION: boolean;
  136545. SS_RGBDREFRACTION: boolean;
  136546. SS_LINEARSPECULARREFRACTION: boolean;
  136547. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136548. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136549. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136550. UNLIT: boolean;
  136551. DEBUGMODE: number;
  136552. /**
  136553. * Initializes the PBR Material defines.
  136554. */
  136555. constructor();
  136556. /**
  136557. * Resets the PBR Material defines.
  136558. */
  136559. reset(): void;
  136560. }
  136561. /**
  136562. * The Physically based material base class of BJS.
  136563. *
  136564. * This offers the main features of a standard PBR material.
  136565. * For more information, please refer to the documentation :
  136566. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136567. */
  136568. export abstract class PBRBaseMaterial extends PushMaterial {
  136569. /**
  136570. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136571. */
  136572. static readonly PBRMATERIAL_OPAQUE: number;
  136573. /**
  136574. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136575. */
  136576. static readonly PBRMATERIAL_ALPHATEST: number;
  136577. /**
  136578. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136579. */
  136580. static readonly PBRMATERIAL_ALPHABLEND: number;
  136581. /**
  136582. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136583. * They are also discarded below the alpha cutoff threshold to improve performances.
  136584. */
  136585. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136586. /**
  136587. * Defines the default value of how much AO map is occluding the analytical lights
  136588. * (point spot...).
  136589. */
  136590. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136591. /**
  136592. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  136593. */
  136594. static readonly LIGHTFALLOFF_PHYSICAL: number;
  136595. /**
  136596. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  136597. * to enhance interoperability with other engines.
  136598. */
  136599. static readonly LIGHTFALLOFF_GLTF: number;
  136600. /**
  136601. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  136602. * to enhance interoperability with other materials.
  136603. */
  136604. static readonly LIGHTFALLOFF_STANDARD: number;
  136605. /**
  136606. * Intensity of the direct lights e.g. the four lights available in your scene.
  136607. * This impacts both the direct diffuse and specular highlights.
  136608. */
  136609. protected _directIntensity: number;
  136610. /**
  136611. * Intensity of the emissive part of the material.
  136612. * This helps controlling the emissive effect without modifying the emissive color.
  136613. */
  136614. protected _emissiveIntensity: number;
  136615. /**
  136616. * Intensity of the environment e.g. how much the environment will light the object
  136617. * either through harmonics for rough material or through the refelction for shiny ones.
  136618. */
  136619. protected _environmentIntensity: number;
  136620. /**
  136621. * This is a special control allowing the reduction of the specular highlights coming from the
  136622. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136623. */
  136624. protected _specularIntensity: number;
  136625. /**
  136626. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  136627. */
  136628. private _lightingInfos;
  136629. /**
  136630. * Debug Control allowing disabling the bump map on this material.
  136631. */
  136632. protected _disableBumpMap: boolean;
  136633. /**
  136634. * AKA Diffuse Texture in standard nomenclature.
  136635. */
  136636. protected _albedoTexture: Nullable<BaseTexture>;
  136637. /**
  136638. * AKA Occlusion Texture in other nomenclature.
  136639. */
  136640. protected _ambientTexture: Nullable<BaseTexture>;
  136641. /**
  136642. * AKA Occlusion Texture Intensity in other nomenclature.
  136643. */
  136644. protected _ambientTextureStrength: number;
  136645. /**
  136646. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136647. * 1 means it completely occludes it
  136648. * 0 mean it has no impact
  136649. */
  136650. protected _ambientTextureImpactOnAnalyticalLights: number;
  136651. /**
  136652. * Stores the alpha values in a texture.
  136653. */
  136654. protected _opacityTexture: Nullable<BaseTexture>;
  136655. /**
  136656. * Stores the reflection values in a texture.
  136657. */
  136658. protected _reflectionTexture: Nullable<BaseTexture>;
  136659. /**
  136660. * Stores the emissive values in a texture.
  136661. */
  136662. protected _emissiveTexture: Nullable<BaseTexture>;
  136663. /**
  136664. * AKA Specular texture in other nomenclature.
  136665. */
  136666. protected _reflectivityTexture: Nullable<BaseTexture>;
  136667. /**
  136668. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136669. */
  136670. protected _metallicTexture: Nullable<BaseTexture>;
  136671. /**
  136672. * Specifies the metallic scalar of the metallic/roughness workflow.
  136673. * Can also be used to scale the metalness values of the metallic texture.
  136674. */
  136675. protected _metallic: Nullable<number>;
  136676. /**
  136677. * Specifies the roughness scalar of the metallic/roughness workflow.
  136678. * Can also be used to scale the roughness values of the metallic texture.
  136679. */
  136680. protected _roughness: Nullable<number>;
  136681. /**
  136682. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136683. * By default the indexOfrefraction is used to compute F0;
  136684. *
  136685. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136686. *
  136687. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136688. * F90 = metallicReflectanceColor;
  136689. */
  136690. protected _metallicF0Factor: number;
  136691. /**
  136692. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136693. * By default the F90 is always 1;
  136694. *
  136695. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136696. *
  136697. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136698. * F90 = metallicReflectanceColor;
  136699. */
  136700. protected _metallicReflectanceColor: Color3;
  136701. /**
  136702. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136703. * This is multiply against the scalar values defined in the material.
  136704. */
  136705. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  136706. /**
  136707. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136708. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136709. */
  136710. protected _microSurfaceTexture: Nullable<BaseTexture>;
  136711. /**
  136712. * Stores surface normal data used to displace a mesh in a texture.
  136713. */
  136714. protected _bumpTexture: Nullable<BaseTexture>;
  136715. /**
  136716. * Stores the pre-calculated light information of a mesh in a texture.
  136717. */
  136718. protected _lightmapTexture: Nullable<BaseTexture>;
  136719. /**
  136720. * The color of a material in ambient lighting.
  136721. */
  136722. protected _ambientColor: Color3;
  136723. /**
  136724. * AKA Diffuse Color in other nomenclature.
  136725. */
  136726. protected _albedoColor: Color3;
  136727. /**
  136728. * AKA Specular Color in other nomenclature.
  136729. */
  136730. protected _reflectivityColor: Color3;
  136731. /**
  136732. * The color applied when light is reflected from a material.
  136733. */
  136734. protected _reflectionColor: Color3;
  136735. /**
  136736. * The color applied when light is emitted from a material.
  136737. */
  136738. protected _emissiveColor: Color3;
  136739. /**
  136740. * AKA Glossiness in other nomenclature.
  136741. */
  136742. protected _microSurface: number;
  136743. /**
  136744. * Specifies that the material will use the light map as a show map.
  136745. */
  136746. protected _useLightmapAsShadowmap: boolean;
  136747. /**
  136748. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136749. * makes the reflect vector face the model (under horizon).
  136750. */
  136751. protected _useHorizonOcclusion: boolean;
  136752. /**
  136753. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136754. * too much the area relying on ambient texture to define their ambient occlusion.
  136755. */
  136756. protected _useRadianceOcclusion: boolean;
  136757. /**
  136758. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136759. */
  136760. protected _useAlphaFromAlbedoTexture: boolean;
  136761. /**
  136762. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  136763. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136764. */
  136765. protected _useSpecularOverAlpha: boolean;
  136766. /**
  136767. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136768. */
  136769. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136770. /**
  136771. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136772. */
  136773. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  136774. /**
  136775. * Specifies if the metallic texture contains the roughness information in its green channel.
  136776. */
  136777. protected _useRoughnessFromMetallicTextureGreen: boolean;
  136778. /**
  136779. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136780. */
  136781. protected _useMetallnessFromMetallicTextureBlue: boolean;
  136782. /**
  136783. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136784. */
  136785. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  136786. /**
  136787. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136788. */
  136789. protected _useAmbientInGrayScale: boolean;
  136790. /**
  136791. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136792. * The material will try to infer what glossiness each pixel should be.
  136793. */
  136794. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  136795. /**
  136796. * Defines the falloff type used in this material.
  136797. * It by default is Physical.
  136798. */
  136799. protected _lightFalloff: number;
  136800. /**
  136801. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136802. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136803. */
  136804. protected _useRadianceOverAlpha: boolean;
  136805. /**
  136806. * Allows using an object space normal map (instead of tangent space).
  136807. */
  136808. protected _useObjectSpaceNormalMap: boolean;
  136809. /**
  136810. * Allows using the bump map in parallax mode.
  136811. */
  136812. protected _useParallax: boolean;
  136813. /**
  136814. * Allows using the bump map in parallax occlusion mode.
  136815. */
  136816. protected _useParallaxOcclusion: boolean;
  136817. /**
  136818. * Controls the scale bias of the parallax mode.
  136819. */
  136820. protected _parallaxScaleBias: number;
  136821. /**
  136822. * If sets to true, disables all the lights affecting the material.
  136823. */
  136824. protected _disableLighting: boolean;
  136825. /**
  136826. * Number of Simultaneous lights allowed on the material.
  136827. */
  136828. protected _maxSimultaneousLights: number;
  136829. /**
  136830. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136831. */
  136832. protected _invertNormalMapX: boolean;
  136833. /**
  136834. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136835. */
  136836. protected _invertNormalMapY: boolean;
  136837. /**
  136838. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136839. */
  136840. protected _twoSidedLighting: boolean;
  136841. /**
  136842. * Defines the alpha limits in alpha test mode.
  136843. */
  136844. protected _alphaCutOff: number;
  136845. /**
  136846. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136847. */
  136848. protected _forceAlphaTest: boolean;
  136849. /**
  136850. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136851. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136852. */
  136853. protected _useAlphaFresnel: boolean;
  136854. /**
  136855. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136856. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136857. */
  136858. protected _useLinearAlphaFresnel: boolean;
  136859. /**
  136860. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  136861. * from cos thetav and roughness:
  136862. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  136863. */
  136864. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  136865. /**
  136866. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136867. */
  136868. protected _forceIrradianceInFragment: boolean;
  136869. private _realTimeFiltering;
  136870. /**
  136871. * Enables realtime filtering on the texture.
  136872. */
  136873. get realTimeFiltering(): boolean;
  136874. set realTimeFiltering(b: boolean);
  136875. private _realTimeFilteringQuality;
  136876. /**
  136877. * Quality switch for realtime filtering
  136878. */
  136879. get realTimeFilteringQuality(): number;
  136880. set realTimeFilteringQuality(n: number);
  136881. /**
  136882. * Can this material render to several textures at once
  136883. */
  136884. get canRenderToMRT(): boolean;
  136885. /**
  136886. * Force normal to face away from face.
  136887. */
  136888. protected _forceNormalForward: boolean;
  136889. /**
  136890. * Enables specular anti aliasing in the PBR shader.
  136891. * It will both interacts on the Geometry for analytical and IBL lighting.
  136892. * It also prefilter the roughness map based on the bump values.
  136893. */
  136894. protected _enableSpecularAntiAliasing: boolean;
  136895. /**
  136896. * Default configuration related to image processing available in the PBR Material.
  136897. */
  136898. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  136899. /**
  136900. * Keep track of the image processing observer to allow dispose and replace.
  136901. */
  136902. private _imageProcessingObserver;
  136903. /**
  136904. * Attaches a new image processing configuration to the PBR Material.
  136905. * @param configuration
  136906. */
  136907. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  136908. /**
  136909. * Stores the available render targets.
  136910. */
  136911. private _renderTargets;
  136912. /**
  136913. * Sets the global ambient color for the material used in lighting calculations.
  136914. */
  136915. private _globalAmbientColor;
  136916. /**
  136917. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  136918. */
  136919. private _useLogarithmicDepth;
  136920. /**
  136921. * If set to true, no lighting calculations will be applied.
  136922. */
  136923. private _unlit;
  136924. private _debugMode;
  136925. /**
  136926. * @hidden
  136927. * This is reserved for the inspector.
  136928. * Defines the material debug mode.
  136929. * It helps seeing only some components of the material while troubleshooting.
  136930. */
  136931. debugMode: number;
  136932. /**
  136933. * @hidden
  136934. * This is reserved for the inspector.
  136935. * Specify from where on screen the debug mode should start.
  136936. * The value goes from -1 (full screen) to 1 (not visible)
  136937. * It helps with side by side comparison against the final render
  136938. * This defaults to -1
  136939. */
  136940. private debugLimit;
  136941. /**
  136942. * @hidden
  136943. * This is reserved for the inspector.
  136944. * As the default viewing range might not be enough (if the ambient is really small for instance)
  136945. * You can use the factor to better multiply the final value.
  136946. */
  136947. private debugFactor;
  136948. /**
  136949. * Defines the clear coat layer parameters for the material.
  136950. */
  136951. readonly clearCoat: PBRClearCoatConfiguration;
  136952. /**
  136953. * Defines the anisotropic parameters for the material.
  136954. */
  136955. readonly anisotropy: PBRAnisotropicConfiguration;
  136956. /**
  136957. * Defines the BRDF parameters for the material.
  136958. */
  136959. readonly brdf: PBRBRDFConfiguration;
  136960. /**
  136961. * Defines the Sheen parameters for the material.
  136962. */
  136963. readonly sheen: PBRSheenConfiguration;
  136964. /**
  136965. * Defines the SubSurface parameters for the material.
  136966. */
  136967. readonly subSurface: PBRSubSurfaceConfiguration;
  136968. /**
  136969. * Defines the detail map parameters for the material.
  136970. */
  136971. readonly detailMap: DetailMapConfiguration;
  136972. protected _rebuildInParallel: boolean;
  136973. /**
  136974. * Instantiates a new PBRMaterial instance.
  136975. *
  136976. * @param name The material name
  136977. * @param scene The scene the material will be use in.
  136978. */
  136979. constructor(name: string, scene: Scene);
  136980. /**
  136981. * Gets a boolean indicating that current material needs to register RTT
  136982. */
  136983. get hasRenderTargetTextures(): boolean;
  136984. /**
  136985. * Gets the name of the material class.
  136986. */
  136987. getClassName(): string;
  136988. /**
  136989. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136990. */
  136991. get useLogarithmicDepth(): boolean;
  136992. /**
  136993. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136994. */
  136995. set useLogarithmicDepth(value: boolean);
  136996. /**
  136997. * Returns true if alpha blending should be disabled.
  136998. */
  136999. protected get _disableAlphaBlending(): boolean;
  137000. /**
  137001. * Specifies whether or not this material should be rendered in alpha blend mode.
  137002. */
  137003. needAlphaBlending(): boolean;
  137004. /**
  137005. * Specifies whether or not this material should be rendered in alpha test mode.
  137006. */
  137007. needAlphaTesting(): boolean;
  137008. /**
  137009. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137010. */
  137011. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137012. /**
  137013. * Gets the texture used for the alpha test.
  137014. */
  137015. getAlphaTestTexture(): Nullable<BaseTexture>;
  137016. /**
  137017. * Specifies that the submesh is ready to be used.
  137018. * @param mesh - BJS mesh.
  137019. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137020. * @param useInstances - Specifies that instances should be used.
  137021. * @returns - boolean indicating that the submesh is ready or not.
  137022. */
  137023. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137024. /**
  137025. * Specifies if the material uses metallic roughness workflow.
  137026. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137027. */
  137028. isMetallicWorkflow(): boolean;
  137029. private _prepareEffect;
  137030. private _prepareDefines;
  137031. /**
  137032. * Force shader compilation
  137033. */
  137034. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137035. /**
  137036. * Initializes the uniform buffer layout for the shader.
  137037. */
  137038. buildUniformLayout(): void;
  137039. /**
  137040. * Unbinds the material from the mesh
  137041. */
  137042. unbind(): void;
  137043. /**
  137044. * Binds the submesh data.
  137045. * @param world - The world matrix.
  137046. * @param mesh - The BJS mesh.
  137047. * @param subMesh - A submesh of the BJS mesh.
  137048. */
  137049. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137050. /**
  137051. * Returns the animatable textures.
  137052. * @returns - Array of animatable textures.
  137053. */
  137054. getAnimatables(): IAnimatable[];
  137055. /**
  137056. * Returns the texture used for reflections.
  137057. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137058. */
  137059. private _getReflectionTexture;
  137060. /**
  137061. * Returns an array of the actively used textures.
  137062. * @returns - Array of BaseTextures
  137063. */
  137064. getActiveTextures(): BaseTexture[];
  137065. /**
  137066. * Checks to see if a texture is used in the material.
  137067. * @param texture - Base texture to use.
  137068. * @returns - Boolean specifying if a texture is used in the material.
  137069. */
  137070. hasTexture(texture: BaseTexture): boolean;
  137071. /**
  137072. * Sets the required values to the prepass renderer.
  137073. * @param prePassRenderer defines the prepass renderer to setup
  137074. */
  137075. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137076. /**
  137077. * Disposes the resources of the material.
  137078. * @param forceDisposeEffect - Forces the disposal of effects.
  137079. * @param forceDisposeTextures - Forces the disposal of all textures.
  137080. */
  137081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137082. }
  137083. }
  137084. declare module BABYLON {
  137085. /**
  137086. * The Physically based material of BJS.
  137087. *
  137088. * This offers the main features of a standard PBR material.
  137089. * For more information, please refer to the documentation :
  137090. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137091. */
  137092. export class PBRMaterial extends PBRBaseMaterial {
  137093. /**
  137094. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137095. */
  137096. static readonly PBRMATERIAL_OPAQUE: number;
  137097. /**
  137098. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137099. */
  137100. static readonly PBRMATERIAL_ALPHATEST: number;
  137101. /**
  137102. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137103. */
  137104. static readonly PBRMATERIAL_ALPHABLEND: number;
  137105. /**
  137106. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137107. * They are also discarded below the alpha cutoff threshold to improve performances.
  137108. */
  137109. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137110. /**
  137111. * Defines the default value of how much AO map is occluding the analytical lights
  137112. * (point spot...).
  137113. */
  137114. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137115. /**
  137116. * Intensity of the direct lights e.g. the four lights available in your scene.
  137117. * This impacts both the direct diffuse and specular highlights.
  137118. */
  137119. directIntensity: number;
  137120. /**
  137121. * Intensity of the emissive part of the material.
  137122. * This helps controlling the emissive effect without modifying the emissive color.
  137123. */
  137124. emissiveIntensity: number;
  137125. /**
  137126. * Intensity of the environment e.g. how much the environment will light the object
  137127. * either through harmonics for rough material or through the refelction for shiny ones.
  137128. */
  137129. environmentIntensity: number;
  137130. /**
  137131. * This is a special control allowing the reduction of the specular highlights coming from the
  137132. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137133. */
  137134. specularIntensity: number;
  137135. /**
  137136. * Debug Control allowing disabling the bump map on this material.
  137137. */
  137138. disableBumpMap: boolean;
  137139. /**
  137140. * AKA Diffuse Texture in standard nomenclature.
  137141. */
  137142. albedoTexture: BaseTexture;
  137143. /**
  137144. * AKA Occlusion Texture in other nomenclature.
  137145. */
  137146. ambientTexture: BaseTexture;
  137147. /**
  137148. * AKA Occlusion Texture Intensity in other nomenclature.
  137149. */
  137150. ambientTextureStrength: number;
  137151. /**
  137152. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137153. * 1 means it completely occludes it
  137154. * 0 mean it has no impact
  137155. */
  137156. ambientTextureImpactOnAnalyticalLights: number;
  137157. /**
  137158. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137159. */
  137160. opacityTexture: BaseTexture;
  137161. /**
  137162. * Stores the reflection values in a texture.
  137163. */
  137164. reflectionTexture: Nullable<BaseTexture>;
  137165. /**
  137166. * Stores the emissive values in a texture.
  137167. */
  137168. emissiveTexture: BaseTexture;
  137169. /**
  137170. * AKA Specular texture in other nomenclature.
  137171. */
  137172. reflectivityTexture: BaseTexture;
  137173. /**
  137174. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137175. */
  137176. metallicTexture: BaseTexture;
  137177. /**
  137178. * Specifies the metallic scalar of the metallic/roughness workflow.
  137179. * Can also be used to scale the metalness values of the metallic texture.
  137180. */
  137181. metallic: Nullable<number>;
  137182. /**
  137183. * Specifies the roughness scalar of the metallic/roughness workflow.
  137184. * Can also be used to scale the roughness values of the metallic texture.
  137185. */
  137186. roughness: Nullable<number>;
  137187. /**
  137188. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137189. * By default the indexOfrefraction is used to compute F0;
  137190. *
  137191. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137192. *
  137193. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137194. * F90 = metallicReflectanceColor;
  137195. */
  137196. metallicF0Factor: number;
  137197. /**
  137198. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137199. * By default the F90 is always 1;
  137200. *
  137201. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137202. *
  137203. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137204. * F90 = metallicReflectanceColor;
  137205. */
  137206. metallicReflectanceColor: Color3;
  137207. /**
  137208. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137209. * This is multiply against the scalar values defined in the material.
  137210. */
  137211. metallicReflectanceTexture: Nullable<BaseTexture>;
  137212. /**
  137213. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137214. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137215. */
  137216. microSurfaceTexture: BaseTexture;
  137217. /**
  137218. * Stores surface normal data used to displace a mesh in a texture.
  137219. */
  137220. bumpTexture: BaseTexture;
  137221. /**
  137222. * Stores the pre-calculated light information of a mesh in a texture.
  137223. */
  137224. lightmapTexture: BaseTexture;
  137225. /**
  137226. * Stores the refracted light information in a texture.
  137227. */
  137228. get refractionTexture(): Nullable<BaseTexture>;
  137229. set refractionTexture(value: Nullable<BaseTexture>);
  137230. /**
  137231. * The color of a material in ambient lighting.
  137232. */
  137233. ambientColor: Color3;
  137234. /**
  137235. * AKA Diffuse Color in other nomenclature.
  137236. */
  137237. albedoColor: Color3;
  137238. /**
  137239. * AKA Specular Color in other nomenclature.
  137240. */
  137241. reflectivityColor: Color3;
  137242. /**
  137243. * The color reflected from the material.
  137244. */
  137245. reflectionColor: Color3;
  137246. /**
  137247. * The color emitted from the material.
  137248. */
  137249. emissiveColor: Color3;
  137250. /**
  137251. * AKA Glossiness in other nomenclature.
  137252. */
  137253. microSurface: number;
  137254. /**
  137255. * Index of refraction of the material base layer.
  137256. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137257. *
  137258. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137259. *
  137260. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137261. */
  137262. get indexOfRefraction(): number;
  137263. set indexOfRefraction(value: number);
  137264. /**
  137265. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137266. */
  137267. get invertRefractionY(): boolean;
  137268. set invertRefractionY(value: boolean);
  137269. /**
  137270. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137271. * Materials half opaque for instance using refraction could benefit from this control.
  137272. */
  137273. get linkRefractionWithTransparency(): boolean;
  137274. set linkRefractionWithTransparency(value: boolean);
  137275. /**
  137276. * If true, the light map contains occlusion information instead of lighting info.
  137277. */
  137278. useLightmapAsShadowmap: boolean;
  137279. /**
  137280. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137281. */
  137282. useAlphaFromAlbedoTexture: boolean;
  137283. /**
  137284. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137285. */
  137286. forceAlphaTest: boolean;
  137287. /**
  137288. * Defines the alpha limits in alpha test mode.
  137289. */
  137290. alphaCutOff: number;
  137291. /**
  137292. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137293. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137294. */
  137295. useSpecularOverAlpha: boolean;
  137296. /**
  137297. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137298. */
  137299. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137300. /**
  137301. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137302. */
  137303. useRoughnessFromMetallicTextureAlpha: boolean;
  137304. /**
  137305. * Specifies if the metallic texture contains the roughness information in its green channel.
  137306. */
  137307. useRoughnessFromMetallicTextureGreen: boolean;
  137308. /**
  137309. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137310. */
  137311. useMetallnessFromMetallicTextureBlue: boolean;
  137312. /**
  137313. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137314. */
  137315. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137316. /**
  137317. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137318. */
  137319. useAmbientInGrayScale: boolean;
  137320. /**
  137321. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137322. * The material will try to infer what glossiness each pixel should be.
  137323. */
  137324. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137325. /**
  137326. * BJS is using an harcoded light falloff based on a manually sets up range.
  137327. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137328. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137329. */
  137330. get usePhysicalLightFalloff(): boolean;
  137331. /**
  137332. * BJS is using an harcoded light falloff based on a manually sets up range.
  137333. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137334. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137335. */
  137336. set usePhysicalLightFalloff(value: boolean);
  137337. /**
  137338. * In order to support the falloff compatibility with gltf, a special mode has been added
  137339. * to reproduce the gltf light falloff.
  137340. */
  137341. get useGLTFLightFalloff(): boolean;
  137342. /**
  137343. * In order to support the falloff compatibility with gltf, a special mode has been added
  137344. * to reproduce the gltf light falloff.
  137345. */
  137346. set useGLTFLightFalloff(value: boolean);
  137347. /**
  137348. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137349. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137350. */
  137351. useRadianceOverAlpha: boolean;
  137352. /**
  137353. * Allows using an object space normal map (instead of tangent space).
  137354. */
  137355. useObjectSpaceNormalMap: boolean;
  137356. /**
  137357. * Allows using the bump map in parallax mode.
  137358. */
  137359. useParallax: boolean;
  137360. /**
  137361. * Allows using the bump map in parallax occlusion mode.
  137362. */
  137363. useParallaxOcclusion: boolean;
  137364. /**
  137365. * Controls the scale bias of the parallax mode.
  137366. */
  137367. parallaxScaleBias: number;
  137368. /**
  137369. * If sets to true, disables all the lights affecting the material.
  137370. */
  137371. disableLighting: boolean;
  137372. /**
  137373. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137374. */
  137375. forceIrradianceInFragment: boolean;
  137376. /**
  137377. * Number of Simultaneous lights allowed on the material.
  137378. */
  137379. maxSimultaneousLights: number;
  137380. /**
  137381. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137382. */
  137383. invertNormalMapX: boolean;
  137384. /**
  137385. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137386. */
  137387. invertNormalMapY: boolean;
  137388. /**
  137389. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137390. */
  137391. twoSidedLighting: boolean;
  137392. /**
  137393. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137394. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137395. */
  137396. useAlphaFresnel: boolean;
  137397. /**
  137398. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137399. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137400. */
  137401. useLinearAlphaFresnel: boolean;
  137402. /**
  137403. * Let user defines the brdf lookup texture used for IBL.
  137404. * A default 8bit version is embedded but you could point at :
  137405. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137406. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137407. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137408. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137409. */
  137410. environmentBRDFTexture: Nullable<BaseTexture>;
  137411. /**
  137412. * Force normal to face away from face.
  137413. */
  137414. forceNormalForward: boolean;
  137415. /**
  137416. * Enables specular anti aliasing in the PBR shader.
  137417. * It will both interacts on the Geometry for analytical and IBL lighting.
  137418. * It also prefilter the roughness map based on the bump values.
  137419. */
  137420. enableSpecularAntiAliasing: boolean;
  137421. /**
  137422. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137423. * makes the reflect vector face the model (under horizon).
  137424. */
  137425. useHorizonOcclusion: boolean;
  137426. /**
  137427. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137428. * too much the area relying on ambient texture to define their ambient occlusion.
  137429. */
  137430. useRadianceOcclusion: boolean;
  137431. /**
  137432. * If set to true, no lighting calculations will be applied.
  137433. */
  137434. unlit: boolean;
  137435. /**
  137436. * Gets the image processing configuration used either in this material.
  137437. */
  137438. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137439. /**
  137440. * Sets the Default image processing configuration used either in the this material.
  137441. *
  137442. * If sets to null, the scene one is in use.
  137443. */
  137444. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137445. /**
  137446. * Gets wether the color curves effect is enabled.
  137447. */
  137448. get cameraColorCurvesEnabled(): boolean;
  137449. /**
  137450. * Sets wether the color curves effect is enabled.
  137451. */
  137452. set cameraColorCurvesEnabled(value: boolean);
  137453. /**
  137454. * Gets wether the color grading effect is enabled.
  137455. */
  137456. get cameraColorGradingEnabled(): boolean;
  137457. /**
  137458. * Gets wether the color grading effect is enabled.
  137459. */
  137460. set cameraColorGradingEnabled(value: boolean);
  137461. /**
  137462. * Gets wether tonemapping is enabled or not.
  137463. */
  137464. get cameraToneMappingEnabled(): boolean;
  137465. /**
  137466. * Sets wether tonemapping is enabled or not
  137467. */
  137468. set cameraToneMappingEnabled(value: boolean);
  137469. /**
  137470. * The camera exposure used on this material.
  137471. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137472. * This corresponds to a photographic exposure.
  137473. */
  137474. get cameraExposure(): number;
  137475. /**
  137476. * The camera exposure used on this material.
  137477. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137478. * This corresponds to a photographic exposure.
  137479. */
  137480. set cameraExposure(value: number);
  137481. /**
  137482. * Gets The camera contrast used on this material.
  137483. */
  137484. get cameraContrast(): number;
  137485. /**
  137486. * Sets The camera contrast used on this material.
  137487. */
  137488. set cameraContrast(value: number);
  137489. /**
  137490. * Gets the Color Grading 2D Lookup Texture.
  137491. */
  137492. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137493. /**
  137494. * Sets the Color Grading 2D Lookup Texture.
  137495. */
  137496. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137497. /**
  137498. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137499. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137500. * 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;
  137501. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137502. */
  137503. get cameraColorCurves(): Nullable<ColorCurves>;
  137504. /**
  137505. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137506. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137507. * 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;
  137508. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137509. */
  137510. set cameraColorCurves(value: Nullable<ColorCurves>);
  137511. /**
  137512. * Instantiates a new PBRMaterial instance.
  137513. *
  137514. * @param name The material name
  137515. * @param scene The scene the material will be use in.
  137516. */
  137517. constructor(name: string, scene: Scene);
  137518. /**
  137519. * Returns the name of this material class.
  137520. */
  137521. getClassName(): string;
  137522. /**
  137523. * Makes a duplicate of the current material.
  137524. * @param name - name to use for the new material.
  137525. */
  137526. clone(name: string): PBRMaterial;
  137527. /**
  137528. * Serializes this PBR Material.
  137529. * @returns - An object with the serialized material.
  137530. */
  137531. serialize(): any;
  137532. /**
  137533. * Parses a PBR Material from a serialized object.
  137534. * @param source - Serialized object.
  137535. * @param scene - BJS scene instance.
  137536. * @param rootUrl - url for the scene object
  137537. * @returns - PBRMaterial
  137538. */
  137539. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137540. }
  137541. }
  137542. declare module BABYLON {
  137543. /**
  137544. * Direct draw surface info
  137545. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137546. */
  137547. export interface DDSInfo {
  137548. /**
  137549. * Width of the texture
  137550. */
  137551. width: number;
  137552. /**
  137553. * Width of the texture
  137554. */
  137555. height: number;
  137556. /**
  137557. * Number of Mipmaps for the texture
  137558. * @see https://en.wikipedia.org/wiki/Mipmap
  137559. */
  137560. mipmapCount: number;
  137561. /**
  137562. * If the textures format is a known fourCC format
  137563. * @see https://www.fourcc.org/
  137564. */
  137565. isFourCC: boolean;
  137566. /**
  137567. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137568. */
  137569. isRGB: boolean;
  137570. /**
  137571. * If the texture is a lumincance format
  137572. */
  137573. isLuminance: boolean;
  137574. /**
  137575. * If this is a cube texture
  137576. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137577. */
  137578. isCube: boolean;
  137579. /**
  137580. * If the texture is a compressed format eg. FOURCC_DXT1
  137581. */
  137582. isCompressed: boolean;
  137583. /**
  137584. * The dxgiFormat of the texture
  137585. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137586. */
  137587. dxgiFormat: number;
  137588. /**
  137589. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137590. */
  137591. textureType: number;
  137592. /**
  137593. * Sphericle polynomial created for the dds texture
  137594. */
  137595. sphericalPolynomial?: SphericalPolynomial;
  137596. }
  137597. /**
  137598. * Class used to provide DDS decompression tools
  137599. */
  137600. export class DDSTools {
  137601. /**
  137602. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  137603. */
  137604. static StoreLODInAlphaChannel: boolean;
  137605. /**
  137606. * Gets DDS information from an array buffer
  137607. * @param data defines the array buffer view to read data from
  137608. * @returns the DDS information
  137609. */
  137610. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  137611. private static _FloatView;
  137612. private static _Int32View;
  137613. private static _ToHalfFloat;
  137614. private static _FromHalfFloat;
  137615. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  137616. private static _GetHalfFloatRGBAArrayBuffer;
  137617. private static _GetFloatRGBAArrayBuffer;
  137618. private static _GetFloatAsUIntRGBAArrayBuffer;
  137619. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  137620. private static _GetRGBAArrayBuffer;
  137621. private static _ExtractLongWordOrder;
  137622. private static _GetRGBArrayBuffer;
  137623. private static _GetLuminanceArrayBuffer;
  137624. /**
  137625. * Uploads DDS Levels to a Babylon Texture
  137626. * @hidden
  137627. */
  137628. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  137629. }
  137630. interface ThinEngine {
  137631. /**
  137632. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  137633. * @param rootUrl defines the url where the file to load is located
  137634. * @param scene defines the current scene
  137635. * @param lodScale defines scale to apply to the mip map selection
  137636. * @param lodOffset defines offset to apply to the mip map selection
  137637. * @param onLoad defines an optional callback raised when the texture is loaded
  137638. * @param onError defines an optional callback raised if there is an issue to load the texture
  137639. * @param format defines the format of the data
  137640. * @param forcedExtension defines the extension to use to pick the right loader
  137641. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  137642. * @returns the cube texture as an InternalTexture
  137643. */
  137644. 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;
  137645. }
  137646. }
  137647. declare module BABYLON {
  137648. /**
  137649. * Implementation of the DDS Texture Loader.
  137650. * @hidden
  137651. */
  137652. export class _DDSTextureLoader implements IInternalTextureLoader {
  137653. /**
  137654. * Defines wether the loader supports cascade loading the different faces.
  137655. */
  137656. readonly supportCascades: boolean;
  137657. /**
  137658. * This returns if the loader support the current file information.
  137659. * @param extension defines the file extension of the file being loaded
  137660. * @returns true if the loader can load the specified file
  137661. */
  137662. canLoad(extension: string): boolean;
  137663. /**
  137664. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137665. * @param data contains the texture data
  137666. * @param texture defines the BabylonJS internal texture
  137667. * @param createPolynomials will be true if polynomials have been requested
  137668. * @param onLoad defines the callback to trigger once the texture is ready
  137669. * @param onError defines the callback to trigger in case of error
  137670. */
  137671. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137672. /**
  137673. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137674. * @param data contains the texture data
  137675. * @param texture defines the BabylonJS internal texture
  137676. * @param callback defines the method to call once ready to upload
  137677. */
  137678. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137679. }
  137680. }
  137681. declare module BABYLON {
  137682. /**
  137683. * Implementation of the ENV Texture Loader.
  137684. * @hidden
  137685. */
  137686. export class _ENVTextureLoader implements IInternalTextureLoader {
  137687. /**
  137688. * Defines wether the loader supports cascade loading the different faces.
  137689. */
  137690. readonly supportCascades: boolean;
  137691. /**
  137692. * This returns if the loader support the current file information.
  137693. * @param extension defines the file extension of the file being loaded
  137694. * @returns true if the loader can load the specified file
  137695. */
  137696. canLoad(extension: string): boolean;
  137697. /**
  137698. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137699. * @param data contains the texture data
  137700. * @param texture defines the BabylonJS internal texture
  137701. * @param createPolynomials will be true if polynomials have been requested
  137702. * @param onLoad defines the callback to trigger once the texture is ready
  137703. * @param onError defines the callback to trigger in case of error
  137704. */
  137705. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137706. /**
  137707. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137708. * @param data contains the texture data
  137709. * @param texture defines the BabylonJS internal texture
  137710. * @param callback defines the method to call once ready to upload
  137711. */
  137712. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137713. }
  137714. }
  137715. declare module BABYLON {
  137716. /**
  137717. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137718. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137719. */
  137720. export class KhronosTextureContainer {
  137721. /** contents of the KTX container file */
  137722. data: ArrayBufferView;
  137723. private static HEADER_LEN;
  137724. private static COMPRESSED_2D;
  137725. private static COMPRESSED_3D;
  137726. private static TEX_2D;
  137727. private static TEX_3D;
  137728. /**
  137729. * Gets the openGL type
  137730. */
  137731. glType: number;
  137732. /**
  137733. * Gets the openGL type size
  137734. */
  137735. glTypeSize: number;
  137736. /**
  137737. * Gets the openGL format
  137738. */
  137739. glFormat: number;
  137740. /**
  137741. * Gets the openGL internal format
  137742. */
  137743. glInternalFormat: number;
  137744. /**
  137745. * Gets the base internal format
  137746. */
  137747. glBaseInternalFormat: number;
  137748. /**
  137749. * Gets image width in pixel
  137750. */
  137751. pixelWidth: number;
  137752. /**
  137753. * Gets image height in pixel
  137754. */
  137755. pixelHeight: number;
  137756. /**
  137757. * Gets image depth in pixels
  137758. */
  137759. pixelDepth: number;
  137760. /**
  137761. * Gets the number of array elements
  137762. */
  137763. numberOfArrayElements: number;
  137764. /**
  137765. * Gets the number of faces
  137766. */
  137767. numberOfFaces: number;
  137768. /**
  137769. * Gets the number of mipmap levels
  137770. */
  137771. numberOfMipmapLevels: number;
  137772. /**
  137773. * Gets the bytes of key value data
  137774. */
  137775. bytesOfKeyValueData: number;
  137776. /**
  137777. * Gets the load type
  137778. */
  137779. loadType: number;
  137780. /**
  137781. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  137782. */
  137783. isInvalid: boolean;
  137784. /**
  137785. * Creates a new KhronosTextureContainer
  137786. * @param data contents of the KTX container file
  137787. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  137788. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  137789. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  137790. */
  137791. constructor(
  137792. /** contents of the KTX container file */
  137793. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  137794. /**
  137795. * Uploads KTX content to a Babylon Texture.
  137796. * It is assumed that the texture has already been created & is currently bound
  137797. * @hidden
  137798. */
  137799. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  137800. private _upload2DCompressedLevels;
  137801. /**
  137802. * Checks if the given data starts with a KTX file identifier.
  137803. * @param data the data to check
  137804. * @returns true if the data is a KTX file or false otherwise
  137805. */
  137806. static IsValid(data: ArrayBufferView): boolean;
  137807. }
  137808. }
  137809. declare module BABYLON {
  137810. /**
  137811. * Helper class to push actions to a pool of workers.
  137812. */
  137813. export class WorkerPool implements IDisposable {
  137814. private _workerInfos;
  137815. private _pendingActions;
  137816. /**
  137817. * Constructor
  137818. * @param workers Array of workers to use for actions
  137819. */
  137820. constructor(workers: Array<Worker>);
  137821. /**
  137822. * Terminates all workers and clears any pending actions.
  137823. */
  137824. dispose(): void;
  137825. /**
  137826. * Pushes an action to the worker pool. If all the workers are active, the action will be
  137827. * pended until a worker has completed its action.
  137828. * @param action The action to perform. Call onComplete when the action is complete.
  137829. */
  137830. push(action: (worker: Worker, onComplete: () => void) => void): void;
  137831. private _execute;
  137832. }
  137833. }
  137834. declare module BABYLON {
  137835. /**
  137836. * Class for loading KTX2 files
  137837. * @hidden
  137838. */
  137839. export class KhronosTextureContainer2 {
  137840. private static _WorkerPoolPromise?;
  137841. private static _Initialized;
  137842. private static _Ktx2Decoder;
  137843. /**
  137844. * URL to use when loading the KTX2 decoder module
  137845. */
  137846. static JSModuleURL: string;
  137847. /**
  137848. * Default number of workers used to handle data decoding
  137849. */
  137850. static DefaultNumWorkers: number;
  137851. private static GetDefaultNumWorkers;
  137852. private _engine;
  137853. private static _CreateWorkerPool;
  137854. /**
  137855. * Constructor
  137856. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  137857. */
  137858. constructor(engine: ThinEngine, numWorkers?: number);
  137859. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  137860. /**
  137861. * Stop all async operations and release resources.
  137862. */
  137863. dispose(): void;
  137864. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  137865. /**
  137866. * Checks if the given data starts with a KTX2 file identifier.
  137867. * @param data the data to check
  137868. * @returns true if the data is a KTX2 file or false otherwise
  137869. */
  137870. static IsValid(data: ArrayBufferView): boolean;
  137871. }
  137872. export function workerFunc(): void;
  137873. }
  137874. declare module BABYLON {
  137875. /**
  137876. * Implementation of the KTX Texture Loader.
  137877. * @hidden
  137878. */
  137879. export class _KTXTextureLoader implements IInternalTextureLoader {
  137880. /**
  137881. * Defines wether the loader supports cascade loading the different faces.
  137882. */
  137883. readonly supportCascades: boolean;
  137884. /**
  137885. * This returns if the loader support the current file information.
  137886. * @param extension defines the file extension of the file being loaded
  137887. * @param mimeType defines the optional mime type of the file being loaded
  137888. * @returns true if the loader can load the specified file
  137889. */
  137890. canLoad(extension: string, mimeType?: string): boolean;
  137891. /**
  137892. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137893. * @param data contains the texture data
  137894. * @param texture defines the BabylonJS internal texture
  137895. * @param createPolynomials will be true if polynomials have been requested
  137896. * @param onLoad defines the callback to trigger once the texture is ready
  137897. * @param onError defines the callback to trigger in case of error
  137898. */
  137899. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137900. /**
  137901. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137902. * @param data contains the texture data
  137903. * @param texture defines the BabylonJS internal texture
  137904. * @param callback defines the method to call once ready to upload
  137905. */
  137906. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  137907. }
  137908. }
  137909. declare module BABYLON {
  137910. /** @hidden */
  137911. export var _forceSceneHelpersToBundle: boolean;
  137912. interface Scene {
  137913. /**
  137914. * Creates a default light for the scene.
  137915. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  137916. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  137917. */
  137918. createDefaultLight(replace?: boolean): void;
  137919. /**
  137920. * Creates a default camera for the scene.
  137921. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  137922. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137923. * @param replace has default false, when true replaces the active camera in the scene
  137924. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  137925. */
  137926. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137927. /**
  137928. * Creates a default camera and a default light.
  137929. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  137930. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137931. * @param replace has the default false, when true replaces the active camera/light in the scene
  137932. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  137933. */
  137934. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137935. /**
  137936. * Creates a new sky box
  137937. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  137938. * @param environmentTexture defines the texture to use as environment texture
  137939. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  137940. * @param scale defines the overall scale of the skybox
  137941. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  137942. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  137943. * @returns a new mesh holding the sky box
  137944. */
  137945. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  137946. /**
  137947. * Creates a new environment
  137948. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  137949. * @param options defines the options you can use to configure the environment
  137950. * @returns the new EnvironmentHelper
  137951. */
  137952. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  137953. /**
  137954. * Creates a new VREXperienceHelper
  137955. * @see https://doc.babylonjs.com/how_to/webvr_helper
  137956. * @param webVROptions defines the options used to create the new VREXperienceHelper
  137957. * @returns a new VREXperienceHelper
  137958. */
  137959. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  137960. /**
  137961. * Creates a new WebXRDefaultExperience
  137962. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  137963. * @param options experience options
  137964. * @returns a promise for a new WebXRDefaultExperience
  137965. */
  137966. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  137967. }
  137968. }
  137969. declare module BABYLON {
  137970. /**
  137971. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  137972. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  137973. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  137974. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  137975. */
  137976. export class VideoDome extends TextureDome<VideoTexture> {
  137977. /**
  137978. * Define the video source as a Monoscopic panoramic 360 video.
  137979. */
  137980. static readonly MODE_MONOSCOPIC: number;
  137981. /**
  137982. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  137983. */
  137984. static readonly MODE_TOPBOTTOM: number;
  137985. /**
  137986. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  137987. */
  137988. static readonly MODE_SIDEBYSIDE: number;
  137989. /**
  137990. * Get the video texture associated with this video dome
  137991. */
  137992. get videoTexture(): VideoTexture;
  137993. /**
  137994. * Get the video mode of this dome
  137995. */
  137996. get videoMode(): number;
  137997. /**
  137998. * Set the video mode of this dome.
  137999. * @see textureMode
  138000. */
  138001. set videoMode(value: number);
  138002. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138003. }
  138004. }
  138005. declare module BABYLON {
  138006. /**
  138007. * This class can be used to get instrumentation data from a Babylon engine
  138008. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138009. */
  138010. export class EngineInstrumentation implements IDisposable {
  138011. /**
  138012. * Define the instrumented engine.
  138013. */
  138014. engine: Engine;
  138015. private _captureGPUFrameTime;
  138016. private _gpuFrameTimeToken;
  138017. private _gpuFrameTime;
  138018. private _captureShaderCompilationTime;
  138019. private _shaderCompilationTime;
  138020. private _onBeginFrameObserver;
  138021. private _onEndFrameObserver;
  138022. private _onBeforeShaderCompilationObserver;
  138023. private _onAfterShaderCompilationObserver;
  138024. /**
  138025. * Gets the perf counter used for GPU frame time
  138026. */
  138027. get gpuFrameTimeCounter(): PerfCounter;
  138028. /**
  138029. * Gets the GPU frame time capture status
  138030. */
  138031. get captureGPUFrameTime(): boolean;
  138032. /**
  138033. * Enable or disable the GPU frame time capture
  138034. */
  138035. set captureGPUFrameTime(value: boolean);
  138036. /**
  138037. * Gets the perf counter used for shader compilation time
  138038. */
  138039. get shaderCompilationTimeCounter(): PerfCounter;
  138040. /**
  138041. * Gets the shader compilation time capture status
  138042. */
  138043. get captureShaderCompilationTime(): boolean;
  138044. /**
  138045. * Enable or disable the shader compilation time capture
  138046. */
  138047. set captureShaderCompilationTime(value: boolean);
  138048. /**
  138049. * Instantiates a new engine instrumentation.
  138050. * This class can be used to get instrumentation data from a Babylon engine
  138051. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138052. * @param engine Defines the engine to instrument
  138053. */
  138054. constructor(
  138055. /**
  138056. * Define the instrumented engine.
  138057. */
  138058. engine: Engine);
  138059. /**
  138060. * Dispose and release associated resources.
  138061. */
  138062. dispose(): void;
  138063. }
  138064. }
  138065. declare module BABYLON {
  138066. /**
  138067. * This class can be used to get instrumentation data from a Babylon engine
  138068. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138069. */
  138070. export class SceneInstrumentation implements IDisposable {
  138071. /**
  138072. * Defines the scene to instrument
  138073. */
  138074. scene: Scene;
  138075. private _captureActiveMeshesEvaluationTime;
  138076. private _activeMeshesEvaluationTime;
  138077. private _captureRenderTargetsRenderTime;
  138078. private _renderTargetsRenderTime;
  138079. private _captureFrameTime;
  138080. private _frameTime;
  138081. private _captureRenderTime;
  138082. private _renderTime;
  138083. private _captureInterFrameTime;
  138084. private _interFrameTime;
  138085. private _captureParticlesRenderTime;
  138086. private _particlesRenderTime;
  138087. private _captureSpritesRenderTime;
  138088. private _spritesRenderTime;
  138089. private _capturePhysicsTime;
  138090. private _physicsTime;
  138091. private _captureAnimationsTime;
  138092. private _animationsTime;
  138093. private _captureCameraRenderTime;
  138094. private _cameraRenderTime;
  138095. private _onBeforeActiveMeshesEvaluationObserver;
  138096. private _onAfterActiveMeshesEvaluationObserver;
  138097. private _onBeforeRenderTargetsRenderObserver;
  138098. private _onAfterRenderTargetsRenderObserver;
  138099. private _onAfterRenderObserver;
  138100. private _onBeforeDrawPhaseObserver;
  138101. private _onAfterDrawPhaseObserver;
  138102. private _onBeforeAnimationsObserver;
  138103. private _onBeforeParticlesRenderingObserver;
  138104. private _onAfterParticlesRenderingObserver;
  138105. private _onBeforeSpritesRenderingObserver;
  138106. private _onAfterSpritesRenderingObserver;
  138107. private _onBeforePhysicsObserver;
  138108. private _onAfterPhysicsObserver;
  138109. private _onAfterAnimationsObserver;
  138110. private _onBeforeCameraRenderObserver;
  138111. private _onAfterCameraRenderObserver;
  138112. /**
  138113. * Gets the perf counter used for active meshes evaluation time
  138114. */
  138115. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138116. /**
  138117. * Gets the active meshes evaluation time capture status
  138118. */
  138119. get captureActiveMeshesEvaluationTime(): boolean;
  138120. /**
  138121. * Enable or disable the active meshes evaluation time capture
  138122. */
  138123. set captureActiveMeshesEvaluationTime(value: boolean);
  138124. /**
  138125. * Gets the perf counter used for render targets render time
  138126. */
  138127. get renderTargetsRenderTimeCounter(): PerfCounter;
  138128. /**
  138129. * Gets the render targets render time capture status
  138130. */
  138131. get captureRenderTargetsRenderTime(): boolean;
  138132. /**
  138133. * Enable or disable the render targets render time capture
  138134. */
  138135. set captureRenderTargetsRenderTime(value: boolean);
  138136. /**
  138137. * Gets the perf counter used for particles render time
  138138. */
  138139. get particlesRenderTimeCounter(): PerfCounter;
  138140. /**
  138141. * Gets the particles render time capture status
  138142. */
  138143. get captureParticlesRenderTime(): boolean;
  138144. /**
  138145. * Enable or disable the particles render time capture
  138146. */
  138147. set captureParticlesRenderTime(value: boolean);
  138148. /**
  138149. * Gets the perf counter used for sprites render time
  138150. */
  138151. get spritesRenderTimeCounter(): PerfCounter;
  138152. /**
  138153. * Gets the sprites render time capture status
  138154. */
  138155. get captureSpritesRenderTime(): boolean;
  138156. /**
  138157. * Enable or disable the sprites render time capture
  138158. */
  138159. set captureSpritesRenderTime(value: boolean);
  138160. /**
  138161. * Gets the perf counter used for physics time
  138162. */
  138163. get physicsTimeCounter(): PerfCounter;
  138164. /**
  138165. * Gets the physics time capture status
  138166. */
  138167. get capturePhysicsTime(): boolean;
  138168. /**
  138169. * Enable or disable the physics time capture
  138170. */
  138171. set capturePhysicsTime(value: boolean);
  138172. /**
  138173. * Gets the perf counter used for animations time
  138174. */
  138175. get animationsTimeCounter(): PerfCounter;
  138176. /**
  138177. * Gets the animations time capture status
  138178. */
  138179. get captureAnimationsTime(): boolean;
  138180. /**
  138181. * Enable or disable the animations time capture
  138182. */
  138183. set captureAnimationsTime(value: boolean);
  138184. /**
  138185. * Gets the perf counter used for frame time capture
  138186. */
  138187. get frameTimeCounter(): PerfCounter;
  138188. /**
  138189. * Gets the frame time capture status
  138190. */
  138191. get captureFrameTime(): boolean;
  138192. /**
  138193. * Enable or disable the frame time capture
  138194. */
  138195. set captureFrameTime(value: boolean);
  138196. /**
  138197. * Gets the perf counter used for inter-frames time capture
  138198. */
  138199. get interFrameTimeCounter(): PerfCounter;
  138200. /**
  138201. * Gets the inter-frames time capture status
  138202. */
  138203. get captureInterFrameTime(): boolean;
  138204. /**
  138205. * Enable or disable the inter-frames time capture
  138206. */
  138207. set captureInterFrameTime(value: boolean);
  138208. /**
  138209. * Gets the perf counter used for render time capture
  138210. */
  138211. get renderTimeCounter(): PerfCounter;
  138212. /**
  138213. * Gets the render time capture status
  138214. */
  138215. get captureRenderTime(): boolean;
  138216. /**
  138217. * Enable or disable the render time capture
  138218. */
  138219. set captureRenderTime(value: boolean);
  138220. /**
  138221. * Gets the perf counter used for camera render time capture
  138222. */
  138223. get cameraRenderTimeCounter(): PerfCounter;
  138224. /**
  138225. * Gets the camera render time capture status
  138226. */
  138227. get captureCameraRenderTime(): boolean;
  138228. /**
  138229. * Enable or disable the camera render time capture
  138230. */
  138231. set captureCameraRenderTime(value: boolean);
  138232. /**
  138233. * Gets the perf counter used for draw calls
  138234. */
  138235. get drawCallsCounter(): PerfCounter;
  138236. /**
  138237. * Instantiates a new scene instrumentation.
  138238. * This class can be used to get instrumentation data from a Babylon engine
  138239. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138240. * @param scene Defines the scene to instrument
  138241. */
  138242. constructor(
  138243. /**
  138244. * Defines the scene to instrument
  138245. */
  138246. scene: Scene);
  138247. /**
  138248. * Dispose and release associated resources.
  138249. */
  138250. dispose(): void;
  138251. }
  138252. }
  138253. declare module BABYLON {
  138254. /** @hidden */
  138255. export var glowMapGenerationPixelShader: {
  138256. name: string;
  138257. shader: string;
  138258. };
  138259. }
  138260. declare module BABYLON {
  138261. /** @hidden */
  138262. export var glowMapGenerationVertexShader: {
  138263. name: string;
  138264. shader: string;
  138265. };
  138266. }
  138267. declare module BABYLON {
  138268. /**
  138269. * Effect layer options. This helps customizing the behaviour
  138270. * of the effect layer.
  138271. */
  138272. export interface IEffectLayerOptions {
  138273. /**
  138274. * Multiplication factor apply to the canvas size to compute the render target size
  138275. * used to generated the objects (the smaller the faster).
  138276. */
  138277. mainTextureRatio: number;
  138278. /**
  138279. * Enforces a fixed size texture to ensure effect stability across devices.
  138280. */
  138281. mainTextureFixedSize?: number;
  138282. /**
  138283. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138284. */
  138285. alphaBlendingMode: number;
  138286. /**
  138287. * The camera attached to the layer.
  138288. */
  138289. camera: Nullable<Camera>;
  138290. /**
  138291. * The rendering group to draw the layer in.
  138292. */
  138293. renderingGroupId: number;
  138294. }
  138295. /**
  138296. * The effect layer Helps adding post process effect blended with the main pass.
  138297. *
  138298. * This can be for instance use to generate glow or higlight effects on the scene.
  138299. *
  138300. * The effect layer class can not be used directly and is intented to inherited from to be
  138301. * customized per effects.
  138302. */
  138303. export abstract class EffectLayer {
  138304. private _vertexBuffers;
  138305. private _indexBuffer;
  138306. private _cachedDefines;
  138307. private _effectLayerMapGenerationEffect;
  138308. private _effectLayerOptions;
  138309. private _mergeEffect;
  138310. protected _scene: Scene;
  138311. protected _engine: Engine;
  138312. protected _maxSize: number;
  138313. protected _mainTextureDesiredSize: ISize;
  138314. protected _mainTexture: RenderTargetTexture;
  138315. protected _shouldRender: boolean;
  138316. protected _postProcesses: PostProcess[];
  138317. protected _textures: BaseTexture[];
  138318. protected _emissiveTextureAndColor: {
  138319. texture: Nullable<BaseTexture>;
  138320. color: Color4;
  138321. };
  138322. /**
  138323. * The name of the layer
  138324. */
  138325. name: string;
  138326. /**
  138327. * The clear color of the texture used to generate the glow map.
  138328. */
  138329. neutralColor: Color4;
  138330. /**
  138331. * Specifies whether the highlight layer is enabled or not.
  138332. */
  138333. isEnabled: boolean;
  138334. /**
  138335. * Gets the camera attached to the layer.
  138336. */
  138337. get camera(): Nullable<Camera>;
  138338. /**
  138339. * Gets the rendering group id the layer should render in.
  138340. */
  138341. get renderingGroupId(): number;
  138342. set renderingGroupId(renderingGroupId: number);
  138343. /**
  138344. * An event triggered when the effect layer has been disposed.
  138345. */
  138346. onDisposeObservable: Observable<EffectLayer>;
  138347. /**
  138348. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138349. */
  138350. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138351. /**
  138352. * An event triggered when the generated texture is being merged in the scene.
  138353. */
  138354. onBeforeComposeObservable: Observable<EffectLayer>;
  138355. /**
  138356. * An event triggered when the mesh is rendered into the effect render target.
  138357. */
  138358. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138359. /**
  138360. * An event triggered after the mesh has been rendered into the effect render target.
  138361. */
  138362. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138363. /**
  138364. * An event triggered when the generated texture has been merged in the scene.
  138365. */
  138366. onAfterComposeObservable: Observable<EffectLayer>;
  138367. /**
  138368. * An event triggered when the efffect layer changes its size.
  138369. */
  138370. onSizeChangedObservable: Observable<EffectLayer>;
  138371. /** @hidden */
  138372. static _SceneComponentInitialization: (scene: Scene) => void;
  138373. /**
  138374. * Instantiates a new effect Layer and references it in the scene.
  138375. * @param name The name of the layer
  138376. * @param scene The scene to use the layer in
  138377. */
  138378. constructor(
  138379. /** The Friendly of the effect in the scene */
  138380. name: string, scene: Scene);
  138381. /**
  138382. * Get the effect name of the layer.
  138383. * @return The effect name
  138384. */
  138385. abstract getEffectName(): string;
  138386. /**
  138387. * Checks for the readiness of the element composing the layer.
  138388. * @param subMesh the mesh to check for
  138389. * @param useInstances specify whether or not to use instances to render the mesh
  138390. * @return true if ready otherwise, false
  138391. */
  138392. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138393. /**
  138394. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138395. * @returns true if the effect requires stencil during the main canvas render pass.
  138396. */
  138397. abstract needStencil(): boolean;
  138398. /**
  138399. * Create the merge effect. This is the shader use to blit the information back
  138400. * to the main canvas at the end of the scene rendering.
  138401. * @returns The effect containing the shader used to merge the effect on the main canvas
  138402. */
  138403. protected abstract _createMergeEffect(): Effect;
  138404. /**
  138405. * Creates the render target textures and post processes used in the effect layer.
  138406. */
  138407. protected abstract _createTextureAndPostProcesses(): void;
  138408. /**
  138409. * Implementation specific of rendering the generating effect on the main canvas.
  138410. * @param effect The effect used to render through
  138411. */
  138412. protected abstract _internalRender(effect: Effect): void;
  138413. /**
  138414. * Sets the required values for both the emissive texture and and the main color.
  138415. */
  138416. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138417. /**
  138418. * Free any resources and references associated to a mesh.
  138419. * Internal use
  138420. * @param mesh The mesh to free.
  138421. */
  138422. abstract _disposeMesh(mesh: Mesh): void;
  138423. /**
  138424. * Serializes this layer (Glow or Highlight for example)
  138425. * @returns a serialized layer object
  138426. */
  138427. abstract serialize?(): any;
  138428. /**
  138429. * Initializes the effect layer with the required options.
  138430. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138431. */
  138432. protected _init(options: Partial<IEffectLayerOptions>): void;
  138433. /**
  138434. * Generates the index buffer of the full screen quad blending to the main canvas.
  138435. */
  138436. private _generateIndexBuffer;
  138437. /**
  138438. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138439. */
  138440. private _generateVertexBuffer;
  138441. /**
  138442. * Sets the main texture desired size which is the closest power of two
  138443. * of the engine canvas size.
  138444. */
  138445. private _setMainTextureSize;
  138446. /**
  138447. * Creates the main texture for the effect layer.
  138448. */
  138449. protected _createMainTexture(): void;
  138450. /**
  138451. * Adds specific effects defines.
  138452. * @param defines The defines to add specifics to.
  138453. */
  138454. protected _addCustomEffectDefines(defines: string[]): void;
  138455. /**
  138456. * Checks for the readiness of the element composing the layer.
  138457. * @param subMesh the mesh to check for
  138458. * @param useInstances specify whether or not to use instances to render the mesh
  138459. * @param emissiveTexture the associated emissive texture used to generate the glow
  138460. * @return true if ready otherwise, false
  138461. */
  138462. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138463. /**
  138464. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138465. */
  138466. render(): void;
  138467. /**
  138468. * Determine if a given mesh will be used in the current effect.
  138469. * @param mesh mesh to test
  138470. * @returns true if the mesh will be used
  138471. */
  138472. hasMesh(mesh: AbstractMesh): boolean;
  138473. /**
  138474. * Returns true if the layer contains information to display, otherwise false.
  138475. * @returns true if the glow layer should be rendered
  138476. */
  138477. shouldRender(): boolean;
  138478. /**
  138479. * Returns true if the mesh should render, otherwise false.
  138480. * @param mesh The mesh to render
  138481. * @returns true if it should render otherwise false
  138482. */
  138483. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138484. /**
  138485. * Returns true if the mesh can be rendered, otherwise false.
  138486. * @param mesh The mesh to render
  138487. * @param material The material used on the mesh
  138488. * @returns true if it can be rendered otherwise false
  138489. */
  138490. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138491. /**
  138492. * Returns true if the mesh should render, otherwise false.
  138493. * @param mesh The mesh to render
  138494. * @returns true if it should render otherwise false
  138495. */
  138496. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138497. /**
  138498. * Renders the submesh passed in parameter to the generation map.
  138499. */
  138500. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138501. /**
  138502. * Defines whether the current material of the mesh should be use to render the effect.
  138503. * @param mesh defines the current mesh to render
  138504. */
  138505. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138506. /**
  138507. * Rebuild the required buffers.
  138508. * @hidden Internal use only.
  138509. */
  138510. _rebuild(): void;
  138511. /**
  138512. * Dispose only the render target textures and post process.
  138513. */
  138514. private _disposeTextureAndPostProcesses;
  138515. /**
  138516. * Dispose the highlight layer and free resources.
  138517. */
  138518. dispose(): void;
  138519. /**
  138520. * Gets the class name of the effect layer
  138521. * @returns the string with the class name of the effect layer
  138522. */
  138523. getClassName(): string;
  138524. /**
  138525. * Creates an effect layer from parsed effect layer data
  138526. * @param parsedEffectLayer defines effect layer data
  138527. * @param scene defines the current scene
  138528. * @param rootUrl defines the root URL containing the effect layer information
  138529. * @returns a parsed effect Layer
  138530. */
  138531. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138532. }
  138533. }
  138534. declare module BABYLON {
  138535. interface AbstractScene {
  138536. /**
  138537. * The list of effect layers (highlights/glow) added to the scene
  138538. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138539. * @see https://doc.babylonjs.com/how_to/glow_layer
  138540. */
  138541. effectLayers: Array<EffectLayer>;
  138542. /**
  138543. * Removes the given effect layer from this scene.
  138544. * @param toRemove defines the effect layer to remove
  138545. * @returns the index of the removed effect layer
  138546. */
  138547. removeEffectLayer(toRemove: EffectLayer): number;
  138548. /**
  138549. * Adds the given effect layer to this scene
  138550. * @param newEffectLayer defines the effect layer to add
  138551. */
  138552. addEffectLayer(newEffectLayer: EffectLayer): void;
  138553. }
  138554. /**
  138555. * Defines the layer scene component responsible to manage any effect layers
  138556. * in a given scene.
  138557. */
  138558. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138559. /**
  138560. * The component name helpfull to identify the component in the list of scene components.
  138561. */
  138562. readonly name: string;
  138563. /**
  138564. * The scene the component belongs to.
  138565. */
  138566. scene: Scene;
  138567. private _engine;
  138568. private _renderEffects;
  138569. private _needStencil;
  138570. private _previousStencilState;
  138571. /**
  138572. * Creates a new instance of the component for the given scene
  138573. * @param scene Defines the scene to register the component in
  138574. */
  138575. constructor(scene: Scene);
  138576. /**
  138577. * Registers the component in a given scene
  138578. */
  138579. register(): void;
  138580. /**
  138581. * Rebuilds the elements related to this component in case of
  138582. * context lost for instance.
  138583. */
  138584. rebuild(): void;
  138585. /**
  138586. * Serializes the component data to the specified json object
  138587. * @param serializationObject The object to serialize to
  138588. */
  138589. serialize(serializationObject: any): void;
  138590. /**
  138591. * Adds all the elements from the container to the scene
  138592. * @param container the container holding the elements
  138593. */
  138594. addFromContainer(container: AbstractScene): void;
  138595. /**
  138596. * Removes all the elements in the container from the scene
  138597. * @param container contains the elements to remove
  138598. * @param dispose if the removed element should be disposed (default: false)
  138599. */
  138600. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138601. /**
  138602. * Disposes the component and the associated ressources.
  138603. */
  138604. dispose(): void;
  138605. private _isReadyForMesh;
  138606. private _renderMainTexture;
  138607. private _setStencil;
  138608. private _setStencilBack;
  138609. private _draw;
  138610. private _drawCamera;
  138611. private _drawRenderingGroup;
  138612. }
  138613. }
  138614. declare module BABYLON {
  138615. /** @hidden */
  138616. export var glowMapMergePixelShader: {
  138617. name: string;
  138618. shader: string;
  138619. };
  138620. }
  138621. declare module BABYLON {
  138622. /** @hidden */
  138623. export var glowMapMergeVertexShader: {
  138624. name: string;
  138625. shader: string;
  138626. };
  138627. }
  138628. declare module BABYLON {
  138629. interface AbstractScene {
  138630. /**
  138631. * Return a the first highlight layer of the scene with a given name.
  138632. * @param name The name of the highlight layer to look for.
  138633. * @return The highlight layer if found otherwise null.
  138634. */
  138635. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  138636. }
  138637. /**
  138638. * Glow layer options. This helps customizing the behaviour
  138639. * of the glow layer.
  138640. */
  138641. export interface IGlowLayerOptions {
  138642. /**
  138643. * Multiplication factor apply to the canvas size to compute the render target size
  138644. * used to generated the glowing objects (the smaller the faster).
  138645. */
  138646. mainTextureRatio: number;
  138647. /**
  138648. * Enforces a fixed size texture to ensure resize independant blur.
  138649. */
  138650. mainTextureFixedSize?: number;
  138651. /**
  138652. * How big is the kernel of the blur texture.
  138653. */
  138654. blurKernelSize: number;
  138655. /**
  138656. * The camera attached to the layer.
  138657. */
  138658. camera: Nullable<Camera>;
  138659. /**
  138660. * Enable MSAA by chosing the number of samples.
  138661. */
  138662. mainTextureSamples?: number;
  138663. /**
  138664. * The rendering group to draw the layer in.
  138665. */
  138666. renderingGroupId: number;
  138667. }
  138668. /**
  138669. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  138670. *
  138671. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  138672. *
  138673. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  138674. */
  138675. export class GlowLayer extends EffectLayer {
  138676. /**
  138677. * Effect Name of the layer.
  138678. */
  138679. static readonly EffectName: string;
  138680. /**
  138681. * The default blur kernel size used for the glow.
  138682. */
  138683. static DefaultBlurKernelSize: number;
  138684. /**
  138685. * The default texture size ratio used for the glow.
  138686. */
  138687. static DefaultTextureRatio: number;
  138688. /**
  138689. * Sets the kernel size of the blur.
  138690. */
  138691. set blurKernelSize(value: number);
  138692. /**
  138693. * Gets the kernel size of the blur.
  138694. */
  138695. get blurKernelSize(): number;
  138696. /**
  138697. * Sets the glow intensity.
  138698. */
  138699. set intensity(value: number);
  138700. /**
  138701. * Gets the glow intensity.
  138702. */
  138703. get intensity(): number;
  138704. private _options;
  138705. private _intensity;
  138706. private _horizontalBlurPostprocess1;
  138707. private _verticalBlurPostprocess1;
  138708. private _horizontalBlurPostprocess2;
  138709. private _verticalBlurPostprocess2;
  138710. private _blurTexture1;
  138711. private _blurTexture2;
  138712. private _postProcesses1;
  138713. private _postProcesses2;
  138714. private _includedOnlyMeshes;
  138715. private _excludedMeshes;
  138716. private _meshesUsingTheirOwnMaterials;
  138717. /**
  138718. * Callback used to let the user override the color selection on a per mesh basis
  138719. */
  138720. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  138721. /**
  138722. * Callback used to let the user override the texture selection on a per mesh basis
  138723. */
  138724. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  138725. /**
  138726. * Instantiates a new glow Layer and references it to the scene.
  138727. * @param name The name of the layer
  138728. * @param scene The scene to use the layer in
  138729. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  138730. */
  138731. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  138732. /**
  138733. * Get the effect name of the layer.
  138734. * @return The effect name
  138735. */
  138736. getEffectName(): string;
  138737. /**
  138738. * Create the merge effect. This is the shader use to blit the information back
  138739. * to the main canvas at the end of the scene rendering.
  138740. */
  138741. protected _createMergeEffect(): Effect;
  138742. /**
  138743. * Creates the render target textures and post processes used in the glow layer.
  138744. */
  138745. protected _createTextureAndPostProcesses(): void;
  138746. /**
  138747. * Checks for the readiness of the element composing the layer.
  138748. * @param subMesh the mesh to check for
  138749. * @param useInstances specify wether or not to use instances to render the mesh
  138750. * @param emissiveTexture the associated emissive texture used to generate the glow
  138751. * @return true if ready otherwise, false
  138752. */
  138753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138754. /**
  138755. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138756. */
  138757. needStencil(): boolean;
  138758. /**
  138759. * Returns true if the mesh can be rendered, otherwise false.
  138760. * @param mesh The mesh to render
  138761. * @param material The material used on the mesh
  138762. * @returns true if it can be rendered otherwise false
  138763. */
  138764. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138765. /**
  138766. * Implementation specific of rendering the generating effect on the main canvas.
  138767. * @param effect The effect used to render through
  138768. */
  138769. protected _internalRender(effect: Effect): void;
  138770. /**
  138771. * Sets the required values for both the emissive texture and and the main color.
  138772. */
  138773. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138774. /**
  138775. * Returns true if the mesh should render, otherwise false.
  138776. * @param mesh The mesh to render
  138777. * @returns true if it should render otherwise false
  138778. */
  138779. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138780. /**
  138781. * Adds specific effects defines.
  138782. * @param defines The defines to add specifics to.
  138783. */
  138784. protected _addCustomEffectDefines(defines: string[]): void;
  138785. /**
  138786. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  138787. * @param mesh The mesh to exclude from the glow layer
  138788. */
  138789. addExcludedMesh(mesh: Mesh): void;
  138790. /**
  138791. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  138792. * @param mesh The mesh to remove
  138793. */
  138794. removeExcludedMesh(mesh: Mesh): void;
  138795. /**
  138796. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  138797. * @param mesh The mesh to include in the glow layer
  138798. */
  138799. addIncludedOnlyMesh(mesh: Mesh): void;
  138800. /**
  138801. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  138802. * @param mesh The mesh to remove
  138803. */
  138804. removeIncludedOnlyMesh(mesh: Mesh): void;
  138805. /**
  138806. * Determine if a given mesh will be used in the glow layer
  138807. * @param mesh The mesh to test
  138808. * @returns true if the mesh will be highlighted by the current glow layer
  138809. */
  138810. hasMesh(mesh: AbstractMesh): boolean;
  138811. /**
  138812. * Defines whether the current material of the mesh should be use to render the effect.
  138813. * @param mesh defines the current mesh to render
  138814. */
  138815. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138816. /**
  138817. * Add a mesh to be rendered through its own material and not with emissive only.
  138818. * @param mesh The mesh for which we need to use its material
  138819. */
  138820. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  138821. /**
  138822. * Remove a mesh from being rendered through its own material and not with emissive only.
  138823. * @param mesh The mesh for which we need to not use its material
  138824. */
  138825. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  138826. /**
  138827. * Free any resources and references associated to a mesh.
  138828. * Internal use
  138829. * @param mesh The mesh to free.
  138830. * @hidden
  138831. */
  138832. _disposeMesh(mesh: Mesh): void;
  138833. /**
  138834. * Gets the class name of the effect layer
  138835. * @returns the string with the class name of the effect layer
  138836. */
  138837. getClassName(): string;
  138838. /**
  138839. * Serializes this glow layer
  138840. * @returns a serialized glow layer object
  138841. */
  138842. serialize(): any;
  138843. /**
  138844. * Creates a Glow Layer from parsed glow layer data
  138845. * @param parsedGlowLayer defines glow layer data
  138846. * @param scene defines the current scene
  138847. * @param rootUrl defines the root URL containing the glow layer information
  138848. * @returns a parsed Glow Layer
  138849. */
  138850. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  138851. }
  138852. }
  138853. declare module BABYLON {
  138854. /** @hidden */
  138855. export var glowBlurPostProcessPixelShader: {
  138856. name: string;
  138857. shader: string;
  138858. };
  138859. }
  138860. declare module BABYLON {
  138861. interface AbstractScene {
  138862. /**
  138863. * Return a the first highlight layer of the scene with a given name.
  138864. * @param name The name of the highlight layer to look for.
  138865. * @return The highlight layer if found otherwise null.
  138866. */
  138867. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  138868. }
  138869. /**
  138870. * Highlight layer options. This helps customizing the behaviour
  138871. * of the highlight layer.
  138872. */
  138873. export interface IHighlightLayerOptions {
  138874. /**
  138875. * Multiplication factor apply to the canvas size to compute the render target size
  138876. * used to generated the glowing objects (the smaller the faster).
  138877. */
  138878. mainTextureRatio: number;
  138879. /**
  138880. * Enforces a fixed size texture to ensure resize independant blur.
  138881. */
  138882. mainTextureFixedSize?: number;
  138883. /**
  138884. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  138885. * of the picture to blur (the smaller the faster).
  138886. */
  138887. blurTextureSizeRatio: number;
  138888. /**
  138889. * How big in texel of the blur texture is the vertical blur.
  138890. */
  138891. blurVerticalSize: number;
  138892. /**
  138893. * How big in texel of the blur texture is the horizontal blur.
  138894. */
  138895. blurHorizontalSize: number;
  138896. /**
  138897. * Alpha blending mode used to apply the blur. Default is combine.
  138898. */
  138899. alphaBlendingMode: number;
  138900. /**
  138901. * The camera attached to the layer.
  138902. */
  138903. camera: Nullable<Camera>;
  138904. /**
  138905. * Should we display highlight as a solid stroke?
  138906. */
  138907. isStroke?: boolean;
  138908. /**
  138909. * The rendering group to draw the layer in.
  138910. */
  138911. renderingGroupId: number;
  138912. }
  138913. /**
  138914. * The highlight layer Helps adding a glow effect around a mesh.
  138915. *
  138916. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  138917. * glowy meshes to your scene.
  138918. *
  138919. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  138920. */
  138921. export class HighlightLayer extends EffectLayer {
  138922. name: string;
  138923. /**
  138924. * Effect Name of the highlight layer.
  138925. */
  138926. static readonly EffectName: string;
  138927. /**
  138928. * The neutral color used during the preparation of the glow effect.
  138929. * This is black by default as the blend operation is a blend operation.
  138930. */
  138931. static NeutralColor: Color4;
  138932. /**
  138933. * Stencil value used for glowing meshes.
  138934. */
  138935. static GlowingMeshStencilReference: number;
  138936. /**
  138937. * Stencil value used for the other meshes in the scene.
  138938. */
  138939. static NormalMeshStencilReference: number;
  138940. /**
  138941. * Specifies whether or not the inner glow is ACTIVE in the layer.
  138942. */
  138943. innerGlow: boolean;
  138944. /**
  138945. * Specifies whether or not the outer glow is ACTIVE in the layer.
  138946. */
  138947. outerGlow: boolean;
  138948. /**
  138949. * Specifies the horizontal size of the blur.
  138950. */
  138951. set blurHorizontalSize(value: number);
  138952. /**
  138953. * Specifies the vertical size of the blur.
  138954. */
  138955. set blurVerticalSize(value: number);
  138956. /**
  138957. * Gets the horizontal size of the blur.
  138958. */
  138959. get blurHorizontalSize(): number;
  138960. /**
  138961. * Gets the vertical size of the blur.
  138962. */
  138963. get blurVerticalSize(): number;
  138964. /**
  138965. * An event triggered when the highlight layer is being blurred.
  138966. */
  138967. onBeforeBlurObservable: Observable<HighlightLayer>;
  138968. /**
  138969. * An event triggered when the highlight layer has been blurred.
  138970. */
  138971. onAfterBlurObservable: Observable<HighlightLayer>;
  138972. private _instanceGlowingMeshStencilReference;
  138973. private _options;
  138974. private _downSamplePostprocess;
  138975. private _horizontalBlurPostprocess;
  138976. private _verticalBlurPostprocess;
  138977. private _blurTexture;
  138978. private _meshes;
  138979. private _excludedMeshes;
  138980. /**
  138981. * Instantiates a new highlight Layer and references it to the scene..
  138982. * @param name The name of the layer
  138983. * @param scene The scene to use the layer in
  138984. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  138985. */
  138986. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  138987. /**
  138988. * Get the effect name of the layer.
  138989. * @return The effect name
  138990. */
  138991. getEffectName(): string;
  138992. /**
  138993. * Create the merge effect. This is the shader use to blit the information back
  138994. * to the main canvas at the end of the scene rendering.
  138995. */
  138996. protected _createMergeEffect(): Effect;
  138997. /**
  138998. * Creates the render target textures and post processes used in the highlight layer.
  138999. */
  139000. protected _createTextureAndPostProcesses(): void;
  139001. /**
  139002. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139003. */
  139004. needStencil(): boolean;
  139005. /**
  139006. * Checks for the readiness of the element composing the layer.
  139007. * @param subMesh the mesh to check for
  139008. * @param useInstances specify wether or not to use instances to render the mesh
  139009. * @param emissiveTexture the associated emissive texture used to generate the glow
  139010. * @return true if ready otherwise, false
  139011. */
  139012. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139013. /**
  139014. * Implementation specific of rendering the generating effect on the main canvas.
  139015. * @param effect The effect used to render through
  139016. */
  139017. protected _internalRender(effect: Effect): void;
  139018. /**
  139019. * Returns true if the layer contains information to display, otherwise false.
  139020. */
  139021. shouldRender(): boolean;
  139022. /**
  139023. * Returns true if the mesh should render, otherwise false.
  139024. * @param mesh The mesh to render
  139025. * @returns true if it should render otherwise false
  139026. */
  139027. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139028. /**
  139029. * Returns true if the mesh can be rendered, otherwise false.
  139030. * @param mesh The mesh to render
  139031. * @param material The material used on the mesh
  139032. * @returns true if it can be rendered otherwise false
  139033. */
  139034. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139035. /**
  139036. * Adds specific effects defines.
  139037. * @param defines The defines to add specifics to.
  139038. */
  139039. protected _addCustomEffectDefines(defines: string[]): void;
  139040. /**
  139041. * Sets the required values for both the emissive texture and and the main color.
  139042. */
  139043. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139044. /**
  139045. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139046. * @param mesh The mesh to exclude from the highlight layer
  139047. */
  139048. addExcludedMesh(mesh: Mesh): void;
  139049. /**
  139050. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139051. * @param mesh The mesh to highlight
  139052. */
  139053. removeExcludedMesh(mesh: Mesh): void;
  139054. /**
  139055. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139056. * @param mesh mesh to test
  139057. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139058. */
  139059. hasMesh(mesh: AbstractMesh): boolean;
  139060. /**
  139061. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139062. * @param mesh The mesh to highlight
  139063. * @param color The color of the highlight
  139064. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139065. */
  139066. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139067. /**
  139068. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139069. * @param mesh The mesh to highlight
  139070. */
  139071. removeMesh(mesh: Mesh): void;
  139072. /**
  139073. * Remove all the meshes currently referenced in the highlight layer
  139074. */
  139075. removeAllMeshes(): void;
  139076. /**
  139077. * Force the stencil to the normal expected value for none glowing parts
  139078. */
  139079. private _defaultStencilReference;
  139080. /**
  139081. * Free any resources and references associated to a mesh.
  139082. * Internal use
  139083. * @param mesh The mesh to free.
  139084. * @hidden
  139085. */
  139086. _disposeMesh(mesh: Mesh): void;
  139087. /**
  139088. * Dispose the highlight layer and free resources.
  139089. */
  139090. dispose(): void;
  139091. /**
  139092. * Gets the class name of the effect layer
  139093. * @returns the string with the class name of the effect layer
  139094. */
  139095. getClassName(): string;
  139096. /**
  139097. * Serializes this Highlight layer
  139098. * @returns a serialized Highlight layer object
  139099. */
  139100. serialize(): any;
  139101. /**
  139102. * Creates a Highlight layer from parsed Highlight layer data
  139103. * @param parsedHightlightLayer defines the Highlight layer data
  139104. * @param scene defines the current scene
  139105. * @param rootUrl defines the root URL containing the Highlight layer information
  139106. * @returns a parsed Highlight layer
  139107. */
  139108. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139109. }
  139110. }
  139111. declare module BABYLON {
  139112. interface AbstractScene {
  139113. /**
  139114. * The list of layers (background and foreground) of the scene
  139115. */
  139116. layers: Array<Layer>;
  139117. }
  139118. /**
  139119. * Defines the layer scene component responsible to manage any layers
  139120. * in a given scene.
  139121. */
  139122. export class LayerSceneComponent implements ISceneComponent {
  139123. /**
  139124. * The component name helpfull to identify the component in the list of scene components.
  139125. */
  139126. readonly name: string;
  139127. /**
  139128. * The scene the component belongs to.
  139129. */
  139130. scene: Scene;
  139131. private _engine;
  139132. /**
  139133. * Creates a new instance of the component for the given scene
  139134. * @param scene Defines the scene to register the component in
  139135. */
  139136. constructor(scene: Scene);
  139137. /**
  139138. * Registers the component in a given scene
  139139. */
  139140. register(): void;
  139141. /**
  139142. * Rebuilds the elements related to this component in case of
  139143. * context lost for instance.
  139144. */
  139145. rebuild(): void;
  139146. /**
  139147. * Disposes the component and the associated ressources.
  139148. */
  139149. dispose(): void;
  139150. private _draw;
  139151. private _drawCameraPredicate;
  139152. private _drawCameraBackground;
  139153. private _drawCameraForeground;
  139154. private _drawRenderTargetPredicate;
  139155. private _drawRenderTargetBackground;
  139156. private _drawRenderTargetForeground;
  139157. /**
  139158. * Adds all the elements from the container to the scene
  139159. * @param container the container holding the elements
  139160. */
  139161. addFromContainer(container: AbstractScene): void;
  139162. /**
  139163. * Removes all the elements in the container from the scene
  139164. * @param container contains the elements to remove
  139165. * @param dispose if the removed element should be disposed (default: false)
  139166. */
  139167. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139168. }
  139169. }
  139170. declare module BABYLON {
  139171. /** @hidden */
  139172. export var layerPixelShader: {
  139173. name: string;
  139174. shader: string;
  139175. };
  139176. }
  139177. declare module BABYLON {
  139178. /** @hidden */
  139179. export var layerVertexShader: {
  139180. name: string;
  139181. shader: string;
  139182. };
  139183. }
  139184. declare module BABYLON {
  139185. /**
  139186. * This represents a full screen 2d layer.
  139187. * This can be useful to display a picture in the background of your scene for instance.
  139188. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139189. */
  139190. export class Layer {
  139191. /**
  139192. * Define the name of the layer.
  139193. */
  139194. name: string;
  139195. /**
  139196. * Define the texture the layer should display.
  139197. */
  139198. texture: Nullable<Texture>;
  139199. /**
  139200. * Is the layer in background or foreground.
  139201. */
  139202. isBackground: boolean;
  139203. /**
  139204. * Define the color of the layer (instead of texture).
  139205. */
  139206. color: Color4;
  139207. /**
  139208. * Define the scale of the layer in order to zoom in out of the texture.
  139209. */
  139210. scale: Vector2;
  139211. /**
  139212. * Define an offset for the layer in order to shift the texture.
  139213. */
  139214. offset: Vector2;
  139215. /**
  139216. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139217. */
  139218. alphaBlendingMode: number;
  139219. /**
  139220. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139221. * Alpha test will not mix with the background color in case of transparency.
  139222. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139223. */
  139224. alphaTest: boolean;
  139225. /**
  139226. * Define a mask to restrict the layer to only some of the scene cameras.
  139227. */
  139228. layerMask: number;
  139229. /**
  139230. * Define the list of render target the layer is visible into.
  139231. */
  139232. renderTargetTextures: RenderTargetTexture[];
  139233. /**
  139234. * Define if the layer is only used in renderTarget or if it also
  139235. * renders in the main frame buffer of the canvas.
  139236. */
  139237. renderOnlyInRenderTargetTextures: boolean;
  139238. private _scene;
  139239. private _vertexBuffers;
  139240. private _indexBuffer;
  139241. private _effect;
  139242. private _previousDefines;
  139243. /**
  139244. * An event triggered when the layer is disposed.
  139245. */
  139246. onDisposeObservable: Observable<Layer>;
  139247. private _onDisposeObserver;
  139248. /**
  139249. * Back compatibility with callback before the onDisposeObservable existed.
  139250. * The set callback will be triggered when the layer has been disposed.
  139251. */
  139252. set onDispose(callback: () => void);
  139253. /**
  139254. * An event triggered before rendering the scene
  139255. */
  139256. onBeforeRenderObservable: Observable<Layer>;
  139257. private _onBeforeRenderObserver;
  139258. /**
  139259. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139260. * The set callback will be triggered just before rendering the layer.
  139261. */
  139262. set onBeforeRender(callback: () => void);
  139263. /**
  139264. * An event triggered after rendering the scene
  139265. */
  139266. onAfterRenderObservable: Observable<Layer>;
  139267. private _onAfterRenderObserver;
  139268. /**
  139269. * Back compatibility with callback before the onAfterRenderObservable existed.
  139270. * The set callback will be triggered just after rendering the layer.
  139271. */
  139272. set onAfterRender(callback: () => void);
  139273. /**
  139274. * Instantiates a new layer.
  139275. * This represents a full screen 2d layer.
  139276. * This can be useful to display a picture in the background of your scene for instance.
  139277. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139278. * @param name Define the name of the layer in the scene
  139279. * @param imgUrl Define the url of the texture to display in the layer
  139280. * @param scene Define the scene the layer belongs to
  139281. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139282. * @param color Defines a color for the layer
  139283. */
  139284. constructor(
  139285. /**
  139286. * Define the name of the layer.
  139287. */
  139288. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139289. private _createIndexBuffer;
  139290. /** @hidden */
  139291. _rebuild(): void;
  139292. /**
  139293. * Renders the layer in the scene.
  139294. */
  139295. render(): void;
  139296. /**
  139297. * Disposes and releases the associated ressources.
  139298. */
  139299. dispose(): void;
  139300. }
  139301. }
  139302. declare module BABYLON {
  139303. /** @hidden */
  139304. export var lensFlarePixelShader: {
  139305. name: string;
  139306. shader: string;
  139307. };
  139308. }
  139309. declare module BABYLON {
  139310. /** @hidden */
  139311. export var lensFlareVertexShader: {
  139312. name: string;
  139313. shader: string;
  139314. };
  139315. }
  139316. declare module BABYLON {
  139317. /**
  139318. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139319. * It is usually composed of several `lensFlare`.
  139320. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139321. */
  139322. export class LensFlareSystem {
  139323. /**
  139324. * Define the name of the lens flare system
  139325. */
  139326. name: string;
  139327. /**
  139328. * List of lens flares used in this system.
  139329. */
  139330. lensFlares: LensFlare[];
  139331. /**
  139332. * Define a limit from the border the lens flare can be visible.
  139333. */
  139334. borderLimit: number;
  139335. /**
  139336. * Define a viewport border we do not want to see the lens flare in.
  139337. */
  139338. viewportBorder: number;
  139339. /**
  139340. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139341. */
  139342. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139343. /**
  139344. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139345. */
  139346. layerMask: number;
  139347. /**
  139348. * Define the id of the lens flare system in the scene.
  139349. * (equal to name by default)
  139350. */
  139351. id: string;
  139352. private _scene;
  139353. private _emitter;
  139354. private _vertexBuffers;
  139355. private _indexBuffer;
  139356. private _effect;
  139357. private _positionX;
  139358. private _positionY;
  139359. private _isEnabled;
  139360. /** @hidden */
  139361. static _SceneComponentInitialization: (scene: Scene) => void;
  139362. /**
  139363. * Instantiates a lens flare system.
  139364. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139365. * It is usually composed of several `lensFlare`.
  139366. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139367. * @param name Define the name of the lens flare system in the scene
  139368. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139369. * @param scene Define the scene the lens flare system belongs to
  139370. */
  139371. constructor(
  139372. /**
  139373. * Define the name of the lens flare system
  139374. */
  139375. name: string, emitter: any, scene: Scene);
  139376. /**
  139377. * Define if the lens flare system is enabled.
  139378. */
  139379. get isEnabled(): boolean;
  139380. set isEnabled(value: boolean);
  139381. /**
  139382. * Get the scene the effects belongs to.
  139383. * @returns the scene holding the lens flare system
  139384. */
  139385. getScene(): Scene;
  139386. /**
  139387. * Get the emitter of the lens flare system.
  139388. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139389. * @returns the emitter of the lens flare system
  139390. */
  139391. getEmitter(): any;
  139392. /**
  139393. * Set the emitter of the lens flare system.
  139394. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139395. * @param newEmitter Define the new emitter of the system
  139396. */
  139397. setEmitter(newEmitter: any): void;
  139398. /**
  139399. * Get the lens flare system emitter position.
  139400. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139401. * @returns the position
  139402. */
  139403. getEmitterPosition(): Vector3;
  139404. /**
  139405. * @hidden
  139406. */
  139407. computeEffectivePosition(globalViewport: Viewport): boolean;
  139408. /** @hidden */
  139409. _isVisible(): boolean;
  139410. /**
  139411. * @hidden
  139412. */
  139413. render(): boolean;
  139414. /**
  139415. * Dispose and release the lens flare with its associated resources.
  139416. */
  139417. dispose(): void;
  139418. /**
  139419. * Parse a lens flare system from a JSON repressentation
  139420. * @param parsedLensFlareSystem Define the JSON to parse
  139421. * @param scene Define the scene the parsed system should be instantiated in
  139422. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139423. * @returns the parsed system
  139424. */
  139425. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139426. /**
  139427. * Serialize the current Lens Flare System into a JSON representation.
  139428. * @returns the serialized JSON
  139429. */
  139430. serialize(): any;
  139431. }
  139432. }
  139433. declare module BABYLON {
  139434. /**
  139435. * This represents one of the lens effect in a `lensFlareSystem`.
  139436. * It controls one of the indiviual texture used in the effect.
  139437. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139438. */
  139439. export class LensFlare {
  139440. /**
  139441. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139442. */
  139443. size: number;
  139444. /**
  139445. * 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.
  139446. */
  139447. position: number;
  139448. /**
  139449. * Define the lens color.
  139450. */
  139451. color: Color3;
  139452. /**
  139453. * Define the lens texture.
  139454. */
  139455. texture: Nullable<Texture>;
  139456. /**
  139457. * Define the alpha mode to render this particular lens.
  139458. */
  139459. alphaMode: number;
  139460. private _system;
  139461. /**
  139462. * Creates a new Lens Flare.
  139463. * This represents one of the lens effect in a `lensFlareSystem`.
  139464. * It controls one of the indiviual texture used in the effect.
  139465. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139466. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139467. * @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.
  139468. * @param color Define the lens color
  139469. * @param imgUrl Define the lens texture url
  139470. * @param system Define the `lensFlareSystem` this flare is part of
  139471. * @returns The newly created Lens Flare
  139472. */
  139473. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139474. /**
  139475. * Instantiates a new Lens Flare.
  139476. * This represents one of the lens effect in a `lensFlareSystem`.
  139477. * It controls one of the indiviual texture used in the effect.
  139478. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139479. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139480. * @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.
  139481. * @param color Define the lens color
  139482. * @param imgUrl Define the lens texture url
  139483. * @param system Define the `lensFlareSystem` this flare is part of
  139484. */
  139485. constructor(
  139486. /**
  139487. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139488. */
  139489. size: number,
  139490. /**
  139491. * 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.
  139492. */
  139493. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139494. /**
  139495. * Dispose and release the lens flare with its associated resources.
  139496. */
  139497. dispose(): void;
  139498. }
  139499. }
  139500. declare module BABYLON {
  139501. interface AbstractScene {
  139502. /**
  139503. * The list of lens flare system added to the scene
  139504. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139505. */
  139506. lensFlareSystems: Array<LensFlareSystem>;
  139507. /**
  139508. * Removes the given lens flare system from this scene.
  139509. * @param toRemove The lens flare system to remove
  139510. * @returns The index of the removed lens flare system
  139511. */
  139512. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139513. /**
  139514. * Adds the given lens flare system to this scene
  139515. * @param newLensFlareSystem The lens flare system to add
  139516. */
  139517. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139518. /**
  139519. * Gets a lens flare system using its name
  139520. * @param name defines the name to look for
  139521. * @returns the lens flare system or null if not found
  139522. */
  139523. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139524. /**
  139525. * Gets a lens flare system using its id
  139526. * @param id defines the id to look for
  139527. * @returns the lens flare system or null if not found
  139528. */
  139529. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139530. }
  139531. /**
  139532. * Defines the lens flare scene component responsible to manage any lens flares
  139533. * in a given scene.
  139534. */
  139535. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139536. /**
  139537. * The component name helpfull to identify the component in the list of scene components.
  139538. */
  139539. readonly name: string;
  139540. /**
  139541. * The scene the component belongs to.
  139542. */
  139543. scene: Scene;
  139544. /**
  139545. * Creates a new instance of the component for the given scene
  139546. * @param scene Defines the scene to register the component in
  139547. */
  139548. constructor(scene: Scene);
  139549. /**
  139550. * Registers the component in a given scene
  139551. */
  139552. register(): void;
  139553. /**
  139554. * Rebuilds the elements related to this component in case of
  139555. * context lost for instance.
  139556. */
  139557. rebuild(): void;
  139558. /**
  139559. * Adds all the elements from the container to the scene
  139560. * @param container the container holding the elements
  139561. */
  139562. addFromContainer(container: AbstractScene): void;
  139563. /**
  139564. * Removes all the elements in the container from the scene
  139565. * @param container contains the elements to remove
  139566. * @param dispose if the removed element should be disposed (default: false)
  139567. */
  139568. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139569. /**
  139570. * Serializes the component data to the specified json object
  139571. * @param serializationObject The object to serialize to
  139572. */
  139573. serialize(serializationObject: any): void;
  139574. /**
  139575. * Disposes the component and the associated ressources.
  139576. */
  139577. dispose(): void;
  139578. private _draw;
  139579. }
  139580. }
  139581. declare module BABYLON {
  139582. /** @hidden */
  139583. export var depthPixelShader: {
  139584. name: string;
  139585. shader: string;
  139586. };
  139587. }
  139588. declare module BABYLON {
  139589. /** @hidden */
  139590. export var depthVertexShader: {
  139591. name: string;
  139592. shader: string;
  139593. };
  139594. }
  139595. declare module BABYLON {
  139596. /**
  139597. * This represents a depth renderer in Babylon.
  139598. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  139599. */
  139600. export class DepthRenderer {
  139601. private _scene;
  139602. private _depthMap;
  139603. private _effect;
  139604. private readonly _storeNonLinearDepth;
  139605. private readonly _clearColor;
  139606. /** Get if the depth renderer is using packed depth or not */
  139607. readonly isPacked: boolean;
  139608. private _cachedDefines;
  139609. private _camera;
  139610. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  139611. enabled: boolean;
  139612. /**
  139613. * Specifiess that the depth renderer will only be used within
  139614. * the camera it is created for.
  139615. * This can help forcing its rendering during the camera processing.
  139616. */
  139617. useOnlyInActiveCamera: boolean;
  139618. /** @hidden */
  139619. static _SceneComponentInitialization: (scene: Scene) => void;
  139620. /**
  139621. * Instantiates a depth renderer
  139622. * @param scene The scene the renderer belongs to
  139623. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139624. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139625. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139626. */
  139627. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  139628. /**
  139629. * Creates the depth rendering effect and checks if the effect is ready.
  139630. * @param subMesh The submesh to be used to render the depth map of
  139631. * @param useInstances If multiple world instances should be used
  139632. * @returns if the depth renderer is ready to render the depth map
  139633. */
  139634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139635. /**
  139636. * Gets the texture which the depth map will be written to.
  139637. * @returns The depth map texture
  139638. */
  139639. getDepthMap(): RenderTargetTexture;
  139640. /**
  139641. * Disposes of the depth renderer.
  139642. */
  139643. dispose(): void;
  139644. }
  139645. }
  139646. declare module BABYLON {
  139647. /** @hidden */
  139648. export var minmaxReduxPixelShader: {
  139649. name: string;
  139650. shader: string;
  139651. };
  139652. }
  139653. declare module BABYLON {
  139654. /**
  139655. * This class computes a min/max reduction from a texture: it means it computes the minimum
  139656. * and maximum values from all values of the texture.
  139657. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  139658. * The source values are read from the red channel of the texture.
  139659. */
  139660. export class MinMaxReducer {
  139661. /**
  139662. * Observable triggered when the computation has been performed
  139663. */
  139664. onAfterReductionPerformed: Observable<{
  139665. min: number;
  139666. max: number;
  139667. }>;
  139668. protected _camera: Camera;
  139669. protected _sourceTexture: Nullable<RenderTargetTexture>;
  139670. protected _reductionSteps: Nullable<Array<PostProcess>>;
  139671. protected _postProcessManager: PostProcessManager;
  139672. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  139673. protected _forceFullscreenViewport: boolean;
  139674. /**
  139675. * Creates a min/max reducer
  139676. * @param camera The camera to use for the post processes
  139677. */
  139678. constructor(camera: Camera);
  139679. /**
  139680. * Gets the texture used to read the values from.
  139681. */
  139682. get sourceTexture(): Nullable<RenderTargetTexture>;
  139683. /**
  139684. * Sets the source texture to read the values from.
  139685. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  139686. * because in such textures '1' value must not be taken into account to compute the maximum
  139687. * as this value is used to clear the texture.
  139688. * Note that the computation is not activated by calling this function, you must call activate() for that!
  139689. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  139690. * @param depthRedux Indicates if the texture is a depth texture or not
  139691. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  139692. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139693. */
  139694. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139695. /**
  139696. * Defines the refresh rate of the computation.
  139697. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139698. */
  139699. get refreshRate(): number;
  139700. set refreshRate(value: number);
  139701. protected _activated: boolean;
  139702. /**
  139703. * Gets the activation status of the reducer
  139704. */
  139705. get activated(): boolean;
  139706. /**
  139707. * Activates the reduction computation.
  139708. * When activated, the observers registered in onAfterReductionPerformed are
  139709. * called after the compuation is performed
  139710. */
  139711. activate(): void;
  139712. /**
  139713. * Deactivates the reduction computation.
  139714. */
  139715. deactivate(): void;
  139716. /**
  139717. * Disposes the min/max reducer
  139718. * @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.
  139719. */
  139720. dispose(disposeAll?: boolean): void;
  139721. }
  139722. }
  139723. declare module BABYLON {
  139724. /**
  139725. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  139726. */
  139727. export class DepthReducer extends MinMaxReducer {
  139728. private _depthRenderer;
  139729. private _depthRendererId;
  139730. /**
  139731. * Gets the depth renderer used for the computation.
  139732. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  139733. */
  139734. get depthRenderer(): Nullable<DepthRenderer>;
  139735. /**
  139736. * Creates a depth reducer
  139737. * @param camera The camera used to render the depth texture
  139738. */
  139739. constructor(camera: Camera);
  139740. /**
  139741. * Sets the depth renderer to use to generate the depth map
  139742. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  139743. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  139744. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139745. */
  139746. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  139747. /** @hidden */
  139748. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139749. /**
  139750. * Activates the reduction computation.
  139751. * When activated, the observers registered in onAfterReductionPerformed are
  139752. * called after the compuation is performed
  139753. */
  139754. activate(): void;
  139755. /**
  139756. * Deactivates the reduction computation.
  139757. */
  139758. deactivate(): void;
  139759. /**
  139760. * Disposes the depth reducer
  139761. * @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.
  139762. */
  139763. dispose(disposeAll?: boolean): void;
  139764. }
  139765. }
  139766. declare module BABYLON {
  139767. /**
  139768. * A CSM implementation allowing casting shadows on large scenes.
  139769. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139770. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  139771. */
  139772. export class CascadedShadowGenerator extends ShadowGenerator {
  139773. private static readonly frustumCornersNDCSpace;
  139774. /**
  139775. * Name of the CSM class
  139776. */
  139777. static CLASSNAME: string;
  139778. /**
  139779. * Defines the default number of cascades used by the CSM.
  139780. */
  139781. static readonly DEFAULT_CASCADES_COUNT: number;
  139782. /**
  139783. * Defines the minimum number of cascades used by the CSM.
  139784. */
  139785. static readonly MIN_CASCADES_COUNT: number;
  139786. /**
  139787. * Defines the maximum number of cascades used by the CSM.
  139788. */
  139789. static readonly MAX_CASCADES_COUNT: number;
  139790. protected _validateFilter(filter: number): number;
  139791. /**
  139792. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  139793. */
  139794. penumbraDarkness: number;
  139795. private _numCascades;
  139796. /**
  139797. * Gets or set the number of cascades used by the CSM.
  139798. */
  139799. get numCascades(): number;
  139800. set numCascades(value: number);
  139801. /**
  139802. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  139803. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  139804. */
  139805. stabilizeCascades: boolean;
  139806. private _freezeShadowCastersBoundingInfo;
  139807. private _freezeShadowCastersBoundingInfoObservable;
  139808. /**
  139809. * Enables or disables the shadow casters bounding info computation.
  139810. * If your shadow casters don't move, you can disable this feature.
  139811. * If it is enabled, the bounding box computation is done every frame.
  139812. */
  139813. get freezeShadowCastersBoundingInfo(): boolean;
  139814. set freezeShadowCastersBoundingInfo(freeze: boolean);
  139815. private _scbiMin;
  139816. private _scbiMax;
  139817. protected _computeShadowCastersBoundingInfo(): void;
  139818. protected _shadowCastersBoundingInfo: BoundingInfo;
  139819. /**
  139820. * Gets or sets the shadow casters bounding info.
  139821. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  139822. * so that the system won't overwrite the bounds you provide
  139823. */
  139824. get shadowCastersBoundingInfo(): BoundingInfo;
  139825. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  139826. protected _breaksAreDirty: boolean;
  139827. protected _minDistance: number;
  139828. protected _maxDistance: number;
  139829. /**
  139830. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  139831. *
  139832. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  139833. * If you don't know these values, simply leave them to their defaults and don't call this function.
  139834. * @param min minimal distance for the breaks (default to 0.)
  139835. * @param max maximal distance for the breaks (default to 1.)
  139836. */
  139837. setMinMaxDistance(min: number, max: number): void;
  139838. /** Gets the minimal distance used in the cascade break computation */
  139839. get minDistance(): number;
  139840. /** Gets the maximal distance used in the cascade break computation */
  139841. get maxDistance(): number;
  139842. /**
  139843. * Gets the class name of that object
  139844. * @returns "CascadedShadowGenerator"
  139845. */
  139846. getClassName(): string;
  139847. private _cascadeMinExtents;
  139848. private _cascadeMaxExtents;
  139849. /**
  139850. * Gets a cascade minimum extents
  139851. * @param cascadeIndex index of the cascade
  139852. * @returns the minimum cascade extents
  139853. */
  139854. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  139855. /**
  139856. * Gets a cascade maximum extents
  139857. * @param cascadeIndex index of the cascade
  139858. * @returns the maximum cascade extents
  139859. */
  139860. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  139861. private _cascades;
  139862. private _currentLayer;
  139863. private _viewSpaceFrustumsZ;
  139864. private _viewMatrices;
  139865. private _projectionMatrices;
  139866. private _transformMatrices;
  139867. private _transformMatricesAsArray;
  139868. private _frustumLengths;
  139869. private _lightSizeUVCorrection;
  139870. private _depthCorrection;
  139871. private _frustumCornersWorldSpace;
  139872. private _frustumCenter;
  139873. private _shadowCameraPos;
  139874. private _shadowMaxZ;
  139875. /**
  139876. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  139877. * It defaults to camera.maxZ
  139878. */
  139879. get shadowMaxZ(): number;
  139880. /**
  139881. * Sets the shadow max z distance.
  139882. */
  139883. set shadowMaxZ(value: number);
  139884. protected _debug: boolean;
  139885. /**
  139886. * Gets or sets the debug flag.
  139887. * When enabled, the cascades are materialized by different colors on the screen.
  139888. */
  139889. get debug(): boolean;
  139890. set debug(dbg: boolean);
  139891. private _depthClamp;
  139892. /**
  139893. * Gets or sets the depth clamping value.
  139894. *
  139895. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  139896. * to account for the shadow casters far away.
  139897. *
  139898. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  139899. */
  139900. get depthClamp(): boolean;
  139901. set depthClamp(value: boolean);
  139902. private _cascadeBlendPercentage;
  139903. /**
  139904. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  139905. * It defaults to 0.1 (10% blending).
  139906. */
  139907. get cascadeBlendPercentage(): number;
  139908. set cascadeBlendPercentage(value: number);
  139909. private _lambda;
  139910. /**
  139911. * Gets or set the lambda parameter.
  139912. * This parameter is used to split the camera frustum and create the cascades.
  139913. * 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.
  139914. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  139915. */
  139916. get lambda(): number;
  139917. set lambda(value: number);
  139918. /**
  139919. * Gets the view matrix corresponding to a given cascade
  139920. * @param cascadeNum cascade to retrieve the view matrix from
  139921. * @returns the cascade view matrix
  139922. */
  139923. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  139924. /**
  139925. * Gets the projection matrix corresponding to a given cascade
  139926. * @param cascadeNum cascade to retrieve the projection matrix from
  139927. * @returns the cascade projection matrix
  139928. */
  139929. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  139930. /**
  139931. * Gets the transformation matrix corresponding to a given cascade
  139932. * @param cascadeNum cascade to retrieve the transformation matrix from
  139933. * @returns the cascade transformation matrix
  139934. */
  139935. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  139936. private _depthRenderer;
  139937. /**
  139938. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  139939. *
  139940. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  139941. *
  139942. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  139943. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  139944. * @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
  139945. */
  139946. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  139947. private _depthReducer;
  139948. private _autoCalcDepthBounds;
  139949. /**
  139950. * Gets or sets the autoCalcDepthBounds property.
  139951. *
  139952. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  139953. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  139954. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  139955. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  139956. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  139957. */
  139958. get autoCalcDepthBounds(): boolean;
  139959. set autoCalcDepthBounds(value: boolean);
  139960. /**
  139961. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  139962. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139963. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  139964. * for setting the refresh rate on the renderer yourself!
  139965. */
  139966. get autoCalcDepthBoundsRefreshRate(): number;
  139967. set autoCalcDepthBoundsRefreshRate(value: number);
  139968. /**
  139969. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  139970. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  139971. * you change the camera near/far planes!
  139972. */
  139973. splitFrustum(): void;
  139974. private _splitFrustum;
  139975. private _computeMatrices;
  139976. private _computeFrustumInWorldSpace;
  139977. private _computeCascadeFrustum;
  139978. /**
  139979. * Support test.
  139980. */
  139981. static get IsSupported(): boolean;
  139982. /** @hidden */
  139983. static _SceneComponentInitialization: (scene: Scene) => void;
  139984. /**
  139985. * Creates a Cascaded Shadow Generator object.
  139986. * A ShadowGenerator is the required tool to use the shadows.
  139987. * Each directional light casting shadows needs to use its own ShadowGenerator.
  139988. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139989. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  139990. * @param light The directional light object generating the shadows.
  139991. * @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.
  139992. */
  139993. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  139994. protected _initializeGenerator(): void;
  139995. protected _createTargetRenderTexture(): void;
  139996. protected _initializeShadowMap(): void;
  139997. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  139998. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  139999. /**
  140000. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140001. * @param defines Defines of the material we want to update
  140002. * @param lightIndex Index of the light in the enabled light list of the material
  140003. */
  140004. prepareDefines(defines: any, lightIndex: number): void;
  140005. /**
  140006. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140007. * defined in the generator but impacting the effect).
  140008. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140009. * @param effect The effect we are binfing the information for
  140010. */
  140011. bindShadowLight(lightIndex: string, effect: Effect): void;
  140012. /**
  140013. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140014. * (eq to view projection * shadow projection matrices)
  140015. * @returns The transform matrix used to create the shadow map
  140016. */
  140017. getTransformMatrix(): Matrix;
  140018. /**
  140019. * Disposes the ShadowGenerator.
  140020. * Returns nothing.
  140021. */
  140022. dispose(): void;
  140023. /**
  140024. * Serializes the shadow generator setup to a json object.
  140025. * @returns The serialized JSON object
  140026. */
  140027. serialize(): any;
  140028. /**
  140029. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140030. * @param parsedShadowGenerator The JSON object to parse
  140031. * @param scene The scene to create the shadow map for
  140032. * @returns The parsed shadow generator
  140033. */
  140034. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140035. }
  140036. }
  140037. declare module BABYLON {
  140038. /**
  140039. * Defines the shadow generator component responsible to manage any shadow generators
  140040. * in a given scene.
  140041. */
  140042. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140043. /**
  140044. * The component name helpfull to identify the component in the list of scene components.
  140045. */
  140046. readonly name: string;
  140047. /**
  140048. * The scene the component belongs to.
  140049. */
  140050. scene: Scene;
  140051. /**
  140052. * Creates a new instance of the component for the given scene
  140053. * @param scene Defines the scene to register the component in
  140054. */
  140055. constructor(scene: Scene);
  140056. /**
  140057. * Registers the component in a given scene
  140058. */
  140059. register(): void;
  140060. /**
  140061. * Rebuilds the elements related to this component in case of
  140062. * context lost for instance.
  140063. */
  140064. rebuild(): void;
  140065. /**
  140066. * Serializes the component data to the specified json object
  140067. * @param serializationObject The object to serialize to
  140068. */
  140069. serialize(serializationObject: any): void;
  140070. /**
  140071. * Adds all the elements from the container to the scene
  140072. * @param container the container holding the elements
  140073. */
  140074. addFromContainer(container: AbstractScene): void;
  140075. /**
  140076. * Removes all the elements in the container from the scene
  140077. * @param container contains the elements to remove
  140078. * @param dispose if the removed element should be disposed (default: false)
  140079. */
  140080. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140081. /**
  140082. * Rebuilds the elements related to this component in case of
  140083. * context lost for instance.
  140084. */
  140085. dispose(): void;
  140086. private _gatherRenderTargets;
  140087. }
  140088. }
  140089. declare module BABYLON {
  140090. /**
  140091. * A point light is a light defined by an unique point in world space.
  140092. * The light is emitted in every direction from this point.
  140093. * A good example of a point light is a standard light bulb.
  140094. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140095. */
  140096. export class PointLight extends ShadowLight {
  140097. private _shadowAngle;
  140098. /**
  140099. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140100. * This specifies what angle the shadow will use to be created.
  140101. *
  140102. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140103. */
  140104. get shadowAngle(): number;
  140105. /**
  140106. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140107. * This specifies what angle the shadow will use to be created.
  140108. *
  140109. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140110. */
  140111. set shadowAngle(value: number);
  140112. /**
  140113. * Gets the direction if it has been set.
  140114. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140115. */
  140116. get direction(): Vector3;
  140117. /**
  140118. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140119. */
  140120. set direction(value: Vector3);
  140121. /**
  140122. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140123. * A PointLight emits the light in every direction.
  140124. * It can cast shadows.
  140125. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140126. * ```javascript
  140127. * var pointLight = new PointLight("pl", camera.position, scene);
  140128. * ```
  140129. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140130. * @param name The light friendly name
  140131. * @param position The position of the point light in the scene
  140132. * @param scene The scene the lights belongs to
  140133. */
  140134. constructor(name: string, position: Vector3, scene: Scene);
  140135. /**
  140136. * Returns the string "PointLight"
  140137. * @returns the class name
  140138. */
  140139. getClassName(): string;
  140140. /**
  140141. * Returns the integer 0.
  140142. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140143. */
  140144. getTypeID(): number;
  140145. /**
  140146. * Specifies wether or not the shadowmap should be a cube texture.
  140147. * @returns true if the shadowmap needs to be a cube texture.
  140148. */
  140149. needCube(): boolean;
  140150. /**
  140151. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140152. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140153. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140154. */
  140155. getShadowDirection(faceIndex?: number): Vector3;
  140156. /**
  140157. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140158. * - fov = PI / 2
  140159. * - aspect ratio : 1.0
  140160. * - z-near and far equal to the active camera minZ and maxZ.
  140161. * Returns the PointLight.
  140162. */
  140163. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140164. protected _buildUniformLayout(): void;
  140165. /**
  140166. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140167. * @param effect The effect to update
  140168. * @param lightIndex The index of the light in the effect to update
  140169. * @returns The point light
  140170. */
  140171. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140172. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140173. /**
  140174. * Prepares the list of defines specific to the light type.
  140175. * @param defines the list of defines
  140176. * @param lightIndex defines the index of the light for the effect
  140177. */
  140178. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140179. }
  140180. }
  140181. declare module BABYLON {
  140182. /**
  140183. * Header information of HDR texture files.
  140184. */
  140185. export interface HDRInfo {
  140186. /**
  140187. * The height of the texture in pixels.
  140188. */
  140189. height: number;
  140190. /**
  140191. * The width of the texture in pixels.
  140192. */
  140193. width: number;
  140194. /**
  140195. * The index of the beginning of the data in the binary file.
  140196. */
  140197. dataPosition: number;
  140198. }
  140199. /**
  140200. * This groups tools to convert HDR texture to native colors array.
  140201. */
  140202. export class HDRTools {
  140203. private static Ldexp;
  140204. private static Rgbe2float;
  140205. private static readStringLine;
  140206. /**
  140207. * Reads header information from an RGBE texture stored in a native array.
  140208. * More information on this format are available here:
  140209. * https://en.wikipedia.org/wiki/RGBE_image_format
  140210. *
  140211. * @param uint8array The binary file stored in native array.
  140212. * @return The header information.
  140213. */
  140214. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140215. /**
  140216. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140217. * This RGBE texture needs to store the information as a panorama.
  140218. *
  140219. * More information on this format are available here:
  140220. * https://en.wikipedia.org/wiki/RGBE_image_format
  140221. *
  140222. * @param buffer The binary file stored in an array buffer.
  140223. * @param size The expected size of the extracted cubemap.
  140224. * @return The Cube Map information.
  140225. */
  140226. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140227. /**
  140228. * Returns the pixels data extracted from an RGBE texture.
  140229. * This pixels will be stored left to right up to down in the R G B order in one array.
  140230. *
  140231. * More information on this format are available here:
  140232. * https://en.wikipedia.org/wiki/RGBE_image_format
  140233. *
  140234. * @param uint8array The binary file stored in an array buffer.
  140235. * @param hdrInfo The header information of the file.
  140236. * @return The pixels data in RGB right to left up to down order.
  140237. */
  140238. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140239. private static RGBE_ReadPixels_RLE;
  140240. private static RGBE_ReadPixels_NOT_RLE;
  140241. }
  140242. }
  140243. declare module BABYLON {
  140244. /**
  140245. * Effect Render Options
  140246. */
  140247. export interface IEffectRendererOptions {
  140248. /**
  140249. * Defines the vertices positions.
  140250. */
  140251. positions?: number[];
  140252. /**
  140253. * Defines the indices.
  140254. */
  140255. indices?: number[];
  140256. }
  140257. /**
  140258. * Helper class to render one or more effects.
  140259. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140260. */
  140261. export class EffectRenderer {
  140262. private engine;
  140263. private static _DefaultOptions;
  140264. private _vertexBuffers;
  140265. private _indexBuffer;
  140266. private _fullscreenViewport;
  140267. /**
  140268. * Creates an effect renderer
  140269. * @param engine the engine to use for rendering
  140270. * @param options defines the options of the effect renderer
  140271. */
  140272. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140273. /**
  140274. * Sets the current viewport in normalized coordinates 0-1
  140275. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140276. */
  140277. setViewport(viewport?: Viewport): void;
  140278. /**
  140279. * Binds the embedded attributes buffer to the effect.
  140280. * @param effect Defines the effect to bind the attributes for
  140281. */
  140282. bindBuffers(effect: Effect): void;
  140283. /**
  140284. * Sets the current effect wrapper to use during draw.
  140285. * The effect needs to be ready before calling this api.
  140286. * This also sets the default full screen position attribute.
  140287. * @param effectWrapper Defines the effect to draw with
  140288. */
  140289. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140290. /**
  140291. * Restores engine states
  140292. */
  140293. restoreStates(): void;
  140294. /**
  140295. * Draws a full screen quad.
  140296. */
  140297. draw(): void;
  140298. private isRenderTargetTexture;
  140299. /**
  140300. * renders one or more effects to a specified texture
  140301. * @param effectWrapper the effect to renderer
  140302. * @param outputTexture texture to draw to, if null it will render to the screen.
  140303. */
  140304. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140305. /**
  140306. * Disposes of the effect renderer
  140307. */
  140308. dispose(): void;
  140309. }
  140310. /**
  140311. * Options to create an EffectWrapper
  140312. */
  140313. interface EffectWrapperCreationOptions {
  140314. /**
  140315. * Engine to use to create the effect
  140316. */
  140317. engine: ThinEngine;
  140318. /**
  140319. * Fragment shader for the effect
  140320. */
  140321. fragmentShader: string;
  140322. /**
  140323. * Use the shader store instead of direct source code
  140324. */
  140325. useShaderStore?: boolean;
  140326. /**
  140327. * Vertex shader for the effect
  140328. */
  140329. vertexShader?: string;
  140330. /**
  140331. * Attributes to use in the shader
  140332. */
  140333. attributeNames?: Array<string>;
  140334. /**
  140335. * Uniforms to use in the shader
  140336. */
  140337. uniformNames?: Array<string>;
  140338. /**
  140339. * Texture sampler names to use in the shader
  140340. */
  140341. samplerNames?: Array<string>;
  140342. /**
  140343. * Defines to use in the shader
  140344. */
  140345. defines?: Array<string>;
  140346. /**
  140347. * Callback when effect is compiled
  140348. */
  140349. onCompiled?: Nullable<(effect: Effect) => void>;
  140350. /**
  140351. * The friendly name of the effect displayed in Spector.
  140352. */
  140353. name?: string;
  140354. }
  140355. /**
  140356. * Wraps an effect to be used for rendering
  140357. */
  140358. export class EffectWrapper {
  140359. /**
  140360. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140361. */
  140362. onApplyObservable: Observable<{}>;
  140363. /**
  140364. * The underlying effect
  140365. */
  140366. effect: Effect;
  140367. /**
  140368. * Creates an effect to be renderer
  140369. * @param creationOptions options to create the effect
  140370. */
  140371. constructor(creationOptions: EffectWrapperCreationOptions);
  140372. /**
  140373. * Disposes of the effect wrapper
  140374. */
  140375. dispose(): void;
  140376. }
  140377. }
  140378. declare module BABYLON {
  140379. /** @hidden */
  140380. export var hdrFilteringVertexShader: {
  140381. name: string;
  140382. shader: string;
  140383. };
  140384. }
  140385. declare module BABYLON {
  140386. /** @hidden */
  140387. export var hdrFilteringPixelShader: {
  140388. name: string;
  140389. shader: string;
  140390. };
  140391. }
  140392. declare module BABYLON {
  140393. /**
  140394. * Options for texture filtering
  140395. */
  140396. interface IHDRFilteringOptions {
  140397. /**
  140398. * Scales pixel intensity for the input HDR map.
  140399. */
  140400. hdrScale?: number;
  140401. /**
  140402. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140403. */
  140404. quality?: number;
  140405. }
  140406. /**
  140407. * Filters HDR maps to get correct renderings of PBR reflections
  140408. */
  140409. export class HDRFiltering {
  140410. private _engine;
  140411. private _effectRenderer;
  140412. private _effectWrapper;
  140413. private _lodGenerationOffset;
  140414. private _lodGenerationScale;
  140415. /**
  140416. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140417. * you care about baking speed.
  140418. */
  140419. quality: number;
  140420. /**
  140421. * Scales pixel intensity for the input HDR map.
  140422. */
  140423. hdrScale: number;
  140424. /**
  140425. * Instantiates HDR filter for reflection maps
  140426. *
  140427. * @param engine Thin engine
  140428. * @param options Options
  140429. */
  140430. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140431. private _createRenderTarget;
  140432. private _prefilterInternal;
  140433. private _createEffect;
  140434. /**
  140435. * Get a value indicating if the filter is ready to be used
  140436. * @param texture Texture to filter
  140437. * @returns true if the filter is ready
  140438. */
  140439. isReady(texture: BaseTexture): boolean;
  140440. /**
  140441. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140442. * Prefiltering will be invoked at the end of next rendering pass.
  140443. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140444. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140445. * @param texture Texture to filter
  140446. * @param onFinished Callback when filtering is done
  140447. * @return Promise called when prefiltering is done
  140448. */
  140449. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140450. }
  140451. }
  140452. declare module BABYLON {
  140453. /**
  140454. * This represents a texture coming from an HDR input.
  140455. *
  140456. * The only supported format is currently panorama picture stored in RGBE format.
  140457. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140458. */
  140459. export class HDRCubeTexture extends BaseTexture {
  140460. private static _facesMapping;
  140461. private _generateHarmonics;
  140462. private _noMipmap;
  140463. private _prefilterOnLoad;
  140464. private _textureMatrix;
  140465. private _size;
  140466. private _onLoad;
  140467. private _onError;
  140468. /**
  140469. * The texture URL.
  140470. */
  140471. url: string;
  140472. protected _isBlocking: boolean;
  140473. /**
  140474. * Sets wether or not the texture is blocking during loading.
  140475. */
  140476. set isBlocking(value: boolean);
  140477. /**
  140478. * Gets wether or not the texture is blocking during loading.
  140479. */
  140480. get isBlocking(): boolean;
  140481. protected _rotationY: number;
  140482. /**
  140483. * Sets texture matrix rotation angle around Y axis in radians.
  140484. */
  140485. set rotationY(value: number);
  140486. /**
  140487. * Gets texture matrix rotation angle around Y axis radians.
  140488. */
  140489. get rotationY(): number;
  140490. /**
  140491. * Gets or sets the center of the bounding box associated with the cube texture
  140492. * It must define where the camera used to render the texture was set
  140493. */
  140494. boundingBoxPosition: Vector3;
  140495. private _boundingBoxSize;
  140496. /**
  140497. * Gets or sets the size of the bounding box associated with the cube texture
  140498. * When defined, the cubemap will switch to local mode
  140499. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140500. * @example https://www.babylonjs-playground.com/#RNASML
  140501. */
  140502. set boundingBoxSize(value: Vector3);
  140503. get boundingBoxSize(): Vector3;
  140504. /**
  140505. * Instantiates an HDRTexture from the following parameters.
  140506. *
  140507. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140508. * @param sceneOrEngine The scene or engine the texture will be used in
  140509. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140510. * @param noMipmap Forces to not generate the mipmap if true
  140511. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140512. * @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)
  140513. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140514. */
  140515. 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>);
  140516. /**
  140517. * Get the current class name of the texture useful for serialization or dynamic coding.
  140518. * @returns "HDRCubeTexture"
  140519. */
  140520. getClassName(): string;
  140521. /**
  140522. * Occurs when the file is raw .hdr file.
  140523. */
  140524. private loadTexture;
  140525. clone(): HDRCubeTexture;
  140526. delayLoad(): void;
  140527. /**
  140528. * Get the texture reflection matrix used to rotate/transform the reflection.
  140529. * @returns the reflection matrix
  140530. */
  140531. getReflectionTextureMatrix(): Matrix;
  140532. /**
  140533. * Set the texture reflection matrix used to rotate/transform the reflection.
  140534. * @param value Define the reflection matrix to set
  140535. */
  140536. setReflectionTextureMatrix(value: Matrix): void;
  140537. /**
  140538. * Parses a JSON representation of an HDR Texture in order to create the texture
  140539. * @param parsedTexture Define the JSON representation
  140540. * @param scene Define the scene the texture should be created in
  140541. * @param rootUrl Define the root url in case we need to load relative dependencies
  140542. * @returns the newly created texture after parsing
  140543. */
  140544. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140545. serialize(): any;
  140546. }
  140547. }
  140548. declare module BABYLON {
  140549. /**
  140550. * Class used to control physics engine
  140551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140552. */
  140553. export class PhysicsEngine implements IPhysicsEngine {
  140554. private _physicsPlugin;
  140555. /**
  140556. * Global value used to control the smallest number supported by the simulation
  140557. */
  140558. static Epsilon: number;
  140559. private _impostors;
  140560. private _joints;
  140561. private _subTimeStep;
  140562. /**
  140563. * Gets the gravity vector used by the simulation
  140564. */
  140565. gravity: Vector3;
  140566. /**
  140567. * Factory used to create the default physics plugin.
  140568. * @returns The default physics plugin
  140569. */
  140570. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140571. /**
  140572. * Creates a new Physics Engine
  140573. * @param gravity defines the gravity vector used by the simulation
  140574. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140575. */
  140576. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140577. /**
  140578. * Sets the gravity vector used by the simulation
  140579. * @param gravity defines the gravity vector to use
  140580. */
  140581. setGravity(gravity: Vector3): void;
  140582. /**
  140583. * Set the time step of the physics engine.
  140584. * Default is 1/60.
  140585. * To slow it down, enter 1/600 for example.
  140586. * To speed it up, 1/30
  140587. * @param newTimeStep defines the new timestep to apply to this world.
  140588. */
  140589. setTimeStep(newTimeStep?: number): void;
  140590. /**
  140591. * Get the time step of the physics engine.
  140592. * @returns the current time step
  140593. */
  140594. getTimeStep(): number;
  140595. /**
  140596. * Set the sub time step of the physics engine.
  140597. * Default is 0 meaning there is no sub steps
  140598. * To increase physics resolution precision, set a small value (like 1 ms)
  140599. * @param subTimeStep defines the new sub timestep used for physics resolution.
  140600. */
  140601. setSubTimeStep(subTimeStep?: number): void;
  140602. /**
  140603. * Get the sub time step of the physics engine.
  140604. * @returns the current sub time step
  140605. */
  140606. getSubTimeStep(): number;
  140607. /**
  140608. * Release all resources
  140609. */
  140610. dispose(): void;
  140611. /**
  140612. * Gets the name of the current physics plugin
  140613. * @returns the name of the plugin
  140614. */
  140615. getPhysicsPluginName(): string;
  140616. /**
  140617. * Adding a new impostor for the impostor tracking.
  140618. * This will be done by the impostor itself.
  140619. * @param impostor the impostor to add
  140620. */
  140621. addImpostor(impostor: PhysicsImpostor): void;
  140622. /**
  140623. * Remove an impostor from the engine.
  140624. * This impostor and its mesh will not longer be updated by the physics engine.
  140625. * @param impostor the impostor to remove
  140626. */
  140627. removeImpostor(impostor: PhysicsImpostor): void;
  140628. /**
  140629. * Add a joint to the physics engine
  140630. * @param mainImpostor defines the main impostor to which the joint is added.
  140631. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  140632. * @param joint defines the joint that will connect both impostors.
  140633. */
  140634. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140635. /**
  140636. * Removes a joint from the simulation
  140637. * @param mainImpostor defines the impostor used with the joint
  140638. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  140639. * @param joint defines the joint to remove
  140640. */
  140641. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140642. /**
  140643. * Called by the scene. No need to call it.
  140644. * @param delta defines the timespam between frames
  140645. */
  140646. _step(delta: number): void;
  140647. /**
  140648. * Gets the current plugin used to run the simulation
  140649. * @returns current plugin
  140650. */
  140651. getPhysicsPlugin(): IPhysicsEnginePlugin;
  140652. /**
  140653. * Gets the list of physic impostors
  140654. * @returns an array of PhysicsImpostor
  140655. */
  140656. getImpostors(): Array<PhysicsImpostor>;
  140657. /**
  140658. * Gets the impostor for a physics enabled object
  140659. * @param object defines the object impersonated by the impostor
  140660. * @returns the PhysicsImpostor or null if not found
  140661. */
  140662. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  140663. /**
  140664. * Gets the impostor for a physics body object
  140665. * @param body defines physics body used by the impostor
  140666. * @returns the PhysicsImpostor or null if not found
  140667. */
  140668. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  140669. /**
  140670. * Does a raycast in the physics world
  140671. * @param from when should the ray start?
  140672. * @param to when should the ray end?
  140673. * @returns PhysicsRaycastResult
  140674. */
  140675. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140676. }
  140677. }
  140678. declare module BABYLON {
  140679. /** @hidden */
  140680. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  140681. private _useDeltaForWorldStep;
  140682. world: any;
  140683. name: string;
  140684. private _physicsMaterials;
  140685. private _fixedTimeStep;
  140686. private _cannonRaycastResult;
  140687. private _raycastResult;
  140688. private _physicsBodysToRemoveAfterStep;
  140689. private _firstFrame;
  140690. BJSCANNON: any;
  140691. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  140692. setGravity(gravity: Vector3): void;
  140693. setTimeStep(timeStep: number): void;
  140694. getTimeStep(): number;
  140695. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140696. private _removeMarkedPhysicsBodiesFromWorld;
  140697. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140698. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140699. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140700. private _processChildMeshes;
  140701. removePhysicsBody(impostor: PhysicsImpostor): void;
  140702. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140703. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140704. private _addMaterial;
  140705. private _checkWithEpsilon;
  140706. private _createShape;
  140707. private _createHeightmap;
  140708. private _minus90X;
  140709. private _plus90X;
  140710. private _tmpPosition;
  140711. private _tmpDeltaPosition;
  140712. private _tmpUnityRotation;
  140713. private _updatePhysicsBodyTransformation;
  140714. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140715. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140716. isSupported(): boolean;
  140717. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140718. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140719. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140720. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140721. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140722. getBodyMass(impostor: PhysicsImpostor): number;
  140723. getBodyFriction(impostor: PhysicsImpostor): number;
  140724. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140725. getBodyRestitution(impostor: PhysicsImpostor): number;
  140726. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140727. sleepBody(impostor: PhysicsImpostor): void;
  140728. wakeUpBody(impostor: PhysicsImpostor): void;
  140729. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  140730. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140731. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140732. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140733. getRadius(impostor: PhysicsImpostor): number;
  140734. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140735. dispose(): void;
  140736. private _extendNamespace;
  140737. /**
  140738. * Does a raycast in the physics world
  140739. * @param from when should the ray start?
  140740. * @param to when should the ray end?
  140741. * @returns PhysicsRaycastResult
  140742. */
  140743. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140744. }
  140745. }
  140746. declare module BABYLON {
  140747. /** @hidden */
  140748. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  140749. private _useDeltaForWorldStep;
  140750. world: any;
  140751. name: string;
  140752. BJSOIMO: any;
  140753. private _raycastResult;
  140754. private _fixedTimeStep;
  140755. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  140756. setGravity(gravity: Vector3): void;
  140757. setTimeStep(timeStep: number): void;
  140758. getTimeStep(): number;
  140759. private _tmpImpostorsArray;
  140760. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140761. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140762. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140763. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140764. private _tmpPositionVector;
  140765. removePhysicsBody(impostor: PhysicsImpostor): void;
  140766. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140767. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140768. isSupported(): boolean;
  140769. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140770. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140771. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140772. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140773. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140774. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140775. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140776. getBodyMass(impostor: PhysicsImpostor): number;
  140777. getBodyFriction(impostor: PhysicsImpostor): number;
  140778. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140779. getBodyRestitution(impostor: PhysicsImpostor): number;
  140780. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140781. sleepBody(impostor: PhysicsImpostor): void;
  140782. wakeUpBody(impostor: PhysicsImpostor): void;
  140783. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140784. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  140785. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  140786. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140787. getRadius(impostor: PhysicsImpostor): number;
  140788. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140789. dispose(): void;
  140790. /**
  140791. * Does a raycast in the physics world
  140792. * @param from when should the ray start?
  140793. * @param to when should the ray end?
  140794. * @returns PhysicsRaycastResult
  140795. */
  140796. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140797. }
  140798. }
  140799. declare module BABYLON {
  140800. /**
  140801. * AmmoJS Physics plugin
  140802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140803. * @see https://github.com/kripken/ammo.js/
  140804. */
  140805. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  140806. private _useDeltaForWorldStep;
  140807. /**
  140808. * Reference to the Ammo library
  140809. */
  140810. bjsAMMO: any;
  140811. /**
  140812. * Created ammoJS world which physics bodies are added to
  140813. */
  140814. world: any;
  140815. /**
  140816. * Name of the plugin
  140817. */
  140818. name: string;
  140819. private _timeStep;
  140820. private _fixedTimeStep;
  140821. private _maxSteps;
  140822. private _tmpQuaternion;
  140823. private _tmpAmmoTransform;
  140824. private _tmpAmmoQuaternion;
  140825. private _tmpAmmoConcreteContactResultCallback;
  140826. private _collisionConfiguration;
  140827. private _dispatcher;
  140828. private _overlappingPairCache;
  140829. private _solver;
  140830. private _softBodySolver;
  140831. private _tmpAmmoVectorA;
  140832. private _tmpAmmoVectorB;
  140833. private _tmpAmmoVectorC;
  140834. private _tmpAmmoVectorD;
  140835. private _tmpContactCallbackResult;
  140836. private _tmpAmmoVectorRCA;
  140837. private _tmpAmmoVectorRCB;
  140838. private _raycastResult;
  140839. private static readonly DISABLE_COLLISION_FLAG;
  140840. private static readonly KINEMATIC_FLAG;
  140841. private static readonly DISABLE_DEACTIVATION_FLAG;
  140842. /**
  140843. * Initializes the ammoJS plugin
  140844. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  140845. * @param ammoInjection can be used to inject your own ammo reference
  140846. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  140847. */
  140848. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  140849. /**
  140850. * Sets the gravity of the physics world (m/(s^2))
  140851. * @param gravity Gravity to set
  140852. */
  140853. setGravity(gravity: Vector3): void;
  140854. /**
  140855. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  140856. * @param timeStep timestep to use in seconds
  140857. */
  140858. setTimeStep(timeStep: number): void;
  140859. /**
  140860. * 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)
  140861. * @param fixedTimeStep fixedTimeStep to use in seconds
  140862. */
  140863. setFixedTimeStep(fixedTimeStep: number): void;
  140864. /**
  140865. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  140866. * @param maxSteps the maximum number of steps by the physics engine per frame
  140867. */
  140868. setMaxSteps(maxSteps: number): void;
  140869. /**
  140870. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  140871. * @returns the current timestep in seconds
  140872. */
  140873. getTimeStep(): number;
  140874. /**
  140875. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  140876. */
  140877. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  140878. private _isImpostorInContact;
  140879. private _isImpostorPairInContact;
  140880. private _stepSimulation;
  140881. /**
  140882. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  140883. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  140884. * After the step the babylon meshes are set to the position of the physics imposters
  140885. * @param delta amount of time to step forward
  140886. * @param impostors array of imposters to update before/after the step
  140887. */
  140888. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140889. /**
  140890. * Update babylon mesh to match physics world object
  140891. * @param impostor imposter to match
  140892. */
  140893. private _afterSoftStep;
  140894. /**
  140895. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140896. * @param impostor imposter to match
  140897. */
  140898. private _ropeStep;
  140899. /**
  140900. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140901. * @param impostor imposter to match
  140902. */
  140903. private _softbodyOrClothStep;
  140904. private _tmpMatrix;
  140905. /**
  140906. * Applies an impulse on the imposter
  140907. * @param impostor imposter to apply impulse to
  140908. * @param force amount of force to be applied to the imposter
  140909. * @param contactPoint the location to apply the impulse on the imposter
  140910. */
  140911. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140912. /**
  140913. * Applies a force on the imposter
  140914. * @param impostor imposter to apply force
  140915. * @param force amount of force to be applied to the imposter
  140916. * @param contactPoint the location to apply the force on the imposter
  140917. */
  140918. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140919. /**
  140920. * Creates a physics body using the plugin
  140921. * @param impostor the imposter to create the physics body on
  140922. */
  140923. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140924. /**
  140925. * Removes the physics body from the imposter and disposes of the body's memory
  140926. * @param impostor imposter to remove the physics body from
  140927. */
  140928. removePhysicsBody(impostor: PhysicsImpostor): void;
  140929. /**
  140930. * Generates a joint
  140931. * @param impostorJoint the imposter joint to create the joint with
  140932. */
  140933. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140934. /**
  140935. * Removes a joint
  140936. * @param impostorJoint the imposter joint to remove the joint from
  140937. */
  140938. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140939. private _addMeshVerts;
  140940. /**
  140941. * Initialise the soft body vertices to match its object's (mesh) vertices
  140942. * Softbody vertices (nodes) are in world space and to match this
  140943. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  140944. * @param impostor to create the softbody for
  140945. */
  140946. private _softVertexData;
  140947. /**
  140948. * Create an impostor's soft body
  140949. * @param impostor to create the softbody for
  140950. */
  140951. private _createSoftbody;
  140952. /**
  140953. * Create cloth for an impostor
  140954. * @param impostor to create the softbody for
  140955. */
  140956. private _createCloth;
  140957. /**
  140958. * Create rope for an impostor
  140959. * @param impostor to create the softbody for
  140960. */
  140961. private _createRope;
  140962. /**
  140963. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  140964. * @param impostor to create the custom physics shape for
  140965. */
  140966. private _createCustom;
  140967. private _addHullVerts;
  140968. private _createShape;
  140969. /**
  140970. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  140971. * @param impostor imposter containing the physics body and babylon object
  140972. */
  140973. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140974. /**
  140975. * Sets the babylon object's position/rotation from the physics body's position/rotation
  140976. * @param impostor imposter containing the physics body and babylon object
  140977. * @param newPosition new position
  140978. * @param newRotation new rotation
  140979. */
  140980. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140981. /**
  140982. * If this plugin is supported
  140983. * @returns true if its supported
  140984. */
  140985. isSupported(): boolean;
  140986. /**
  140987. * Sets the linear velocity of the physics body
  140988. * @param impostor imposter to set the velocity on
  140989. * @param velocity velocity to set
  140990. */
  140991. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140992. /**
  140993. * Sets the angular velocity of the physics body
  140994. * @param impostor imposter to set the velocity on
  140995. * @param velocity velocity to set
  140996. */
  140997. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140998. /**
  140999. * gets the linear velocity
  141000. * @param impostor imposter to get linear velocity from
  141001. * @returns linear velocity
  141002. */
  141003. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141004. /**
  141005. * gets the angular velocity
  141006. * @param impostor imposter to get angular velocity from
  141007. * @returns angular velocity
  141008. */
  141009. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141010. /**
  141011. * Sets the mass of physics body
  141012. * @param impostor imposter to set the mass on
  141013. * @param mass mass to set
  141014. */
  141015. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141016. /**
  141017. * Gets the mass of the physics body
  141018. * @param impostor imposter to get the mass from
  141019. * @returns mass
  141020. */
  141021. getBodyMass(impostor: PhysicsImpostor): number;
  141022. /**
  141023. * Gets friction of the impostor
  141024. * @param impostor impostor to get friction from
  141025. * @returns friction value
  141026. */
  141027. getBodyFriction(impostor: PhysicsImpostor): number;
  141028. /**
  141029. * Sets friction of the impostor
  141030. * @param impostor impostor to set friction on
  141031. * @param friction friction value
  141032. */
  141033. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141034. /**
  141035. * Gets restitution of the impostor
  141036. * @param impostor impostor to get restitution from
  141037. * @returns restitution value
  141038. */
  141039. getBodyRestitution(impostor: PhysicsImpostor): number;
  141040. /**
  141041. * Sets resitution of the impostor
  141042. * @param impostor impostor to set resitution on
  141043. * @param restitution resitution value
  141044. */
  141045. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141046. /**
  141047. * Gets pressure inside the impostor
  141048. * @param impostor impostor to get pressure from
  141049. * @returns pressure value
  141050. */
  141051. getBodyPressure(impostor: PhysicsImpostor): number;
  141052. /**
  141053. * Sets pressure inside a soft body impostor
  141054. * Cloth and rope must remain 0 pressure
  141055. * @param impostor impostor to set pressure on
  141056. * @param pressure pressure value
  141057. */
  141058. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141059. /**
  141060. * Gets stiffness of the impostor
  141061. * @param impostor impostor to get stiffness from
  141062. * @returns pressure value
  141063. */
  141064. getBodyStiffness(impostor: PhysicsImpostor): number;
  141065. /**
  141066. * Sets stiffness of the impostor
  141067. * @param impostor impostor to set stiffness on
  141068. * @param stiffness stiffness value from 0 to 1
  141069. */
  141070. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141071. /**
  141072. * Gets velocityIterations of the impostor
  141073. * @param impostor impostor to get velocity iterations from
  141074. * @returns velocityIterations value
  141075. */
  141076. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141077. /**
  141078. * Sets velocityIterations of the impostor
  141079. * @param impostor impostor to set velocity iterations on
  141080. * @param velocityIterations velocityIterations value
  141081. */
  141082. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141083. /**
  141084. * Gets positionIterations of the impostor
  141085. * @param impostor impostor to get position iterations from
  141086. * @returns positionIterations value
  141087. */
  141088. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141089. /**
  141090. * Sets positionIterations of the impostor
  141091. * @param impostor impostor to set position on
  141092. * @param positionIterations positionIterations value
  141093. */
  141094. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141095. /**
  141096. * Append an anchor to a cloth object
  141097. * @param impostor is the cloth impostor to add anchor to
  141098. * @param otherImpostor is the rigid impostor to anchor to
  141099. * @param width ratio across width from 0 to 1
  141100. * @param height ratio up height from 0 to 1
  141101. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141102. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141103. */
  141104. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141105. /**
  141106. * Append an hook to a rope object
  141107. * @param impostor is the rope impostor to add hook to
  141108. * @param otherImpostor is the rigid impostor to hook to
  141109. * @param length ratio along the rope from 0 to 1
  141110. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141111. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141112. */
  141113. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141114. /**
  141115. * Sleeps the physics body and stops it from being active
  141116. * @param impostor impostor to sleep
  141117. */
  141118. sleepBody(impostor: PhysicsImpostor): void;
  141119. /**
  141120. * Activates the physics body
  141121. * @param impostor impostor to activate
  141122. */
  141123. wakeUpBody(impostor: PhysicsImpostor): void;
  141124. /**
  141125. * Updates the distance parameters of the joint
  141126. * @param joint joint to update
  141127. * @param maxDistance maximum distance of the joint
  141128. * @param minDistance minimum distance of the joint
  141129. */
  141130. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141131. /**
  141132. * Sets a motor on the joint
  141133. * @param joint joint to set motor on
  141134. * @param speed speed of the motor
  141135. * @param maxForce maximum force of the motor
  141136. * @param motorIndex index of the motor
  141137. */
  141138. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141139. /**
  141140. * Sets the motors limit
  141141. * @param joint joint to set limit on
  141142. * @param upperLimit upper limit
  141143. * @param lowerLimit lower limit
  141144. */
  141145. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141146. /**
  141147. * Syncs the position and rotation of a mesh with the impostor
  141148. * @param mesh mesh to sync
  141149. * @param impostor impostor to update the mesh with
  141150. */
  141151. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141152. /**
  141153. * Gets the radius of the impostor
  141154. * @param impostor impostor to get radius from
  141155. * @returns the radius
  141156. */
  141157. getRadius(impostor: PhysicsImpostor): number;
  141158. /**
  141159. * Gets the box size of the impostor
  141160. * @param impostor impostor to get box size from
  141161. * @param result the resulting box size
  141162. */
  141163. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141164. /**
  141165. * Disposes of the impostor
  141166. */
  141167. dispose(): void;
  141168. /**
  141169. * Does a raycast in the physics world
  141170. * @param from when should the ray start?
  141171. * @param to when should the ray end?
  141172. * @returns PhysicsRaycastResult
  141173. */
  141174. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141175. }
  141176. }
  141177. declare module BABYLON {
  141178. interface AbstractScene {
  141179. /**
  141180. * The list of reflection probes added to the scene
  141181. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141182. */
  141183. reflectionProbes: Array<ReflectionProbe>;
  141184. /**
  141185. * Removes the given reflection probe from this scene.
  141186. * @param toRemove The reflection probe to remove
  141187. * @returns The index of the removed reflection probe
  141188. */
  141189. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141190. /**
  141191. * Adds the given reflection probe to this scene.
  141192. * @param newReflectionProbe The reflection probe to add
  141193. */
  141194. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141195. }
  141196. /**
  141197. * Class used to generate realtime reflection / refraction cube textures
  141198. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141199. */
  141200. export class ReflectionProbe {
  141201. /** defines the name of the probe */
  141202. name: string;
  141203. private _scene;
  141204. private _renderTargetTexture;
  141205. private _projectionMatrix;
  141206. private _viewMatrix;
  141207. private _target;
  141208. private _add;
  141209. private _attachedMesh;
  141210. private _invertYAxis;
  141211. /** Gets or sets probe position (center of the cube map) */
  141212. position: Vector3;
  141213. /**
  141214. * Creates a new reflection probe
  141215. * @param name defines the name of the probe
  141216. * @param size defines the texture resolution (for each face)
  141217. * @param scene defines the hosting scene
  141218. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141219. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141220. */
  141221. constructor(
  141222. /** defines the name of the probe */
  141223. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141224. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141225. get samples(): number;
  141226. set samples(value: number);
  141227. /** Gets or sets the refresh rate to use (on every frame by default) */
  141228. get refreshRate(): number;
  141229. set refreshRate(value: number);
  141230. /**
  141231. * Gets the hosting scene
  141232. * @returns a Scene
  141233. */
  141234. getScene(): Scene;
  141235. /** Gets the internal CubeTexture used to render to */
  141236. get cubeTexture(): RenderTargetTexture;
  141237. /** Gets the list of meshes to render */
  141238. get renderList(): Nullable<AbstractMesh[]>;
  141239. /**
  141240. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141241. * @param mesh defines the mesh to attach to
  141242. */
  141243. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141244. /**
  141245. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141246. * @param renderingGroupId The rendering group id corresponding to its index
  141247. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141248. */
  141249. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141250. /**
  141251. * Clean all associated resources
  141252. */
  141253. dispose(): void;
  141254. /**
  141255. * Converts the reflection probe information to a readable string for debug purpose.
  141256. * @param fullDetails Supports for multiple levels of logging within scene loading
  141257. * @returns the human readable reflection probe info
  141258. */
  141259. toString(fullDetails?: boolean): string;
  141260. /**
  141261. * Get the class name of the relfection probe.
  141262. * @returns "ReflectionProbe"
  141263. */
  141264. getClassName(): string;
  141265. /**
  141266. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141267. * @returns The JSON representation of the texture
  141268. */
  141269. serialize(): any;
  141270. /**
  141271. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141272. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141273. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141274. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141275. * @returns The parsed reflection probe if successful
  141276. */
  141277. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141278. }
  141279. }
  141280. declare module BABYLON {
  141281. /** @hidden */
  141282. export var _BabylonLoaderRegistered: boolean;
  141283. /**
  141284. * Helps setting up some configuration for the babylon file loader.
  141285. */
  141286. export class BabylonFileLoaderConfiguration {
  141287. /**
  141288. * The loader does not allow injecting custom physix engine into the plugins.
  141289. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141290. * So you could set this variable to your engine import to make it work.
  141291. */
  141292. static LoaderInjectedPhysicsEngine: any;
  141293. }
  141294. }
  141295. declare module BABYLON {
  141296. /**
  141297. * The Physically based simple base material of BJS.
  141298. *
  141299. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141300. * It is used as the base class for both the specGloss and metalRough conventions.
  141301. */
  141302. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141303. /**
  141304. * Number of Simultaneous lights allowed on the material.
  141305. */
  141306. maxSimultaneousLights: number;
  141307. /**
  141308. * If sets to true, disables all the lights affecting the material.
  141309. */
  141310. disableLighting: boolean;
  141311. /**
  141312. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141313. */
  141314. environmentTexture: BaseTexture;
  141315. /**
  141316. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141317. */
  141318. invertNormalMapX: boolean;
  141319. /**
  141320. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141321. */
  141322. invertNormalMapY: boolean;
  141323. /**
  141324. * Normal map used in the model.
  141325. */
  141326. normalTexture: BaseTexture;
  141327. /**
  141328. * Emissivie color used to self-illuminate the model.
  141329. */
  141330. emissiveColor: Color3;
  141331. /**
  141332. * Emissivie texture used to self-illuminate the model.
  141333. */
  141334. emissiveTexture: BaseTexture;
  141335. /**
  141336. * Occlusion Channel Strenght.
  141337. */
  141338. occlusionStrength: number;
  141339. /**
  141340. * Occlusion Texture of the material (adding extra occlusion effects).
  141341. */
  141342. occlusionTexture: BaseTexture;
  141343. /**
  141344. * Defines the alpha limits in alpha test mode.
  141345. */
  141346. alphaCutOff: number;
  141347. /**
  141348. * Gets the current double sided mode.
  141349. */
  141350. get doubleSided(): boolean;
  141351. /**
  141352. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141353. */
  141354. set doubleSided(value: boolean);
  141355. /**
  141356. * Stores the pre-calculated light information of a mesh in a texture.
  141357. */
  141358. lightmapTexture: BaseTexture;
  141359. /**
  141360. * If true, the light map contains occlusion information instead of lighting info.
  141361. */
  141362. useLightmapAsShadowmap: boolean;
  141363. /**
  141364. * Instantiates a new PBRMaterial instance.
  141365. *
  141366. * @param name The material name
  141367. * @param scene The scene the material will be use in.
  141368. */
  141369. constructor(name: string, scene: Scene);
  141370. getClassName(): string;
  141371. }
  141372. }
  141373. declare module BABYLON {
  141374. /**
  141375. * The PBR material of BJS following the metal roughness convention.
  141376. *
  141377. * This fits to the PBR convention in the GLTF definition:
  141378. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141379. */
  141380. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141381. /**
  141382. * The base color has two different interpretations depending on the value of metalness.
  141383. * When the material is a metal, the base color is the specific measured reflectance value
  141384. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141385. * of the material.
  141386. */
  141387. baseColor: Color3;
  141388. /**
  141389. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141390. * well as opacity information in the alpha channel.
  141391. */
  141392. baseTexture: BaseTexture;
  141393. /**
  141394. * Specifies the metallic scalar value of the material.
  141395. * Can also be used to scale the metalness values of the metallic texture.
  141396. */
  141397. metallic: number;
  141398. /**
  141399. * Specifies the roughness scalar value of the material.
  141400. * Can also be used to scale the roughness values of the metallic texture.
  141401. */
  141402. roughness: number;
  141403. /**
  141404. * Texture containing both the metallic value in the B channel and the
  141405. * roughness value in the G channel to keep better precision.
  141406. */
  141407. metallicRoughnessTexture: BaseTexture;
  141408. /**
  141409. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141410. *
  141411. * @param name The material name
  141412. * @param scene The scene the material will be use in.
  141413. */
  141414. constructor(name: string, scene: Scene);
  141415. /**
  141416. * Return the currrent class name of the material.
  141417. */
  141418. getClassName(): string;
  141419. /**
  141420. * Makes a duplicate of the current material.
  141421. * @param name - name to use for the new material.
  141422. */
  141423. clone(name: string): PBRMetallicRoughnessMaterial;
  141424. /**
  141425. * Serialize the material to a parsable JSON object.
  141426. */
  141427. serialize(): any;
  141428. /**
  141429. * Parses a JSON object correponding to the serialize function.
  141430. */
  141431. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141432. }
  141433. }
  141434. declare module BABYLON {
  141435. /**
  141436. * The PBR material of BJS following the specular glossiness convention.
  141437. *
  141438. * This fits to the PBR convention in the GLTF definition:
  141439. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141440. */
  141441. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141442. /**
  141443. * Specifies the diffuse color of the material.
  141444. */
  141445. diffuseColor: Color3;
  141446. /**
  141447. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141448. * channel.
  141449. */
  141450. diffuseTexture: BaseTexture;
  141451. /**
  141452. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141453. */
  141454. specularColor: Color3;
  141455. /**
  141456. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141457. */
  141458. glossiness: number;
  141459. /**
  141460. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141461. */
  141462. specularGlossinessTexture: BaseTexture;
  141463. /**
  141464. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141465. *
  141466. * @param name The material name
  141467. * @param scene The scene the material will be use in.
  141468. */
  141469. constructor(name: string, scene: Scene);
  141470. /**
  141471. * Return the currrent class name of the material.
  141472. */
  141473. getClassName(): string;
  141474. /**
  141475. * Makes a duplicate of the current material.
  141476. * @param name - name to use for the new material.
  141477. */
  141478. clone(name: string): PBRSpecularGlossinessMaterial;
  141479. /**
  141480. * Serialize the material to a parsable JSON object.
  141481. */
  141482. serialize(): any;
  141483. /**
  141484. * Parses a JSON object correponding to the serialize function.
  141485. */
  141486. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141487. }
  141488. }
  141489. declare module BABYLON {
  141490. /**
  141491. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141492. * It can help converting any input color in a desired output one. This can then be used to create effects
  141493. * from sepia, black and white to sixties or futuristic rendering...
  141494. *
  141495. * The only supported format is currently 3dl.
  141496. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141497. */
  141498. export class ColorGradingTexture extends BaseTexture {
  141499. /**
  141500. * The texture URL.
  141501. */
  141502. url: string;
  141503. /**
  141504. * Empty line regex stored for GC.
  141505. */
  141506. private static _noneEmptyLineRegex;
  141507. private _textureMatrix;
  141508. private _onLoad;
  141509. /**
  141510. * Instantiates a ColorGradingTexture from the following parameters.
  141511. *
  141512. * @param url The location of the color gradind data (currently only supporting 3dl)
  141513. * @param sceneOrEngine The scene or engine the texture will be used in
  141514. * @param onLoad defines a callback triggered when the texture has been loaded
  141515. */
  141516. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141517. /**
  141518. * Fires the onload event from the constructor if requested.
  141519. */
  141520. private _triggerOnLoad;
  141521. /**
  141522. * Returns the texture matrix used in most of the material.
  141523. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141524. */
  141525. getTextureMatrix(): Matrix;
  141526. /**
  141527. * Occurs when the file being loaded is a .3dl LUT file.
  141528. */
  141529. private load3dlTexture;
  141530. /**
  141531. * Starts the loading process of the texture.
  141532. */
  141533. private loadTexture;
  141534. /**
  141535. * Clones the color gradind texture.
  141536. */
  141537. clone(): ColorGradingTexture;
  141538. /**
  141539. * Called during delayed load for textures.
  141540. */
  141541. delayLoad(): void;
  141542. /**
  141543. * Parses a color grading texture serialized by Babylon.
  141544. * @param parsedTexture The texture information being parsedTexture
  141545. * @param scene The scene to load the texture in
  141546. * @param rootUrl The root url of the data assets to load
  141547. * @return A color gradind texture
  141548. */
  141549. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141550. /**
  141551. * Serializes the LUT texture to json format.
  141552. */
  141553. serialize(): any;
  141554. }
  141555. }
  141556. declare module BABYLON {
  141557. /**
  141558. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141559. */
  141560. export class EquiRectangularCubeTexture extends BaseTexture {
  141561. /** The six faces of the cube. */
  141562. private static _FacesMapping;
  141563. private _noMipmap;
  141564. private _onLoad;
  141565. private _onError;
  141566. /** The size of the cubemap. */
  141567. private _size;
  141568. /** The buffer of the image. */
  141569. private _buffer;
  141570. /** The width of the input image. */
  141571. private _width;
  141572. /** The height of the input image. */
  141573. private _height;
  141574. /** The URL to the image. */
  141575. url: string;
  141576. /**
  141577. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141578. * @param url The location of the image
  141579. * @param scene The scene the texture will be used in
  141580. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141581. * @param noMipmap Forces to not generate the mipmap if true
  141582. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141583. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141584. * @param onLoad — defines a callback called when texture is loaded
  141585. * @param onError — defines a callback called if there is an error
  141586. */
  141587. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  141588. /**
  141589. * Load the image data, by putting the image on a canvas and extracting its buffer.
  141590. */
  141591. private loadImage;
  141592. /**
  141593. * Convert the image buffer into a cubemap and create a CubeTexture.
  141594. */
  141595. private loadTexture;
  141596. /**
  141597. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  141598. * @param buffer The ArrayBuffer that should be converted.
  141599. * @returns The buffer as Float32Array.
  141600. */
  141601. private getFloat32ArrayFromArrayBuffer;
  141602. /**
  141603. * Get the current class name of the texture useful for serialization or dynamic coding.
  141604. * @returns "EquiRectangularCubeTexture"
  141605. */
  141606. getClassName(): string;
  141607. /**
  141608. * Create a clone of the current EquiRectangularCubeTexture and return it.
  141609. * @returns A clone of the current EquiRectangularCubeTexture.
  141610. */
  141611. clone(): EquiRectangularCubeTexture;
  141612. }
  141613. }
  141614. declare module BABYLON {
  141615. /**
  141616. * Defines the options related to the creation of an HtmlElementTexture
  141617. */
  141618. export interface IHtmlElementTextureOptions {
  141619. /**
  141620. * Defines wether mip maps should be created or not.
  141621. */
  141622. generateMipMaps?: boolean;
  141623. /**
  141624. * Defines the sampling mode of the texture.
  141625. */
  141626. samplingMode?: number;
  141627. /**
  141628. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  141629. */
  141630. engine: Nullable<ThinEngine>;
  141631. /**
  141632. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  141633. */
  141634. scene: Nullable<Scene>;
  141635. }
  141636. /**
  141637. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  141638. * To be as efficient as possible depending on your constraints nothing aside the first upload
  141639. * is automatically managed.
  141640. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  141641. * in your application.
  141642. *
  141643. * As the update is not automatic, you need to call them manually.
  141644. */
  141645. export class HtmlElementTexture extends BaseTexture {
  141646. /**
  141647. * The texture URL.
  141648. */
  141649. element: HTMLVideoElement | HTMLCanvasElement;
  141650. private static readonly DefaultOptions;
  141651. private _textureMatrix;
  141652. private _isVideo;
  141653. private _generateMipMaps;
  141654. private _samplingMode;
  141655. /**
  141656. * Instantiates a HtmlElementTexture from the following parameters.
  141657. *
  141658. * @param name Defines the name of the texture
  141659. * @param element Defines the video or canvas the texture is filled with
  141660. * @param options Defines the other none mandatory texture creation options
  141661. */
  141662. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  141663. private _createInternalTexture;
  141664. /**
  141665. * Returns the texture matrix used in most of the material.
  141666. */
  141667. getTextureMatrix(): Matrix;
  141668. /**
  141669. * Updates the content of the texture.
  141670. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  141671. */
  141672. update(invertY?: Nullable<boolean>): void;
  141673. }
  141674. }
  141675. declare module BABYLON {
  141676. /**
  141677. * Based on jsTGALoader - Javascript loader for TGA file
  141678. * By Vincent Thibault
  141679. * @see http://blog.robrowser.com/javascript-tga-loader.html
  141680. */
  141681. export class TGATools {
  141682. private static _TYPE_INDEXED;
  141683. private static _TYPE_RGB;
  141684. private static _TYPE_GREY;
  141685. private static _TYPE_RLE_INDEXED;
  141686. private static _TYPE_RLE_RGB;
  141687. private static _TYPE_RLE_GREY;
  141688. private static _ORIGIN_MASK;
  141689. private static _ORIGIN_SHIFT;
  141690. private static _ORIGIN_BL;
  141691. private static _ORIGIN_BR;
  141692. private static _ORIGIN_UL;
  141693. private static _ORIGIN_UR;
  141694. /**
  141695. * Gets the header of a TGA file
  141696. * @param data defines the TGA data
  141697. * @returns the header
  141698. */
  141699. static GetTGAHeader(data: Uint8Array): any;
  141700. /**
  141701. * Uploads TGA content to a Babylon Texture
  141702. * @hidden
  141703. */
  141704. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  141705. /** @hidden */
  141706. 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;
  141707. /** @hidden */
  141708. 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;
  141709. /** @hidden */
  141710. 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;
  141711. /** @hidden */
  141712. 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;
  141713. /** @hidden */
  141714. 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;
  141715. /** @hidden */
  141716. 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;
  141717. }
  141718. }
  141719. declare module BABYLON {
  141720. /**
  141721. * Implementation of the TGA Texture Loader.
  141722. * @hidden
  141723. */
  141724. export class _TGATextureLoader implements IInternalTextureLoader {
  141725. /**
  141726. * Defines wether the loader supports cascade loading the different faces.
  141727. */
  141728. readonly supportCascades: boolean;
  141729. /**
  141730. * This returns if the loader support the current file information.
  141731. * @param extension defines the file extension of the file being loaded
  141732. * @returns true if the loader can load the specified file
  141733. */
  141734. canLoad(extension: string): boolean;
  141735. /**
  141736. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141737. * @param data contains the texture data
  141738. * @param texture defines the BabylonJS internal texture
  141739. * @param createPolynomials will be true if polynomials have been requested
  141740. * @param onLoad defines the callback to trigger once the texture is ready
  141741. * @param onError defines the callback to trigger in case of error
  141742. */
  141743. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141744. /**
  141745. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141746. * @param data contains the texture data
  141747. * @param texture defines the BabylonJS internal texture
  141748. * @param callback defines the method to call once ready to upload
  141749. */
  141750. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141751. }
  141752. }
  141753. declare module BABYLON {
  141754. /**
  141755. * Info about the .basis files
  141756. */
  141757. class BasisFileInfo {
  141758. /**
  141759. * If the file has alpha
  141760. */
  141761. hasAlpha: boolean;
  141762. /**
  141763. * Info about each image of the basis file
  141764. */
  141765. images: Array<{
  141766. levels: Array<{
  141767. width: number;
  141768. height: number;
  141769. transcodedPixels: ArrayBufferView;
  141770. }>;
  141771. }>;
  141772. }
  141773. /**
  141774. * Result of transcoding a basis file
  141775. */
  141776. class TranscodeResult {
  141777. /**
  141778. * Info about the .basis file
  141779. */
  141780. fileInfo: BasisFileInfo;
  141781. /**
  141782. * Format to use when loading the file
  141783. */
  141784. format: number;
  141785. }
  141786. /**
  141787. * Configuration options for the Basis transcoder
  141788. */
  141789. export class BasisTranscodeConfiguration {
  141790. /**
  141791. * Supported compression formats used to determine the supported output format of the transcoder
  141792. */
  141793. supportedCompressionFormats?: {
  141794. /**
  141795. * etc1 compression format
  141796. */
  141797. etc1?: boolean;
  141798. /**
  141799. * s3tc compression format
  141800. */
  141801. s3tc?: boolean;
  141802. /**
  141803. * pvrtc compression format
  141804. */
  141805. pvrtc?: boolean;
  141806. /**
  141807. * etc2 compression format
  141808. */
  141809. etc2?: boolean;
  141810. };
  141811. /**
  141812. * If mipmap levels should be loaded for transcoded images (Default: true)
  141813. */
  141814. loadMipmapLevels?: boolean;
  141815. /**
  141816. * Index of a single image to load (Default: all images)
  141817. */
  141818. loadSingleImage?: number;
  141819. }
  141820. /**
  141821. * Used to load .Basis files
  141822. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  141823. */
  141824. export class BasisTools {
  141825. private static _IgnoreSupportedFormats;
  141826. /**
  141827. * URL to use when loading the basis transcoder
  141828. */
  141829. static JSModuleURL: string;
  141830. /**
  141831. * URL to use when loading the wasm module for the transcoder
  141832. */
  141833. static WasmModuleURL: string;
  141834. /**
  141835. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  141836. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  141837. * @returns internal format corresponding to the Basis format
  141838. */
  141839. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  141840. private static _WorkerPromise;
  141841. private static _Worker;
  141842. private static _actionId;
  141843. private static _CreateWorkerAsync;
  141844. /**
  141845. * Transcodes a loaded image file to compressed pixel data
  141846. * @param data image data to transcode
  141847. * @param config configuration options for the transcoding
  141848. * @returns a promise resulting in the transcoded image
  141849. */
  141850. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  141851. /**
  141852. * Loads a texture from the transcode result
  141853. * @param texture texture load to
  141854. * @param transcodeResult the result of transcoding the basis file to load from
  141855. */
  141856. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  141857. }
  141858. }
  141859. declare module BABYLON {
  141860. /**
  141861. * Loader for .basis file format
  141862. */
  141863. export class _BasisTextureLoader implements IInternalTextureLoader {
  141864. /**
  141865. * Defines whether the loader supports cascade loading the different faces.
  141866. */
  141867. readonly supportCascades: boolean;
  141868. /**
  141869. * This returns if the loader support the current file information.
  141870. * @param extension defines the file extension of the file being loaded
  141871. * @returns true if the loader can load the specified file
  141872. */
  141873. canLoad(extension: string): boolean;
  141874. /**
  141875. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141876. * @param data contains the texture data
  141877. * @param texture defines the BabylonJS internal texture
  141878. * @param createPolynomials will be true if polynomials have been requested
  141879. * @param onLoad defines the callback to trigger once the texture is ready
  141880. * @param onError defines the callback to trigger in case of error
  141881. */
  141882. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141883. /**
  141884. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141885. * @param data contains the texture data
  141886. * @param texture defines the BabylonJS internal texture
  141887. * @param callback defines the method to call once ready to upload
  141888. */
  141889. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141890. }
  141891. }
  141892. declare module BABYLON {
  141893. /**
  141894. * Defines the basic options interface of a TexturePacker Frame
  141895. */
  141896. export interface ITexturePackerFrame {
  141897. /**
  141898. * The frame ID
  141899. */
  141900. id: number;
  141901. /**
  141902. * The frames Scale
  141903. */
  141904. scale: Vector2;
  141905. /**
  141906. * The Frames offset
  141907. */
  141908. offset: Vector2;
  141909. }
  141910. /**
  141911. * This is a support class for frame Data on texture packer sets.
  141912. */
  141913. export class TexturePackerFrame implements ITexturePackerFrame {
  141914. /**
  141915. * The frame ID
  141916. */
  141917. id: number;
  141918. /**
  141919. * The frames Scale
  141920. */
  141921. scale: Vector2;
  141922. /**
  141923. * The Frames offset
  141924. */
  141925. offset: Vector2;
  141926. /**
  141927. * Initializes a texture package frame.
  141928. * @param id The numerical frame identifier
  141929. * @param scale Scalar Vector2 for UV frame
  141930. * @param offset Vector2 for the frame position in UV units.
  141931. * @returns TexturePackerFrame
  141932. */
  141933. constructor(id: number, scale: Vector2, offset: Vector2);
  141934. }
  141935. }
  141936. declare module BABYLON {
  141937. /**
  141938. * Defines the basic options interface of a TexturePacker
  141939. */
  141940. export interface ITexturePackerOptions {
  141941. /**
  141942. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  141943. */
  141944. map?: string[];
  141945. /**
  141946. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141947. */
  141948. uvsIn?: string;
  141949. /**
  141950. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141951. */
  141952. uvsOut?: string;
  141953. /**
  141954. * number representing the layout style. Defaults to LAYOUT_STRIP
  141955. */
  141956. layout?: number;
  141957. /**
  141958. * number of columns if using custom column count layout(2). This defaults to 4.
  141959. */
  141960. colnum?: number;
  141961. /**
  141962. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  141963. */
  141964. updateInputMeshes?: boolean;
  141965. /**
  141966. * boolean flag to dispose all the source textures. Defaults to true.
  141967. */
  141968. disposeSources?: boolean;
  141969. /**
  141970. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  141971. */
  141972. fillBlanks?: boolean;
  141973. /**
  141974. * string value representing the context fill style color. Defaults to 'black'.
  141975. */
  141976. customFillColor?: string;
  141977. /**
  141978. * Width and Height Value of each Frame in the TexturePacker Sets
  141979. */
  141980. frameSize?: number;
  141981. /**
  141982. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  141983. */
  141984. paddingRatio?: number;
  141985. /**
  141986. * Number that declares the fill method for the padding gutter.
  141987. */
  141988. paddingMode?: number;
  141989. /**
  141990. * If in SUBUV_COLOR padding mode what color to use.
  141991. */
  141992. paddingColor?: Color3 | Color4;
  141993. }
  141994. /**
  141995. * Defines the basic interface of a TexturePacker JSON File
  141996. */
  141997. export interface ITexturePackerJSON {
  141998. /**
  141999. * The frame ID
  142000. */
  142001. name: string;
  142002. /**
  142003. * The base64 channel data
  142004. */
  142005. sets: any;
  142006. /**
  142007. * The options of the Packer
  142008. */
  142009. options: ITexturePackerOptions;
  142010. /**
  142011. * The frame data of the Packer
  142012. */
  142013. frames: Array<number>;
  142014. }
  142015. /**
  142016. * This is a support class that generates a series of packed texture sets.
  142017. * @see https://doc.babylonjs.com/babylon101/materials
  142018. */
  142019. export class TexturePacker {
  142020. /** Packer Layout Constant 0 */
  142021. static readonly LAYOUT_STRIP: number;
  142022. /** Packer Layout Constant 1 */
  142023. static readonly LAYOUT_POWER2: number;
  142024. /** Packer Layout Constant 2 */
  142025. static readonly LAYOUT_COLNUM: number;
  142026. /** Packer Layout Constant 0 */
  142027. static readonly SUBUV_WRAP: number;
  142028. /** Packer Layout Constant 1 */
  142029. static readonly SUBUV_EXTEND: number;
  142030. /** Packer Layout Constant 2 */
  142031. static readonly SUBUV_COLOR: number;
  142032. /** The Name of the Texture Package */
  142033. name: string;
  142034. /** The scene scope of the TexturePacker */
  142035. scene: Scene;
  142036. /** The Meshes to target */
  142037. meshes: AbstractMesh[];
  142038. /** Arguments passed with the Constructor */
  142039. options: ITexturePackerOptions;
  142040. /** The promise that is started upon initialization */
  142041. promise: Nullable<Promise<TexturePacker | string>>;
  142042. /** The Container object for the channel sets that are generated */
  142043. sets: object;
  142044. /** The Container array for the frames that are generated */
  142045. frames: TexturePackerFrame[];
  142046. /** The expected number of textures the system is parsing. */
  142047. private _expecting;
  142048. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142049. private _paddingValue;
  142050. /**
  142051. * Initializes a texture package series from an array of meshes or a single mesh.
  142052. * @param name The name of the package
  142053. * @param meshes The target meshes to compose the package from
  142054. * @param options The arguments that texture packer should follow while building.
  142055. * @param scene The scene which the textures are scoped to.
  142056. * @returns TexturePacker
  142057. */
  142058. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142059. /**
  142060. * Starts the package process
  142061. * @param resolve The promises resolution function
  142062. * @returns TexturePacker
  142063. */
  142064. private _createFrames;
  142065. /**
  142066. * Calculates the Size of the Channel Sets
  142067. * @returns Vector2
  142068. */
  142069. private _calculateSize;
  142070. /**
  142071. * Calculates the UV data for the frames.
  142072. * @param baseSize the base frameSize
  142073. * @param padding the base frame padding
  142074. * @param dtSize size of the Dynamic Texture for that channel
  142075. * @param dtUnits is 1/dtSize
  142076. * @param update flag to update the input meshes
  142077. */
  142078. private _calculateMeshUVFrames;
  142079. /**
  142080. * Calculates the frames Offset.
  142081. * @param index of the frame
  142082. * @returns Vector2
  142083. */
  142084. private _getFrameOffset;
  142085. /**
  142086. * Updates a Mesh to the frame data
  142087. * @param mesh that is the target
  142088. * @param frameID or the frame index
  142089. */
  142090. private _updateMeshUV;
  142091. /**
  142092. * Updates a Meshes materials to use the texture packer channels
  142093. * @param m is the mesh to target
  142094. * @param force all channels on the packer to be set.
  142095. */
  142096. private _updateTextureReferences;
  142097. /**
  142098. * Public method to set a Mesh to a frame
  142099. * @param m that is the target
  142100. * @param frameID or the frame index
  142101. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142102. */
  142103. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142104. /**
  142105. * Starts the async promise to compile the texture packer.
  142106. * @returns Promise<void>
  142107. */
  142108. processAsync(): Promise<void>;
  142109. /**
  142110. * Disposes all textures associated with this packer
  142111. */
  142112. dispose(): void;
  142113. /**
  142114. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142115. * @param imageType is the image type to use.
  142116. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142117. */
  142118. download(imageType?: string, quality?: number): void;
  142119. /**
  142120. * Public method to load a texturePacker JSON file.
  142121. * @param data of the JSON file in string format.
  142122. */
  142123. updateFromJSON(data: string): void;
  142124. }
  142125. }
  142126. declare module BABYLON {
  142127. /**
  142128. * 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.
  142129. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142130. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142131. */
  142132. export class CustomProceduralTexture extends ProceduralTexture {
  142133. private _animate;
  142134. private _time;
  142135. private _config;
  142136. private _texturePath;
  142137. /**
  142138. * Instantiates a new Custom Procedural Texture.
  142139. * 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.
  142140. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142141. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142142. * @param name Define the name of the texture
  142143. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142144. * @param size Define the size of the texture to create
  142145. * @param scene Define the scene the texture belongs to
  142146. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142147. * @param generateMipMaps Define if the texture should creates mip maps or not
  142148. */
  142149. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142150. private _loadJson;
  142151. /**
  142152. * Is the texture ready to be used ? (rendered at least once)
  142153. * @returns true if ready, otherwise, false.
  142154. */
  142155. isReady(): boolean;
  142156. /**
  142157. * Render the texture to its associated render target.
  142158. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142159. */
  142160. render(useCameraPostProcess?: boolean): void;
  142161. /**
  142162. * Update the list of dependant textures samplers in the shader.
  142163. */
  142164. updateTextures(): void;
  142165. /**
  142166. * Update the uniform values of the procedural texture in the shader.
  142167. */
  142168. updateShaderUniforms(): void;
  142169. /**
  142170. * Define if the texture animates or not.
  142171. */
  142172. get animate(): boolean;
  142173. set animate(value: boolean);
  142174. }
  142175. }
  142176. declare module BABYLON {
  142177. /** @hidden */
  142178. export var noisePixelShader: {
  142179. name: string;
  142180. shader: string;
  142181. };
  142182. }
  142183. declare module BABYLON {
  142184. /**
  142185. * Class used to generate noise procedural textures
  142186. */
  142187. export class NoiseProceduralTexture extends ProceduralTexture {
  142188. /** Gets or sets the start time (default is 0) */
  142189. time: number;
  142190. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142191. brightness: number;
  142192. /** Defines the number of octaves to process */
  142193. octaves: number;
  142194. /** Defines the level of persistence (0.8 by default) */
  142195. persistence: number;
  142196. /** Gets or sets animation speed factor (default is 1) */
  142197. animationSpeedFactor: number;
  142198. /**
  142199. * Creates a new NoiseProceduralTexture
  142200. * @param name defines the name fo the texture
  142201. * @param size defines the size of the texture (default is 256)
  142202. * @param scene defines the hosting scene
  142203. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142204. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142205. */
  142206. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142207. private _updateShaderUniforms;
  142208. protected _getDefines(): string;
  142209. /** Generate the current state of the procedural texture */
  142210. render(useCameraPostProcess?: boolean): void;
  142211. /**
  142212. * Serializes this noise procedural texture
  142213. * @returns a serialized noise procedural texture object
  142214. */
  142215. serialize(): any;
  142216. /**
  142217. * Clone the texture.
  142218. * @returns the cloned texture
  142219. */
  142220. clone(): NoiseProceduralTexture;
  142221. /**
  142222. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142223. * @param parsedTexture defines parsed texture data
  142224. * @param scene defines the current scene
  142225. * @param rootUrl defines the root URL containing noise procedural texture information
  142226. * @returns a parsed NoiseProceduralTexture
  142227. */
  142228. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142229. }
  142230. }
  142231. declare module BABYLON {
  142232. /**
  142233. * Raw cube texture where the raw buffers are passed in
  142234. */
  142235. export class RawCubeTexture extends CubeTexture {
  142236. /**
  142237. * Creates a cube texture where the raw buffers are passed in.
  142238. * @param scene defines the scene the texture is attached to
  142239. * @param data defines the array of data to use to create each face
  142240. * @param size defines the size of the textures
  142241. * @param format defines the format of the data
  142242. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142243. * @param generateMipMaps defines if the engine should generate the mip levels
  142244. * @param invertY defines if data must be stored with Y axis inverted
  142245. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142246. * @param compression defines the compression used (null by default)
  142247. */
  142248. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142249. /**
  142250. * Updates the raw cube texture.
  142251. * @param data defines the data to store
  142252. * @param format defines the data format
  142253. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142254. * @param invertY defines if data must be stored with Y axis inverted
  142255. * @param compression defines the compression used (null by default)
  142256. * @param level defines which level of the texture to update
  142257. */
  142258. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142259. /**
  142260. * Updates a raw cube texture with RGBD encoded data.
  142261. * @param data defines the array of data [mipmap][face] to use to create each face
  142262. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142263. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142264. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142265. * @returns a promsie that resolves when the operation is complete
  142266. */
  142267. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142268. /**
  142269. * Clones the raw cube texture.
  142270. * @return a new cube texture
  142271. */
  142272. clone(): CubeTexture;
  142273. /** @hidden */
  142274. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142275. }
  142276. }
  142277. declare module BABYLON {
  142278. /**
  142279. * Class used to store 2D array textures containing user data
  142280. */
  142281. export class RawTexture2DArray extends Texture {
  142282. /** Gets or sets the texture format to use */
  142283. format: number;
  142284. /**
  142285. * Create a new RawTexture2DArray
  142286. * @param data defines the data of the texture
  142287. * @param width defines the width of the texture
  142288. * @param height defines the height of the texture
  142289. * @param depth defines the number of layers of the texture
  142290. * @param format defines the texture format to use
  142291. * @param scene defines the hosting scene
  142292. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142293. * @param invertY defines if texture must be stored with Y axis inverted
  142294. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142295. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142296. */
  142297. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142298. /** Gets or sets the texture format to use */
  142299. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142300. /**
  142301. * Update the texture with new data
  142302. * @param data defines the data to store in the texture
  142303. */
  142304. update(data: ArrayBufferView): void;
  142305. }
  142306. }
  142307. declare module BABYLON {
  142308. /**
  142309. * Class used to store 3D textures containing user data
  142310. */
  142311. export class RawTexture3D extends Texture {
  142312. /** Gets or sets the texture format to use */
  142313. format: number;
  142314. /**
  142315. * Create a new RawTexture3D
  142316. * @param data defines the data of the texture
  142317. * @param width defines the width of the texture
  142318. * @param height defines the height of the texture
  142319. * @param depth defines the depth of the texture
  142320. * @param format defines the texture format to use
  142321. * @param scene defines the hosting scene
  142322. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142323. * @param invertY defines if texture must be stored with Y axis inverted
  142324. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142325. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142326. */
  142327. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142328. /** Gets or sets the texture format to use */
  142329. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142330. /**
  142331. * Update the texture with new data
  142332. * @param data defines the data to store in the texture
  142333. */
  142334. update(data: ArrayBufferView): void;
  142335. }
  142336. }
  142337. declare module BABYLON {
  142338. /**
  142339. * Creates a refraction texture used by refraction channel of the standard material.
  142340. * It is like a mirror but to see through a material.
  142341. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142342. */
  142343. export class RefractionTexture extends RenderTargetTexture {
  142344. /**
  142345. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142346. * 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.
  142347. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142348. */
  142349. refractionPlane: Plane;
  142350. /**
  142351. * Define how deep under the surface we should see.
  142352. */
  142353. depth: number;
  142354. /**
  142355. * Creates a refraction texture used by refraction channel of the standard material.
  142356. * It is like a mirror but to see through a material.
  142357. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142358. * @param name Define the texture name
  142359. * @param size Define the size of the underlying texture
  142360. * @param scene Define the scene the refraction belongs to
  142361. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142362. */
  142363. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142364. /**
  142365. * Clone the refraction texture.
  142366. * @returns the cloned texture
  142367. */
  142368. clone(): RefractionTexture;
  142369. /**
  142370. * Serialize the texture to a JSON representation you could use in Parse later on
  142371. * @returns the serialized JSON representation
  142372. */
  142373. serialize(): any;
  142374. }
  142375. }
  142376. declare module BABYLON {
  142377. /**
  142378. * Block used to add support for vertex skinning (bones)
  142379. */
  142380. export class BonesBlock extends NodeMaterialBlock {
  142381. /**
  142382. * Creates a new BonesBlock
  142383. * @param name defines the block name
  142384. */
  142385. constructor(name: string);
  142386. /**
  142387. * Initialize the block and prepare the context for build
  142388. * @param state defines the state that will be used for the build
  142389. */
  142390. initialize(state: NodeMaterialBuildState): void;
  142391. /**
  142392. * Gets the current class name
  142393. * @returns the class name
  142394. */
  142395. getClassName(): string;
  142396. /**
  142397. * Gets the matrix indices input component
  142398. */
  142399. get matricesIndices(): NodeMaterialConnectionPoint;
  142400. /**
  142401. * Gets the matrix weights input component
  142402. */
  142403. get matricesWeights(): NodeMaterialConnectionPoint;
  142404. /**
  142405. * Gets the extra matrix indices input component
  142406. */
  142407. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142408. /**
  142409. * Gets the extra matrix weights input component
  142410. */
  142411. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142412. /**
  142413. * Gets the world input component
  142414. */
  142415. get world(): NodeMaterialConnectionPoint;
  142416. /**
  142417. * Gets the output component
  142418. */
  142419. get output(): NodeMaterialConnectionPoint;
  142420. autoConfigure(material: NodeMaterial): void;
  142421. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142422. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142424. protected _buildBlock(state: NodeMaterialBuildState): this;
  142425. }
  142426. }
  142427. declare module BABYLON {
  142428. /**
  142429. * Block used to add support for instances
  142430. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142431. */
  142432. export class InstancesBlock extends NodeMaterialBlock {
  142433. /**
  142434. * Creates a new InstancesBlock
  142435. * @param name defines the block name
  142436. */
  142437. constructor(name: string);
  142438. /**
  142439. * Gets the current class name
  142440. * @returns the class name
  142441. */
  142442. getClassName(): string;
  142443. /**
  142444. * Gets the first world row input component
  142445. */
  142446. get world0(): NodeMaterialConnectionPoint;
  142447. /**
  142448. * Gets the second world row input component
  142449. */
  142450. get world1(): NodeMaterialConnectionPoint;
  142451. /**
  142452. * Gets the third world row input component
  142453. */
  142454. get world2(): NodeMaterialConnectionPoint;
  142455. /**
  142456. * Gets the forth world row input component
  142457. */
  142458. get world3(): NodeMaterialConnectionPoint;
  142459. /**
  142460. * Gets the world input component
  142461. */
  142462. get world(): NodeMaterialConnectionPoint;
  142463. /**
  142464. * Gets the output component
  142465. */
  142466. get output(): NodeMaterialConnectionPoint;
  142467. /**
  142468. * Gets the isntanceID component
  142469. */
  142470. get instanceID(): NodeMaterialConnectionPoint;
  142471. autoConfigure(material: NodeMaterial): void;
  142472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142473. protected _buildBlock(state: NodeMaterialBuildState): this;
  142474. }
  142475. }
  142476. declare module BABYLON {
  142477. /**
  142478. * Block used to add morph targets support to vertex shader
  142479. */
  142480. export class MorphTargetsBlock extends NodeMaterialBlock {
  142481. private _repeatableContentAnchor;
  142482. /**
  142483. * Create a new MorphTargetsBlock
  142484. * @param name defines the block name
  142485. */
  142486. constructor(name: string);
  142487. /**
  142488. * Gets the current class name
  142489. * @returns the class name
  142490. */
  142491. getClassName(): string;
  142492. /**
  142493. * Gets the position input component
  142494. */
  142495. get position(): NodeMaterialConnectionPoint;
  142496. /**
  142497. * Gets the normal input component
  142498. */
  142499. get normal(): NodeMaterialConnectionPoint;
  142500. /**
  142501. * Gets the tangent input component
  142502. */
  142503. get tangent(): NodeMaterialConnectionPoint;
  142504. /**
  142505. * Gets the tangent input component
  142506. */
  142507. get uv(): NodeMaterialConnectionPoint;
  142508. /**
  142509. * Gets the position output component
  142510. */
  142511. get positionOutput(): NodeMaterialConnectionPoint;
  142512. /**
  142513. * Gets the normal output component
  142514. */
  142515. get normalOutput(): NodeMaterialConnectionPoint;
  142516. /**
  142517. * Gets the tangent output component
  142518. */
  142519. get tangentOutput(): NodeMaterialConnectionPoint;
  142520. /**
  142521. * Gets the tangent output component
  142522. */
  142523. get uvOutput(): NodeMaterialConnectionPoint;
  142524. initialize(state: NodeMaterialBuildState): void;
  142525. autoConfigure(material: NodeMaterial): void;
  142526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142527. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142528. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142529. protected _buildBlock(state: NodeMaterialBuildState): this;
  142530. }
  142531. }
  142532. declare module BABYLON {
  142533. /**
  142534. * Block used to get data information from a light
  142535. */
  142536. export class LightInformationBlock extends NodeMaterialBlock {
  142537. private _lightDataUniformName;
  142538. private _lightColorUniformName;
  142539. private _lightTypeDefineName;
  142540. /**
  142541. * Gets or sets the light associated with this block
  142542. */
  142543. light: Nullable<Light>;
  142544. /**
  142545. * Creates a new LightInformationBlock
  142546. * @param name defines the block name
  142547. */
  142548. constructor(name: string);
  142549. /**
  142550. * Gets the current class name
  142551. * @returns the class name
  142552. */
  142553. getClassName(): string;
  142554. /**
  142555. * Gets the world position input component
  142556. */
  142557. get worldPosition(): NodeMaterialConnectionPoint;
  142558. /**
  142559. * Gets the direction output component
  142560. */
  142561. get direction(): NodeMaterialConnectionPoint;
  142562. /**
  142563. * Gets the direction output component
  142564. */
  142565. get color(): NodeMaterialConnectionPoint;
  142566. /**
  142567. * Gets the direction output component
  142568. */
  142569. get intensity(): NodeMaterialConnectionPoint;
  142570. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142572. protected _buildBlock(state: NodeMaterialBuildState): this;
  142573. serialize(): any;
  142574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142575. }
  142576. }
  142577. declare module BABYLON {
  142578. /**
  142579. * Block used to add image processing support to fragment shader
  142580. */
  142581. export class ImageProcessingBlock extends NodeMaterialBlock {
  142582. /**
  142583. * Create a new ImageProcessingBlock
  142584. * @param name defines the block name
  142585. */
  142586. constructor(name: string);
  142587. /**
  142588. * Gets the current class name
  142589. * @returns the class name
  142590. */
  142591. getClassName(): string;
  142592. /**
  142593. * Gets the color input component
  142594. */
  142595. get color(): NodeMaterialConnectionPoint;
  142596. /**
  142597. * Gets the output component
  142598. */
  142599. get output(): NodeMaterialConnectionPoint;
  142600. /**
  142601. * Initialize the block and prepare the context for build
  142602. * @param state defines the state that will be used for the build
  142603. */
  142604. initialize(state: NodeMaterialBuildState): void;
  142605. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  142606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142607. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142608. protected _buildBlock(state: NodeMaterialBuildState): this;
  142609. }
  142610. }
  142611. declare module BABYLON {
  142612. /**
  142613. * Block used to pertub normals based on a normal map
  142614. */
  142615. export class PerturbNormalBlock extends NodeMaterialBlock {
  142616. private _tangentSpaceParameterName;
  142617. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142618. invertX: boolean;
  142619. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  142620. invertY: boolean;
  142621. /**
  142622. * Create a new PerturbNormalBlock
  142623. * @param name defines the block name
  142624. */
  142625. constructor(name: string);
  142626. /**
  142627. * Gets the current class name
  142628. * @returns the class name
  142629. */
  142630. getClassName(): string;
  142631. /**
  142632. * Gets the world position input component
  142633. */
  142634. get worldPosition(): NodeMaterialConnectionPoint;
  142635. /**
  142636. * Gets the world normal input component
  142637. */
  142638. get worldNormal(): NodeMaterialConnectionPoint;
  142639. /**
  142640. * Gets the world tangent input component
  142641. */
  142642. get worldTangent(): NodeMaterialConnectionPoint;
  142643. /**
  142644. * Gets the uv input component
  142645. */
  142646. get uv(): NodeMaterialConnectionPoint;
  142647. /**
  142648. * Gets the normal map color input component
  142649. */
  142650. get normalMapColor(): NodeMaterialConnectionPoint;
  142651. /**
  142652. * Gets the strength input component
  142653. */
  142654. get strength(): NodeMaterialConnectionPoint;
  142655. /**
  142656. * Gets the output component
  142657. */
  142658. get output(): NodeMaterialConnectionPoint;
  142659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142660. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142661. autoConfigure(material: NodeMaterial): void;
  142662. protected _buildBlock(state: NodeMaterialBuildState): this;
  142663. protected _dumpPropertiesCode(): string;
  142664. serialize(): any;
  142665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142666. }
  142667. }
  142668. declare module BABYLON {
  142669. /**
  142670. * Block used to discard a pixel if a value is smaller than a cutoff
  142671. */
  142672. export class DiscardBlock extends NodeMaterialBlock {
  142673. /**
  142674. * Create a new DiscardBlock
  142675. * @param name defines the block name
  142676. */
  142677. constructor(name: string);
  142678. /**
  142679. * Gets the current class name
  142680. * @returns the class name
  142681. */
  142682. getClassName(): string;
  142683. /**
  142684. * Gets the color input component
  142685. */
  142686. get value(): NodeMaterialConnectionPoint;
  142687. /**
  142688. * Gets the cutoff input component
  142689. */
  142690. get cutoff(): NodeMaterialConnectionPoint;
  142691. protected _buildBlock(state: NodeMaterialBuildState): this;
  142692. }
  142693. }
  142694. declare module BABYLON {
  142695. /**
  142696. * Block used to test if the fragment shader is front facing
  142697. */
  142698. export class FrontFacingBlock extends NodeMaterialBlock {
  142699. /**
  142700. * Creates a new FrontFacingBlock
  142701. * @param name defines the block name
  142702. */
  142703. constructor(name: string);
  142704. /**
  142705. * Gets the current class name
  142706. * @returns the class name
  142707. */
  142708. getClassName(): string;
  142709. /**
  142710. * Gets the output component
  142711. */
  142712. get output(): NodeMaterialConnectionPoint;
  142713. protected _buildBlock(state: NodeMaterialBuildState): this;
  142714. }
  142715. }
  142716. declare module BABYLON {
  142717. /**
  142718. * Block used to get the derivative value on x and y of a given input
  142719. */
  142720. export class DerivativeBlock extends NodeMaterialBlock {
  142721. /**
  142722. * Create a new DerivativeBlock
  142723. * @param name defines the block name
  142724. */
  142725. constructor(name: string);
  142726. /**
  142727. * Gets the current class name
  142728. * @returns the class name
  142729. */
  142730. getClassName(): string;
  142731. /**
  142732. * Gets the input component
  142733. */
  142734. get input(): NodeMaterialConnectionPoint;
  142735. /**
  142736. * Gets the derivative output on x
  142737. */
  142738. get dx(): NodeMaterialConnectionPoint;
  142739. /**
  142740. * Gets the derivative output on y
  142741. */
  142742. get dy(): NodeMaterialConnectionPoint;
  142743. protected _buildBlock(state: NodeMaterialBuildState): this;
  142744. }
  142745. }
  142746. declare module BABYLON {
  142747. /**
  142748. * Block used to make gl_FragCoord available
  142749. */
  142750. export class FragCoordBlock extends NodeMaterialBlock {
  142751. /**
  142752. * Creates a new FragCoordBlock
  142753. * @param name defines the block name
  142754. */
  142755. constructor(name: string);
  142756. /**
  142757. * Gets the current class name
  142758. * @returns the class name
  142759. */
  142760. getClassName(): string;
  142761. /**
  142762. * Gets the xy component
  142763. */
  142764. get xy(): NodeMaterialConnectionPoint;
  142765. /**
  142766. * Gets the xyz component
  142767. */
  142768. get xyz(): NodeMaterialConnectionPoint;
  142769. /**
  142770. * Gets the xyzw component
  142771. */
  142772. get xyzw(): NodeMaterialConnectionPoint;
  142773. /**
  142774. * Gets the x component
  142775. */
  142776. get x(): NodeMaterialConnectionPoint;
  142777. /**
  142778. * Gets the y component
  142779. */
  142780. get y(): NodeMaterialConnectionPoint;
  142781. /**
  142782. * Gets the z component
  142783. */
  142784. get z(): NodeMaterialConnectionPoint;
  142785. /**
  142786. * Gets the w component
  142787. */
  142788. get output(): NodeMaterialConnectionPoint;
  142789. protected writeOutputs(state: NodeMaterialBuildState): string;
  142790. protected _buildBlock(state: NodeMaterialBuildState): this;
  142791. }
  142792. }
  142793. declare module BABYLON {
  142794. /**
  142795. * Block used to get the screen sizes
  142796. */
  142797. export class ScreenSizeBlock extends NodeMaterialBlock {
  142798. private _varName;
  142799. private _scene;
  142800. /**
  142801. * Creates a new ScreenSizeBlock
  142802. * @param name defines the block name
  142803. */
  142804. constructor(name: string);
  142805. /**
  142806. * Gets the current class name
  142807. * @returns the class name
  142808. */
  142809. getClassName(): string;
  142810. /**
  142811. * Gets the xy component
  142812. */
  142813. get xy(): NodeMaterialConnectionPoint;
  142814. /**
  142815. * Gets the x component
  142816. */
  142817. get x(): NodeMaterialConnectionPoint;
  142818. /**
  142819. * Gets the y component
  142820. */
  142821. get y(): NodeMaterialConnectionPoint;
  142822. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142823. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  142824. protected _buildBlock(state: NodeMaterialBuildState): this;
  142825. }
  142826. }
  142827. declare module BABYLON {
  142828. /**
  142829. * Block used to add support for scene fog
  142830. */
  142831. export class FogBlock extends NodeMaterialBlock {
  142832. private _fogDistanceName;
  142833. private _fogParameters;
  142834. /**
  142835. * Create a new FogBlock
  142836. * @param name defines the block name
  142837. */
  142838. constructor(name: string);
  142839. /**
  142840. * Gets the current class name
  142841. * @returns the class name
  142842. */
  142843. getClassName(): string;
  142844. /**
  142845. * Gets the world position input component
  142846. */
  142847. get worldPosition(): NodeMaterialConnectionPoint;
  142848. /**
  142849. * Gets the view input component
  142850. */
  142851. get view(): NodeMaterialConnectionPoint;
  142852. /**
  142853. * Gets the color input component
  142854. */
  142855. get input(): NodeMaterialConnectionPoint;
  142856. /**
  142857. * Gets the fog color input component
  142858. */
  142859. get fogColor(): NodeMaterialConnectionPoint;
  142860. /**
  142861. * Gets the output component
  142862. */
  142863. get output(): NodeMaterialConnectionPoint;
  142864. autoConfigure(material: NodeMaterial): void;
  142865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142866. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142867. protected _buildBlock(state: NodeMaterialBuildState): this;
  142868. }
  142869. }
  142870. declare module BABYLON {
  142871. /**
  142872. * Block used to add light in the fragment shader
  142873. */
  142874. export class LightBlock extends NodeMaterialBlock {
  142875. private _lightId;
  142876. /**
  142877. * Gets or sets the light associated with this block
  142878. */
  142879. light: Nullable<Light>;
  142880. /**
  142881. * Create a new LightBlock
  142882. * @param name defines the block name
  142883. */
  142884. constructor(name: string);
  142885. /**
  142886. * Gets the current class name
  142887. * @returns the class name
  142888. */
  142889. getClassName(): string;
  142890. /**
  142891. * Gets the world position input component
  142892. */
  142893. get worldPosition(): NodeMaterialConnectionPoint;
  142894. /**
  142895. * Gets the world normal input component
  142896. */
  142897. get worldNormal(): NodeMaterialConnectionPoint;
  142898. /**
  142899. * Gets the camera (or eye) position component
  142900. */
  142901. get cameraPosition(): NodeMaterialConnectionPoint;
  142902. /**
  142903. * Gets the glossiness component
  142904. */
  142905. get glossiness(): NodeMaterialConnectionPoint;
  142906. /**
  142907. * Gets the glossinness power component
  142908. */
  142909. get glossPower(): NodeMaterialConnectionPoint;
  142910. /**
  142911. * Gets the diffuse color component
  142912. */
  142913. get diffuseColor(): NodeMaterialConnectionPoint;
  142914. /**
  142915. * Gets the specular color component
  142916. */
  142917. get specularColor(): NodeMaterialConnectionPoint;
  142918. /**
  142919. * Gets the diffuse output component
  142920. */
  142921. get diffuseOutput(): NodeMaterialConnectionPoint;
  142922. /**
  142923. * Gets the specular output component
  142924. */
  142925. get specularOutput(): NodeMaterialConnectionPoint;
  142926. /**
  142927. * Gets the shadow output component
  142928. */
  142929. get shadow(): NodeMaterialConnectionPoint;
  142930. autoConfigure(material: NodeMaterial): void;
  142931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142932. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142933. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142934. private _injectVertexCode;
  142935. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142936. serialize(): any;
  142937. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142938. }
  142939. }
  142940. declare module BABYLON {
  142941. /**
  142942. * Block used to read a reflection texture from a sampler
  142943. */
  142944. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  142945. /**
  142946. * Create a new ReflectionTextureBlock
  142947. * @param name defines the block name
  142948. */
  142949. constructor(name: string);
  142950. /**
  142951. * Gets the current class name
  142952. * @returns the class name
  142953. */
  142954. getClassName(): string;
  142955. /**
  142956. * Gets the world position input component
  142957. */
  142958. get position(): NodeMaterialConnectionPoint;
  142959. /**
  142960. * Gets the world position input component
  142961. */
  142962. get worldPosition(): NodeMaterialConnectionPoint;
  142963. /**
  142964. * Gets the world normal input component
  142965. */
  142966. get worldNormal(): NodeMaterialConnectionPoint;
  142967. /**
  142968. * Gets the world input component
  142969. */
  142970. get world(): NodeMaterialConnectionPoint;
  142971. /**
  142972. * Gets the camera (or eye) position component
  142973. */
  142974. get cameraPosition(): NodeMaterialConnectionPoint;
  142975. /**
  142976. * Gets the view input component
  142977. */
  142978. get view(): NodeMaterialConnectionPoint;
  142979. /**
  142980. * Gets the rgb output component
  142981. */
  142982. get rgb(): NodeMaterialConnectionPoint;
  142983. /**
  142984. * Gets the rgba output component
  142985. */
  142986. get rgba(): NodeMaterialConnectionPoint;
  142987. /**
  142988. * Gets the r output component
  142989. */
  142990. get r(): NodeMaterialConnectionPoint;
  142991. /**
  142992. * Gets the g output component
  142993. */
  142994. get g(): NodeMaterialConnectionPoint;
  142995. /**
  142996. * Gets the b output component
  142997. */
  142998. get b(): NodeMaterialConnectionPoint;
  142999. /**
  143000. * Gets the a output component
  143001. */
  143002. get a(): NodeMaterialConnectionPoint;
  143003. autoConfigure(material: NodeMaterial): void;
  143004. protected _buildBlock(state: NodeMaterialBuildState): this;
  143005. }
  143006. }
  143007. declare module BABYLON {
  143008. /**
  143009. * Block used to add 2 vectors
  143010. */
  143011. export class AddBlock extends NodeMaterialBlock {
  143012. /**
  143013. * Creates a new AddBlock
  143014. * @param name defines the block name
  143015. */
  143016. constructor(name: string);
  143017. /**
  143018. * Gets the current class name
  143019. * @returns the class name
  143020. */
  143021. getClassName(): string;
  143022. /**
  143023. * Gets the left operand input component
  143024. */
  143025. get left(): NodeMaterialConnectionPoint;
  143026. /**
  143027. * Gets the right operand input component
  143028. */
  143029. get right(): NodeMaterialConnectionPoint;
  143030. /**
  143031. * Gets the output component
  143032. */
  143033. get output(): NodeMaterialConnectionPoint;
  143034. protected _buildBlock(state: NodeMaterialBuildState): this;
  143035. }
  143036. }
  143037. declare module BABYLON {
  143038. /**
  143039. * Block used to scale a vector by a float
  143040. */
  143041. export class ScaleBlock extends NodeMaterialBlock {
  143042. /**
  143043. * Creates a new ScaleBlock
  143044. * @param name defines the block name
  143045. */
  143046. constructor(name: string);
  143047. /**
  143048. * Gets the current class name
  143049. * @returns the class name
  143050. */
  143051. getClassName(): string;
  143052. /**
  143053. * Gets the input component
  143054. */
  143055. get input(): NodeMaterialConnectionPoint;
  143056. /**
  143057. * Gets the factor input component
  143058. */
  143059. get factor(): NodeMaterialConnectionPoint;
  143060. /**
  143061. * Gets the output component
  143062. */
  143063. get output(): NodeMaterialConnectionPoint;
  143064. protected _buildBlock(state: NodeMaterialBuildState): this;
  143065. }
  143066. }
  143067. declare module BABYLON {
  143068. /**
  143069. * Block used to clamp a float
  143070. */
  143071. export class ClampBlock extends NodeMaterialBlock {
  143072. /** Gets or sets the minimum range */
  143073. minimum: number;
  143074. /** Gets or sets the maximum range */
  143075. maximum: number;
  143076. /**
  143077. * Creates a new ClampBlock
  143078. * @param name defines the block name
  143079. */
  143080. constructor(name: string);
  143081. /**
  143082. * Gets the current class name
  143083. * @returns the class name
  143084. */
  143085. getClassName(): string;
  143086. /**
  143087. * Gets the value input component
  143088. */
  143089. get value(): NodeMaterialConnectionPoint;
  143090. /**
  143091. * Gets the output component
  143092. */
  143093. get output(): NodeMaterialConnectionPoint;
  143094. protected _buildBlock(state: NodeMaterialBuildState): this;
  143095. protected _dumpPropertiesCode(): string;
  143096. serialize(): any;
  143097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143098. }
  143099. }
  143100. declare module BABYLON {
  143101. /**
  143102. * Block used to apply a cross product between 2 vectors
  143103. */
  143104. export class CrossBlock extends NodeMaterialBlock {
  143105. /**
  143106. * Creates a new CrossBlock
  143107. * @param name defines the block name
  143108. */
  143109. constructor(name: string);
  143110. /**
  143111. * Gets the current class name
  143112. * @returns the class name
  143113. */
  143114. getClassName(): string;
  143115. /**
  143116. * Gets the left operand input component
  143117. */
  143118. get left(): NodeMaterialConnectionPoint;
  143119. /**
  143120. * Gets the right operand input component
  143121. */
  143122. get right(): NodeMaterialConnectionPoint;
  143123. /**
  143124. * Gets the output component
  143125. */
  143126. get output(): NodeMaterialConnectionPoint;
  143127. protected _buildBlock(state: NodeMaterialBuildState): this;
  143128. }
  143129. }
  143130. declare module BABYLON {
  143131. /**
  143132. * Block used to apply a dot product between 2 vectors
  143133. */
  143134. export class DotBlock extends NodeMaterialBlock {
  143135. /**
  143136. * Creates a new DotBlock
  143137. * @param name defines the block name
  143138. */
  143139. constructor(name: string);
  143140. /**
  143141. * Gets the current class name
  143142. * @returns the class name
  143143. */
  143144. getClassName(): string;
  143145. /**
  143146. * Gets the left operand input component
  143147. */
  143148. get left(): NodeMaterialConnectionPoint;
  143149. /**
  143150. * Gets the right operand input component
  143151. */
  143152. get right(): NodeMaterialConnectionPoint;
  143153. /**
  143154. * Gets the output component
  143155. */
  143156. get output(): NodeMaterialConnectionPoint;
  143157. protected _buildBlock(state: NodeMaterialBuildState): this;
  143158. }
  143159. }
  143160. declare module BABYLON {
  143161. /**
  143162. * Block used to normalize a vector
  143163. */
  143164. export class NormalizeBlock extends NodeMaterialBlock {
  143165. /**
  143166. * Creates a new NormalizeBlock
  143167. * @param name defines the block name
  143168. */
  143169. constructor(name: string);
  143170. /**
  143171. * Gets the current class name
  143172. * @returns the class name
  143173. */
  143174. getClassName(): string;
  143175. /**
  143176. * Gets the input component
  143177. */
  143178. get input(): NodeMaterialConnectionPoint;
  143179. /**
  143180. * Gets the output component
  143181. */
  143182. get output(): NodeMaterialConnectionPoint;
  143183. protected _buildBlock(state: NodeMaterialBuildState): this;
  143184. }
  143185. }
  143186. declare module BABYLON {
  143187. /**
  143188. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143189. */
  143190. export class ColorMergerBlock extends NodeMaterialBlock {
  143191. /**
  143192. * Create a new ColorMergerBlock
  143193. * @param name defines the block name
  143194. */
  143195. constructor(name: string);
  143196. /**
  143197. * Gets the current class name
  143198. * @returns the class name
  143199. */
  143200. getClassName(): string;
  143201. /**
  143202. * Gets the rgb component (input)
  143203. */
  143204. get rgbIn(): NodeMaterialConnectionPoint;
  143205. /**
  143206. * Gets the r component (input)
  143207. */
  143208. get r(): NodeMaterialConnectionPoint;
  143209. /**
  143210. * Gets the g component (input)
  143211. */
  143212. get g(): NodeMaterialConnectionPoint;
  143213. /**
  143214. * Gets the b component (input)
  143215. */
  143216. get b(): NodeMaterialConnectionPoint;
  143217. /**
  143218. * Gets the a component (input)
  143219. */
  143220. get a(): NodeMaterialConnectionPoint;
  143221. /**
  143222. * Gets the rgba component (output)
  143223. */
  143224. get rgba(): NodeMaterialConnectionPoint;
  143225. /**
  143226. * Gets the rgb component (output)
  143227. */
  143228. get rgbOut(): NodeMaterialConnectionPoint;
  143229. /**
  143230. * Gets the rgb component (output)
  143231. * @deprecated Please use rgbOut instead.
  143232. */
  143233. get rgb(): NodeMaterialConnectionPoint;
  143234. protected _buildBlock(state: NodeMaterialBuildState): this;
  143235. }
  143236. }
  143237. declare module BABYLON {
  143238. /**
  143239. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143240. */
  143241. export class VectorSplitterBlock extends NodeMaterialBlock {
  143242. /**
  143243. * Create a new VectorSplitterBlock
  143244. * @param name defines the block name
  143245. */
  143246. constructor(name: string);
  143247. /**
  143248. * Gets the current class name
  143249. * @returns the class name
  143250. */
  143251. getClassName(): string;
  143252. /**
  143253. * Gets the xyzw component (input)
  143254. */
  143255. get xyzw(): NodeMaterialConnectionPoint;
  143256. /**
  143257. * Gets the xyz component (input)
  143258. */
  143259. get xyzIn(): NodeMaterialConnectionPoint;
  143260. /**
  143261. * Gets the xy component (input)
  143262. */
  143263. get xyIn(): NodeMaterialConnectionPoint;
  143264. /**
  143265. * Gets the xyz component (output)
  143266. */
  143267. get xyzOut(): NodeMaterialConnectionPoint;
  143268. /**
  143269. * Gets the xy component (output)
  143270. */
  143271. get xyOut(): NodeMaterialConnectionPoint;
  143272. /**
  143273. * Gets the x component (output)
  143274. */
  143275. get x(): NodeMaterialConnectionPoint;
  143276. /**
  143277. * Gets the y component (output)
  143278. */
  143279. get y(): NodeMaterialConnectionPoint;
  143280. /**
  143281. * Gets the z component (output)
  143282. */
  143283. get z(): NodeMaterialConnectionPoint;
  143284. /**
  143285. * Gets the w component (output)
  143286. */
  143287. get w(): NodeMaterialConnectionPoint;
  143288. protected _inputRename(name: string): string;
  143289. protected _outputRename(name: string): string;
  143290. protected _buildBlock(state: NodeMaterialBuildState): this;
  143291. }
  143292. }
  143293. declare module BABYLON {
  143294. /**
  143295. * Block used to lerp between 2 values
  143296. */
  143297. export class LerpBlock extends NodeMaterialBlock {
  143298. /**
  143299. * Creates a new LerpBlock
  143300. * @param name defines the block name
  143301. */
  143302. constructor(name: string);
  143303. /**
  143304. * Gets the current class name
  143305. * @returns the class name
  143306. */
  143307. getClassName(): string;
  143308. /**
  143309. * Gets the left operand input component
  143310. */
  143311. get left(): NodeMaterialConnectionPoint;
  143312. /**
  143313. * Gets the right operand input component
  143314. */
  143315. get right(): NodeMaterialConnectionPoint;
  143316. /**
  143317. * Gets the gradient operand input component
  143318. */
  143319. get gradient(): NodeMaterialConnectionPoint;
  143320. /**
  143321. * Gets the output component
  143322. */
  143323. get output(): NodeMaterialConnectionPoint;
  143324. protected _buildBlock(state: NodeMaterialBuildState): this;
  143325. }
  143326. }
  143327. declare module BABYLON {
  143328. /**
  143329. * Block used to divide 2 vectors
  143330. */
  143331. export class DivideBlock extends NodeMaterialBlock {
  143332. /**
  143333. * Creates a new DivideBlock
  143334. * @param name defines the block name
  143335. */
  143336. constructor(name: string);
  143337. /**
  143338. * Gets the current class name
  143339. * @returns the class name
  143340. */
  143341. getClassName(): string;
  143342. /**
  143343. * Gets the left operand input component
  143344. */
  143345. get left(): NodeMaterialConnectionPoint;
  143346. /**
  143347. * Gets the right operand input component
  143348. */
  143349. get right(): NodeMaterialConnectionPoint;
  143350. /**
  143351. * Gets the output component
  143352. */
  143353. get output(): NodeMaterialConnectionPoint;
  143354. protected _buildBlock(state: NodeMaterialBuildState): this;
  143355. }
  143356. }
  143357. declare module BABYLON {
  143358. /**
  143359. * Block used to subtract 2 vectors
  143360. */
  143361. export class SubtractBlock extends NodeMaterialBlock {
  143362. /**
  143363. * Creates a new SubtractBlock
  143364. * @param name defines the block name
  143365. */
  143366. constructor(name: string);
  143367. /**
  143368. * Gets the current class name
  143369. * @returns the class name
  143370. */
  143371. getClassName(): string;
  143372. /**
  143373. * Gets the left operand input component
  143374. */
  143375. get left(): NodeMaterialConnectionPoint;
  143376. /**
  143377. * Gets the right operand input component
  143378. */
  143379. get right(): NodeMaterialConnectionPoint;
  143380. /**
  143381. * Gets the output component
  143382. */
  143383. get output(): NodeMaterialConnectionPoint;
  143384. protected _buildBlock(state: NodeMaterialBuildState): this;
  143385. }
  143386. }
  143387. declare module BABYLON {
  143388. /**
  143389. * Block used to step a value
  143390. */
  143391. export class StepBlock extends NodeMaterialBlock {
  143392. /**
  143393. * Creates a new StepBlock
  143394. * @param name defines the block name
  143395. */
  143396. constructor(name: string);
  143397. /**
  143398. * Gets the current class name
  143399. * @returns the class name
  143400. */
  143401. getClassName(): string;
  143402. /**
  143403. * Gets the value operand input component
  143404. */
  143405. get value(): NodeMaterialConnectionPoint;
  143406. /**
  143407. * Gets the edge operand input component
  143408. */
  143409. get edge(): NodeMaterialConnectionPoint;
  143410. /**
  143411. * Gets the output component
  143412. */
  143413. get output(): NodeMaterialConnectionPoint;
  143414. protected _buildBlock(state: NodeMaterialBuildState): this;
  143415. }
  143416. }
  143417. declare module BABYLON {
  143418. /**
  143419. * Block used to get the opposite (1 - x) of a value
  143420. */
  143421. export class OneMinusBlock extends NodeMaterialBlock {
  143422. /**
  143423. * Creates a new OneMinusBlock
  143424. * @param name defines the block name
  143425. */
  143426. constructor(name: string);
  143427. /**
  143428. * Gets the current class name
  143429. * @returns the class name
  143430. */
  143431. getClassName(): string;
  143432. /**
  143433. * Gets the input component
  143434. */
  143435. get input(): NodeMaterialConnectionPoint;
  143436. /**
  143437. * Gets the output component
  143438. */
  143439. get output(): NodeMaterialConnectionPoint;
  143440. protected _buildBlock(state: NodeMaterialBuildState): this;
  143441. }
  143442. }
  143443. declare module BABYLON {
  143444. /**
  143445. * Block used to get the view direction
  143446. */
  143447. export class ViewDirectionBlock extends NodeMaterialBlock {
  143448. /**
  143449. * Creates a new ViewDirectionBlock
  143450. * @param name defines the block name
  143451. */
  143452. constructor(name: string);
  143453. /**
  143454. * Gets the current class name
  143455. * @returns the class name
  143456. */
  143457. getClassName(): string;
  143458. /**
  143459. * Gets the world position component
  143460. */
  143461. get worldPosition(): NodeMaterialConnectionPoint;
  143462. /**
  143463. * Gets the camera position component
  143464. */
  143465. get cameraPosition(): NodeMaterialConnectionPoint;
  143466. /**
  143467. * Gets the output component
  143468. */
  143469. get output(): NodeMaterialConnectionPoint;
  143470. autoConfigure(material: NodeMaterial): void;
  143471. protected _buildBlock(state: NodeMaterialBuildState): this;
  143472. }
  143473. }
  143474. declare module BABYLON {
  143475. /**
  143476. * Block used to compute fresnel value
  143477. */
  143478. export class FresnelBlock extends NodeMaterialBlock {
  143479. /**
  143480. * Create a new FresnelBlock
  143481. * @param name defines the block name
  143482. */
  143483. constructor(name: string);
  143484. /**
  143485. * Gets the current class name
  143486. * @returns the class name
  143487. */
  143488. getClassName(): string;
  143489. /**
  143490. * Gets the world normal input component
  143491. */
  143492. get worldNormal(): NodeMaterialConnectionPoint;
  143493. /**
  143494. * Gets the view direction input component
  143495. */
  143496. get viewDirection(): NodeMaterialConnectionPoint;
  143497. /**
  143498. * Gets the bias input component
  143499. */
  143500. get bias(): NodeMaterialConnectionPoint;
  143501. /**
  143502. * Gets the camera (or eye) position component
  143503. */
  143504. get power(): NodeMaterialConnectionPoint;
  143505. /**
  143506. * Gets the fresnel output component
  143507. */
  143508. get fresnel(): NodeMaterialConnectionPoint;
  143509. autoConfigure(material: NodeMaterial): void;
  143510. protected _buildBlock(state: NodeMaterialBuildState): this;
  143511. }
  143512. }
  143513. declare module BABYLON {
  143514. /**
  143515. * Block used to get the max of 2 values
  143516. */
  143517. export class MaxBlock extends NodeMaterialBlock {
  143518. /**
  143519. * Creates a new MaxBlock
  143520. * @param name defines the block name
  143521. */
  143522. constructor(name: string);
  143523. /**
  143524. * Gets the current class name
  143525. * @returns the class name
  143526. */
  143527. getClassName(): string;
  143528. /**
  143529. * Gets the left operand input component
  143530. */
  143531. get left(): NodeMaterialConnectionPoint;
  143532. /**
  143533. * Gets the right operand input component
  143534. */
  143535. get right(): NodeMaterialConnectionPoint;
  143536. /**
  143537. * Gets the output component
  143538. */
  143539. get output(): NodeMaterialConnectionPoint;
  143540. protected _buildBlock(state: NodeMaterialBuildState): this;
  143541. }
  143542. }
  143543. declare module BABYLON {
  143544. /**
  143545. * Block used to get the min of 2 values
  143546. */
  143547. export class MinBlock extends NodeMaterialBlock {
  143548. /**
  143549. * Creates a new MinBlock
  143550. * @param name defines the block name
  143551. */
  143552. constructor(name: string);
  143553. /**
  143554. * Gets the current class name
  143555. * @returns the class name
  143556. */
  143557. getClassName(): string;
  143558. /**
  143559. * Gets the left operand input component
  143560. */
  143561. get left(): NodeMaterialConnectionPoint;
  143562. /**
  143563. * Gets the right operand input component
  143564. */
  143565. get right(): NodeMaterialConnectionPoint;
  143566. /**
  143567. * Gets the output component
  143568. */
  143569. get output(): NodeMaterialConnectionPoint;
  143570. protected _buildBlock(state: NodeMaterialBuildState): this;
  143571. }
  143572. }
  143573. declare module BABYLON {
  143574. /**
  143575. * Block used to get the distance between 2 values
  143576. */
  143577. export class DistanceBlock extends NodeMaterialBlock {
  143578. /**
  143579. * Creates a new DistanceBlock
  143580. * @param name defines the block name
  143581. */
  143582. constructor(name: string);
  143583. /**
  143584. * Gets the current class name
  143585. * @returns the class name
  143586. */
  143587. getClassName(): string;
  143588. /**
  143589. * Gets the left operand input component
  143590. */
  143591. get left(): NodeMaterialConnectionPoint;
  143592. /**
  143593. * Gets the right operand input component
  143594. */
  143595. get right(): NodeMaterialConnectionPoint;
  143596. /**
  143597. * Gets the output component
  143598. */
  143599. get output(): NodeMaterialConnectionPoint;
  143600. protected _buildBlock(state: NodeMaterialBuildState): this;
  143601. }
  143602. }
  143603. declare module BABYLON {
  143604. /**
  143605. * Block used to get the length of a vector
  143606. */
  143607. export class LengthBlock extends NodeMaterialBlock {
  143608. /**
  143609. * Creates a new LengthBlock
  143610. * @param name defines the block name
  143611. */
  143612. constructor(name: string);
  143613. /**
  143614. * Gets the current class name
  143615. * @returns the class name
  143616. */
  143617. getClassName(): string;
  143618. /**
  143619. * Gets the value input component
  143620. */
  143621. get value(): NodeMaterialConnectionPoint;
  143622. /**
  143623. * Gets the output component
  143624. */
  143625. get output(): NodeMaterialConnectionPoint;
  143626. protected _buildBlock(state: NodeMaterialBuildState): this;
  143627. }
  143628. }
  143629. declare module BABYLON {
  143630. /**
  143631. * Block used to get negative version of a value (i.e. x * -1)
  143632. */
  143633. export class NegateBlock extends NodeMaterialBlock {
  143634. /**
  143635. * Creates a new NegateBlock
  143636. * @param name defines the block name
  143637. */
  143638. constructor(name: string);
  143639. /**
  143640. * Gets the current class name
  143641. * @returns the class name
  143642. */
  143643. getClassName(): string;
  143644. /**
  143645. * Gets the value input component
  143646. */
  143647. get value(): NodeMaterialConnectionPoint;
  143648. /**
  143649. * Gets the output component
  143650. */
  143651. get output(): NodeMaterialConnectionPoint;
  143652. protected _buildBlock(state: NodeMaterialBuildState): this;
  143653. }
  143654. }
  143655. declare module BABYLON {
  143656. /**
  143657. * Block used to get the value of the first parameter raised to the power of the second
  143658. */
  143659. export class PowBlock extends NodeMaterialBlock {
  143660. /**
  143661. * Creates a new PowBlock
  143662. * @param name defines the block name
  143663. */
  143664. constructor(name: string);
  143665. /**
  143666. * Gets the current class name
  143667. * @returns the class name
  143668. */
  143669. getClassName(): string;
  143670. /**
  143671. * Gets the value operand input component
  143672. */
  143673. get value(): NodeMaterialConnectionPoint;
  143674. /**
  143675. * Gets the power operand input component
  143676. */
  143677. get power(): NodeMaterialConnectionPoint;
  143678. /**
  143679. * Gets the output component
  143680. */
  143681. get output(): NodeMaterialConnectionPoint;
  143682. protected _buildBlock(state: NodeMaterialBuildState): this;
  143683. }
  143684. }
  143685. declare module BABYLON {
  143686. /**
  143687. * Block used to get a random number
  143688. */
  143689. export class RandomNumberBlock extends NodeMaterialBlock {
  143690. /**
  143691. * Creates a new RandomNumberBlock
  143692. * @param name defines the block name
  143693. */
  143694. constructor(name: string);
  143695. /**
  143696. * Gets the current class name
  143697. * @returns the class name
  143698. */
  143699. getClassName(): string;
  143700. /**
  143701. * Gets the seed input component
  143702. */
  143703. get seed(): NodeMaterialConnectionPoint;
  143704. /**
  143705. * Gets the output component
  143706. */
  143707. get output(): NodeMaterialConnectionPoint;
  143708. protected _buildBlock(state: NodeMaterialBuildState): this;
  143709. }
  143710. }
  143711. declare module BABYLON {
  143712. /**
  143713. * Block used to compute arc tangent of 2 values
  143714. */
  143715. export class ArcTan2Block extends NodeMaterialBlock {
  143716. /**
  143717. * Creates a new ArcTan2Block
  143718. * @param name defines the block name
  143719. */
  143720. constructor(name: string);
  143721. /**
  143722. * Gets the current class name
  143723. * @returns the class name
  143724. */
  143725. getClassName(): string;
  143726. /**
  143727. * Gets the x operand input component
  143728. */
  143729. get x(): NodeMaterialConnectionPoint;
  143730. /**
  143731. * Gets the y operand input component
  143732. */
  143733. get y(): NodeMaterialConnectionPoint;
  143734. /**
  143735. * Gets the output component
  143736. */
  143737. get output(): NodeMaterialConnectionPoint;
  143738. protected _buildBlock(state: NodeMaterialBuildState): this;
  143739. }
  143740. }
  143741. declare module BABYLON {
  143742. /**
  143743. * Block used to smooth step a value
  143744. */
  143745. export class SmoothStepBlock extends NodeMaterialBlock {
  143746. /**
  143747. * Creates a new SmoothStepBlock
  143748. * @param name defines the block name
  143749. */
  143750. constructor(name: string);
  143751. /**
  143752. * Gets the current class name
  143753. * @returns the class name
  143754. */
  143755. getClassName(): string;
  143756. /**
  143757. * Gets the value operand input component
  143758. */
  143759. get value(): NodeMaterialConnectionPoint;
  143760. /**
  143761. * Gets the first edge operand input component
  143762. */
  143763. get edge0(): NodeMaterialConnectionPoint;
  143764. /**
  143765. * Gets the second edge operand input component
  143766. */
  143767. get edge1(): NodeMaterialConnectionPoint;
  143768. /**
  143769. * Gets the output component
  143770. */
  143771. get output(): NodeMaterialConnectionPoint;
  143772. protected _buildBlock(state: NodeMaterialBuildState): this;
  143773. }
  143774. }
  143775. declare module BABYLON {
  143776. /**
  143777. * Block used to get the reciprocal (1 / x) of a value
  143778. */
  143779. export class ReciprocalBlock extends NodeMaterialBlock {
  143780. /**
  143781. * Creates a new ReciprocalBlock
  143782. * @param name defines the block name
  143783. */
  143784. constructor(name: string);
  143785. /**
  143786. * Gets the current class name
  143787. * @returns the class name
  143788. */
  143789. getClassName(): string;
  143790. /**
  143791. * Gets the input component
  143792. */
  143793. get input(): NodeMaterialConnectionPoint;
  143794. /**
  143795. * Gets the output component
  143796. */
  143797. get output(): NodeMaterialConnectionPoint;
  143798. protected _buildBlock(state: NodeMaterialBuildState): this;
  143799. }
  143800. }
  143801. declare module BABYLON {
  143802. /**
  143803. * Block used to replace a color by another one
  143804. */
  143805. export class ReplaceColorBlock extends NodeMaterialBlock {
  143806. /**
  143807. * Creates a new ReplaceColorBlock
  143808. * @param name defines the block name
  143809. */
  143810. constructor(name: string);
  143811. /**
  143812. * Gets the current class name
  143813. * @returns the class name
  143814. */
  143815. getClassName(): string;
  143816. /**
  143817. * Gets the value input component
  143818. */
  143819. get value(): NodeMaterialConnectionPoint;
  143820. /**
  143821. * Gets the reference input component
  143822. */
  143823. get reference(): NodeMaterialConnectionPoint;
  143824. /**
  143825. * Gets the distance input component
  143826. */
  143827. get distance(): NodeMaterialConnectionPoint;
  143828. /**
  143829. * Gets the replacement input component
  143830. */
  143831. get replacement(): NodeMaterialConnectionPoint;
  143832. /**
  143833. * Gets the output component
  143834. */
  143835. get output(): NodeMaterialConnectionPoint;
  143836. protected _buildBlock(state: NodeMaterialBuildState): this;
  143837. }
  143838. }
  143839. declare module BABYLON {
  143840. /**
  143841. * Block used to posterize a value
  143842. * @see https://en.wikipedia.org/wiki/Posterization
  143843. */
  143844. export class PosterizeBlock extends NodeMaterialBlock {
  143845. /**
  143846. * Creates a new PosterizeBlock
  143847. * @param name defines the block name
  143848. */
  143849. constructor(name: string);
  143850. /**
  143851. * Gets the current class name
  143852. * @returns the class name
  143853. */
  143854. getClassName(): string;
  143855. /**
  143856. * Gets the value input component
  143857. */
  143858. get value(): NodeMaterialConnectionPoint;
  143859. /**
  143860. * Gets the steps input component
  143861. */
  143862. get steps(): NodeMaterialConnectionPoint;
  143863. /**
  143864. * Gets the output component
  143865. */
  143866. get output(): NodeMaterialConnectionPoint;
  143867. protected _buildBlock(state: NodeMaterialBuildState): this;
  143868. }
  143869. }
  143870. declare module BABYLON {
  143871. /**
  143872. * Operations supported by the Wave block
  143873. */
  143874. export enum WaveBlockKind {
  143875. /** SawTooth */
  143876. SawTooth = 0,
  143877. /** Square */
  143878. Square = 1,
  143879. /** Triangle */
  143880. Triangle = 2
  143881. }
  143882. /**
  143883. * Block used to apply wave operation to floats
  143884. */
  143885. export class WaveBlock extends NodeMaterialBlock {
  143886. /**
  143887. * Gets or sets the kibnd of wave to be applied by the block
  143888. */
  143889. kind: WaveBlockKind;
  143890. /**
  143891. * Creates a new WaveBlock
  143892. * @param name defines the block name
  143893. */
  143894. constructor(name: string);
  143895. /**
  143896. * Gets the current class name
  143897. * @returns the class name
  143898. */
  143899. getClassName(): string;
  143900. /**
  143901. * Gets the input component
  143902. */
  143903. get input(): NodeMaterialConnectionPoint;
  143904. /**
  143905. * Gets the output component
  143906. */
  143907. get output(): NodeMaterialConnectionPoint;
  143908. protected _buildBlock(state: NodeMaterialBuildState): this;
  143909. serialize(): any;
  143910. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143911. }
  143912. }
  143913. declare module BABYLON {
  143914. /**
  143915. * Class used to store a color step for the GradientBlock
  143916. */
  143917. export class GradientBlockColorStep {
  143918. private _step;
  143919. /**
  143920. * Gets value indicating which step this color is associated with (between 0 and 1)
  143921. */
  143922. get step(): number;
  143923. /**
  143924. * Sets a value indicating which step this color is associated with (between 0 and 1)
  143925. */
  143926. set step(val: number);
  143927. private _color;
  143928. /**
  143929. * Gets the color associated with this step
  143930. */
  143931. get color(): Color3;
  143932. /**
  143933. * Sets the color associated with this step
  143934. */
  143935. set color(val: Color3);
  143936. /**
  143937. * Creates a new GradientBlockColorStep
  143938. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  143939. * @param color defines the color associated with this step
  143940. */
  143941. constructor(step: number, color: Color3);
  143942. }
  143943. /**
  143944. * Block used to return a color from a gradient based on an input value between 0 and 1
  143945. */
  143946. export class GradientBlock extends NodeMaterialBlock {
  143947. /**
  143948. * Gets or sets the list of color steps
  143949. */
  143950. colorSteps: GradientBlockColorStep[];
  143951. /** Gets an observable raised when the value is changed */
  143952. onValueChangedObservable: Observable<GradientBlock>;
  143953. /** calls observable when the value is changed*/
  143954. colorStepsUpdated(): void;
  143955. /**
  143956. * Creates a new GradientBlock
  143957. * @param name defines the block name
  143958. */
  143959. constructor(name: string);
  143960. /**
  143961. * Gets the current class name
  143962. * @returns the class name
  143963. */
  143964. getClassName(): string;
  143965. /**
  143966. * Gets the gradient input component
  143967. */
  143968. get gradient(): NodeMaterialConnectionPoint;
  143969. /**
  143970. * Gets the output component
  143971. */
  143972. get output(): NodeMaterialConnectionPoint;
  143973. private _writeColorConstant;
  143974. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143975. serialize(): any;
  143976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143977. protected _dumpPropertiesCode(): string;
  143978. }
  143979. }
  143980. declare module BABYLON {
  143981. /**
  143982. * Block used to normalize lerp between 2 values
  143983. */
  143984. export class NLerpBlock extends NodeMaterialBlock {
  143985. /**
  143986. * Creates a new NLerpBlock
  143987. * @param name defines the block name
  143988. */
  143989. constructor(name: string);
  143990. /**
  143991. * Gets the current class name
  143992. * @returns the class name
  143993. */
  143994. getClassName(): string;
  143995. /**
  143996. * Gets the left operand input component
  143997. */
  143998. get left(): NodeMaterialConnectionPoint;
  143999. /**
  144000. * Gets the right operand input component
  144001. */
  144002. get right(): NodeMaterialConnectionPoint;
  144003. /**
  144004. * Gets the gradient operand input component
  144005. */
  144006. get gradient(): NodeMaterialConnectionPoint;
  144007. /**
  144008. * Gets the output component
  144009. */
  144010. get output(): NodeMaterialConnectionPoint;
  144011. protected _buildBlock(state: NodeMaterialBuildState): this;
  144012. }
  144013. }
  144014. declare module BABYLON {
  144015. /**
  144016. * block used to Generate a Worley Noise 3D Noise Pattern
  144017. */
  144018. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144019. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144020. manhattanDistance: boolean;
  144021. /**
  144022. * Creates a new WorleyNoise3DBlock
  144023. * @param name defines the block name
  144024. */
  144025. constructor(name: string);
  144026. /**
  144027. * Gets the current class name
  144028. * @returns the class name
  144029. */
  144030. getClassName(): string;
  144031. /**
  144032. * Gets the seed input component
  144033. */
  144034. get seed(): NodeMaterialConnectionPoint;
  144035. /**
  144036. * Gets the jitter input component
  144037. */
  144038. get jitter(): NodeMaterialConnectionPoint;
  144039. /**
  144040. * Gets the output component
  144041. */
  144042. get output(): NodeMaterialConnectionPoint;
  144043. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144044. /**
  144045. * Exposes the properties to the UI?
  144046. */
  144047. protected _dumpPropertiesCode(): string;
  144048. /**
  144049. * Exposes the properties to the Seralize?
  144050. */
  144051. serialize(): any;
  144052. /**
  144053. * Exposes the properties to the deseralize?
  144054. */
  144055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144056. }
  144057. }
  144058. declare module BABYLON {
  144059. /**
  144060. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144061. */
  144062. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144063. /**
  144064. * Creates a new SimplexPerlin3DBlock
  144065. * @param name defines the block name
  144066. */
  144067. constructor(name: string);
  144068. /**
  144069. * Gets the current class name
  144070. * @returns the class name
  144071. */
  144072. getClassName(): string;
  144073. /**
  144074. * Gets the seed operand input component
  144075. */
  144076. get seed(): NodeMaterialConnectionPoint;
  144077. /**
  144078. * Gets the output component
  144079. */
  144080. get output(): NodeMaterialConnectionPoint;
  144081. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144082. }
  144083. }
  144084. declare module BABYLON {
  144085. /**
  144086. * Block used to blend normals
  144087. */
  144088. export class NormalBlendBlock extends NodeMaterialBlock {
  144089. /**
  144090. * Creates a new NormalBlendBlock
  144091. * @param name defines the block name
  144092. */
  144093. constructor(name: string);
  144094. /**
  144095. * Gets the current class name
  144096. * @returns the class name
  144097. */
  144098. getClassName(): string;
  144099. /**
  144100. * Gets the first input component
  144101. */
  144102. get normalMap0(): NodeMaterialConnectionPoint;
  144103. /**
  144104. * Gets the second input component
  144105. */
  144106. get normalMap1(): NodeMaterialConnectionPoint;
  144107. /**
  144108. * Gets the output component
  144109. */
  144110. get output(): NodeMaterialConnectionPoint;
  144111. protected _buildBlock(state: NodeMaterialBuildState): this;
  144112. }
  144113. }
  144114. declare module BABYLON {
  144115. /**
  144116. * Block used to rotate a 2d vector by a given angle
  144117. */
  144118. export class Rotate2dBlock extends NodeMaterialBlock {
  144119. /**
  144120. * Creates a new Rotate2dBlock
  144121. * @param name defines the block name
  144122. */
  144123. constructor(name: string);
  144124. /**
  144125. * Gets the current class name
  144126. * @returns the class name
  144127. */
  144128. getClassName(): string;
  144129. /**
  144130. * Gets the input vector
  144131. */
  144132. get input(): NodeMaterialConnectionPoint;
  144133. /**
  144134. * Gets the input angle
  144135. */
  144136. get angle(): NodeMaterialConnectionPoint;
  144137. /**
  144138. * Gets the output component
  144139. */
  144140. get output(): NodeMaterialConnectionPoint;
  144141. autoConfigure(material: NodeMaterial): void;
  144142. protected _buildBlock(state: NodeMaterialBuildState): this;
  144143. }
  144144. }
  144145. declare module BABYLON {
  144146. /**
  144147. * Block used to get the reflected vector from a direction and a normal
  144148. */
  144149. export class ReflectBlock extends NodeMaterialBlock {
  144150. /**
  144151. * Creates a new ReflectBlock
  144152. * @param name defines the block name
  144153. */
  144154. constructor(name: string);
  144155. /**
  144156. * Gets the current class name
  144157. * @returns the class name
  144158. */
  144159. getClassName(): string;
  144160. /**
  144161. * Gets the incident component
  144162. */
  144163. get incident(): NodeMaterialConnectionPoint;
  144164. /**
  144165. * Gets the normal component
  144166. */
  144167. get normal(): NodeMaterialConnectionPoint;
  144168. /**
  144169. * Gets the output component
  144170. */
  144171. get output(): NodeMaterialConnectionPoint;
  144172. protected _buildBlock(state: NodeMaterialBuildState): this;
  144173. }
  144174. }
  144175. declare module BABYLON {
  144176. /**
  144177. * Block used to get the refracted vector from a direction and a normal
  144178. */
  144179. export class RefractBlock extends NodeMaterialBlock {
  144180. /**
  144181. * Creates a new RefractBlock
  144182. * @param name defines the block name
  144183. */
  144184. constructor(name: string);
  144185. /**
  144186. * Gets the current class name
  144187. * @returns the class name
  144188. */
  144189. getClassName(): string;
  144190. /**
  144191. * Gets the incident component
  144192. */
  144193. get incident(): NodeMaterialConnectionPoint;
  144194. /**
  144195. * Gets the normal component
  144196. */
  144197. get normal(): NodeMaterialConnectionPoint;
  144198. /**
  144199. * Gets the index of refraction component
  144200. */
  144201. get ior(): NodeMaterialConnectionPoint;
  144202. /**
  144203. * Gets the output component
  144204. */
  144205. get output(): NodeMaterialConnectionPoint;
  144206. protected _buildBlock(state: NodeMaterialBuildState): this;
  144207. }
  144208. }
  144209. declare module BABYLON {
  144210. /**
  144211. * Block used to desaturate a color
  144212. */
  144213. export class DesaturateBlock extends NodeMaterialBlock {
  144214. /**
  144215. * Creates a new DesaturateBlock
  144216. * @param name defines the block name
  144217. */
  144218. constructor(name: string);
  144219. /**
  144220. * Gets the current class name
  144221. * @returns the class name
  144222. */
  144223. getClassName(): string;
  144224. /**
  144225. * Gets the color operand input component
  144226. */
  144227. get color(): NodeMaterialConnectionPoint;
  144228. /**
  144229. * Gets the level operand input component
  144230. */
  144231. get level(): NodeMaterialConnectionPoint;
  144232. /**
  144233. * Gets the output component
  144234. */
  144235. get output(): NodeMaterialConnectionPoint;
  144236. protected _buildBlock(state: NodeMaterialBuildState): this;
  144237. }
  144238. }
  144239. declare module BABYLON {
  144240. /**
  144241. * Block used to implement the ambient occlusion module of the PBR material
  144242. */
  144243. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144244. /**
  144245. * Create a new AmbientOcclusionBlock
  144246. * @param name defines the block name
  144247. */
  144248. constructor(name: string);
  144249. /**
  144250. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144251. */
  144252. useAmbientInGrayScale: boolean;
  144253. /**
  144254. * Initialize the block and prepare the context for build
  144255. * @param state defines the state that will be used for the build
  144256. */
  144257. initialize(state: NodeMaterialBuildState): void;
  144258. /**
  144259. * Gets the current class name
  144260. * @returns the class name
  144261. */
  144262. getClassName(): string;
  144263. /**
  144264. * Gets the texture input component
  144265. */
  144266. get texture(): NodeMaterialConnectionPoint;
  144267. /**
  144268. * Gets the texture intensity component
  144269. */
  144270. get intensity(): NodeMaterialConnectionPoint;
  144271. /**
  144272. * Gets the direct light intensity input component
  144273. */
  144274. get directLightIntensity(): NodeMaterialConnectionPoint;
  144275. /**
  144276. * Gets the ambient occlusion object output component
  144277. */
  144278. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144279. /**
  144280. * Gets the main code of the block (fragment side)
  144281. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144282. * @returns the shader code
  144283. */
  144284. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144286. protected _buildBlock(state: NodeMaterialBuildState): this;
  144287. protected _dumpPropertiesCode(): string;
  144288. serialize(): any;
  144289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144290. }
  144291. }
  144292. declare module BABYLON {
  144293. /**
  144294. * Block used to implement the reflection module of the PBR material
  144295. */
  144296. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144297. /** @hidden */
  144298. _defineLODReflectionAlpha: string;
  144299. /** @hidden */
  144300. _defineLinearSpecularReflection: string;
  144301. private _vEnvironmentIrradianceName;
  144302. /** @hidden */
  144303. _vReflectionMicrosurfaceInfosName: string;
  144304. /** @hidden */
  144305. _vReflectionInfosName: string;
  144306. /** @hidden */
  144307. _vReflectionFilteringInfoName: string;
  144308. private _scene;
  144309. /**
  144310. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144311. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144312. * It's less burden on the user side in the editor part.
  144313. */
  144314. /** @hidden */
  144315. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144316. /** @hidden */
  144317. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144318. /** @hidden */
  144319. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144320. /**
  144321. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144322. * diffuse part of the IBL.
  144323. */
  144324. useSphericalHarmonics: boolean;
  144325. /**
  144326. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144327. */
  144328. forceIrradianceInFragment: boolean;
  144329. /**
  144330. * Create a new ReflectionBlock
  144331. * @param name defines the block name
  144332. */
  144333. constructor(name: string);
  144334. /**
  144335. * Gets the current class name
  144336. * @returns the class name
  144337. */
  144338. getClassName(): string;
  144339. /**
  144340. * Gets the position input component
  144341. */
  144342. get position(): NodeMaterialConnectionPoint;
  144343. /**
  144344. * Gets the world position input component
  144345. */
  144346. get worldPosition(): NodeMaterialConnectionPoint;
  144347. /**
  144348. * Gets the world normal input component
  144349. */
  144350. get worldNormal(): NodeMaterialConnectionPoint;
  144351. /**
  144352. * Gets the world input component
  144353. */
  144354. get world(): NodeMaterialConnectionPoint;
  144355. /**
  144356. * Gets the camera (or eye) position component
  144357. */
  144358. get cameraPosition(): NodeMaterialConnectionPoint;
  144359. /**
  144360. * Gets the view input component
  144361. */
  144362. get view(): NodeMaterialConnectionPoint;
  144363. /**
  144364. * Gets the color input component
  144365. */
  144366. get color(): NodeMaterialConnectionPoint;
  144367. /**
  144368. * Gets the reflection object output component
  144369. */
  144370. get reflection(): NodeMaterialConnectionPoint;
  144371. /**
  144372. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144373. */
  144374. get hasTexture(): boolean;
  144375. /**
  144376. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144377. */
  144378. get reflectionColor(): string;
  144379. protected _getTexture(): Nullable<BaseTexture>;
  144380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144381. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144382. /**
  144383. * Gets the code to inject in the vertex shader
  144384. * @param state current state of the node material building
  144385. * @returns the shader code
  144386. */
  144387. handleVertexSide(state: NodeMaterialBuildState): string;
  144388. /**
  144389. * Gets the main code of the block (fragment side)
  144390. * @param state current state of the node material building
  144391. * @param normalVarName name of the existing variable corresponding to the normal
  144392. * @returns the shader code
  144393. */
  144394. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144395. protected _buildBlock(state: NodeMaterialBuildState): this;
  144396. protected _dumpPropertiesCode(): string;
  144397. serialize(): any;
  144398. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144399. }
  144400. }
  144401. declare module BABYLON {
  144402. /**
  144403. * Block used to implement the sheen module of the PBR material
  144404. */
  144405. export class SheenBlock extends NodeMaterialBlock {
  144406. /**
  144407. * Create a new SheenBlock
  144408. * @param name defines the block name
  144409. */
  144410. constructor(name: string);
  144411. /**
  144412. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144413. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144414. * making it easier to setup and tweak the effect
  144415. */
  144416. albedoScaling: boolean;
  144417. /**
  144418. * Defines if the sheen is linked to the sheen color.
  144419. */
  144420. linkSheenWithAlbedo: boolean;
  144421. /**
  144422. * Initialize the block and prepare the context for build
  144423. * @param state defines the state that will be used for the build
  144424. */
  144425. initialize(state: NodeMaterialBuildState): void;
  144426. /**
  144427. * Gets the current class name
  144428. * @returns the class name
  144429. */
  144430. getClassName(): string;
  144431. /**
  144432. * Gets the intensity input component
  144433. */
  144434. get intensity(): NodeMaterialConnectionPoint;
  144435. /**
  144436. * Gets the color input component
  144437. */
  144438. get color(): NodeMaterialConnectionPoint;
  144439. /**
  144440. * Gets the roughness input component
  144441. */
  144442. get roughness(): NodeMaterialConnectionPoint;
  144443. /**
  144444. * Gets the sheen object output component
  144445. */
  144446. get sheen(): NodeMaterialConnectionPoint;
  144447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144448. /**
  144449. * Gets the main code of the block (fragment side)
  144450. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144451. * @returns the shader code
  144452. */
  144453. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144454. protected _buildBlock(state: NodeMaterialBuildState): this;
  144455. protected _dumpPropertiesCode(): string;
  144456. serialize(): any;
  144457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144458. }
  144459. }
  144460. declare module BABYLON {
  144461. /**
  144462. * Block used to implement the reflectivity module of the PBR material
  144463. */
  144464. export class ReflectivityBlock extends NodeMaterialBlock {
  144465. private _metallicReflectanceColor;
  144466. private _metallicF0Factor;
  144467. /** @hidden */
  144468. _vMetallicReflectanceFactorsName: string;
  144469. /**
  144470. * The property below is set by the main PBR block prior to calling methods of this class.
  144471. */
  144472. /** @hidden */
  144473. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144474. /**
  144475. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144476. */
  144477. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144478. /**
  144479. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144480. */
  144481. useMetallnessFromMetallicTextureBlue: boolean;
  144482. /**
  144483. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144484. */
  144485. useRoughnessFromMetallicTextureAlpha: boolean;
  144486. /**
  144487. * Specifies if the metallic texture contains the roughness information in its green channel.
  144488. */
  144489. useRoughnessFromMetallicTextureGreen: boolean;
  144490. /**
  144491. * Create a new ReflectivityBlock
  144492. * @param name defines the block name
  144493. */
  144494. constructor(name: string);
  144495. /**
  144496. * Initialize the block and prepare the context for build
  144497. * @param state defines the state that will be used for the build
  144498. */
  144499. initialize(state: NodeMaterialBuildState): void;
  144500. /**
  144501. * Gets the current class name
  144502. * @returns the class name
  144503. */
  144504. getClassName(): string;
  144505. /**
  144506. * Gets the metallic input component
  144507. */
  144508. get metallic(): NodeMaterialConnectionPoint;
  144509. /**
  144510. * Gets the roughness input component
  144511. */
  144512. get roughness(): NodeMaterialConnectionPoint;
  144513. /**
  144514. * Gets the texture input component
  144515. */
  144516. get texture(): NodeMaterialConnectionPoint;
  144517. /**
  144518. * Gets the reflectivity object output component
  144519. */
  144520. get reflectivity(): NodeMaterialConnectionPoint;
  144521. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144522. /**
  144523. * Gets the main code of the block (fragment side)
  144524. * @param state current state of the node material building
  144525. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144526. * @returns the shader code
  144527. */
  144528. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144529. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144530. protected _buildBlock(state: NodeMaterialBuildState): this;
  144531. protected _dumpPropertiesCode(): string;
  144532. serialize(): any;
  144533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144534. }
  144535. }
  144536. declare module BABYLON {
  144537. /**
  144538. * Block used to implement the anisotropy module of the PBR material
  144539. */
  144540. export class AnisotropyBlock extends NodeMaterialBlock {
  144541. /**
  144542. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144543. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144544. * It's less burden on the user side in the editor part.
  144545. */
  144546. /** @hidden */
  144547. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144548. /** @hidden */
  144549. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144550. /**
  144551. * Create a new AnisotropyBlock
  144552. * @param name defines the block name
  144553. */
  144554. constructor(name: string);
  144555. /**
  144556. * Initialize the block and prepare the context for build
  144557. * @param state defines the state that will be used for the build
  144558. */
  144559. initialize(state: NodeMaterialBuildState): void;
  144560. /**
  144561. * Gets the current class name
  144562. * @returns the class name
  144563. */
  144564. getClassName(): string;
  144565. /**
  144566. * Gets the intensity input component
  144567. */
  144568. get intensity(): NodeMaterialConnectionPoint;
  144569. /**
  144570. * Gets the direction input component
  144571. */
  144572. get direction(): NodeMaterialConnectionPoint;
  144573. /**
  144574. * Gets the texture input component
  144575. */
  144576. get texture(): NodeMaterialConnectionPoint;
  144577. /**
  144578. * Gets the uv input component
  144579. */
  144580. get uv(): NodeMaterialConnectionPoint;
  144581. /**
  144582. * Gets the worldTangent input component
  144583. */
  144584. get worldTangent(): NodeMaterialConnectionPoint;
  144585. /**
  144586. * Gets the anisotropy object output component
  144587. */
  144588. get anisotropy(): NodeMaterialConnectionPoint;
  144589. private _generateTBNSpace;
  144590. /**
  144591. * Gets the main code of the block (fragment side)
  144592. * @param state current state of the node material building
  144593. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144594. * @returns the shader code
  144595. */
  144596. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  144597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144598. protected _buildBlock(state: NodeMaterialBuildState): this;
  144599. }
  144600. }
  144601. declare module BABYLON {
  144602. /**
  144603. * Block used to implement the clear coat module of the PBR material
  144604. */
  144605. export class ClearCoatBlock extends NodeMaterialBlock {
  144606. private _scene;
  144607. /**
  144608. * Create a new ClearCoatBlock
  144609. * @param name defines the block name
  144610. */
  144611. constructor(name: string);
  144612. /**
  144613. * Initialize the block and prepare the context for build
  144614. * @param state defines the state that will be used for the build
  144615. */
  144616. initialize(state: NodeMaterialBuildState): void;
  144617. /**
  144618. * Gets the current class name
  144619. * @returns the class name
  144620. */
  144621. getClassName(): string;
  144622. /**
  144623. * Gets the intensity input component
  144624. */
  144625. get intensity(): NodeMaterialConnectionPoint;
  144626. /**
  144627. * Gets the roughness input component
  144628. */
  144629. get roughness(): NodeMaterialConnectionPoint;
  144630. /**
  144631. * Gets the ior input component
  144632. */
  144633. get ior(): NodeMaterialConnectionPoint;
  144634. /**
  144635. * Gets the texture input component
  144636. */
  144637. get texture(): NodeMaterialConnectionPoint;
  144638. /**
  144639. * Gets the bump texture input component
  144640. */
  144641. get bumpTexture(): NodeMaterialConnectionPoint;
  144642. /**
  144643. * Gets the uv input component
  144644. */
  144645. get uv(): NodeMaterialConnectionPoint;
  144646. /**
  144647. * Gets the tint color input component
  144648. */
  144649. get tintColor(): NodeMaterialConnectionPoint;
  144650. /**
  144651. * Gets the tint "at distance" input component
  144652. */
  144653. get tintAtDistance(): NodeMaterialConnectionPoint;
  144654. /**
  144655. * Gets the tint thickness input component
  144656. */
  144657. get tintThickness(): NodeMaterialConnectionPoint;
  144658. /**
  144659. * Gets the world tangent input component
  144660. */
  144661. get worldTangent(): NodeMaterialConnectionPoint;
  144662. /**
  144663. * Gets the clear coat object output component
  144664. */
  144665. get clearcoat(): NodeMaterialConnectionPoint;
  144666. autoConfigure(material: NodeMaterial): void;
  144667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144668. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144669. private _generateTBNSpace;
  144670. /**
  144671. * Gets the main code of the block (fragment side)
  144672. * @param state current state of the node material building
  144673. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  144674. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144675. * @param worldPosVarName name of the variable holding the world position
  144676. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144677. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  144678. * @param worldNormalVarName name of the variable holding the world normal
  144679. * @returns the shader code
  144680. */
  144681. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  144682. protected _buildBlock(state: NodeMaterialBuildState): this;
  144683. }
  144684. }
  144685. declare module BABYLON {
  144686. /**
  144687. * Block used to implement the sub surface module of the PBR material
  144688. */
  144689. export class SubSurfaceBlock extends NodeMaterialBlock {
  144690. /**
  144691. * Create a new SubSurfaceBlock
  144692. * @param name defines the block name
  144693. */
  144694. constructor(name: string);
  144695. /**
  144696. * Stores the intensity of the different subsurface effects in the thickness texture.
  144697. * * the green channel is the translucency intensity.
  144698. * * the blue channel is the scattering intensity.
  144699. * * the alpha channel is the refraction intensity.
  144700. */
  144701. useMaskFromThicknessTexture: boolean;
  144702. /**
  144703. * Initialize the block and prepare the context for build
  144704. * @param state defines the state that will be used for the build
  144705. */
  144706. initialize(state: NodeMaterialBuildState): void;
  144707. /**
  144708. * Gets the current class name
  144709. * @returns the class name
  144710. */
  144711. getClassName(): string;
  144712. /**
  144713. * Gets the min thickness input component
  144714. */
  144715. get minThickness(): NodeMaterialConnectionPoint;
  144716. /**
  144717. * Gets the max thickness input component
  144718. */
  144719. get maxThickness(): NodeMaterialConnectionPoint;
  144720. /**
  144721. * Gets the thickness texture component
  144722. */
  144723. get thicknessTexture(): NodeMaterialConnectionPoint;
  144724. /**
  144725. * Gets the tint color input component
  144726. */
  144727. get tintColor(): NodeMaterialConnectionPoint;
  144728. /**
  144729. * Gets the translucency intensity input component
  144730. */
  144731. get translucencyIntensity(): NodeMaterialConnectionPoint;
  144732. /**
  144733. * Gets the translucency diffusion distance input component
  144734. */
  144735. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  144736. /**
  144737. * Gets the refraction object parameters
  144738. */
  144739. get refraction(): NodeMaterialConnectionPoint;
  144740. /**
  144741. * Gets the sub surface object output component
  144742. */
  144743. get subsurface(): NodeMaterialConnectionPoint;
  144744. autoConfigure(material: NodeMaterial): void;
  144745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144746. /**
  144747. * Gets the main code of the block (fragment side)
  144748. * @param state current state of the node material building
  144749. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  144750. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144751. * @param worldPosVarName name of the variable holding the world position
  144752. * @returns the shader code
  144753. */
  144754. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  144755. protected _buildBlock(state: NodeMaterialBuildState): this;
  144756. }
  144757. }
  144758. declare module BABYLON {
  144759. /**
  144760. * Block used to implement the PBR metallic/roughness model
  144761. */
  144762. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  144763. /**
  144764. * Gets or sets the light associated with this block
  144765. */
  144766. light: Nullable<Light>;
  144767. private _lightId;
  144768. private _scene;
  144769. private _environmentBRDFTexture;
  144770. private _environmentBrdfSamplerName;
  144771. private _vNormalWName;
  144772. private _invertNormalName;
  144773. /**
  144774. * Create a new ReflectionBlock
  144775. * @param name defines the block name
  144776. */
  144777. constructor(name: string);
  144778. /**
  144779. * Intensity of the direct lights e.g. the four lights available in your scene.
  144780. * This impacts both the direct diffuse and specular highlights.
  144781. */
  144782. directIntensity: number;
  144783. /**
  144784. * Intensity of the environment e.g. how much the environment will light the object
  144785. * either through harmonics for rough material or through the refelction for shiny ones.
  144786. */
  144787. environmentIntensity: number;
  144788. /**
  144789. * This is a special control allowing the reduction of the specular highlights coming from the
  144790. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  144791. */
  144792. specularIntensity: number;
  144793. /**
  144794. * Defines the falloff type used in this material.
  144795. * It by default is Physical.
  144796. */
  144797. lightFalloff: number;
  144798. /**
  144799. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  144800. */
  144801. useAlphaFromAlbedoTexture: boolean;
  144802. /**
  144803. * Specifies that alpha test should be used
  144804. */
  144805. useAlphaTest: boolean;
  144806. /**
  144807. * Defines the alpha limits in alpha test mode.
  144808. */
  144809. alphaTestCutoff: number;
  144810. /**
  144811. * Specifies that alpha blending should be used
  144812. */
  144813. useAlphaBlending: boolean;
  144814. /**
  144815. * Defines if the alpha value should be determined via the rgb values.
  144816. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  144817. */
  144818. opacityRGB: boolean;
  144819. /**
  144820. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  144821. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  144822. */
  144823. useRadianceOverAlpha: boolean;
  144824. /**
  144825. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  144826. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  144827. */
  144828. useSpecularOverAlpha: boolean;
  144829. /**
  144830. * Enables specular anti aliasing in the PBR shader.
  144831. * It will both interacts on the Geometry for analytical and IBL lighting.
  144832. * It also prefilter the roughness map based on the bump values.
  144833. */
  144834. enableSpecularAntiAliasing: boolean;
  144835. /**
  144836. * Enables realtime filtering on the texture.
  144837. */
  144838. realTimeFiltering: boolean;
  144839. /**
  144840. * Quality switch for realtime filtering
  144841. */
  144842. realTimeFilteringQuality: number;
  144843. /**
  144844. * Defines if the material uses energy conservation.
  144845. */
  144846. useEnergyConservation: boolean;
  144847. /**
  144848. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  144849. * too much the area relying on ambient texture to define their ambient occlusion.
  144850. */
  144851. useRadianceOcclusion: boolean;
  144852. /**
  144853. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  144854. * makes the reflect vector face the model (under horizon).
  144855. */
  144856. useHorizonOcclusion: boolean;
  144857. /**
  144858. * If set to true, no lighting calculations will be applied.
  144859. */
  144860. unlit: boolean;
  144861. /**
  144862. * Force normal to face away from face.
  144863. */
  144864. forceNormalForward: boolean;
  144865. /**
  144866. * Defines the material debug mode.
  144867. * It helps seeing only some components of the material while troubleshooting.
  144868. */
  144869. debugMode: number;
  144870. /**
  144871. * Specify from where on screen the debug mode should start.
  144872. * The value goes from -1 (full screen) to 1 (not visible)
  144873. * It helps with side by side comparison against the final render
  144874. * This defaults to 0
  144875. */
  144876. debugLimit: number;
  144877. /**
  144878. * As the default viewing range might not be enough (if the ambient is really small for instance)
  144879. * You can use the factor to better multiply the final value.
  144880. */
  144881. debugFactor: number;
  144882. /**
  144883. * Initialize the block and prepare the context for build
  144884. * @param state defines the state that will be used for the build
  144885. */
  144886. initialize(state: NodeMaterialBuildState): void;
  144887. /**
  144888. * Gets the current class name
  144889. * @returns the class name
  144890. */
  144891. getClassName(): string;
  144892. /**
  144893. * Gets the world position input component
  144894. */
  144895. get worldPosition(): NodeMaterialConnectionPoint;
  144896. /**
  144897. * Gets the world normal input component
  144898. */
  144899. get worldNormal(): NodeMaterialConnectionPoint;
  144900. /**
  144901. * Gets the perturbed normal input component
  144902. */
  144903. get perturbedNormal(): NodeMaterialConnectionPoint;
  144904. /**
  144905. * Gets the camera position input component
  144906. */
  144907. get cameraPosition(): NodeMaterialConnectionPoint;
  144908. /**
  144909. * Gets the base color input component
  144910. */
  144911. get baseColor(): NodeMaterialConnectionPoint;
  144912. /**
  144913. * Gets the opacity texture input component
  144914. */
  144915. get opacityTexture(): NodeMaterialConnectionPoint;
  144916. /**
  144917. * Gets the ambient color input component
  144918. */
  144919. get ambientColor(): NodeMaterialConnectionPoint;
  144920. /**
  144921. * Gets the reflectivity object parameters
  144922. */
  144923. get reflectivity(): NodeMaterialConnectionPoint;
  144924. /**
  144925. * Gets the ambient occlusion object parameters
  144926. */
  144927. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144928. /**
  144929. * Gets the reflection object parameters
  144930. */
  144931. get reflection(): NodeMaterialConnectionPoint;
  144932. /**
  144933. * Gets the sheen object parameters
  144934. */
  144935. get sheen(): NodeMaterialConnectionPoint;
  144936. /**
  144937. * Gets the clear coat object parameters
  144938. */
  144939. get clearcoat(): NodeMaterialConnectionPoint;
  144940. /**
  144941. * Gets the sub surface object parameters
  144942. */
  144943. get subsurface(): NodeMaterialConnectionPoint;
  144944. /**
  144945. * Gets the anisotropy object parameters
  144946. */
  144947. get anisotropy(): NodeMaterialConnectionPoint;
  144948. /**
  144949. * Gets the ambient output component
  144950. */
  144951. get ambient(): NodeMaterialConnectionPoint;
  144952. /**
  144953. * Gets the diffuse output component
  144954. */
  144955. get diffuse(): NodeMaterialConnectionPoint;
  144956. /**
  144957. * Gets the specular output component
  144958. */
  144959. get specular(): NodeMaterialConnectionPoint;
  144960. /**
  144961. * Gets the sheen output component
  144962. */
  144963. get sheenDir(): NodeMaterialConnectionPoint;
  144964. /**
  144965. * Gets the clear coat output component
  144966. */
  144967. get clearcoatDir(): NodeMaterialConnectionPoint;
  144968. /**
  144969. * Gets the indirect diffuse output component
  144970. */
  144971. get diffuseIndirect(): NodeMaterialConnectionPoint;
  144972. /**
  144973. * Gets the indirect specular output component
  144974. */
  144975. get specularIndirect(): NodeMaterialConnectionPoint;
  144976. /**
  144977. * Gets the indirect sheen output component
  144978. */
  144979. get sheenIndirect(): NodeMaterialConnectionPoint;
  144980. /**
  144981. * Gets the indirect clear coat output component
  144982. */
  144983. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  144984. /**
  144985. * Gets the refraction output component
  144986. */
  144987. get refraction(): NodeMaterialConnectionPoint;
  144988. /**
  144989. * Gets the global lighting output component
  144990. */
  144991. get lighting(): NodeMaterialConnectionPoint;
  144992. /**
  144993. * Gets the shadow output component
  144994. */
  144995. get shadow(): NodeMaterialConnectionPoint;
  144996. /**
  144997. * Gets the alpha output component
  144998. */
  144999. get alpha(): NodeMaterialConnectionPoint;
  145000. autoConfigure(material: NodeMaterial): void;
  145001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145002. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145003. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145004. private _injectVertexCode;
  145005. /**
  145006. * Gets the code corresponding to the albedo/opacity module
  145007. * @returns the shader code
  145008. */
  145009. getAlbedoOpacityCode(): string;
  145010. protected _buildBlock(state: NodeMaterialBuildState): this;
  145011. protected _dumpPropertiesCode(): string;
  145012. serialize(): any;
  145013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145014. }
  145015. }
  145016. declare module BABYLON {
  145017. /**
  145018. * Block used to compute value of one parameter modulo another
  145019. */
  145020. export class ModBlock extends NodeMaterialBlock {
  145021. /**
  145022. * Creates a new ModBlock
  145023. * @param name defines the block name
  145024. */
  145025. constructor(name: string);
  145026. /**
  145027. * Gets the current class name
  145028. * @returns the class name
  145029. */
  145030. getClassName(): string;
  145031. /**
  145032. * Gets the left operand input component
  145033. */
  145034. get left(): NodeMaterialConnectionPoint;
  145035. /**
  145036. * Gets the right operand input component
  145037. */
  145038. get right(): NodeMaterialConnectionPoint;
  145039. /**
  145040. * Gets the output component
  145041. */
  145042. get output(): NodeMaterialConnectionPoint;
  145043. protected _buildBlock(state: NodeMaterialBuildState): this;
  145044. }
  145045. }
  145046. declare module BABYLON {
  145047. /**
  145048. * Configuration for Draco compression
  145049. */
  145050. export interface IDracoCompressionConfiguration {
  145051. /**
  145052. * Configuration for the decoder.
  145053. */
  145054. decoder: {
  145055. /**
  145056. * The url to the WebAssembly module.
  145057. */
  145058. wasmUrl?: string;
  145059. /**
  145060. * The url to the WebAssembly binary.
  145061. */
  145062. wasmBinaryUrl?: string;
  145063. /**
  145064. * The url to the fallback JavaScript module.
  145065. */
  145066. fallbackUrl?: string;
  145067. };
  145068. }
  145069. /**
  145070. * Draco compression (https://google.github.io/draco/)
  145071. *
  145072. * This class wraps the Draco module.
  145073. *
  145074. * **Encoder**
  145075. *
  145076. * The encoder is not currently implemented.
  145077. *
  145078. * **Decoder**
  145079. *
  145080. * 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.
  145081. *
  145082. * To update the configuration, use the following code:
  145083. * ```javascript
  145084. * DracoCompression.Configuration = {
  145085. * decoder: {
  145086. * wasmUrl: "<url to the WebAssembly library>",
  145087. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145088. * fallbackUrl: "<url to the fallback JavaScript library>",
  145089. * }
  145090. * };
  145091. * ```
  145092. *
  145093. * 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.
  145094. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145095. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145096. *
  145097. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145098. * ```javascript
  145099. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145100. * ```
  145101. *
  145102. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145103. */
  145104. export class DracoCompression implements IDisposable {
  145105. private _workerPoolPromise?;
  145106. private _decoderModulePromise?;
  145107. /**
  145108. * The configuration. Defaults to the following urls:
  145109. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145110. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145111. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145112. */
  145113. static Configuration: IDracoCompressionConfiguration;
  145114. /**
  145115. * Returns true if the decoder configuration is available.
  145116. */
  145117. static get DecoderAvailable(): boolean;
  145118. /**
  145119. * Default number of workers to create when creating the draco compression object.
  145120. */
  145121. static DefaultNumWorkers: number;
  145122. private static GetDefaultNumWorkers;
  145123. private static _Default;
  145124. /**
  145125. * Default instance for the draco compression object.
  145126. */
  145127. static get Default(): DracoCompression;
  145128. /**
  145129. * Constructor
  145130. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145131. */
  145132. constructor(numWorkers?: number);
  145133. /**
  145134. * Stop all async operations and release resources.
  145135. */
  145136. dispose(): void;
  145137. /**
  145138. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145139. * @returns a promise that resolves when ready
  145140. */
  145141. whenReadyAsync(): Promise<void>;
  145142. /**
  145143. * Decode Draco compressed mesh data to vertex data.
  145144. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145145. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145146. * @returns A promise that resolves with the decoded vertex data
  145147. */
  145148. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145149. [kind: string]: number;
  145150. }): Promise<VertexData>;
  145151. }
  145152. }
  145153. declare module BABYLON {
  145154. /**
  145155. * Class for building Constructive Solid Geometry
  145156. */
  145157. export class CSG {
  145158. private polygons;
  145159. /**
  145160. * The world matrix
  145161. */
  145162. matrix: Matrix;
  145163. /**
  145164. * Stores the position
  145165. */
  145166. position: Vector3;
  145167. /**
  145168. * Stores the rotation
  145169. */
  145170. rotation: Vector3;
  145171. /**
  145172. * Stores the rotation quaternion
  145173. */
  145174. rotationQuaternion: Nullable<Quaternion>;
  145175. /**
  145176. * Stores the scaling vector
  145177. */
  145178. scaling: Vector3;
  145179. /**
  145180. * Convert the Mesh to CSG
  145181. * @param mesh The Mesh to convert to CSG
  145182. * @returns A new CSG from the Mesh
  145183. */
  145184. static FromMesh(mesh: Mesh): CSG;
  145185. /**
  145186. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145187. * @param polygons Polygons used to construct a CSG solid
  145188. */
  145189. private static FromPolygons;
  145190. /**
  145191. * Clones, or makes a deep copy, of the CSG
  145192. * @returns A new CSG
  145193. */
  145194. clone(): CSG;
  145195. /**
  145196. * Unions this CSG with another CSG
  145197. * @param csg The CSG to union against this CSG
  145198. * @returns The unioned CSG
  145199. */
  145200. union(csg: CSG): CSG;
  145201. /**
  145202. * Unions this CSG with another CSG in place
  145203. * @param csg The CSG to union against this CSG
  145204. */
  145205. unionInPlace(csg: CSG): void;
  145206. /**
  145207. * Subtracts this CSG with another CSG
  145208. * @param csg The CSG to subtract against this CSG
  145209. * @returns A new CSG
  145210. */
  145211. subtract(csg: CSG): CSG;
  145212. /**
  145213. * Subtracts this CSG with another CSG in place
  145214. * @param csg The CSG to subtact against this CSG
  145215. */
  145216. subtractInPlace(csg: CSG): void;
  145217. /**
  145218. * Intersect this CSG with another CSG
  145219. * @param csg The CSG to intersect against this CSG
  145220. * @returns A new CSG
  145221. */
  145222. intersect(csg: CSG): CSG;
  145223. /**
  145224. * Intersects this CSG with another CSG in place
  145225. * @param csg The CSG to intersect against this CSG
  145226. */
  145227. intersectInPlace(csg: CSG): void;
  145228. /**
  145229. * Return a new CSG solid with solid and empty space switched. This solid is
  145230. * not modified.
  145231. * @returns A new CSG solid with solid and empty space switched
  145232. */
  145233. inverse(): CSG;
  145234. /**
  145235. * Inverses the CSG in place
  145236. */
  145237. inverseInPlace(): void;
  145238. /**
  145239. * This is used to keep meshes transformations so they can be restored
  145240. * when we build back a Babylon Mesh
  145241. * NB : All CSG operations are performed in world coordinates
  145242. * @param csg The CSG to copy the transform attributes from
  145243. * @returns This CSG
  145244. */
  145245. copyTransformAttributes(csg: CSG): CSG;
  145246. /**
  145247. * Build Raw mesh from CSG
  145248. * Coordinates here are in world space
  145249. * @param name The name of the mesh geometry
  145250. * @param scene The Scene
  145251. * @param keepSubMeshes Specifies if the submeshes should be kept
  145252. * @returns A new Mesh
  145253. */
  145254. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145255. /**
  145256. * Build Mesh from CSG taking material and transforms into account
  145257. * @param name The name of the Mesh
  145258. * @param material The material of the Mesh
  145259. * @param scene The Scene
  145260. * @param keepSubMeshes Specifies if submeshes should be kept
  145261. * @returns The new Mesh
  145262. */
  145263. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145264. }
  145265. }
  145266. declare module BABYLON {
  145267. /**
  145268. * Class used to create a trail following a mesh
  145269. */
  145270. export class TrailMesh extends Mesh {
  145271. private _generator;
  145272. private _autoStart;
  145273. private _running;
  145274. private _diameter;
  145275. private _length;
  145276. private _sectionPolygonPointsCount;
  145277. private _sectionVectors;
  145278. private _sectionNormalVectors;
  145279. private _beforeRenderObserver;
  145280. /**
  145281. * @constructor
  145282. * @param name The value used by scene.getMeshByName() to do a lookup.
  145283. * @param generator The mesh or transform node to generate a trail.
  145284. * @param scene The scene to add this mesh to.
  145285. * @param diameter Diameter of trailing mesh. Default is 1.
  145286. * @param length Length of trailing mesh. Default is 60.
  145287. * @param autoStart Automatically start trailing mesh. Default true.
  145288. */
  145289. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145290. /**
  145291. * "TrailMesh"
  145292. * @returns "TrailMesh"
  145293. */
  145294. getClassName(): string;
  145295. private _createMesh;
  145296. /**
  145297. * Start trailing mesh.
  145298. */
  145299. start(): void;
  145300. /**
  145301. * Stop trailing mesh.
  145302. */
  145303. stop(): void;
  145304. /**
  145305. * Update trailing mesh geometry.
  145306. */
  145307. update(): void;
  145308. /**
  145309. * Returns a new TrailMesh object.
  145310. * @param name is a string, the name given to the new mesh
  145311. * @param newGenerator use new generator object for cloned trail mesh
  145312. * @returns a new mesh
  145313. */
  145314. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145315. /**
  145316. * Serializes this trail mesh
  145317. * @param serializationObject object to write serialization to
  145318. */
  145319. serialize(serializationObject: any): void;
  145320. /**
  145321. * Parses a serialized trail mesh
  145322. * @param parsedMesh the serialized mesh
  145323. * @param scene the scene to create the trail mesh in
  145324. * @returns the created trail mesh
  145325. */
  145326. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145327. }
  145328. }
  145329. declare module BABYLON {
  145330. /**
  145331. * Class containing static functions to help procedurally build meshes
  145332. */
  145333. export class TiledBoxBuilder {
  145334. /**
  145335. * Creates a box mesh
  145336. * 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)
  145337. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145341. * @param name defines the name of the mesh
  145342. * @param options defines the options used to create the mesh
  145343. * @param scene defines the hosting scene
  145344. * @returns the box mesh
  145345. */
  145346. static CreateTiledBox(name: string, options: {
  145347. pattern?: number;
  145348. width?: number;
  145349. height?: number;
  145350. depth?: number;
  145351. tileSize?: number;
  145352. tileWidth?: number;
  145353. tileHeight?: number;
  145354. alignHorizontal?: number;
  145355. alignVertical?: number;
  145356. faceUV?: Vector4[];
  145357. faceColors?: Color4[];
  145358. sideOrientation?: number;
  145359. updatable?: boolean;
  145360. }, scene?: Nullable<Scene>): Mesh;
  145361. }
  145362. }
  145363. declare module BABYLON {
  145364. /**
  145365. * Class containing static functions to help procedurally build meshes
  145366. */
  145367. export class TorusKnotBuilder {
  145368. /**
  145369. * Creates a torus knot mesh
  145370. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145371. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145372. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145373. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145377. * @param name defines the name of the mesh
  145378. * @param options defines the options used to create the mesh
  145379. * @param scene defines the hosting scene
  145380. * @returns the torus knot mesh
  145381. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145382. */
  145383. static CreateTorusKnot(name: string, options: {
  145384. radius?: number;
  145385. tube?: number;
  145386. radialSegments?: number;
  145387. tubularSegments?: number;
  145388. p?: number;
  145389. q?: number;
  145390. updatable?: boolean;
  145391. sideOrientation?: number;
  145392. frontUVs?: Vector4;
  145393. backUVs?: Vector4;
  145394. }, scene: any): Mesh;
  145395. }
  145396. }
  145397. declare module BABYLON {
  145398. /**
  145399. * Polygon
  145400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145401. */
  145402. export class Polygon {
  145403. /**
  145404. * Creates a rectangle
  145405. * @param xmin bottom X coord
  145406. * @param ymin bottom Y coord
  145407. * @param xmax top X coord
  145408. * @param ymax top Y coord
  145409. * @returns points that make the resulting rectation
  145410. */
  145411. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145412. /**
  145413. * Creates a circle
  145414. * @param radius radius of circle
  145415. * @param cx scale in x
  145416. * @param cy scale in y
  145417. * @param numberOfSides number of sides that make up the circle
  145418. * @returns points that make the resulting circle
  145419. */
  145420. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145421. /**
  145422. * Creates a polygon from input string
  145423. * @param input Input polygon data
  145424. * @returns the parsed points
  145425. */
  145426. static Parse(input: string): Vector2[];
  145427. /**
  145428. * Starts building a polygon from x and y coordinates
  145429. * @param x x coordinate
  145430. * @param y y coordinate
  145431. * @returns the started path2
  145432. */
  145433. static StartingAt(x: number, y: number): Path2;
  145434. }
  145435. /**
  145436. * Builds a polygon
  145437. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145438. */
  145439. export class PolygonMeshBuilder {
  145440. private _points;
  145441. private _outlinepoints;
  145442. private _holes;
  145443. private _name;
  145444. private _scene;
  145445. private _epoints;
  145446. private _eholes;
  145447. private _addToepoint;
  145448. /**
  145449. * Babylon reference to the earcut plugin.
  145450. */
  145451. bjsEarcut: any;
  145452. /**
  145453. * Creates a PolygonMeshBuilder
  145454. * @param name name of the builder
  145455. * @param contours Path of the polygon
  145456. * @param scene scene to add to when creating the mesh
  145457. * @param earcutInjection can be used to inject your own earcut reference
  145458. */
  145459. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145460. /**
  145461. * Adds a whole within the polygon
  145462. * @param hole Array of points defining the hole
  145463. * @returns this
  145464. */
  145465. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145466. /**
  145467. * Creates the polygon
  145468. * @param updatable If the mesh should be updatable
  145469. * @param depth The depth of the mesh created
  145470. * @returns the created mesh
  145471. */
  145472. build(updatable?: boolean, depth?: number): Mesh;
  145473. /**
  145474. * Creates the polygon
  145475. * @param depth The depth of the mesh created
  145476. * @returns the created VertexData
  145477. */
  145478. buildVertexData(depth?: number): VertexData;
  145479. /**
  145480. * Adds a side to the polygon
  145481. * @param positions points that make the polygon
  145482. * @param normals normals of the polygon
  145483. * @param uvs uvs of the polygon
  145484. * @param indices indices of the polygon
  145485. * @param bounds bounds of the polygon
  145486. * @param points points of the polygon
  145487. * @param depth depth of the polygon
  145488. * @param flip flip of the polygon
  145489. */
  145490. private addSide;
  145491. }
  145492. }
  145493. declare module BABYLON {
  145494. /**
  145495. * Class containing static functions to help procedurally build meshes
  145496. */
  145497. export class PolygonBuilder {
  145498. /**
  145499. * Creates a polygon mesh
  145500. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145501. * * 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
  145502. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145505. * * Remember you can only change the shape positions, not their number when updating a polygon
  145506. * @param name defines the name of the mesh
  145507. * @param options defines the options used to create the mesh
  145508. * @param scene defines the hosting scene
  145509. * @param earcutInjection can be used to inject your own earcut reference
  145510. * @returns the polygon mesh
  145511. */
  145512. static CreatePolygon(name: string, options: {
  145513. shape: Vector3[];
  145514. holes?: Vector3[][];
  145515. depth?: number;
  145516. faceUV?: Vector4[];
  145517. faceColors?: Color4[];
  145518. updatable?: boolean;
  145519. sideOrientation?: number;
  145520. frontUVs?: Vector4;
  145521. backUVs?: Vector4;
  145522. wrap?: boolean;
  145523. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145524. /**
  145525. * Creates an extruded polygon mesh, with depth in the Y direction.
  145526. * * 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)
  145527. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145528. * @param name defines the name of the mesh
  145529. * @param options defines the options used to create the mesh
  145530. * @param scene defines the hosting scene
  145531. * @param earcutInjection can be used to inject your own earcut reference
  145532. * @returns the polygon mesh
  145533. */
  145534. static ExtrudePolygon(name: string, options: {
  145535. shape: Vector3[];
  145536. holes?: Vector3[][];
  145537. depth?: number;
  145538. faceUV?: Vector4[];
  145539. faceColors?: Color4[];
  145540. updatable?: boolean;
  145541. sideOrientation?: number;
  145542. frontUVs?: Vector4;
  145543. backUVs?: Vector4;
  145544. wrap?: boolean;
  145545. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145546. }
  145547. }
  145548. declare module BABYLON {
  145549. /**
  145550. * Class containing static functions to help procedurally build meshes
  145551. */
  145552. export class LatheBuilder {
  145553. /**
  145554. * Creates lathe mesh.
  145555. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145556. * * 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
  145557. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145558. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145559. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145560. * * 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
  145561. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145562. * * 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
  145563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145565. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145567. * @param name defines the name of the mesh
  145568. * @param options defines the options used to create the mesh
  145569. * @param scene defines the hosting scene
  145570. * @returns the lathe mesh
  145571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145572. */
  145573. static CreateLathe(name: string, options: {
  145574. shape: Vector3[];
  145575. radius?: number;
  145576. tessellation?: number;
  145577. clip?: number;
  145578. arc?: number;
  145579. closed?: boolean;
  145580. updatable?: boolean;
  145581. sideOrientation?: number;
  145582. frontUVs?: Vector4;
  145583. backUVs?: Vector4;
  145584. cap?: number;
  145585. invertUV?: boolean;
  145586. }, scene?: Nullable<Scene>): Mesh;
  145587. }
  145588. }
  145589. declare module BABYLON {
  145590. /**
  145591. * Class containing static functions to help procedurally build meshes
  145592. */
  145593. export class TiledPlaneBuilder {
  145594. /**
  145595. * Creates a tiled plane mesh
  145596. * * The parameter `pattern` will, depending on value, do nothing or
  145597. * * * flip (reflect about central vertical) alternate tiles across and up
  145598. * * * flip every tile on alternate rows
  145599. * * * rotate (180 degs) alternate tiles across and up
  145600. * * * rotate every tile on alternate rows
  145601. * * * flip and rotate alternate tiles across and up
  145602. * * * flip and rotate every tile on alternate rows
  145603. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  145604. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  145605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145607. * * 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)
  145608. * * 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)
  145609. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145610. * @param name defines the name of the mesh
  145611. * @param options defines the options used to create the mesh
  145612. * @param scene defines the hosting scene
  145613. * @returns the box mesh
  145614. */
  145615. static CreateTiledPlane(name: string, options: {
  145616. pattern?: number;
  145617. tileSize?: number;
  145618. tileWidth?: number;
  145619. tileHeight?: number;
  145620. size?: number;
  145621. width?: number;
  145622. height?: number;
  145623. alignHorizontal?: number;
  145624. alignVertical?: number;
  145625. sideOrientation?: number;
  145626. frontUVs?: Vector4;
  145627. backUVs?: Vector4;
  145628. updatable?: boolean;
  145629. }, scene?: Nullable<Scene>): Mesh;
  145630. }
  145631. }
  145632. declare module BABYLON {
  145633. /**
  145634. * Class containing static functions to help procedurally build meshes
  145635. */
  145636. export class TubeBuilder {
  145637. /**
  145638. * Creates a tube mesh.
  145639. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145640. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145641. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145642. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145643. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145644. * * 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)
  145645. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145646. * * 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
  145647. * * 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
  145648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145652. * @param name defines the name of the mesh
  145653. * @param options defines the options used to create the mesh
  145654. * @param scene defines the hosting scene
  145655. * @returns the tube mesh
  145656. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145657. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145658. */
  145659. static CreateTube(name: string, options: {
  145660. path: Vector3[];
  145661. radius?: number;
  145662. tessellation?: number;
  145663. radiusFunction?: {
  145664. (i: number, distance: number): number;
  145665. };
  145666. cap?: number;
  145667. arc?: number;
  145668. updatable?: boolean;
  145669. sideOrientation?: number;
  145670. frontUVs?: Vector4;
  145671. backUVs?: Vector4;
  145672. instance?: Mesh;
  145673. invertUV?: boolean;
  145674. }, scene?: Nullable<Scene>): Mesh;
  145675. }
  145676. }
  145677. declare module BABYLON {
  145678. /**
  145679. * Class containing static functions to help procedurally build meshes
  145680. */
  145681. export class IcoSphereBuilder {
  145682. /**
  145683. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145684. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145685. * * 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`)
  145686. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145687. * * 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
  145688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145691. * @param name defines the name of the mesh
  145692. * @param options defines the options used to create the mesh
  145693. * @param scene defines the hosting scene
  145694. * @returns the icosahedron mesh
  145695. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145696. */
  145697. static CreateIcoSphere(name: string, options: {
  145698. radius?: number;
  145699. radiusX?: number;
  145700. radiusY?: number;
  145701. radiusZ?: number;
  145702. flat?: boolean;
  145703. subdivisions?: number;
  145704. sideOrientation?: number;
  145705. frontUVs?: Vector4;
  145706. backUVs?: Vector4;
  145707. updatable?: boolean;
  145708. }, scene?: Nullable<Scene>): Mesh;
  145709. }
  145710. }
  145711. declare module BABYLON {
  145712. /**
  145713. * Class containing static functions to help procedurally build meshes
  145714. */
  145715. export class DecalBuilder {
  145716. /**
  145717. * Creates a decal mesh.
  145718. * 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
  145719. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145720. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145721. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145722. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145723. * @param name defines the name of the mesh
  145724. * @param sourceMesh defines the mesh where the decal must be applied
  145725. * @param options defines the options used to create the mesh
  145726. * @param scene defines the hosting scene
  145727. * @returns the decal mesh
  145728. * @see https://doc.babylonjs.com/how_to/decals
  145729. */
  145730. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145731. position?: Vector3;
  145732. normal?: Vector3;
  145733. size?: Vector3;
  145734. angle?: number;
  145735. }): Mesh;
  145736. }
  145737. }
  145738. declare module BABYLON {
  145739. /**
  145740. * Class containing static functions to help procedurally build meshes
  145741. */
  145742. export class MeshBuilder {
  145743. /**
  145744. * Creates a box mesh
  145745. * * The parameter `size` sets the size (float) of each box side (default 1)
  145746. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  145747. * * 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)
  145748. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145752. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145753. * @param name defines the name of the mesh
  145754. * @param options defines the options used to create the mesh
  145755. * @param scene defines the hosting scene
  145756. * @returns the box mesh
  145757. */
  145758. static CreateBox(name: string, options: {
  145759. size?: number;
  145760. width?: number;
  145761. height?: number;
  145762. depth?: number;
  145763. faceUV?: Vector4[];
  145764. faceColors?: Color4[];
  145765. sideOrientation?: number;
  145766. frontUVs?: Vector4;
  145767. backUVs?: Vector4;
  145768. wrap?: boolean;
  145769. topBaseAt?: number;
  145770. bottomBaseAt?: number;
  145771. updatable?: boolean;
  145772. }, scene?: Nullable<Scene>): Mesh;
  145773. /**
  145774. * Creates a tiled box mesh
  145775. * * faceTiles sets the pattern, tile size and number of tiles for a face
  145776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145777. * @param name defines the name of the mesh
  145778. * @param options defines the options used to create the mesh
  145779. * @param scene defines the hosting scene
  145780. * @returns the tiled box mesh
  145781. */
  145782. static CreateTiledBox(name: string, options: {
  145783. pattern?: number;
  145784. size?: number;
  145785. width?: number;
  145786. height?: number;
  145787. depth: number;
  145788. tileSize?: number;
  145789. tileWidth?: number;
  145790. tileHeight?: number;
  145791. faceUV?: Vector4[];
  145792. faceColors?: Color4[];
  145793. alignHorizontal?: number;
  145794. alignVertical?: number;
  145795. sideOrientation?: number;
  145796. updatable?: boolean;
  145797. }, scene?: Nullable<Scene>): Mesh;
  145798. /**
  145799. * Creates a sphere mesh
  145800. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  145801. * * 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`)
  145802. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  145803. * * 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
  145804. * * 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)
  145805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145808. * @param name defines the name of the mesh
  145809. * @param options defines the options used to create the mesh
  145810. * @param scene defines the hosting scene
  145811. * @returns the sphere mesh
  145812. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  145813. */
  145814. static CreateSphere(name: string, options: {
  145815. segments?: number;
  145816. diameter?: number;
  145817. diameterX?: number;
  145818. diameterY?: number;
  145819. diameterZ?: number;
  145820. arc?: number;
  145821. slice?: number;
  145822. sideOrientation?: number;
  145823. frontUVs?: Vector4;
  145824. backUVs?: Vector4;
  145825. updatable?: boolean;
  145826. }, scene?: Nullable<Scene>): Mesh;
  145827. /**
  145828. * Creates a plane polygonal mesh. By default, this is a disc
  145829. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  145830. * * 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
  145831. * * 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
  145832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145835. * @param name defines the name of the mesh
  145836. * @param options defines the options used to create the mesh
  145837. * @param scene defines the hosting scene
  145838. * @returns the plane polygonal mesh
  145839. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  145840. */
  145841. static CreateDisc(name: string, options: {
  145842. radius?: number;
  145843. tessellation?: number;
  145844. arc?: number;
  145845. updatable?: boolean;
  145846. sideOrientation?: number;
  145847. frontUVs?: Vector4;
  145848. backUVs?: Vector4;
  145849. }, scene?: Nullable<Scene>): Mesh;
  145850. /**
  145851. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145852. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145853. * * 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`)
  145854. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145855. * * 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
  145856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145859. * @param name defines the name of the mesh
  145860. * @param options defines the options used to create the mesh
  145861. * @param scene defines the hosting scene
  145862. * @returns the icosahedron mesh
  145863. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145864. */
  145865. static CreateIcoSphere(name: string, options: {
  145866. radius?: number;
  145867. radiusX?: number;
  145868. radiusY?: number;
  145869. radiusZ?: number;
  145870. flat?: boolean;
  145871. subdivisions?: number;
  145872. sideOrientation?: number;
  145873. frontUVs?: Vector4;
  145874. backUVs?: Vector4;
  145875. updatable?: boolean;
  145876. }, scene?: Nullable<Scene>): Mesh;
  145877. /**
  145878. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145879. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  145880. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  145881. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  145882. * * 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
  145883. * * 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
  145884. * * 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
  145885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145888. * * 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
  145889. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  145890. * * 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
  145891. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  145892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145893. * @param name defines the name of the mesh
  145894. * @param options defines the options used to create the mesh
  145895. * @param scene defines the hosting scene
  145896. * @returns the ribbon mesh
  145897. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  145898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145899. */
  145900. static CreateRibbon(name: string, options: {
  145901. pathArray: Vector3[][];
  145902. closeArray?: boolean;
  145903. closePath?: boolean;
  145904. offset?: number;
  145905. updatable?: boolean;
  145906. sideOrientation?: number;
  145907. frontUVs?: Vector4;
  145908. backUVs?: Vector4;
  145909. instance?: Mesh;
  145910. invertUV?: boolean;
  145911. uvs?: Vector2[];
  145912. colors?: Color4[];
  145913. }, scene?: Nullable<Scene>): Mesh;
  145914. /**
  145915. * Creates a cylinder or a cone mesh
  145916. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  145917. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  145918. * * 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.
  145919. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  145920. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  145921. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  145922. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  145923. * * 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).
  145924. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  145925. * * 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).
  145926. * * 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
  145927. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  145928. * * 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
  145929. * * 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.
  145930. * * If `enclose` is false, a ring surface is one element.
  145931. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  145932. * * 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
  145933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145936. * @param name defines the name of the mesh
  145937. * @param options defines the options used to create the mesh
  145938. * @param scene defines the hosting scene
  145939. * @returns the cylinder mesh
  145940. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  145941. */
  145942. static CreateCylinder(name: string, options: {
  145943. height?: number;
  145944. diameterTop?: number;
  145945. diameterBottom?: number;
  145946. diameter?: number;
  145947. tessellation?: number;
  145948. subdivisions?: number;
  145949. arc?: number;
  145950. faceColors?: Color4[];
  145951. faceUV?: Vector4[];
  145952. updatable?: boolean;
  145953. hasRings?: boolean;
  145954. enclose?: boolean;
  145955. cap?: number;
  145956. sideOrientation?: number;
  145957. frontUVs?: Vector4;
  145958. backUVs?: Vector4;
  145959. }, scene?: Nullable<Scene>): Mesh;
  145960. /**
  145961. * Creates a torus mesh
  145962. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  145963. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  145964. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  145965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145968. * @param name defines the name of the mesh
  145969. * @param options defines the options used to create the mesh
  145970. * @param scene defines the hosting scene
  145971. * @returns the torus mesh
  145972. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  145973. */
  145974. static CreateTorus(name: string, options: {
  145975. diameter?: number;
  145976. thickness?: number;
  145977. tessellation?: number;
  145978. updatable?: boolean;
  145979. sideOrientation?: number;
  145980. frontUVs?: Vector4;
  145981. backUVs?: Vector4;
  145982. }, scene?: Nullable<Scene>): Mesh;
  145983. /**
  145984. * Creates a torus knot mesh
  145985. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145986. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145987. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145988. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145992. * @param name defines the name of the mesh
  145993. * @param options defines the options used to create the mesh
  145994. * @param scene defines the hosting scene
  145995. * @returns the torus knot mesh
  145996. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145997. */
  145998. static CreateTorusKnot(name: string, options: {
  145999. radius?: number;
  146000. tube?: number;
  146001. radialSegments?: number;
  146002. tubularSegments?: number;
  146003. p?: number;
  146004. q?: number;
  146005. updatable?: boolean;
  146006. sideOrientation?: number;
  146007. frontUVs?: Vector4;
  146008. backUVs?: Vector4;
  146009. }, scene?: Nullable<Scene>): Mesh;
  146010. /**
  146011. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146012. * * 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
  146013. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146014. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146015. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146016. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146017. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146018. * * 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
  146019. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146022. * @param name defines the name of the new line system
  146023. * @param options defines the options used to create the line system
  146024. * @param scene defines the hosting scene
  146025. * @returns a new line system mesh
  146026. */
  146027. static CreateLineSystem(name: string, options: {
  146028. lines: Vector3[][];
  146029. updatable?: boolean;
  146030. instance?: Nullable<LinesMesh>;
  146031. colors?: Nullable<Color4[][]>;
  146032. useVertexAlpha?: boolean;
  146033. }, scene: Nullable<Scene>): LinesMesh;
  146034. /**
  146035. * Creates a line mesh
  146036. * 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
  146037. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146038. * * The parameter `points` is an array successive Vector3
  146039. * * 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
  146040. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146041. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146042. * * When updating an instance, remember that only point positions can change, not the number of points
  146043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146045. * @param name defines the name of the new line system
  146046. * @param options defines the options used to create the line system
  146047. * @param scene defines the hosting scene
  146048. * @returns a new line mesh
  146049. */
  146050. static CreateLines(name: string, options: {
  146051. points: Vector3[];
  146052. updatable?: boolean;
  146053. instance?: Nullable<LinesMesh>;
  146054. colors?: Color4[];
  146055. useVertexAlpha?: boolean;
  146056. }, scene?: Nullable<Scene>): LinesMesh;
  146057. /**
  146058. * Creates a dashed line mesh
  146059. * * 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
  146060. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146061. * * The parameter `points` is an array successive Vector3
  146062. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146063. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146064. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146065. * * 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
  146066. * * When updating an instance, remember that only point positions can change, not the number of points
  146067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146068. * @param name defines the name of the mesh
  146069. * @param options defines the options used to create the mesh
  146070. * @param scene defines the hosting scene
  146071. * @returns the dashed line mesh
  146072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146073. */
  146074. static CreateDashedLines(name: string, options: {
  146075. points: Vector3[];
  146076. dashSize?: number;
  146077. gapSize?: number;
  146078. dashNb?: number;
  146079. updatable?: boolean;
  146080. instance?: LinesMesh;
  146081. }, scene?: Nullable<Scene>): LinesMesh;
  146082. /**
  146083. * 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.
  146084. * * 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.
  146085. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146086. * * 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.
  146087. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146088. * * 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
  146089. * * 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
  146090. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146095. * @param name defines the name of the mesh
  146096. * @param options defines the options used to create the mesh
  146097. * @param scene defines the hosting scene
  146098. * @returns the extruded shape mesh
  146099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146101. */
  146102. static ExtrudeShape(name: string, options: {
  146103. shape: Vector3[];
  146104. path: Vector3[];
  146105. scale?: number;
  146106. rotation?: number;
  146107. cap?: number;
  146108. updatable?: boolean;
  146109. sideOrientation?: number;
  146110. frontUVs?: Vector4;
  146111. backUVs?: Vector4;
  146112. instance?: Mesh;
  146113. invertUV?: boolean;
  146114. }, scene?: Nullable<Scene>): Mesh;
  146115. /**
  146116. * Creates an custom extruded shape mesh.
  146117. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146118. * * 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.
  146119. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146120. * * 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
  146121. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146122. * * 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
  146123. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146124. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146125. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146126. * * 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
  146127. * * 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
  146128. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146133. * @param name defines the name of the mesh
  146134. * @param options defines the options used to create the mesh
  146135. * @param scene defines the hosting scene
  146136. * @returns the custom extruded shape mesh
  146137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146138. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146140. */
  146141. static ExtrudeShapeCustom(name: string, options: {
  146142. shape: Vector3[];
  146143. path: Vector3[];
  146144. scaleFunction?: any;
  146145. rotationFunction?: any;
  146146. ribbonCloseArray?: boolean;
  146147. ribbonClosePath?: boolean;
  146148. cap?: number;
  146149. updatable?: boolean;
  146150. sideOrientation?: number;
  146151. frontUVs?: Vector4;
  146152. backUVs?: Vector4;
  146153. instance?: Mesh;
  146154. invertUV?: boolean;
  146155. }, scene?: Nullable<Scene>): Mesh;
  146156. /**
  146157. * Creates lathe mesh.
  146158. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146159. * * 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
  146160. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146161. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146162. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146163. * * 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
  146164. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146165. * * 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
  146166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146170. * @param name defines the name of the mesh
  146171. * @param options defines the options used to create the mesh
  146172. * @param scene defines the hosting scene
  146173. * @returns the lathe mesh
  146174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146175. */
  146176. static CreateLathe(name: string, options: {
  146177. shape: Vector3[];
  146178. radius?: number;
  146179. tessellation?: number;
  146180. clip?: number;
  146181. arc?: number;
  146182. closed?: boolean;
  146183. updatable?: boolean;
  146184. sideOrientation?: number;
  146185. frontUVs?: Vector4;
  146186. backUVs?: Vector4;
  146187. cap?: number;
  146188. invertUV?: boolean;
  146189. }, scene?: Nullable<Scene>): Mesh;
  146190. /**
  146191. * Creates a tiled plane mesh
  146192. * * You can set a limited pattern arrangement with the tiles
  146193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146196. * @param name defines the name of the mesh
  146197. * @param options defines the options used to create the mesh
  146198. * @param scene defines the hosting scene
  146199. * @returns the plane mesh
  146200. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146201. */
  146202. static CreateTiledPlane(name: string, options: {
  146203. pattern?: number;
  146204. tileSize?: number;
  146205. tileWidth?: number;
  146206. tileHeight?: number;
  146207. size?: number;
  146208. width?: number;
  146209. height?: number;
  146210. alignHorizontal?: number;
  146211. alignVertical?: number;
  146212. sideOrientation?: number;
  146213. frontUVs?: Vector4;
  146214. backUVs?: Vector4;
  146215. updatable?: boolean;
  146216. }, scene?: Nullable<Scene>): Mesh;
  146217. /**
  146218. * Creates a plane mesh
  146219. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146220. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146221. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146225. * @param name defines the name of the mesh
  146226. * @param options defines the options used to create the mesh
  146227. * @param scene defines the hosting scene
  146228. * @returns the plane mesh
  146229. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146230. */
  146231. static CreatePlane(name: string, options: {
  146232. size?: number;
  146233. width?: number;
  146234. height?: number;
  146235. sideOrientation?: number;
  146236. frontUVs?: Vector4;
  146237. backUVs?: Vector4;
  146238. updatable?: boolean;
  146239. sourcePlane?: Plane;
  146240. }, scene?: Nullable<Scene>): Mesh;
  146241. /**
  146242. * Creates a ground mesh
  146243. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146244. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146246. * @param name defines the name of the mesh
  146247. * @param options defines the options used to create the mesh
  146248. * @param scene defines the hosting scene
  146249. * @returns the ground mesh
  146250. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146251. */
  146252. static CreateGround(name: string, options: {
  146253. width?: number;
  146254. height?: number;
  146255. subdivisions?: number;
  146256. subdivisionsX?: number;
  146257. subdivisionsY?: number;
  146258. updatable?: boolean;
  146259. }, scene?: Nullable<Scene>): Mesh;
  146260. /**
  146261. * Creates a tiled ground mesh
  146262. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146263. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146264. * * 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
  146265. * * 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
  146266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146267. * @param name defines the name of the mesh
  146268. * @param options defines the options used to create the mesh
  146269. * @param scene defines the hosting scene
  146270. * @returns the tiled ground mesh
  146271. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146272. */
  146273. static CreateTiledGround(name: string, options: {
  146274. xmin: number;
  146275. zmin: number;
  146276. xmax: number;
  146277. zmax: number;
  146278. subdivisions?: {
  146279. w: number;
  146280. h: number;
  146281. };
  146282. precision?: {
  146283. w: number;
  146284. h: number;
  146285. };
  146286. updatable?: boolean;
  146287. }, scene?: Nullable<Scene>): Mesh;
  146288. /**
  146289. * Creates a ground mesh from a height map
  146290. * * The parameter `url` sets the URL of the height map image resource.
  146291. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146292. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146293. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146294. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146295. * * 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.
  146296. * * 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).
  146297. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146299. * @param name defines the name of the mesh
  146300. * @param url defines the url to the height map
  146301. * @param options defines the options used to create the mesh
  146302. * @param scene defines the hosting scene
  146303. * @returns the ground mesh
  146304. * @see https://doc.babylonjs.com/babylon101/height_map
  146305. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146306. */
  146307. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146308. width?: number;
  146309. height?: number;
  146310. subdivisions?: number;
  146311. minHeight?: number;
  146312. maxHeight?: number;
  146313. colorFilter?: Color3;
  146314. alphaFilter?: number;
  146315. updatable?: boolean;
  146316. onReady?: (mesh: GroundMesh) => void;
  146317. }, scene?: Nullable<Scene>): GroundMesh;
  146318. /**
  146319. * Creates a polygon mesh
  146320. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146321. * * 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
  146322. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146325. * * Remember you can only change the shape positions, not their number when updating a polygon
  146326. * @param name defines the name of the mesh
  146327. * @param options defines the options used to create the mesh
  146328. * @param scene defines the hosting scene
  146329. * @param earcutInjection can be used to inject your own earcut reference
  146330. * @returns the polygon mesh
  146331. */
  146332. static CreatePolygon(name: string, options: {
  146333. shape: Vector3[];
  146334. holes?: Vector3[][];
  146335. depth?: number;
  146336. faceUV?: Vector4[];
  146337. faceColors?: Color4[];
  146338. updatable?: boolean;
  146339. sideOrientation?: number;
  146340. frontUVs?: Vector4;
  146341. backUVs?: Vector4;
  146342. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146343. /**
  146344. * Creates an extruded polygon mesh, with depth in the Y direction.
  146345. * * 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)
  146346. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146347. * @param name defines the name of the mesh
  146348. * @param options defines the options used to create the mesh
  146349. * @param scene defines the hosting scene
  146350. * @param earcutInjection can be used to inject your own earcut reference
  146351. * @returns the polygon mesh
  146352. */
  146353. static ExtrudePolygon(name: string, options: {
  146354. shape: Vector3[];
  146355. holes?: Vector3[][];
  146356. depth?: number;
  146357. faceUV?: Vector4[];
  146358. faceColors?: Color4[];
  146359. updatable?: boolean;
  146360. sideOrientation?: number;
  146361. frontUVs?: Vector4;
  146362. backUVs?: Vector4;
  146363. wrap?: boolean;
  146364. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146365. /**
  146366. * Creates a tube mesh.
  146367. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146368. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146369. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146370. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146371. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146372. * * 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)
  146373. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146374. * * 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
  146375. * * 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
  146376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146378. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146380. * @param name defines the name of the mesh
  146381. * @param options defines the options used to create the mesh
  146382. * @param scene defines the hosting scene
  146383. * @returns the tube mesh
  146384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146385. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146386. */
  146387. static CreateTube(name: string, options: {
  146388. path: Vector3[];
  146389. radius?: number;
  146390. tessellation?: number;
  146391. radiusFunction?: {
  146392. (i: number, distance: number): number;
  146393. };
  146394. cap?: number;
  146395. arc?: number;
  146396. updatable?: boolean;
  146397. sideOrientation?: number;
  146398. frontUVs?: Vector4;
  146399. backUVs?: Vector4;
  146400. instance?: Mesh;
  146401. invertUV?: boolean;
  146402. }, scene?: Nullable<Scene>): Mesh;
  146403. /**
  146404. * Creates a polyhedron mesh
  146405. * * 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
  146406. * * The parameter `size` (positive float, default 1) sets the polygon size
  146407. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146408. * * 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`
  146409. * * 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
  146410. * * 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)`)
  146411. * * 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
  146412. * * 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
  146413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146416. * @param name defines the name of the mesh
  146417. * @param options defines the options used to create the mesh
  146418. * @param scene defines the hosting scene
  146419. * @returns the polyhedron mesh
  146420. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146421. */
  146422. static CreatePolyhedron(name: string, options: {
  146423. type?: number;
  146424. size?: number;
  146425. sizeX?: number;
  146426. sizeY?: number;
  146427. sizeZ?: number;
  146428. custom?: any;
  146429. faceUV?: Vector4[];
  146430. faceColors?: Color4[];
  146431. flat?: boolean;
  146432. updatable?: boolean;
  146433. sideOrientation?: number;
  146434. frontUVs?: Vector4;
  146435. backUVs?: Vector4;
  146436. }, scene?: Nullable<Scene>): Mesh;
  146437. /**
  146438. * Creates a decal mesh.
  146439. * 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
  146440. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146441. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146442. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146443. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146444. * @param name defines the name of the mesh
  146445. * @param sourceMesh defines the mesh where the decal must be applied
  146446. * @param options defines the options used to create the mesh
  146447. * @param scene defines the hosting scene
  146448. * @returns the decal mesh
  146449. * @see https://doc.babylonjs.com/how_to/decals
  146450. */
  146451. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146452. position?: Vector3;
  146453. normal?: Vector3;
  146454. size?: Vector3;
  146455. angle?: number;
  146456. }): Mesh;
  146457. /**
  146458. * Creates a Capsule Mesh
  146459. * @param name defines the name of the mesh.
  146460. * @param options the constructors options used to shape the mesh.
  146461. * @param scene defines the scene the mesh is scoped to.
  146462. * @returns the capsule mesh
  146463. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146464. */
  146465. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146466. }
  146467. }
  146468. declare module BABYLON {
  146469. /**
  146470. * A simplifier interface for future simplification implementations
  146471. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146472. */
  146473. export interface ISimplifier {
  146474. /**
  146475. * Simplification of a given mesh according to the given settings.
  146476. * Since this requires computation, it is assumed that the function runs async.
  146477. * @param settings The settings of the simplification, including quality and distance
  146478. * @param successCallback A callback that will be called after the mesh was simplified.
  146479. * @param errorCallback in case of an error, this callback will be called. optional.
  146480. */
  146481. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146482. }
  146483. /**
  146484. * Expected simplification settings.
  146485. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146486. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146487. */
  146488. export interface ISimplificationSettings {
  146489. /**
  146490. * Gets or sets the expected quality
  146491. */
  146492. quality: number;
  146493. /**
  146494. * Gets or sets the distance when this optimized version should be used
  146495. */
  146496. distance: number;
  146497. /**
  146498. * Gets an already optimized mesh
  146499. */
  146500. optimizeMesh?: boolean;
  146501. }
  146502. /**
  146503. * Class used to specify simplification options
  146504. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146505. */
  146506. export class SimplificationSettings implements ISimplificationSettings {
  146507. /** expected quality */
  146508. quality: number;
  146509. /** distance when this optimized version should be used */
  146510. distance: number;
  146511. /** already optimized mesh */
  146512. optimizeMesh?: boolean | undefined;
  146513. /**
  146514. * Creates a SimplificationSettings
  146515. * @param quality expected quality
  146516. * @param distance distance when this optimized version should be used
  146517. * @param optimizeMesh already optimized mesh
  146518. */
  146519. constructor(
  146520. /** expected quality */
  146521. quality: number,
  146522. /** distance when this optimized version should be used */
  146523. distance: number,
  146524. /** already optimized mesh */
  146525. optimizeMesh?: boolean | undefined);
  146526. }
  146527. /**
  146528. * Interface used to define a simplification task
  146529. */
  146530. export interface ISimplificationTask {
  146531. /**
  146532. * Array of settings
  146533. */
  146534. settings: Array<ISimplificationSettings>;
  146535. /**
  146536. * Simplification type
  146537. */
  146538. simplificationType: SimplificationType;
  146539. /**
  146540. * Mesh to simplify
  146541. */
  146542. mesh: Mesh;
  146543. /**
  146544. * Callback called on success
  146545. */
  146546. successCallback?: () => void;
  146547. /**
  146548. * Defines if parallel processing can be used
  146549. */
  146550. parallelProcessing: boolean;
  146551. }
  146552. /**
  146553. * Queue used to order the simplification tasks
  146554. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146555. */
  146556. export class SimplificationQueue {
  146557. private _simplificationArray;
  146558. /**
  146559. * Gets a boolean indicating that the process is still running
  146560. */
  146561. running: boolean;
  146562. /**
  146563. * Creates a new queue
  146564. */
  146565. constructor();
  146566. /**
  146567. * Adds a new simplification task
  146568. * @param task defines a task to add
  146569. */
  146570. addTask(task: ISimplificationTask): void;
  146571. /**
  146572. * Execute next task
  146573. */
  146574. executeNext(): void;
  146575. /**
  146576. * Execute a simplification task
  146577. * @param task defines the task to run
  146578. */
  146579. runSimplification(task: ISimplificationTask): void;
  146580. private getSimplifier;
  146581. }
  146582. /**
  146583. * The implemented types of simplification
  146584. * At the moment only Quadratic Error Decimation is implemented
  146585. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146586. */
  146587. export enum SimplificationType {
  146588. /** Quadratic error decimation */
  146589. QUADRATIC = 0
  146590. }
  146591. /**
  146592. * An implementation of the Quadratic Error simplification algorithm.
  146593. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  146594. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  146595. * @author RaananW
  146596. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146597. */
  146598. export class QuadraticErrorSimplification implements ISimplifier {
  146599. private _mesh;
  146600. private triangles;
  146601. private vertices;
  146602. private references;
  146603. private _reconstructedMesh;
  146604. /** Gets or sets the number pf sync interations */
  146605. syncIterations: number;
  146606. /** Gets or sets the aggressiveness of the simplifier */
  146607. aggressiveness: number;
  146608. /** Gets or sets the number of allowed iterations for decimation */
  146609. decimationIterations: number;
  146610. /** Gets or sets the espilon to use for bounding box computation */
  146611. boundingBoxEpsilon: number;
  146612. /**
  146613. * Creates a new QuadraticErrorSimplification
  146614. * @param _mesh defines the target mesh
  146615. */
  146616. constructor(_mesh: Mesh);
  146617. /**
  146618. * Simplification of a given mesh according to the given settings.
  146619. * Since this requires computation, it is assumed that the function runs async.
  146620. * @param settings The settings of the simplification, including quality and distance
  146621. * @param successCallback A callback that will be called after the mesh was simplified.
  146622. */
  146623. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  146624. private runDecimation;
  146625. private initWithMesh;
  146626. private init;
  146627. private reconstructMesh;
  146628. private initDecimatedMesh;
  146629. private isFlipped;
  146630. private updateTriangles;
  146631. private identifyBorder;
  146632. private updateMesh;
  146633. private vertexError;
  146634. private calculateError;
  146635. }
  146636. }
  146637. declare module BABYLON {
  146638. interface Scene {
  146639. /** @hidden (Backing field) */
  146640. _simplificationQueue: SimplificationQueue;
  146641. /**
  146642. * Gets or sets the simplification queue attached to the scene
  146643. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146644. */
  146645. simplificationQueue: SimplificationQueue;
  146646. }
  146647. interface Mesh {
  146648. /**
  146649. * Simplify the mesh according to the given array of settings.
  146650. * Function will return immediately and will simplify async
  146651. * @param settings a collection of simplification settings
  146652. * @param parallelProcessing should all levels calculate parallel or one after the other
  146653. * @param simplificationType the type of simplification to run
  146654. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  146655. * @returns the current mesh
  146656. */
  146657. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  146658. }
  146659. /**
  146660. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  146661. * created in a scene
  146662. */
  146663. export class SimplicationQueueSceneComponent implements ISceneComponent {
  146664. /**
  146665. * The component name helpfull to identify the component in the list of scene components.
  146666. */
  146667. readonly name: string;
  146668. /**
  146669. * The scene the component belongs to.
  146670. */
  146671. scene: Scene;
  146672. /**
  146673. * Creates a new instance of the component for the given scene
  146674. * @param scene Defines the scene to register the component in
  146675. */
  146676. constructor(scene: Scene);
  146677. /**
  146678. * Registers the component in a given scene
  146679. */
  146680. register(): void;
  146681. /**
  146682. * Rebuilds the elements related to this component in case of
  146683. * context lost for instance.
  146684. */
  146685. rebuild(): void;
  146686. /**
  146687. * Disposes the component and the associated ressources
  146688. */
  146689. dispose(): void;
  146690. private _beforeCameraUpdate;
  146691. }
  146692. }
  146693. declare module BABYLON {
  146694. interface Mesh {
  146695. /**
  146696. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  146697. */
  146698. thinInstanceEnablePicking: boolean;
  146699. /**
  146700. * Creates a new thin instance
  146701. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  146702. * @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
  146703. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  146704. */
  146705. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  146706. /**
  146707. * Adds the transformation (matrix) of the current mesh as a thin instance
  146708. * @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
  146709. * @returns the thin instance index number
  146710. */
  146711. thinInstanceAddSelf(refresh: boolean): number;
  146712. /**
  146713. * Registers a custom attribute to be used with thin instances
  146714. * @param kind name of the attribute
  146715. * @param stride size in floats of the attribute
  146716. */
  146717. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  146718. /**
  146719. * Sets the matrix of a thin instance
  146720. * @param index index of the thin instance
  146721. * @param matrix matrix to set
  146722. * @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
  146723. */
  146724. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  146725. /**
  146726. * Sets the value of a custom attribute for a thin instance
  146727. * @param kind name of the attribute
  146728. * @param index index of the thin instance
  146729. * @param value value to set
  146730. * @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
  146731. */
  146732. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  146733. /**
  146734. * 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.
  146735. */
  146736. thinInstanceCount: number;
  146737. /**
  146738. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  146739. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  146740. * @param buffer buffer to set
  146741. * @param stride size in floats of each value of the buffer
  146742. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  146743. */
  146744. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  146745. /**
  146746. * Gets the list of world matrices
  146747. * @return an array containing all the world matrices from the thin instances
  146748. */
  146749. thinInstanceGetWorldMatrices(): Matrix[];
  146750. /**
  146751. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  146752. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146753. */
  146754. thinInstanceBufferUpdated(kind: string): void;
  146755. /**
  146756. * Applies a partial update to a buffer directly on the GPU
  146757. * 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
  146758. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146759. * @param data the data to set in the GPU buffer
  146760. * @param offset the offset in the GPU buffer where to update the data
  146761. */
  146762. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  146763. /**
  146764. * Refreshes the bounding info, taking into account all the thin instances defined
  146765. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  146766. */
  146767. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  146768. /** @hidden */
  146769. _thinInstanceInitializeUserStorage(): void;
  146770. /** @hidden */
  146771. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  146772. /** @hidden */
  146773. _userThinInstanceBuffersStorage: {
  146774. data: {
  146775. [key: string]: Float32Array;
  146776. };
  146777. sizes: {
  146778. [key: string]: number;
  146779. };
  146780. vertexBuffers: {
  146781. [key: string]: Nullable<VertexBuffer>;
  146782. };
  146783. strides: {
  146784. [key: string]: number;
  146785. };
  146786. };
  146787. }
  146788. }
  146789. declare module BABYLON {
  146790. /**
  146791. * Navigation plugin interface to add navigation constrained by a navigation mesh
  146792. */
  146793. export interface INavigationEnginePlugin {
  146794. /**
  146795. * plugin name
  146796. */
  146797. name: string;
  146798. /**
  146799. * Creates a navigation mesh
  146800. * @param meshes array of all the geometry used to compute the navigatio mesh
  146801. * @param parameters bunch of parameters used to filter geometry
  146802. */
  146803. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146804. /**
  146805. * Create a navigation mesh debug mesh
  146806. * @param scene is where the mesh will be added
  146807. * @returns debug display mesh
  146808. */
  146809. createDebugNavMesh(scene: Scene): Mesh;
  146810. /**
  146811. * Get a navigation mesh constrained position, closest to the parameter position
  146812. * @param position world position
  146813. * @returns the closest point to position constrained by the navigation mesh
  146814. */
  146815. getClosestPoint(position: Vector3): Vector3;
  146816. /**
  146817. * Get a navigation mesh constrained position, closest to the parameter position
  146818. * @param position world position
  146819. * @param result output the closest point to position constrained by the navigation mesh
  146820. */
  146821. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146822. /**
  146823. * Get a navigation mesh constrained position, within a particular radius
  146824. * @param position world position
  146825. * @param maxRadius the maximum distance to the constrained world position
  146826. * @returns the closest point to position constrained by the navigation mesh
  146827. */
  146828. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146829. /**
  146830. * Get a navigation mesh constrained position, within a particular radius
  146831. * @param position world position
  146832. * @param maxRadius the maximum distance to the constrained world position
  146833. * @param result output the closest point to position constrained by the navigation mesh
  146834. */
  146835. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146836. /**
  146837. * Compute the final position from a segment made of destination-position
  146838. * @param position world position
  146839. * @param destination world position
  146840. * @returns the resulting point along the navmesh
  146841. */
  146842. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146843. /**
  146844. * Compute the final position from a segment made of destination-position
  146845. * @param position world position
  146846. * @param destination world position
  146847. * @param result output the resulting point along the navmesh
  146848. */
  146849. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146850. /**
  146851. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146852. * @param start world position
  146853. * @param end world position
  146854. * @returns array containing world position composing the path
  146855. */
  146856. computePath(start: Vector3, end: Vector3): Vector3[];
  146857. /**
  146858. * If this plugin is supported
  146859. * @returns true if plugin is supported
  146860. */
  146861. isSupported(): boolean;
  146862. /**
  146863. * Create a new Crowd so you can add agents
  146864. * @param maxAgents the maximum agent count in the crowd
  146865. * @param maxAgentRadius the maximum radius an agent can have
  146866. * @param scene to attach the crowd to
  146867. * @returns the crowd you can add agents to
  146868. */
  146869. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146870. /**
  146871. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146872. * The queries will try to find a solution within those bounds
  146873. * default is (1,1,1)
  146874. * @param extent x,y,z value that define the extent around the queries point of reference
  146875. */
  146876. setDefaultQueryExtent(extent: Vector3): void;
  146877. /**
  146878. * Get the Bounding box extent specified by setDefaultQueryExtent
  146879. * @returns the box extent values
  146880. */
  146881. getDefaultQueryExtent(): Vector3;
  146882. /**
  146883. * build the navmesh from a previously saved state using getNavmeshData
  146884. * @param data the Uint8Array returned by getNavmeshData
  146885. */
  146886. buildFromNavmeshData(data: Uint8Array): void;
  146887. /**
  146888. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146889. * @returns data the Uint8Array that can be saved and reused
  146890. */
  146891. getNavmeshData(): Uint8Array;
  146892. /**
  146893. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146894. * @param result output the box extent values
  146895. */
  146896. getDefaultQueryExtentToRef(result: Vector3): void;
  146897. /**
  146898. * Release all resources
  146899. */
  146900. dispose(): void;
  146901. }
  146902. /**
  146903. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  146904. */
  146905. export interface ICrowd {
  146906. /**
  146907. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146908. * You can attach anything to that node. The node position is updated in the scene update tick.
  146909. * @param pos world position that will be constrained by the navigation mesh
  146910. * @param parameters agent parameters
  146911. * @param transform hooked to the agent that will be update by the scene
  146912. * @returns agent index
  146913. */
  146914. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146915. /**
  146916. * Returns the agent position in world space
  146917. * @param index agent index returned by addAgent
  146918. * @returns world space position
  146919. */
  146920. getAgentPosition(index: number): Vector3;
  146921. /**
  146922. * Gets the agent position result in world space
  146923. * @param index agent index returned by addAgent
  146924. * @param result output world space position
  146925. */
  146926. getAgentPositionToRef(index: number, result: Vector3): void;
  146927. /**
  146928. * Gets the agent velocity in world space
  146929. * @param index agent index returned by addAgent
  146930. * @returns world space velocity
  146931. */
  146932. getAgentVelocity(index: number): Vector3;
  146933. /**
  146934. * Gets the agent velocity result in world space
  146935. * @param index agent index returned by addAgent
  146936. * @param result output world space velocity
  146937. */
  146938. getAgentVelocityToRef(index: number, result: Vector3): void;
  146939. /**
  146940. * remove a particular agent previously created
  146941. * @param index agent index returned by addAgent
  146942. */
  146943. removeAgent(index: number): void;
  146944. /**
  146945. * get the list of all agents attached to this crowd
  146946. * @returns list of agent indices
  146947. */
  146948. getAgents(): number[];
  146949. /**
  146950. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146951. * @param deltaTime in seconds
  146952. */
  146953. update(deltaTime: number): void;
  146954. /**
  146955. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146956. * @param index agent index returned by addAgent
  146957. * @param destination targeted world position
  146958. */
  146959. agentGoto(index: number, destination: Vector3): void;
  146960. /**
  146961. * Teleport the agent to a new position
  146962. * @param index agent index returned by addAgent
  146963. * @param destination targeted world position
  146964. */
  146965. agentTeleport(index: number, destination: Vector3): void;
  146966. /**
  146967. * Update agent parameters
  146968. * @param index agent index returned by addAgent
  146969. * @param parameters agent parameters
  146970. */
  146971. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146972. /**
  146973. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146974. * The queries will try to find a solution within those bounds
  146975. * default is (1,1,1)
  146976. * @param extent x,y,z value that define the extent around the queries point of reference
  146977. */
  146978. setDefaultQueryExtent(extent: Vector3): void;
  146979. /**
  146980. * Get the Bounding box extent specified by setDefaultQueryExtent
  146981. * @returns the box extent values
  146982. */
  146983. getDefaultQueryExtent(): Vector3;
  146984. /**
  146985. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146986. * @param result output the box extent values
  146987. */
  146988. getDefaultQueryExtentToRef(result: Vector3): void;
  146989. /**
  146990. * Release all resources
  146991. */
  146992. dispose(): void;
  146993. }
  146994. /**
  146995. * Configures an agent
  146996. */
  146997. export interface IAgentParameters {
  146998. /**
  146999. * Agent radius. [Limit: >= 0]
  147000. */
  147001. radius: number;
  147002. /**
  147003. * Agent height. [Limit: > 0]
  147004. */
  147005. height: number;
  147006. /**
  147007. * Maximum allowed acceleration. [Limit: >= 0]
  147008. */
  147009. maxAcceleration: number;
  147010. /**
  147011. * Maximum allowed speed. [Limit: >= 0]
  147012. */
  147013. maxSpeed: number;
  147014. /**
  147015. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147016. */
  147017. collisionQueryRange: number;
  147018. /**
  147019. * The path visibility optimization range. [Limit: > 0]
  147020. */
  147021. pathOptimizationRange: number;
  147022. /**
  147023. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147024. */
  147025. separationWeight: number;
  147026. }
  147027. /**
  147028. * Configures the navigation mesh creation
  147029. */
  147030. export interface INavMeshParameters {
  147031. /**
  147032. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147033. */
  147034. cs: number;
  147035. /**
  147036. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147037. */
  147038. ch: number;
  147039. /**
  147040. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147041. */
  147042. walkableSlopeAngle: number;
  147043. /**
  147044. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147045. * be considered walkable. [Limit: >= 3] [Units: vx]
  147046. */
  147047. walkableHeight: number;
  147048. /**
  147049. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147050. */
  147051. walkableClimb: number;
  147052. /**
  147053. * The distance to erode/shrink the walkable area of the heightfield away from
  147054. * obstructions. [Limit: >=0] [Units: vx]
  147055. */
  147056. walkableRadius: number;
  147057. /**
  147058. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147059. */
  147060. maxEdgeLen: number;
  147061. /**
  147062. * The maximum distance a simplfied contour's border edges should deviate
  147063. * the original raw contour. [Limit: >=0] [Units: vx]
  147064. */
  147065. maxSimplificationError: number;
  147066. /**
  147067. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147068. */
  147069. minRegionArea: number;
  147070. /**
  147071. * Any regions with a span count smaller than this value will, if possible,
  147072. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147073. */
  147074. mergeRegionArea: number;
  147075. /**
  147076. * The maximum number of vertices allowed for polygons generated during the
  147077. * contour to polygon conversion process. [Limit: >= 3]
  147078. */
  147079. maxVertsPerPoly: number;
  147080. /**
  147081. * Sets the sampling distance to use when generating the detail mesh.
  147082. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147083. */
  147084. detailSampleDist: number;
  147085. /**
  147086. * The maximum distance the detail mesh surface should deviate from heightfield
  147087. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147088. */
  147089. detailSampleMaxError: number;
  147090. }
  147091. }
  147092. declare module BABYLON {
  147093. /**
  147094. * RecastJS navigation plugin
  147095. */
  147096. export class RecastJSPlugin implements INavigationEnginePlugin {
  147097. /**
  147098. * Reference to the Recast library
  147099. */
  147100. bjsRECAST: any;
  147101. /**
  147102. * plugin name
  147103. */
  147104. name: string;
  147105. /**
  147106. * the first navmesh created. We might extend this to support multiple navmeshes
  147107. */
  147108. navMesh: any;
  147109. /**
  147110. * Initializes the recastJS plugin
  147111. * @param recastInjection can be used to inject your own recast reference
  147112. */
  147113. constructor(recastInjection?: any);
  147114. /**
  147115. * Creates a navigation mesh
  147116. * @param meshes array of all the geometry used to compute the navigatio mesh
  147117. * @param parameters bunch of parameters used to filter geometry
  147118. */
  147119. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147120. /**
  147121. * Create a navigation mesh debug mesh
  147122. * @param scene is where the mesh will be added
  147123. * @returns debug display mesh
  147124. */
  147125. createDebugNavMesh(scene: Scene): Mesh;
  147126. /**
  147127. * Get a navigation mesh constrained position, closest to the parameter position
  147128. * @param position world position
  147129. * @returns the closest point to position constrained by the navigation mesh
  147130. */
  147131. getClosestPoint(position: Vector3): Vector3;
  147132. /**
  147133. * Get a navigation mesh constrained position, closest to the parameter position
  147134. * @param position world position
  147135. * @param result output the closest point to position constrained by the navigation mesh
  147136. */
  147137. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147138. /**
  147139. * Get a navigation mesh constrained position, within a particular radius
  147140. * @param position world position
  147141. * @param maxRadius the maximum distance to the constrained world position
  147142. * @returns the closest point to position constrained by the navigation mesh
  147143. */
  147144. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147145. /**
  147146. * Get a navigation mesh constrained position, within a particular radius
  147147. * @param position world position
  147148. * @param maxRadius the maximum distance to the constrained world position
  147149. * @param result output the closest point to position constrained by the navigation mesh
  147150. */
  147151. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147152. /**
  147153. * Compute the final position from a segment made of destination-position
  147154. * @param position world position
  147155. * @param destination world position
  147156. * @returns the resulting point along the navmesh
  147157. */
  147158. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147159. /**
  147160. * Compute the final position from a segment made of destination-position
  147161. * @param position world position
  147162. * @param destination world position
  147163. * @param result output the resulting point along the navmesh
  147164. */
  147165. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147166. /**
  147167. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147168. * @param start world position
  147169. * @param end world position
  147170. * @returns array containing world position composing the path
  147171. */
  147172. computePath(start: Vector3, end: Vector3): Vector3[];
  147173. /**
  147174. * Create a new Crowd so you can add agents
  147175. * @param maxAgents the maximum agent count in the crowd
  147176. * @param maxAgentRadius the maximum radius an agent can have
  147177. * @param scene to attach the crowd to
  147178. * @returns the crowd you can add agents to
  147179. */
  147180. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147181. /**
  147182. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147183. * The queries will try to find a solution within those bounds
  147184. * default is (1,1,1)
  147185. * @param extent x,y,z value that define the extent around the queries point of reference
  147186. */
  147187. setDefaultQueryExtent(extent: Vector3): void;
  147188. /**
  147189. * Get the Bounding box extent specified by setDefaultQueryExtent
  147190. * @returns the box extent values
  147191. */
  147192. getDefaultQueryExtent(): Vector3;
  147193. /**
  147194. * build the navmesh from a previously saved state using getNavmeshData
  147195. * @param data the Uint8Array returned by getNavmeshData
  147196. */
  147197. buildFromNavmeshData(data: Uint8Array): void;
  147198. /**
  147199. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147200. * @returns data the Uint8Array that can be saved and reused
  147201. */
  147202. getNavmeshData(): Uint8Array;
  147203. /**
  147204. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147205. * @param result output the box extent values
  147206. */
  147207. getDefaultQueryExtentToRef(result: Vector3): void;
  147208. /**
  147209. * Disposes
  147210. */
  147211. dispose(): void;
  147212. /**
  147213. * If this plugin is supported
  147214. * @returns true if plugin is supported
  147215. */
  147216. isSupported(): boolean;
  147217. }
  147218. /**
  147219. * Recast detour crowd implementation
  147220. */
  147221. export class RecastJSCrowd implements ICrowd {
  147222. /**
  147223. * Recast/detour plugin
  147224. */
  147225. bjsRECASTPlugin: RecastJSPlugin;
  147226. /**
  147227. * Link to the detour crowd
  147228. */
  147229. recastCrowd: any;
  147230. /**
  147231. * One transform per agent
  147232. */
  147233. transforms: TransformNode[];
  147234. /**
  147235. * All agents created
  147236. */
  147237. agents: number[];
  147238. /**
  147239. * Link to the scene is kept to unregister the crowd from the scene
  147240. */
  147241. private _scene;
  147242. /**
  147243. * Observer for crowd updates
  147244. */
  147245. private _onBeforeAnimationsObserver;
  147246. /**
  147247. * Constructor
  147248. * @param plugin recastJS plugin
  147249. * @param maxAgents the maximum agent count in the crowd
  147250. * @param maxAgentRadius the maximum radius an agent can have
  147251. * @param scene to attach the crowd to
  147252. * @returns the crowd you can add agents to
  147253. */
  147254. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147255. /**
  147256. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147257. * You can attach anything to that node. The node position is updated in the scene update tick.
  147258. * @param pos world position that will be constrained by the navigation mesh
  147259. * @param parameters agent parameters
  147260. * @param transform hooked to the agent that will be update by the scene
  147261. * @returns agent index
  147262. */
  147263. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147264. /**
  147265. * Returns the agent position in world space
  147266. * @param index agent index returned by addAgent
  147267. * @returns world space position
  147268. */
  147269. getAgentPosition(index: number): Vector3;
  147270. /**
  147271. * Returns the agent position result in world space
  147272. * @param index agent index returned by addAgent
  147273. * @param result output world space position
  147274. */
  147275. getAgentPositionToRef(index: number, result: Vector3): void;
  147276. /**
  147277. * Returns the agent velocity in world space
  147278. * @param index agent index returned by addAgent
  147279. * @returns world space velocity
  147280. */
  147281. getAgentVelocity(index: number): Vector3;
  147282. /**
  147283. * Returns the agent velocity result in world space
  147284. * @param index agent index returned by addAgent
  147285. * @param result output world space velocity
  147286. */
  147287. getAgentVelocityToRef(index: number, result: Vector3): void;
  147288. /**
  147289. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147290. * @param index agent index returned by addAgent
  147291. * @param destination targeted world position
  147292. */
  147293. agentGoto(index: number, destination: Vector3): void;
  147294. /**
  147295. * Teleport the agent to a new position
  147296. * @param index agent index returned by addAgent
  147297. * @param destination targeted world position
  147298. */
  147299. agentTeleport(index: number, destination: Vector3): void;
  147300. /**
  147301. * Update agent parameters
  147302. * @param index agent index returned by addAgent
  147303. * @param parameters agent parameters
  147304. */
  147305. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147306. /**
  147307. * remove a particular agent previously created
  147308. * @param index agent index returned by addAgent
  147309. */
  147310. removeAgent(index: number): void;
  147311. /**
  147312. * get the list of all agents attached to this crowd
  147313. * @returns list of agent indices
  147314. */
  147315. getAgents(): number[];
  147316. /**
  147317. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147318. * @param deltaTime in seconds
  147319. */
  147320. update(deltaTime: number): void;
  147321. /**
  147322. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147323. * The queries will try to find a solution within those bounds
  147324. * default is (1,1,1)
  147325. * @param extent x,y,z value that define the extent around the queries point of reference
  147326. */
  147327. setDefaultQueryExtent(extent: Vector3): void;
  147328. /**
  147329. * Get the Bounding box extent specified by setDefaultQueryExtent
  147330. * @returns the box extent values
  147331. */
  147332. getDefaultQueryExtent(): Vector3;
  147333. /**
  147334. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147335. * @param result output the box extent values
  147336. */
  147337. getDefaultQueryExtentToRef(result: Vector3): void;
  147338. /**
  147339. * Release all resources
  147340. */
  147341. dispose(): void;
  147342. }
  147343. }
  147344. declare module BABYLON {
  147345. /**
  147346. * Class used to enable access to IndexedDB
  147347. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147348. */
  147349. export class Database implements IOfflineProvider {
  147350. private _callbackManifestChecked;
  147351. private _currentSceneUrl;
  147352. private _db;
  147353. private _enableSceneOffline;
  147354. private _enableTexturesOffline;
  147355. private _manifestVersionFound;
  147356. private _mustUpdateRessources;
  147357. private _hasReachedQuota;
  147358. private _isSupported;
  147359. private _idbFactory;
  147360. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147361. private static IsUASupportingBlobStorage;
  147362. /**
  147363. * Gets a boolean indicating if Database storate is enabled (off by default)
  147364. */
  147365. static IDBStorageEnabled: boolean;
  147366. /**
  147367. * Gets a boolean indicating if scene must be saved in the database
  147368. */
  147369. get enableSceneOffline(): boolean;
  147370. /**
  147371. * Gets a boolean indicating if textures must be saved in the database
  147372. */
  147373. get enableTexturesOffline(): boolean;
  147374. /**
  147375. * Creates a new Database
  147376. * @param urlToScene defines the url to load the scene
  147377. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147378. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147379. */
  147380. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147381. private static _ParseURL;
  147382. private static _ReturnFullUrlLocation;
  147383. private _checkManifestFile;
  147384. /**
  147385. * Open the database and make it available
  147386. * @param successCallback defines the callback to call on success
  147387. * @param errorCallback defines the callback to call on error
  147388. */
  147389. open(successCallback: () => void, errorCallback: () => void): void;
  147390. /**
  147391. * Loads an image from the database
  147392. * @param url defines the url to load from
  147393. * @param image defines the target DOM image
  147394. */
  147395. loadImage(url: string, image: HTMLImageElement): void;
  147396. private _loadImageFromDBAsync;
  147397. private _saveImageIntoDBAsync;
  147398. private _checkVersionFromDB;
  147399. private _loadVersionFromDBAsync;
  147400. private _saveVersionIntoDBAsync;
  147401. /**
  147402. * Loads a file from database
  147403. * @param url defines the URL to load from
  147404. * @param sceneLoaded defines a callback to call on success
  147405. * @param progressCallBack defines a callback to call when progress changed
  147406. * @param errorCallback defines a callback to call on error
  147407. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147408. */
  147409. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147410. private _loadFileAsync;
  147411. private _saveFileAsync;
  147412. /**
  147413. * Validates if xhr data is correct
  147414. * @param xhr defines the request to validate
  147415. * @param dataType defines the expected data type
  147416. * @returns true if data is correct
  147417. */
  147418. private static _ValidateXHRData;
  147419. }
  147420. }
  147421. declare module BABYLON {
  147422. /** @hidden */
  147423. export var gpuUpdateParticlesPixelShader: {
  147424. name: string;
  147425. shader: string;
  147426. };
  147427. }
  147428. declare module BABYLON {
  147429. /** @hidden */
  147430. export var gpuUpdateParticlesVertexShader: {
  147431. name: string;
  147432. shader: string;
  147433. };
  147434. }
  147435. declare module BABYLON {
  147436. /** @hidden */
  147437. export var clipPlaneFragmentDeclaration2: {
  147438. name: string;
  147439. shader: string;
  147440. };
  147441. }
  147442. declare module BABYLON {
  147443. /** @hidden */
  147444. export var gpuRenderParticlesPixelShader: {
  147445. name: string;
  147446. shader: string;
  147447. };
  147448. }
  147449. declare module BABYLON {
  147450. /** @hidden */
  147451. export var clipPlaneVertexDeclaration2: {
  147452. name: string;
  147453. shader: string;
  147454. };
  147455. }
  147456. declare module BABYLON {
  147457. /** @hidden */
  147458. export var gpuRenderParticlesVertexShader: {
  147459. name: string;
  147460. shader: string;
  147461. };
  147462. }
  147463. declare module BABYLON {
  147464. /**
  147465. * This represents a GPU particle system in Babylon
  147466. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147467. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147468. */
  147469. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147470. /**
  147471. * The layer mask we are rendering the particles through.
  147472. */
  147473. layerMask: number;
  147474. private _capacity;
  147475. private _activeCount;
  147476. private _currentActiveCount;
  147477. private _accumulatedCount;
  147478. private _renderEffect;
  147479. private _updateEffect;
  147480. private _buffer0;
  147481. private _buffer1;
  147482. private _spriteBuffer;
  147483. private _updateVAO;
  147484. private _renderVAO;
  147485. private _targetIndex;
  147486. private _sourceBuffer;
  147487. private _targetBuffer;
  147488. private _currentRenderId;
  147489. private _started;
  147490. private _stopped;
  147491. private _timeDelta;
  147492. private _randomTexture;
  147493. private _randomTexture2;
  147494. private _attributesStrideSize;
  147495. private _updateEffectOptions;
  147496. private _randomTextureSize;
  147497. private _actualFrame;
  147498. private _customEffect;
  147499. private readonly _rawTextureWidth;
  147500. /**
  147501. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147502. */
  147503. static get IsSupported(): boolean;
  147504. /**
  147505. * An event triggered when the system is disposed.
  147506. */
  147507. onDisposeObservable: Observable<IParticleSystem>;
  147508. /**
  147509. * Gets the maximum number of particles active at the same time.
  147510. * @returns The max number of active particles.
  147511. */
  147512. getCapacity(): number;
  147513. /**
  147514. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147515. * to override the particles.
  147516. */
  147517. forceDepthWrite: boolean;
  147518. /**
  147519. * Gets or set the number of active particles
  147520. */
  147521. get activeParticleCount(): number;
  147522. set activeParticleCount(value: number);
  147523. private _preWarmDone;
  147524. /**
  147525. * Specifies if the particles are updated in emitter local space or world space.
  147526. */
  147527. isLocal: boolean;
  147528. /** Gets or sets a matrix to use to compute projection */
  147529. defaultProjectionMatrix: Matrix;
  147530. /**
  147531. * Is this system ready to be used/rendered
  147532. * @return true if the system is ready
  147533. */
  147534. isReady(): boolean;
  147535. /**
  147536. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147537. * @returns True if it has been started, otherwise false.
  147538. */
  147539. isStarted(): boolean;
  147540. /**
  147541. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147542. * @returns True if it has been stopped, otherwise false.
  147543. */
  147544. isStopped(): boolean;
  147545. /**
  147546. * Gets a boolean indicating that the system is stopping
  147547. * @returns true if the system is currently stopping
  147548. */
  147549. isStopping(): boolean;
  147550. /**
  147551. * Gets the number of particles active at the same time.
  147552. * @returns The number of active particles.
  147553. */
  147554. getActiveCount(): number;
  147555. /**
  147556. * Starts the particle system and begins to emit
  147557. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147558. */
  147559. start(delay?: number): void;
  147560. /**
  147561. * Stops the particle system.
  147562. */
  147563. stop(): void;
  147564. /**
  147565. * Remove all active particles
  147566. */
  147567. reset(): void;
  147568. /**
  147569. * Returns the string "GPUParticleSystem"
  147570. * @returns a string containing the class name
  147571. */
  147572. getClassName(): string;
  147573. /**
  147574. * Gets the custom effect used to render the particles
  147575. * @param blendMode Blend mode for which the effect should be retrieved
  147576. * @returns The effect
  147577. */
  147578. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147579. /**
  147580. * Sets the custom effect used to render the particles
  147581. * @param effect The effect to set
  147582. * @param blendMode Blend mode for which the effect should be set
  147583. */
  147584. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147585. /** @hidden */
  147586. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147587. /**
  147588. * Observable that will be called just before the particles are drawn
  147589. */
  147590. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147591. /**
  147592. * Gets the name of the particle vertex shader
  147593. */
  147594. get vertexShaderName(): string;
  147595. private _colorGradientsTexture;
  147596. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  147597. /**
  147598. * Adds a new color gradient
  147599. * @param gradient defines the gradient to use (between 0 and 1)
  147600. * @param color1 defines the color to affect to the specified gradient
  147601. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  147602. * @returns the current particle system
  147603. */
  147604. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  147605. private _refreshColorGradient;
  147606. /** Force the system to rebuild all gradients that need to be resync */
  147607. forceRefreshGradients(): void;
  147608. /**
  147609. * Remove a specific color gradient
  147610. * @param gradient defines the gradient to remove
  147611. * @returns the current particle system
  147612. */
  147613. removeColorGradient(gradient: number): GPUParticleSystem;
  147614. private _angularSpeedGradientsTexture;
  147615. private _sizeGradientsTexture;
  147616. private _velocityGradientsTexture;
  147617. private _limitVelocityGradientsTexture;
  147618. private _dragGradientsTexture;
  147619. private _addFactorGradient;
  147620. /**
  147621. * Adds a new size gradient
  147622. * @param gradient defines the gradient to use (between 0 and 1)
  147623. * @param factor defines the size factor to affect to the specified gradient
  147624. * @returns the current particle system
  147625. */
  147626. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  147627. /**
  147628. * Remove a specific size gradient
  147629. * @param gradient defines the gradient to remove
  147630. * @returns the current particle system
  147631. */
  147632. removeSizeGradient(gradient: number): GPUParticleSystem;
  147633. private _refreshFactorGradient;
  147634. /**
  147635. * Adds a new angular speed gradient
  147636. * @param gradient defines the gradient to use (between 0 and 1)
  147637. * @param factor defines the angular speed to affect to the specified gradient
  147638. * @returns the current particle system
  147639. */
  147640. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  147641. /**
  147642. * Remove a specific angular speed gradient
  147643. * @param gradient defines the gradient to remove
  147644. * @returns the current particle system
  147645. */
  147646. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  147647. /**
  147648. * Adds a new velocity gradient
  147649. * @param gradient defines the gradient to use (between 0 and 1)
  147650. * @param factor defines the velocity to affect to the specified gradient
  147651. * @returns the current particle system
  147652. */
  147653. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147654. /**
  147655. * Remove a specific velocity gradient
  147656. * @param gradient defines the gradient to remove
  147657. * @returns the current particle system
  147658. */
  147659. removeVelocityGradient(gradient: number): GPUParticleSystem;
  147660. /**
  147661. * Adds a new limit velocity gradient
  147662. * @param gradient defines the gradient to use (between 0 and 1)
  147663. * @param factor defines the limit velocity value to affect to the specified gradient
  147664. * @returns the current particle system
  147665. */
  147666. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147667. /**
  147668. * Remove a specific limit velocity gradient
  147669. * @param gradient defines the gradient to remove
  147670. * @returns the current particle system
  147671. */
  147672. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  147673. /**
  147674. * Adds a new drag gradient
  147675. * @param gradient defines the gradient to use (between 0 and 1)
  147676. * @param factor defines the drag value to affect to the specified gradient
  147677. * @returns the current particle system
  147678. */
  147679. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  147680. /**
  147681. * Remove a specific drag gradient
  147682. * @param gradient defines the gradient to remove
  147683. * @returns the current particle system
  147684. */
  147685. removeDragGradient(gradient: number): GPUParticleSystem;
  147686. /**
  147687. * Not supported by GPUParticleSystem
  147688. * @param gradient defines the gradient to use (between 0 and 1)
  147689. * @param factor defines the emit rate value to affect to the specified gradient
  147690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147691. * @returns the current particle system
  147692. */
  147693. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147694. /**
  147695. * Not supported by GPUParticleSystem
  147696. * @param gradient defines the gradient to remove
  147697. * @returns the current particle system
  147698. */
  147699. removeEmitRateGradient(gradient: number): IParticleSystem;
  147700. /**
  147701. * Not supported by GPUParticleSystem
  147702. * @param gradient defines the gradient to use (between 0 and 1)
  147703. * @param factor defines the start size value to affect to the specified gradient
  147704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147705. * @returns the current particle system
  147706. */
  147707. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147708. /**
  147709. * Not supported by GPUParticleSystem
  147710. * @param gradient defines the gradient to remove
  147711. * @returns the current particle system
  147712. */
  147713. removeStartSizeGradient(gradient: number): IParticleSystem;
  147714. /**
  147715. * Not supported by GPUParticleSystem
  147716. * @param gradient defines the gradient to use (between 0 and 1)
  147717. * @param min defines the color remap minimal range
  147718. * @param max defines the color remap maximal range
  147719. * @returns the current particle system
  147720. */
  147721. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147722. /**
  147723. * Not supported by GPUParticleSystem
  147724. * @param gradient defines the gradient to remove
  147725. * @returns the current particle system
  147726. */
  147727. removeColorRemapGradient(): IParticleSystem;
  147728. /**
  147729. * Not supported by GPUParticleSystem
  147730. * @param gradient defines the gradient to use (between 0 and 1)
  147731. * @param min defines the alpha remap minimal range
  147732. * @param max defines the alpha remap maximal range
  147733. * @returns the current particle system
  147734. */
  147735. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147736. /**
  147737. * Not supported by GPUParticleSystem
  147738. * @param gradient defines the gradient to remove
  147739. * @returns the current particle system
  147740. */
  147741. removeAlphaRemapGradient(): IParticleSystem;
  147742. /**
  147743. * Not supported by GPUParticleSystem
  147744. * @param gradient defines the gradient to use (between 0 and 1)
  147745. * @param color defines the color to affect to the specified gradient
  147746. * @returns the current particle system
  147747. */
  147748. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  147749. /**
  147750. * Not supported by GPUParticleSystem
  147751. * @param gradient defines the gradient to remove
  147752. * @returns the current particle system
  147753. */
  147754. removeRampGradient(): IParticleSystem;
  147755. /**
  147756. * Not supported by GPUParticleSystem
  147757. * @returns the list of ramp gradients
  147758. */
  147759. getRampGradients(): Nullable<Array<Color3Gradient>>;
  147760. /**
  147761. * Not supported by GPUParticleSystem
  147762. * Gets or sets a boolean indicating that ramp gradients must be used
  147763. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  147764. */
  147765. get useRampGradients(): boolean;
  147766. set useRampGradients(value: boolean);
  147767. /**
  147768. * Not supported by GPUParticleSystem
  147769. * @param gradient defines the gradient to use (between 0 and 1)
  147770. * @param factor defines the life time factor to affect to the specified gradient
  147771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147772. * @returns the current particle system
  147773. */
  147774. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147775. /**
  147776. * Not supported by GPUParticleSystem
  147777. * @param gradient defines the gradient to remove
  147778. * @returns the current particle system
  147779. */
  147780. removeLifeTimeGradient(gradient: number): IParticleSystem;
  147781. /**
  147782. * Instantiates a GPU particle system.
  147783. * 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.
  147784. * @param name The name of the particle system
  147785. * @param options The options used to create the system
  147786. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  147787. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  147788. * @param customEffect a custom effect used to change the way particles are rendered by default
  147789. */
  147790. constructor(name: string, options: Partial<{
  147791. capacity: number;
  147792. randomTextureSize: number;
  147793. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  147794. protected _reset(): void;
  147795. private _createUpdateVAO;
  147796. private _createRenderVAO;
  147797. private _initialize;
  147798. /** @hidden */
  147799. _recreateUpdateEffect(): void;
  147800. private _getEffect;
  147801. /**
  147802. * Fill the defines array according to the current settings of the particle system
  147803. * @param defines Array to be updated
  147804. * @param blendMode blend mode to take into account when updating the array
  147805. */
  147806. fillDefines(defines: Array<string>, blendMode?: number): void;
  147807. /**
  147808. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  147809. * @param uniforms Uniforms array to fill
  147810. * @param attributes Attributes array to fill
  147811. * @param samplers Samplers array to fill
  147812. */
  147813. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  147814. /** @hidden */
  147815. _recreateRenderEffect(): Effect;
  147816. /**
  147817. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  147818. * @param preWarm defines if we are in the pre-warmimg phase
  147819. */
  147820. animate(preWarm?: boolean): void;
  147821. private _createFactorGradientTexture;
  147822. private _createSizeGradientTexture;
  147823. private _createAngularSpeedGradientTexture;
  147824. private _createVelocityGradientTexture;
  147825. private _createLimitVelocityGradientTexture;
  147826. private _createDragGradientTexture;
  147827. private _createColorGradientTexture;
  147828. /**
  147829. * Renders the particle system in its current state
  147830. * @param preWarm defines if the system should only update the particles but not render them
  147831. * @returns the current number of particles
  147832. */
  147833. render(preWarm?: boolean): number;
  147834. /**
  147835. * Rebuilds the particle system
  147836. */
  147837. rebuild(): void;
  147838. private _releaseBuffers;
  147839. private _releaseVAOs;
  147840. /**
  147841. * Disposes the particle system and free the associated resources
  147842. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  147843. */
  147844. dispose(disposeTexture?: boolean): void;
  147845. /**
  147846. * Clones the particle system.
  147847. * @param name The name of the cloned object
  147848. * @param newEmitter The new emitter to use
  147849. * @returns the cloned particle system
  147850. */
  147851. clone(name: string, newEmitter: any): GPUParticleSystem;
  147852. /**
  147853. * Serializes the particle system to a JSON object
  147854. * @param serializeTexture defines if the texture must be serialized as well
  147855. * @returns the JSON object
  147856. */
  147857. serialize(serializeTexture?: boolean): any;
  147858. /**
  147859. * Parses a JSON object to create a GPU particle system.
  147860. * @param parsedParticleSystem The JSON object to parse
  147861. * @param sceneOrEngine The scene or the engine to create the particle system in
  147862. * @param rootUrl The root url to use to load external dependencies like texture
  147863. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  147864. * @returns the parsed GPU particle system
  147865. */
  147866. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  147867. }
  147868. }
  147869. declare module BABYLON {
  147870. /**
  147871. * Represents a set of particle systems working together to create a specific effect
  147872. */
  147873. export class ParticleSystemSet implements IDisposable {
  147874. /**
  147875. * Gets or sets base Assets URL
  147876. */
  147877. static BaseAssetsUrl: string;
  147878. private _emitterCreationOptions;
  147879. private _emitterNode;
  147880. /**
  147881. * Gets the particle system list
  147882. */
  147883. systems: IParticleSystem[];
  147884. /**
  147885. * Gets the emitter node used with this set
  147886. */
  147887. get emitterNode(): Nullable<TransformNode>;
  147888. /**
  147889. * Creates a new emitter mesh as a sphere
  147890. * @param options defines the options used to create the sphere
  147891. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  147892. * @param scene defines the hosting scene
  147893. */
  147894. setEmitterAsSphere(options: {
  147895. diameter: number;
  147896. segments: number;
  147897. color: Color3;
  147898. }, renderingGroupId: number, scene: Scene): void;
  147899. /**
  147900. * Starts all particle systems of the set
  147901. * @param emitter defines an optional mesh to use as emitter for the particle systems
  147902. */
  147903. start(emitter?: AbstractMesh): void;
  147904. /**
  147905. * Release all associated resources
  147906. */
  147907. dispose(): void;
  147908. /**
  147909. * Serialize the set into a JSON compatible object
  147910. * @param serializeTexture defines if the texture must be serialized as well
  147911. * @returns a JSON compatible representation of the set
  147912. */
  147913. serialize(serializeTexture?: boolean): any;
  147914. /**
  147915. * Parse a new ParticleSystemSet from a serialized source
  147916. * @param data defines a JSON compatible representation of the set
  147917. * @param scene defines the hosting scene
  147918. * @param gpu defines if we want GPU particles or CPU particles
  147919. * @returns a new ParticleSystemSet
  147920. */
  147921. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  147922. }
  147923. }
  147924. declare module BABYLON {
  147925. /**
  147926. * This class is made for on one-liner static method to help creating particle system set.
  147927. */
  147928. export class ParticleHelper {
  147929. /**
  147930. * Gets or sets base Assets URL
  147931. */
  147932. static BaseAssetsUrl: string;
  147933. /** Define the Url to load snippets */
  147934. static SnippetUrl: string;
  147935. /**
  147936. * Create a default particle system that you can tweak
  147937. * @param emitter defines the emitter to use
  147938. * @param capacity defines the system capacity (default is 500 particles)
  147939. * @param scene defines the hosting scene
  147940. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  147941. * @returns the new Particle system
  147942. */
  147943. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  147944. /**
  147945. * This is the main static method (one-liner) of this helper to create different particle systems
  147946. * @param type This string represents the type to the particle system to create
  147947. * @param scene The scene where the particle system should live
  147948. * @param gpu If the system will use gpu
  147949. * @returns the ParticleSystemSet created
  147950. */
  147951. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  147952. /**
  147953. * Static function used to export a particle system to a ParticleSystemSet variable.
  147954. * Please note that the emitter shape is not exported
  147955. * @param systems defines the particle systems to export
  147956. * @returns the created particle system set
  147957. */
  147958. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  147959. /**
  147960. * Creates a particle system from a snippet saved in a remote file
  147961. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  147962. * @param url defines the url to load from
  147963. * @param scene defines the hosting scene
  147964. * @param gpu If the system will use gpu
  147965. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147966. * @returns a promise that will resolve to the new particle system
  147967. */
  147968. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147969. /**
  147970. * Creates a particle system from a snippet saved by the particle system editor
  147971. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  147972. * @param scene defines the hosting scene
  147973. * @param gpu If the system will use gpu
  147974. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147975. * @returns a promise that will resolve to the new particle system
  147976. */
  147977. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147978. }
  147979. }
  147980. declare module BABYLON {
  147981. interface Engine {
  147982. /**
  147983. * Create an effect to use with particle systems.
  147984. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  147985. * the particle system for which you want to create a custom effect in the last parameter
  147986. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  147987. * @param uniformsNames defines a list of attribute names
  147988. * @param samplers defines an array of string used to represent textures
  147989. * @param defines defines the string containing the defines to use to compile the shaders
  147990. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  147991. * @param onCompiled defines a function to call when the effect creation is successful
  147992. * @param onError defines a function to call when the effect creation has failed
  147993. * @param particleSystem the particle system you want to create the effect for
  147994. * @returns the new Effect
  147995. */
  147996. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  147997. }
  147998. interface Mesh {
  147999. /**
  148000. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148001. * @returns an array of IParticleSystem
  148002. */
  148003. getEmittedParticleSystems(): IParticleSystem[];
  148004. /**
  148005. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148006. * @returns an array of IParticleSystem
  148007. */
  148008. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148009. }
  148010. }
  148011. declare module BABYLON {
  148012. /** Defines the 4 color options */
  148013. export enum PointColor {
  148014. /** color value */
  148015. Color = 2,
  148016. /** uv value */
  148017. UV = 1,
  148018. /** random value */
  148019. Random = 0,
  148020. /** stated value */
  148021. Stated = 3
  148022. }
  148023. /**
  148024. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148025. * 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.
  148026. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148027. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148028. *
  148029. * Full documentation here : TO BE ENTERED
  148030. */
  148031. export class PointsCloudSystem implements IDisposable {
  148032. /**
  148033. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148034. * Example : var p = SPS.particles[i];
  148035. */
  148036. particles: CloudPoint[];
  148037. /**
  148038. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148039. */
  148040. nbParticles: number;
  148041. /**
  148042. * This a counter for your own usage. It's not set by any SPS functions.
  148043. */
  148044. counter: number;
  148045. /**
  148046. * The PCS name. This name is also given to the underlying mesh.
  148047. */
  148048. name: string;
  148049. /**
  148050. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148051. */
  148052. mesh: Mesh;
  148053. /**
  148054. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148055. * Please read :
  148056. */
  148057. vars: any;
  148058. /**
  148059. * @hidden
  148060. */
  148061. _size: number;
  148062. private _scene;
  148063. private _promises;
  148064. private _positions;
  148065. private _indices;
  148066. private _normals;
  148067. private _colors;
  148068. private _uvs;
  148069. private _indices32;
  148070. private _positions32;
  148071. private _colors32;
  148072. private _uvs32;
  148073. private _updatable;
  148074. private _isVisibilityBoxLocked;
  148075. private _alwaysVisible;
  148076. private _groups;
  148077. private _groupCounter;
  148078. private _computeParticleColor;
  148079. private _computeParticleTexture;
  148080. private _computeParticleRotation;
  148081. private _computeBoundingBox;
  148082. private _isReady;
  148083. /**
  148084. * Creates a PCS (Points Cloud System) object
  148085. * @param name (String) is the PCS name, this will be the underlying mesh name
  148086. * @param pointSize (number) is the size for each point
  148087. * @param scene (Scene) is the scene in which the PCS is added
  148088. * @param options defines the options of the PCS e.g.
  148089. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148090. */
  148091. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148092. updatable?: boolean;
  148093. });
  148094. /**
  148095. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148096. * If no points were added to the PCS, the returned mesh is just a single point.
  148097. * @returns a promise for the created mesh
  148098. */
  148099. buildMeshAsync(): Promise<Mesh>;
  148100. /**
  148101. * @hidden
  148102. */
  148103. private _buildMesh;
  148104. private _addParticle;
  148105. private _randomUnitVector;
  148106. private _getColorIndicesForCoord;
  148107. private _setPointsColorOrUV;
  148108. private _colorFromTexture;
  148109. private _calculateDensity;
  148110. /**
  148111. * Adds points to the PCS in random positions within a unit sphere
  148112. * @param nb (positive integer) the number of particles to be created from this model
  148113. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148114. * @returns the number of groups in the system
  148115. */
  148116. addPoints(nb: number, pointFunction?: any): number;
  148117. /**
  148118. * Adds points to the PCS from the surface of the model shape
  148119. * @param mesh is any Mesh object that will be used as a surface model for the points
  148120. * @param nb (positive integer) the number of particles to be created from this model
  148121. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148122. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148123. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148124. * @returns the number of groups in the system
  148125. */
  148126. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148127. /**
  148128. * Adds points to the PCS inside the model shape
  148129. * @param mesh is any Mesh object that will be used as a surface model for the points
  148130. * @param nb (positive integer) the number of particles to be created from this model
  148131. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148132. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148133. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148134. * @returns the number of groups in the system
  148135. */
  148136. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148137. /**
  148138. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148139. * This method calls `updateParticle()` for each particle of the SPS.
  148140. * For an animated SPS, it is usually called within the render loop.
  148141. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148142. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148143. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148144. * @returns the PCS.
  148145. */
  148146. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148147. /**
  148148. * Disposes the PCS.
  148149. */
  148150. dispose(): void;
  148151. /**
  148152. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148153. * doc :
  148154. * @returns the PCS.
  148155. */
  148156. refreshVisibleSize(): PointsCloudSystem;
  148157. /**
  148158. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148159. * @param size the size (float) of the visibility box
  148160. * note : this doesn't lock the PCS mesh bounding box.
  148161. * doc :
  148162. */
  148163. setVisibilityBox(size: number): void;
  148164. /**
  148165. * Gets whether the PCS is always visible or not
  148166. * doc :
  148167. */
  148168. get isAlwaysVisible(): boolean;
  148169. /**
  148170. * Sets the PCS as always visible or not
  148171. * doc :
  148172. */
  148173. set isAlwaysVisible(val: boolean);
  148174. /**
  148175. * Tells to `setParticles()` to compute the particle rotations or not
  148176. * Default value : false. The PCS is faster when it's set to false
  148177. * Note : particle rotations are only applied to parent particles
  148178. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148179. */
  148180. set computeParticleRotation(val: boolean);
  148181. /**
  148182. * Tells to `setParticles()` to compute the particle colors or not.
  148183. * Default value : true. The PCS is faster when it's set to false.
  148184. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148185. */
  148186. set computeParticleColor(val: boolean);
  148187. set computeParticleTexture(val: boolean);
  148188. /**
  148189. * Gets if `setParticles()` computes the particle colors or not.
  148190. * Default value : false. The PCS is faster when it's set to false.
  148191. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148192. */
  148193. get computeParticleColor(): boolean;
  148194. /**
  148195. * Gets if `setParticles()` computes the particle textures or not.
  148196. * Default value : false. The PCS is faster when it's set to false.
  148197. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148198. */
  148199. get computeParticleTexture(): boolean;
  148200. /**
  148201. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148202. */
  148203. set computeBoundingBox(val: boolean);
  148204. /**
  148205. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148206. */
  148207. get computeBoundingBox(): boolean;
  148208. /**
  148209. * This function does nothing. It may be overwritten to set all the particle first values.
  148210. * The PCS doesn't call this function, you may have to call it by your own.
  148211. * doc :
  148212. */
  148213. initParticles(): void;
  148214. /**
  148215. * This function does nothing. It may be overwritten to recycle a particle
  148216. * The PCS doesn't call this function, you can to call it
  148217. * doc :
  148218. * @param particle The particle to recycle
  148219. * @returns the recycled particle
  148220. */
  148221. recycleParticle(particle: CloudPoint): CloudPoint;
  148222. /**
  148223. * Updates a particle : this function should be overwritten by the user.
  148224. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148225. * doc :
  148226. * @example : just set a particle position or velocity and recycle conditions
  148227. * @param particle The particle to update
  148228. * @returns the updated particle
  148229. */
  148230. updateParticle(particle: CloudPoint): CloudPoint;
  148231. /**
  148232. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148233. * This does nothing and may be overwritten by the user.
  148234. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148235. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148236. * @param update the boolean update value actually passed to setParticles()
  148237. */
  148238. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148239. /**
  148240. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148241. * This will be passed three parameters.
  148242. * This does nothing and may be overwritten by the user.
  148243. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148244. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148245. * @param update the boolean update value actually passed to setParticles()
  148246. */
  148247. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148248. }
  148249. }
  148250. declare module BABYLON {
  148251. /**
  148252. * Represents one particle of a points cloud system.
  148253. */
  148254. export class CloudPoint {
  148255. /**
  148256. * particle global index
  148257. */
  148258. idx: number;
  148259. /**
  148260. * The color of the particle
  148261. */
  148262. color: Nullable<Color4>;
  148263. /**
  148264. * The world space position of the particle.
  148265. */
  148266. position: Vector3;
  148267. /**
  148268. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148269. */
  148270. rotation: Vector3;
  148271. /**
  148272. * The world space rotation quaternion of the particle.
  148273. */
  148274. rotationQuaternion: Nullable<Quaternion>;
  148275. /**
  148276. * The uv of the particle.
  148277. */
  148278. uv: Nullable<Vector2>;
  148279. /**
  148280. * The current speed of the particle.
  148281. */
  148282. velocity: Vector3;
  148283. /**
  148284. * The pivot point in the particle local space.
  148285. */
  148286. pivot: Vector3;
  148287. /**
  148288. * Must the particle be translated from its pivot point in its local space ?
  148289. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148290. * Default : false
  148291. */
  148292. translateFromPivot: boolean;
  148293. /**
  148294. * Index of this particle in the global "positions" array (Internal use)
  148295. * @hidden
  148296. */
  148297. _pos: number;
  148298. /**
  148299. * @hidden Index of this particle in the global "indices" array (Internal use)
  148300. */
  148301. _ind: number;
  148302. /**
  148303. * Group this particle belongs to
  148304. */
  148305. _group: PointsGroup;
  148306. /**
  148307. * Group id of this particle
  148308. */
  148309. groupId: number;
  148310. /**
  148311. * Index of the particle in its group id (Internal use)
  148312. */
  148313. idxInGroup: number;
  148314. /**
  148315. * @hidden Particle BoundingInfo object (Internal use)
  148316. */
  148317. _boundingInfo: BoundingInfo;
  148318. /**
  148319. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148320. */
  148321. _pcs: PointsCloudSystem;
  148322. /**
  148323. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148324. */
  148325. _stillInvisible: boolean;
  148326. /**
  148327. * @hidden Last computed particle rotation matrix
  148328. */
  148329. _rotationMatrix: number[];
  148330. /**
  148331. * Parent particle Id, if any.
  148332. * Default null.
  148333. */
  148334. parentId: Nullable<number>;
  148335. /**
  148336. * @hidden Internal global position in the PCS.
  148337. */
  148338. _globalPosition: Vector3;
  148339. /**
  148340. * Creates a Point Cloud object.
  148341. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148342. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148343. * @param group (PointsGroup) is the group the particle belongs to
  148344. * @param groupId (integer) is the group identifier in the PCS.
  148345. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148346. * @param pcs defines the PCS it is associated to
  148347. */
  148348. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148349. /**
  148350. * get point size
  148351. */
  148352. get size(): Vector3;
  148353. /**
  148354. * Set point size
  148355. */
  148356. set size(scale: Vector3);
  148357. /**
  148358. * Legacy support, changed quaternion to rotationQuaternion
  148359. */
  148360. get quaternion(): Nullable<Quaternion>;
  148361. /**
  148362. * Legacy support, changed quaternion to rotationQuaternion
  148363. */
  148364. set quaternion(q: Nullable<Quaternion>);
  148365. /**
  148366. * Returns a boolean. True if the particle intersects a mesh, else false
  148367. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148368. * @param target is the object (point or mesh) what the intersection is computed against
  148369. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148370. * @returns true if it intersects
  148371. */
  148372. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148373. /**
  148374. * get the rotation matrix of the particle
  148375. * @hidden
  148376. */
  148377. getRotationMatrix(m: Matrix): void;
  148378. }
  148379. /**
  148380. * Represents a group of points in a points cloud system
  148381. * * PCS internal tool, don't use it manually.
  148382. */
  148383. export class PointsGroup {
  148384. /**
  148385. * The group id
  148386. * @hidden
  148387. */
  148388. groupID: number;
  148389. /**
  148390. * image data for group (internal use)
  148391. * @hidden
  148392. */
  148393. _groupImageData: Nullable<ArrayBufferView>;
  148394. /**
  148395. * Image Width (internal use)
  148396. * @hidden
  148397. */
  148398. _groupImgWidth: number;
  148399. /**
  148400. * Image Height (internal use)
  148401. * @hidden
  148402. */
  148403. _groupImgHeight: number;
  148404. /**
  148405. * Custom position function (internal use)
  148406. * @hidden
  148407. */
  148408. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148409. /**
  148410. * density per facet for surface points
  148411. * @hidden
  148412. */
  148413. _groupDensity: number[];
  148414. /**
  148415. * Only when points are colored by texture carries pointer to texture list array
  148416. * @hidden
  148417. */
  148418. _textureNb: number;
  148419. /**
  148420. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148421. * PCS internal tool, don't use it manually.
  148422. * @hidden
  148423. */
  148424. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148425. }
  148426. }
  148427. declare module BABYLON {
  148428. interface Scene {
  148429. /** @hidden (Backing field) */
  148430. _physicsEngine: Nullable<IPhysicsEngine>;
  148431. /** @hidden */
  148432. _physicsTimeAccumulator: number;
  148433. /**
  148434. * Gets the current physics engine
  148435. * @returns a IPhysicsEngine or null if none attached
  148436. */
  148437. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148438. /**
  148439. * Enables physics to the current scene
  148440. * @param gravity defines the scene's gravity for the physics engine
  148441. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148442. * @return a boolean indicating if the physics engine was initialized
  148443. */
  148444. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148445. /**
  148446. * Disables and disposes the physics engine associated with the scene
  148447. */
  148448. disablePhysicsEngine(): void;
  148449. /**
  148450. * Gets a boolean indicating if there is an active physics engine
  148451. * @returns a boolean indicating if there is an active physics engine
  148452. */
  148453. isPhysicsEnabled(): boolean;
  148454. /**
  148455. * Deletes a physics compound impostor
  148456. * @param compound defines the compound to delete
  148457. */
  148458. deleteCompoundImpostor(compound: any): void;
  148459. /**
  148460. * An event triggered when physic simulation is about to be run
  148461. */
  148462. onBeforePhysicsObservable: Observable<Scene>;
  148463. /**
  148464. * An event triggered when physic simulation has been done
  148465. */
  148466. onAfterPhysicsObservable: Observable<Scene>;
  148467. }
  148468. interface AbstractMesh {
  148469. /** @hidden */
  148470. _physicsImpostor: Nullable<PhysicsImpostor>;
  148471. /**
  148472. * Gets or sets impostor used for physic simulation
  148473. * @see https://doc.babylonjs.com/features/physics_engine
  148474. */
  148475. physicsImpostor: Nullable<PhysicsImpostor>;
  148476. /**
  148477. * Gets the current physics impostor
  148478. * @see https://doc.babylonjs.com/features/physics_engine
  148479. * @returns a physics impostor or null
  148480. */
  148481. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148482. /** Apply a physic impulse to the mesh
  148483. * @param force defines the force to apply
  148484. * @param contactPoint defines where to apply the force
  148485. * @returns the current mesh
  148486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148487. */
  148488. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148489. /**
  148490. * Creates a physic joint between two meshes
  148491. * @param otherMesh defines the other mesh to use
  148492. * @param pivot1 defines the pivot to use on this mesh
  148493. * @param pivot2 defines the pivot to use on the other mesh
  148494. * @param options defines additional options (can be plugin dependent)
  148495. * @returns the current mesh
  148496. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148497. */
  148498. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148499. /** @hidden */
  148500. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148501. }
  148502. /**
  148503. * Defines the physics engine scene component responsible to manage a physics engine
  148504. */
  148505. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148506. /**
  148507. * The component name helpful to identify the component in the list of scene components.
  148508. */
  148509. readonly name: string;
  148510. /**
  148511. * The scene the component belongs to.
  148512. */
  148513. scene: Scene;
  148514. /**
  148515. * Creates a new instance of the component for the given scene
  148516. * @param scene Defines the scene to register the component in
  148517. */
  148518. constructor(scene: Scene);
  148519. /**
  148520. * Registers the component in a given scene
  148521. */
  148522. register(): void;
  148523. /**
  148524. * Rebuilds the elements related to this component in case of
  148525. * context lost for instance.
  148526. */
  148527. rebuild(): void;
  148528. /**
  148529. * Disposes the component and the associated ressources
  148530. */
  148531. dispose(): void;
  148532. }
  148533. }
  148534. declare module BABYLON {
  148535. /**
  148536. * A helper for physics simulations
  148537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148538. */
  148539. export class PhysicsHelper {
  148540. private _scene;
  148541. private _physicsEngine;
  148542. /**
  148543. * Initializes the Physics helper
  148544. * @param scene Babylon.js scene
  148545. */
  148546. constructor(scene: Scene);
  148547. /**
  148548. * Applies a radial explosion impulse
  148549. * @param origin the origin of the explosion
  148550. * @param radiusOrEventOptions the radius or the options of radial explosion
  148551. * @param strength the explosion strength
  148552. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148553. * @returns A physics radial explosion event, or null
  148554. */
  148555. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148556. /**
  148557. * Applies a radial explosion force
  148558. * @param origin the origin of the explosion
  148559. * @param radiusOrEventOptions the radius or the options of radial explosion
  148560. * @param strength the explosion strength
  148561. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148562. * @returns A physics radial explosion event, or null
  148563. */
  148564. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148565. /**
  148566. * Creates a gravitational field
  148567. * @param origin the origin of the explosion
  148568. * @param radiusOrEventOptions the radius or the options of radial explosion
  148569. * @param strength the explosion strength
  148570. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148571. * @returns A physics gravitational field event, or null
  148572. */
  148573. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148574. /**
  148575. * Creates a physics updraft event
  148576. * @param origin the origin of the updraft
  148577. * @param radiusOrEventOptions the radius or the options of the updraft
  148578. * @param strength the strength of the updraft
  148579. * @param height the height of the updraft
  148580. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148581. * @returns A physics updraft event, or null
  148582. */
  148583. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148584. /**
  148585. * Creates a physics vortex event
  148586. * @param origin the of the vortex
  148587. * @param radiusOrEventOptions the radius or the options of the vortex
  148588. * @param strength the strength of the vortex
  148589. * @param height the height of the vortex
  148590. * @returns a Physics vortex event, or null
  148591. * A physics vortex event or null
  148592. */
  148593. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  148594. }
  148595. /**
  148596. * Represents a physics radial explosion event
  148597. */
  148598. class PhysicsRadialExplosionEvent {
  148599. private _scene;
  148600. private _options;
  148601. private _sphere;
  148602. private _dataFetched;
  148603. /**
  148604. * Initializes a radial explosioin event
  148605. * @param _scene BabylonJS scene
  148606. * @param _options The options for the vortex event
  148607. */
  148608. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  148609. /**
  148610. * Returns the data related to the radial explosion event (sphere).
  148611. * @returns The radial explosion event data
  148612. */
  148613. getData(): PhysicsRadialExplosionEventData;
  148614. /**
  148615. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  148616. * @param impostor A physics imposter
  148617. * @param origin the origin of the explosion
  148618. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  148619. */
  148620. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  148621. /**
  148622. * Triggers affecterd impostors callbacks
  148623. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  148624. */
  148625. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  148626. /**
  148627. * Disposes the sphere.
  148628. * @param force Specifies if the sphere should be disposed by force
  148629. */
  148630. dispose(force?: boolean): void;
  148631. /*** Helpers ***/
  148632. private _prepareSphere;
  148633. private _intersectsWithSphere;
  148634. }
  148635. /**
  148636. * Represents a gravitational field event
  148637. */
  148638. class PhysicsGravitationalFieldEvent {
  148639. private _physicsHelper;
  148640. private _scene;
  148641. private _origin;
  148642. private _options;
  148643. private _tickCallback;
  148644. private _sphere;
  148645. private _dataFetched;
  148646. /**
  148647. * Initializes the physics gravitational field event
  148648. * @param _physicsHelper A physics helper
  148649. * @param _scene BabylonJS scene
  148650. * @param _origin The origin position of the gravitational field event
  148651. * @param _options The options for the vortex event
  148652. */
  148653. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  148654. /**
  148655. * Returns the data related to the gravitational field event (sphere).
  148656. * @returns A gravitational field event
  148657. */
  148658. getData(): PhysicsGravitationalFieldEventData;
  148659. /**
  148660. * Enables the gravitational field.
  148661. */
  148662. enable(): void;
  148663. /**
  148664. * Disables the gravitational field.
  148665. */
  148666. disable(): void;
  148667. /**
  148668. * Disposes the sphere.
  148669. * @param force The force to dispose from the gravitational field event
  148670. */
  148671. dispose(force?: boolean): void;
  148672. private _tick;
  148673. }
  148674. /**
  148675. * Represents a physics updraft event
  148676. */
  148677. class PhysicsUpdraftEvent {
  148678. private _scene;
  148679. private _origin;
  148680. private _options;
  148681. private _physicsEngine;
  148682. private _originTop;
  148683. private _originDirection;
  148684. private _tickCallback;
  148685. private _cylinder;
  148686. private _cylinderPosition;
  148687. private _dataFetched;
  148688. /**
  148689. * Initializes the physics updraft event
  148690. * @param _scene BabylonJS scene
  148691. * @param _origin The origin position of the updraft
  148692. * @param _options The options for the updraft event
  148693. */
  148694. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  148695. /**
  148696. * Returns the data related to the updraft event (cylinder).
  148697. * @returns A physics updraft event
  148698. */
  148699. getData(): PhysicsUpdraftEventData;
  148700. /**
  148701. * Enables the updraft.
  148702. */
  148703. enable(): void;
  148704. /**
  148705. * Disables the updraft.
  148706. */
  148707. disable(): void;
  148708. /**
  148709. * Disposes the cylinder.
  148710. * @param force Specifies if the updraft should be disposed by force
  148711. */
  148712. dispose(force?: boolean): void;
  148713. private getImpostorHitData;
  148714. private _tick;
  148715. /*** Helpers ***/
  148716. private _prepareCylinder;
  148717. private _intersectsWithCylinder;
  148718. }
  148719. /**
  148720. * Represents a physics vortex event
  148721. */
  148722. class PhysicsVortexEvent {
  148723. private _scene;
  148724. private _origin;
  148725. private _options;
  148726. private _physicsEngine;
  148727. private _originTop;
  148728. private _tickCallback;
  148729. private _cylinder;
  148730. private _cylinderPosition;
  148731. private _dataFetched;
  148732. /**
  148733. * Initializes the physics vortex event
  148734. * @param _scene The BabylonJS scene
  148735. * @param _origin The origin position of the vortex
  148736. * @param _options The options for the vortex event
  148737. */
  148738. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  148739. /**
  148740. * Returns the data related to the vortex event (cylinder).
  148741. * @returns The physics vortex event data
  148742. */
  148743. getData(): PhysicsVortexEventData;
  148744. /**
  148745. * Enables the vortex.
  148746. */
  148747. enable(): void;
  148748. /**
  148749. * Disables the cortex.
  148750. */
  148751. disable(): void;
  148752. /**
  148753. * Disposes the sphere.
  148754. * @param force
  148755. */
  148756. dispose(force?: boolean): void;
  148757. private getImpostorHitData;
  148758. private _tick;
  148759. /*** Helpers ***/
  148760. private _prepareCylinder;
  148761. private _intersectsWithCylinder;
  148762. }
  148763. /**
  148764. * Options fot the radial explosion event
  148765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148766. */
  148767. export class PhysicsRadialExplosionEventOptions {
  148768. /**
  148769. * The radius of the sphere for the radial explosion.
  148770. */
  148771. radius: number;
  148772. /**
  148773. * The strenth of the explosion.
  148774. */
  148775. strength: number;
  148776. /**
  148777. * The strenght of the force in correspondence to the distance of the affected object
  148778. */
  148779. falloff: PhysicsRadialImpulseFalloff;
  148780. /**
  148781. * Sphere options for the radial explosion.
  148782. */
  148783. sphere: {
  148784. segments: number;
  148785. diameter: number;
  148786. };
  148787. /**
  148788. * Sphere options for the radial explosion.
  148789. */
  148790. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  148791. }
  148792. /**
  148793. * Options fot the updraft event
  148794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148795. */
  148796. export class PhysicsUpdraftEventOptions {
  148797. /**
  148798. * The radius of the cylinder for the vortex
  148799. */
  148800. radius: number;
  148801. /**
  148802. * The strenth of the updraft.
  148803. */
  148804. strength: number;
  148805. /**
  148806. * The height of the cylinder for the updraft.
  148807. */
  148808. height: number;
  148809. /**
  148810. * The mode for the the updraft.
  148811. */
  148812. updraftMode: PhysicsUpdraftMode;
  148813. }
  148814. /**
  148815. * Options fot the vortex event
  148816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148817. */
  148818. export class PhysicsVortexEventOptions {
  148819. /**
  148820. * The radius of the cylinder for the vortex
  148821. */
  148822. radius: number;
  148823. /**
  148824. * The strenth of the vortex.
  148825. */
  148826. strength: number;
  148827. /**
  148828. * The height of the cylinder for the vortex.
  148829. */
  148830. height: number;
  148831. /**
  148832. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  148833. */
  148834. centripetalForceThreshold: number;
  148835. /**
  148836. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  148837. */
  148838. centripetalForceMultiplier: number;
  148839. /**
  148840. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  148841. */
  148842. centrifugalForceMultiplier: number;
  148843. /**
  148844. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  148845. */
  148846. updraftForceMultiplier: number;
  148847. }
  148848. /**
  148849. * The strenght of the force in correspondence to the distance of the affected object
  148850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148851. */
  148852. export enum PhysicsRadialImpulseFalloff {
  148853. /** Defines that impulse is constant in strength across it's whole radius */
  148854. Constant = 0,
  148855. /** Defines that impulse gets weaker if it's further from the origin */
  148856. Linear = 1
  148857. }
  148858. /**
  148859. * The strength of the force in correspondence to the distance of the affected object
  148860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148861. */
  148862. export enum PhysicsUpdraftMode {
  148863. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  148864. Center = 0,
  148865. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  148866. Perpendicular = 1
  148867. }
  148868. /**
  148869. * Interface for a physics hit data
  148870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148871. */
  148872. export interface PhysicsHitData {
  148873. /**
  148874. * The force applied at the contact point
  148875. */
  148876. force: Vector3;
  148877. /**
  148878. * The contact point
  148879. */
  148880. contactPoint: Vector3;
  148881. /**
  148882. * The distance from the origin to the contact point
  148883. */
  148884. distanceFromOrigin: number;
  148885. }
  148886. /**
  148887. * Interface for radial explosion event data
  148888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148889. */
  148890. export interface PhysicsRadialExplosionEventData {
  148891. /**
  148892. * A sphere used for the radial explosion event
  148893. */
  148894. sphere: Mesh;
  148895. }
  148896. /**
  148897. * Interface for gravitational field event data
  148898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148899. */
  148900. export interface PhysicsGravitationalFieldEventData {
  148901. /**
  148902. * A sphere mesh used for the gravitational field event
  148903. */
  148904. sphere: Mesh;
  148905. }
  148906. /**
  148907. * Interface for updraft event data
  148908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148909. */
  148910. export interface PhysicsUpdraftEventData {
  148911. /**
  148912. * A cylinder used for the updraft event
  148913. */
  148914. cylinder: Mesh;
  148915. }
  148916. /**
  148917. * Interface for vortex event data
  148918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148919. */
  148920. export interface PhysicsVortexEventData {
  148921. /**
  148922. * A cylinder used for the vortex event
  148923. */
  148924. cylinder: Mesh;
  148925. }
  148926. /**
  148927. * Interface for an affected physics impostor
  148928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148929. */
  148930. export interface PhysicsAffectedImpostorWithData {
  148931. /**
  148932. * The impostor affected by the effect
  148933. */
  148934. impostor: PhysicsImpostor;
  148935. /**
  148936. * The data about the hit/horce from the explosion
  148937. */
  148938. hitData: PhysicsHitData;
  148939. }
  148940. }
  148941. declare module BABYLON {
  148942. /** @hidden */
  148943. export var blackAndWhitePixelShader: {
  148944. name: string;
  148945. shader: string;
  148946. };
  148947. }
  148948. declare module BABYLON {
  148949. /**
  148950. * Post process used to render in black and white
  148951. */
  148952. export class BlackAndWhitePostProcess extends PostProcess {
  148953. /**
  148954. * Linear about to convert he result to black and white (default: 1)
  148955. */
  148956. degree: number;
  148957. /**
  148958. * Gets a string identifying the name of the class
  148959. * @returns "BlackAndWhitePostProcess" string
  148960. */
  148961. getClassName(): string;
  148962. /**
  148963. * Creates a black and white post process
  148964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  148965. * @param name The name of the effect.
  148966. * @param options The required width/height ratio to downsize to before computing the render pass.
  148967. * @param camera The camera to apply the render pass to.
  148968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148969. * @param engine The engine which the post process will be applied. (default: current engine)
  148970. * @param reusable If the post process can be reused on the same frame. (default: false)
  148971. */
  148972. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148973. /** @hidden */
  148974. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  148975. }
  148976. }
  148977. declare module BABYLON {
  148978. /**
  148979. * This represents a set of one or more post processes in Babylon.
  148980. * A post process can be used to apply a shader to a texture after it is rendered.
  148981. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148982. */
  148983. export class PostProcessRenderEffect {
  148984. private _postProcesses;
  148985. private _getPostProcesses;
  148986. private _singleInstance;
  148987. private _cameras;
  148988. private _indicesForCamera;
  148989. /**
  148990. * Name of the effect
  148991. * @hidden
  148992. */
  148993. _name: string;
  148994. /**
  148995. * Instantiates a post process render effect.
  148996. * A post process can be used to apply a shader to a texture after it is rendered.
  148997. * @param engine The engine the effect is tied to
  148998. * @param name The name of the effect
  148999. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149000. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149001. */
  149002. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149003. /**
  149004. * Checks if all the post processes in the effect are supported.
  149005. */
  149006. get isSupported(): boolean;
  149007. /**
  149008. * Updates the current state of the effect
  149009. * @hidden
  149010. */
  149011. _update(): void;
  149012. /**
  149013. * Attaches the effect on cameras
  149014. * @param cameras The camera to attach to.
  149015. * @hidden
  149016. */
  149017. _attachCameras(cameras: Camera): void;
  149018. /**
  149019. * Attaches the effect on cameras
  149020. * @param cameras The camera to attach to.
  149021. * @hidden
  149022. */
  149023. _attachCameras(cameras: Camera[]): void;
  149024. /**
  149025. * Detaches the effect on cameras
  149026. * @param cameras The camera to detatch from.
  149027. * @hidden
  149028. */
  149029. _detachCameras(cameras: Camera): void;
  149030. /**
  149031. * Detatches the effect on cameras
  149032. * @param cameras The camera to detatch from.
  149033. * @hidden
  149034. */
  149035. _detachCameras(cameras: Camera[]): void;
  149036. /**
  149037. * Enables the effect on given cameras
  149038. * @param cameras The camera to enable.
  149039. * @hidden
  149040. */
  149041. _enable(cameras: Camera): void;
  149042. /**
  149043. * Enables the effect on given cameras
  149044. * @param cameras The camera to enable.
  149045. * @hidden
  149046. */
  149047. _enable(cameras: Nullable<Camera[]>): void;
  149048. /**
  149049. * Disables the effect on the given cameras
  149050. * @param cameras The camera to disable.
  149051. * @hidden
  149052. */
  149053. _disable(cameras: Camera): void;
  149054. /**
  149055. * Disables the effect on the given cameras
  149056. * @param cameras The camera to disable.
  149057. * @hidden
  149058. */
  149059. _disable(cameras: Nullable<Camera[]>): void;
  149060. /**
  149061. * Gets a list of the post processes contained in the effect.
  149062. * @param camera The camera to get the post processes on.
  149063. * @returns The list of the post processes in the effect.
  149064. */
  149065. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149066. }
  149067. }
  149068. declare module BABYLON {
  149069. /** @hidden */
  149070. export var extractHighlightsPixelShader: {
  149071. name: string;
  149072. shader: string;
  149073. };
  149074. }
  149075. declare module BABYLON {
  149076. /**
  149077. * 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.
  149078. */
  149079. export class ExtractHighlightsPostProcess extends PostProcess {
  149080. /**
  149081. * The luminance threshold, pixels below this value will be set to black.
  149082. */
  149083. threshold: number;
  149084. /** @hidden */
  149085. _exposure: number;
  149086. /**
  149087. * Post process which has the input texture to be used when performing highlight extraction
  149088. * @hidden
  149089. */
  149090. _inputPostProcess: Nullable<PostProcess>;
  149091. /**
  149092. * Gets a string identifying the name of the class
  149093. * @returns "ExtractHighlightsPostProcess" string
  149094. */
  149095. getClassName(): string;
  149096. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149097. }
  149098. }
  149099. declare module BABYLON {
  149100. /** @hidden */
  149101. export var bloomMergePixelShader: {
  149102. name: string;
  149103. shader: string;
  149104. };
  149105. }
  149106. declare module BABYLON {
  149107. /**
  149108. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149109. */
  149110. export class BloomMergePostProcess extends PostProcess {
  149111. /** Weight of the bloom to be added to the original input. */
  149112. weight: number;
  149113. /**
  149114. * Gets a string identifying the name of the class
  149115. * @returns "BloomMergePostProcess" string
  149116. */
  149117. getClassName(): string;
  149118. /**
  149119. * Creates a new instance of @see BloomMergePostProcess
  149120. * @param name The name of the effect.
  149121. * @param originalFromInput Post process which's input will be used for the merge.
  149122. * @param blurred Blurred highlights post process which's output will be used.
  149123. * @param weight Weight of the bloom to be added to the original input.
  149124. * @param options The required width/height ratio to downsize to before computing the render pass.
  149125. * @param camera The camera to apply the render pass to.
  149126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149127. * @param engine The engine which the post process will be applied. (default: current engine)
  149128. * @param reusable If the post process can be reused on the same frame. (default: false)
  149129. * @param textureType Type of textures used when performing the post process. (default: 0)
  149130. * @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)
  149131. */
  149132. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149133. /** Weight of the bloom to be added to the original input. */
  149134. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149135. }
  149136. }
  149137. declare module BABYLON {
  149138. /**
  149139. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149140. */
  149141. export class BloomEffect extends PostProcessRenderEffect {
  149142. private bloomScale;
  149143. /**
  149144. * @hidden Internal
  149145. */
  149146. _effects: Array<PostProcess>;
  149147. /**
  149148. * @hidden Internal
  149149. */
  149150. _downscale: ExtractHighlightsPostProcess;
  149151. private _blurX;
  149152. private _blurY;
  149153. private _merge;
  149154. /**
  149155. * The luminance threshold to find bright areas of the image to bloom.
  149156. */
  149157. get threshold(): number;
  149158. set threshold(value: number);
  149159. /**
  149160. * The strength of the bloom.
  149161. */
  149162. get weight(): number;
  149163. set weight(value: number);
  149164. /**
  149165. * Specifies the size of the bloom blur kernel, relative to the final output size
  149166. */
  149167. get kernel(): number;
  149168. set kernel(value: number);
  149169. /**
  149170. * Creates a new instance of @see BloomEffect
  149171. * @param scene The scene the effect belongs to.
  149172. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149173. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149174. * @param bloomWeight The the strength of bloom.
  149175. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149176. * @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)
  149177. */
  149178. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149179. /**
  149180. * Disposes each of the internal effects for a given camera.
  149181. * @param camera The camera to dispose the effect on.
  149182. */
  149183. disposeEffects(camera: Camera): void;
  149184. /**
  149185. * @hidden Internal
  149186. */
  149187. _updateEffects(): void;
  149188. /**
  149189. * Internal
  149190. * @returns if all the contained post processes are ready.
  149191. * @hidden
  149192. */
  149193. _isReady(): boolean;
  149194. }
  149195. }
  149196. declare module BABYLON {
  149197. /** @hidden */
  149198. export var chromaticAberrationPixelShader: {
  149199. name: string;
  149200. shader: string;
  149201. };
  149202. }
  149203. declare module BABYLON {
  149204. /**
  149205. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149206. */
  149207. export class ChromaticAberrationPostProcess extends PostProcess {
  149208. /**
  149209. * The amount of seperation of rgb channels (default: 30)
  149210. */
  149211. aberrationAmount: number;
  149212. /**
  149213. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149214. */
  149215. radialIntensity: number;
  149216. /**
  149217. * 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))
  149218. */
  149219. direction: Vector2;
  149220. /**
  149221. * 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))
  149222. */
  149223. centerPosition: Vector2;
  149224. /** The width of the screen to apply the effect on */
  149225. screenWidth: number;
  149226. /** The height of the screen to apply the effect on */
  149227. screenHeight: number;
  149228. /**
  149229. * Gets a string identifying the name of the class
  149230. * @returns "ChromaticAberrationPostProcess" string
  149231. */
  149232. getClassName(): string;
  149233. /**
  149234. * Creates a new instance ChromaticAberrationPostProcess
  149235. * @param name The name of the effect.
  149236. * @param screenWidth The width of the screen to apply the effect on.
  149237. * @param screenHeight The height of the screen to apply the effect on.
  149238. * @param options The required width/height ratio to downsize to before computing the render pass.
  149239. * @param camera The camera to apply the render pass to.
  149240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149241. * @param engine The engine which the post process will be applied. (default: current engine)
  149242. * @param reusable If the post process can be reused on the same frame. (default: false)
  149243. * @param textureType Type of textures used when performing the post process. (default: 0)
  149244. * @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)
  149245. */
  149246. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149247. /** @hidden */
  149248. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149249. }
  149250. }
  149251. declare module BABYLON {
  149252. /** @hidden */
  149253. export var circleOfConfusionPixelShader: {
  149254. name: string;
  149255. shader: string;
  149256. };
  149257. }
  149258. declare module BABYLON {
  149259. /**
  149260. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149261. */
  149262. export class CircleOfConfusionPostProcess extends PostProcess {
  149263. /**
  149264. * 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.
  149265. */
  149266. lensSize: number;
  149267. /**
  149268. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149269. */
  149270. fStop: number;
  149271. /**
  149272. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149273. */
  149274. focusDistance: number;
  149275. /**
  149276. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149277. */
  149278. focalLength: number;
  149279. /**
  149280. * Gets a string identifying the name of the class
  149281. * @returns "CircleOfConfusionPostProcess" string
  149282. */
  149283. getClassName(): string;
  149284. private _depthTexture;
  149285. /**
  149286. * Creates a new instance CircleOfConfusionPostProcess
  149287. * @param name The name of the effect.
  149288. * @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.
  149289. * @param options The required width/height ratio to downsize to before computing the render pass.
  149290. * @param camera The camera to apply the render pass to.
  149291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149292. * @param engine The engine which the post process will be applied. (default: current engine)
  149293. * @param reusable If the post process can be reused on the same frame. (default: false)
  149294. * @param textureType Type of textures used when performing the post process. (default: 0)
  149295. * @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)
  149296. */
  149297. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149298. /**
  149299. * 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.
  149300. */
  149301. set depthTexture(value: RenderTargetTexture);
  149302. }
  149303. }
  149304. declare module BABYLON {
  149305. /** @hidden */
  149306. export var colorCorrectionPixelShader: {
  149307. name: string;
  149308. shader: string;
  149309. };
  149310. }
  149311. declare module BABYLON {
  149312. /**
  149313. *
  149314. * This post-process allows the modification of rendered colors by using
  149315. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149316. *
  149317. * The object needs to be provided an url to a texture containing the color
  149318. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149319. * Use an image editing software to tweak the LUT to match your needs.
  149320. *
  149321. * For an example of a color LUT, see here:
  149322. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149323. * For explanations on color grading, see here:
  149324. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149325. *
  149326. */
  149327. export class ColorCorrectionPostProcess extends PostProcess {
  149328. private _colorTableTexture;
  149329. /**
  149330. * Gets the color table url used to create the LUT texture
  149331. */
  149332. colorTableUrl: string;
  149333. /**
  149334. * Gets a string identifying the name of the class
  149335. * @returns "ColorCorrectionPostProcess" string
  149336. */
  149337. getClassName(): string;
  149338. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149339. /** @hidden */
  149340. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149341. }
  149342. }
  149343. declare module BABYLON {
  149344. /** @hidden */
  149345. export var convolutionPixelShader: {
  149346. name: string;
  149347. shader: string;
  149348. };
  149349. }
  149350. declare module BABYLON {
  149351. /**
  149352. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149353. * input texture to perform effects such as edge detection or sharpening
  149354. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149355. */
  149356. export class ConvolutionPostProcess extends PostProcess {
  149357. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149358. kernel: number[];
  149359. /**
  149360. * Gets a string identifying the name of the class
  149361. * @returns "ConvolutionPostProcess" string
  149362. */
  149363. getClassName(): string;
  149364. /**
  149365. * Creates a new instance ConvolutionPostProcess
  149366. * @param name The name of the effect.
  149367. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149368. * @param options The required width/height ratio to downsize to before computing the render pass.
  149369. * @param camera The camera to apply the render pass to.
  149370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149371. * @param engine The engine which the post process will be applied. (default: current engine)
  149372. * @param reusable If the post process can be reused on the same frame. (default: false)
  149373. * @param textureType Type of textures used when performing the post process. (default: 0)
  149374. */
  149375. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149376. /** @hidden */
  149377. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149378. /**
  149379. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149380. */
  149381. static EdgeDetect0Kernel: number[];
  149382. /**
  149383. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149384. */
  149385. static EdgeDetect1Kernel: number[];
  149386. /**
  149387. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149388. */
  149389. static EdgeDetect2Kernel: number[];
  149390. /**
  149391. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149392. */
  149393. static SharpenKernel: number[];
  149394. /**
  149395. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149396. */
  149397. static EmbossKernel: number[];
  149398. /**
  149399. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149400. */
  149401. static GaussianKernel: number[];
  149402. }
  149403. }
  149404. declare module BABYLON {
  149405. /**
  149406. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149407. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149408. * based on samples that have a large difference in distance than the center pixel.
  149409. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149410. */
  149411. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149412. /**
  149413. * The direction the blur should be applied
  149414. */
  149415. direction: Vector2;
  149416. /**
  149417. * Gets a string identifying the name of the class
  149418. * @returns "DepthOfFieldBlurPostProcess" string
  149419. */
  149420. getClassName(): string;
  149421. /**
  149422. * Creates a new instance CircleOfConfusionPostProcess
  149423. * @param name The name of the effect.
  149424. * @param scene The scene the effect belongs to.
  149425. * @param direction The direction the blur should be applied.
  149426. * @param kernel The size of the kernel used to blur.
  149427. * @param options The required width/height ratio to downsize to before computing the render pass.
  149428. * @param camera The camera to apply the render pass to.
  149429. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149430. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149432. * @param engine The engine which the post process will be applied. (default: current engine)
  149433. * @param reusable If the post process can be reused on the same frame. (default: false)
  149434. * @param textureType Type of textures used when performing the post process. (default: 0)
  149435. * @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)
  149436. */
  149437. 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);
  149438. }
  149439. }
  149440. declare module BABYLON {
  149441. /** @hidden */
  149442. export var depthOfFieldMergePixelShader: {
  149443. name: string;
  149444. shader: string;
  149445. };
  149446. }
  149447. declare module BABYLON {
  149448. /**
  149449. * Options to be set when merging outputs from the default pipeline.
  149450. */
  149451. export class DepthOfFieldMergePostProcessOptions {
  149452. /**
  149453. * The original image to merge on top of
  149454. */
  149455. originalFromInput: PostProcess;
  149456. /**
  149457. * Parameters to perform the merge of the depth of field effect
  149458. */
  149459. depthOfField?: {
  149460. circleOfConfusion: PostProcess;
  149461. blurSteps: Array<PostProcess>;
  149462. };
  149463. /**
  149464. * Parameters to perform the merge of bloom effect
  149465. */
  149466. bloom?: {
  149467. blurred: PostProcess;
  149468. weight: number;
  149469. };
  149470. }
  149471. /**
  149472. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149473. */
  149474. export class DepthOfFieldMergePostProcess extends PostProcess {
  149475. private blurSteps;
  149476. /**
  149477. * Gets a string identifying the name of the class
  149478. * @returns "DepthOfFieldMergePostProcess" string
  149479. */
  149480. getClassName(): string;
  149481. /**
  149482. * Creates a new instance of DepthOfFieldMergePostProcess
  149483. * @param name The name of the effect.
  149484. * @param originalFromInput Post process which's input will be used for the merge.
  149485. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149486. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149487. * @param options The required width/height ratio to downsize to before computing the render pass.
  149488. * @param camera The camera to apply the render pass to.
  149489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149490. * @param engine The engine which the post process will be applied. (default: current engine)
  149491. * @param reusable If the post process can be reused on the same frame. (default: false)
  149492. * @param textureType Type of textures used when performing the post process. (default: 0)
  149493. * @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)
  149494. */
  149495. 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);
  149496. /**
  149497. * Updates the effect with the current post process compile time values and recompiles the shader.
  149498. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149499. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149500. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149501. * @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
  149502. * @param onCompiled Called when the shader has been compiled.
  149503. * @param onError Called if there is an error when compiling a shader.
  149504. */
  149505. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149506. }
  149507. }
  149508. declare module BABYLON {
  149509. /**
  149510. * Specifies the level of max blur that should be applied when using the depth of field effect
  149511. */
  149512. export enum DepthOfFieldEffectBlurLevel {
  149513. /**
  149514. * Subtle blur
  149515. */
  149516. Low = 0,
  149517. /**
  149518. * Medium blur
  149519. */
  149520. Medium = 1,
  149521. /**
  149522. * Large blur
  149523. */
  149524. High = 2
  149525. }
  149526. /**
  149527. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149528. */
  149529. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149530. private _circleOfConfusion;
  149531. /**
  149532. * @hidden Internal, blurs from high to low
  149533. */
  149534. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149535. private _depthOfFieldBlurY;
  149536. private _dofMerge;
  149537. /**
  149538. * @hidden Internal post processes in depth of field effect
  149539. */
  149540. _effects: Array<PostProcess>;
  149541. /**
  149542. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149543. */
  149544. set focalLength(value: number);
  149545. get focalLength(): number;
  149546. /**
  149547. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149548. */
  149549. set fStop(value: number);
  149550. get fStop(): number;
  149551. /**
  149552. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149553. */
  149554. set focusDistance(value: number);
  149555. get focusDistance(): number;
  149556. /**
  149557. * 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.
  149558. */
  149559. set lensSize(value: number);
  149560. get lensSize(): number;
  149561. /**
  149562. * Creates a new instance DepthOfFieldEffect
  149563. * @param scene The scene the effect belongs to.
  149564. * @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.
  149565. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149566. * @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)
  149567. */
  149568. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149569. /**
  149570. * Get the current class name of the current effet
  149571. * @returns "DepthOfFieldEffect"
  149572. */
  149573. getClassName(): string;
  149574. /**
  149575. * 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.
  149576. */
  149577. set depthTexture(value: RenderTargetTexture);
  149578. /**
  149579. * Disposes each of the internal effects for a given camera.
  149580. * @param camera The camera to dispose the effect on.
  149581. */
  149582. disposeEffects(camera: Camera): void;
  149583. /**
  149584. * @hidden Internal
  149585. */
  149586. _updateEffects(): void;
  149587. /**
  149588. * Internal
  149589. * @returns if all the contained post processes are ready.
  149590. * @hidden
  149591. */
  149592. _isReady(): boolean;
  149593. }
  149594. }
  149595. declare module BABYLON {
  149596. /** @hidden */
  149597. export var displayPassPixelShader: {
  149598. name: string;
  149599. shader: string;
  149600. };
  149601. }
  149602. declare module BABYLON {
  149603. /**
  149604. * DisplayPassPostProcess which produces an output the same as it's input
  149605. */
  149606. export class DisplayPassPostProcess extends PostProcess {
  149607. /**
  149608. * Gets a string identifying the name of the class
  149609. * @returns "DisplayPassPostProcess" string
  149610. */
  149611. getClassName(): string;
  149612. /**
  149613. * Creates the DisplayPassPostProcess
  149614. * @param name The name of the effect.
  149615. * @param options The required width/height ratio to downsize to before computing the render pass.
  149616. * @param camera The camera to apply the render pass to.
  149617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149618. * @param engine The engine which the post process will be applied. (default: current engine)
  149619. * @param reusable If the post process can be reused on the same frame. (default: false)
  149620. */
  149621. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149622. /** @hidden */
  149623. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  149624. }
  149625. }
  149626. declare module BABYLON {
  149627. /** @hidden */
  149628. export var filterPixelShader: {
  149629. name: string;
  149630. shader: string;
  149631. };
  149632. }
  149633. declare module BABYLON {
  149634. /**
  149635. * Applies a kernel filter to the image
  149636. */
  149637. export class FilterPostProcess extends PostProcess {
  149638. /** The matrix to be applied to the image */
  149639. kernelMatrix: Matrix;
  149640. /**
  149641. * Gets a string identifying the name of the class
  149642. * @returns "FilterPostProcess" string
  149643. */
  149644. getClassName(): string;
  149645. /**
  149646. *
  149647. * @param name The name of the effect.
  149648. * @param kernelMatrix The matrix to be applied to the image
  149649. * @param options The required width/height ratio to downsize to before computing the render pass.
  149650. * @param camera The camera to apply the render pass to.
  149651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149652. * @param engine The engine which the post process will be applied. (default: current engine)
  149653. * @param reusable If the post process can be reused on the same frame. (default: false)
  149654. */
  149655. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149656. /** @hidden */
  149657. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  149658. }
  149659. }
  149660. declare module BABYLON {
  149661. /** @hidden */
  149662. export var fxaaPixelShader: {
  149663. name: string;
  149664. shader: string;
  149665. };
  149666. }
  149667. declare module BABYLON {
  149668. /** @hidden */
  149669. export var fxaaVertexShader: {
  149670. name: string;
  149671. shader: string;
  149672. };
  149673. }
  149674. declare module BABYLON {
  149675. /**
  149676. * Fxaa post process
  149677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  149678. */
  149679. export class FxaaPostProcess extends PostProcess {
  149680. /**
  149681. * Gets a string identifying the name of the class
  149682. * @returns "FxaaPostProcess" string
  149683. */
  149684. getClassName(): string;
  149685. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149686. private _getDefines;
  149687. /** @hidden */
  149688. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  149689. }
  149690. }
  149691. declare module BABYLON {
  149692. /** @hidden */
  149693. export var grainPixelShader: {
  149694. name: string;
  149695. shader: string;
  149696. };
  149697. }
  149698. declare module BABYLON {
  149699. /**
  149700. * The GrainPostProcess adds noise to the image at mid luminance levels
  149701. */
  149702. export class GrainPostProcess extends PostProcess {
  149703. /**
  149704. * The intensity of the grain added (default: 30)
  149705. */
  149706. intensity: number;
  149707. /**
  149708. * If the grain should be randomized on every frame
  149709. */
  149710. animated: boolean;
  149711. /**
  149712. * Gets a string identifying the name of the class
  149713. * @returns "GrainPostProcess" string
  149714. */
  149715. getClassName(): string;
  149716. /**
  149717. * Creates a new instance of @see GrainPostProcess
  149718. * @param name The name of the effect.
  149719. * @param options The required width/height ratio to downsize to before computing the render pass.
  149720. * @param camera The camera to apply the render pass to.
  149721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149722. * @param engine The engine which the post process will be applied. (default: current engine)
  149723. * @param reusable If the post process can be reused on the same frame. (default: false)
  149724. * @param textureType Type of textures used when performing the post process. (default: 0)
  149725. * @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)
  149726. */
  149727. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149728. /** @hidden */
  149729. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  149730. }
  149731. }
  149732. declare module BABYLON {
  149733. /** @hidden */
  149734. export var highlightsPixelShader: {
  149735. name: string;
  149736. shader: string;
  149737. };
  149738. }
  149739. declare module BABYLON {
  149740. /**
  149741. * Extracts highlights from the image
  149742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149743. */
  149744. export class HighlightsPostProcess extends PostProcess {
  149745. /**
  149746. * Gets a string identifying the name of the class
  149747. * @returns "HighlightsPostProcess" string
  149748. */
  149749. getClassName(): string;
  149750. /**
  149751. * Extracts highlights from the image
  149752. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149753. * @param name The name of the effect.
  149754. * @param options The required width/height ratio to downsize to before computing the render pass.
  149755. * @param camera The camera to apply the render pass to.
  149756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149757. * @param engine The engine which the post process will be applied. (default: current engine)
  149758. * @param reusable If the post process can be reused on the same frame. (default: false)
  149759. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  149760. */
  149761. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149762. }
  149763. }
  149764. declare module BABYLON {
  149765. /** @hidden */
  149766. export var mrtFragmentDeclaration: {
  149767. name: string;
  149768. shader: string;
  149769. };
  149770. }
  149771. declare module BABYLON {
  149772. /** @hidden */
  149773. export var geometryPixelShader: {
  149774. name: string;
  149775. shader: string;
  149776. };
  149777. }
  149778. declare module BABYLON {
  149779. /** @hidden */
  149780. export var geometryVertexShader: {
  149781. name: string;
  149782. shader: string;
  149783. };
  149784. }
  149785. declare module BABYLON {
  149786. /** @hidden */
  149787. interface ISavedTransformationMatrix {
  149788. world: Matrix;
  149789. viewProjection: Matrix;
  149790. }
  149791. /**
  149792. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  149793. */
  149794. export class GeometryBufferRenderer {
  149795. /**
  149796. * Constant used to retrieve the position texture index in the G-Buffer textures array
  149797. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  149798. */
  149799. static readonly POSITION_TEXTURE_TYPE: number;
  149800. /**
  149801. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  149802. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  149803. */
  149804. static readonly VELOCITY_TEXTURE_TYPE: number;
  149805. /**
  149806. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  149807. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  149808. */
  149809. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  149810. /**
  149811. * Dictionary used to store the previous transformation matrices of each rendered mesh
  149812. * in order to compute objects velocities when enableVelocity is set to "true"
  149813. * @hidden
  149814. */
  149815. _previousTransformationMatrices: {
  149816. [index: number]: ISavedTransformationMatrix;
  149817. };
  149818. /**
  149819. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  149820. * in order to compute objects velocities when enableVelocity is set to "true"
  149821. * @hidden
  149822. */
  149823. _previousBonesTransformationMatrices: {
  149824. [index: number]: Float32Array;
  149825. };
  149826. /**
  149827. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  149828. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  149829. */
  149830. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  149831. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  149832. renderTransparentMeshes: boolean;
  149833. private _scene;
  149834. private _resizeObserver;
  149835. private _multiRenderTarget;
  149836. private _ratio;
  149837. private _enablePosition;
  149838. private _enableVelocity;
  149839. private _enableReflectivity;
  149840. private _positionIndex;
  149841. private _velocityIndex;
  149842. private _reflectivityIndex;
  149843. protected _effect: Effect;
  149844. protected _cachedDefines: string;
  149845. /**
  149846. * Set the render list (meshes to be rendered) used in the G buffer.
  149847. */
  149848. set renderList(meshes: Mesh[]);
  149849. /**
  149850. * Gets wether or not G buffer are supported by the running hardware.
  149851. * This requires draw buffer supports
  149852. */
  149853. get isSupported(): boolean;
  149854. /**
  149855. * Returns the index of the given texture type in the G-Buffer textures array
  149856. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  149857. * @returns the index of the given texture type in the G-Buffer textures array
  149858. */
  149859. getTextureIndex(textureType: number): number;
  149860. /**
  149861. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  149862. */
  149863. get enablePosition(): boolean;
  149864. /**
  149865. * Sets whether or not objects positions are enabled for the G buffer.
  149866. */
  149867. set enablePosition(enable: boolean);
  149868. /**
  149869. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  149870. */
  149871. get enableVelocity(): boolean;
  149872. /**
  149873. * Sets wether or not objects velocities are enabled for the G buffer.
  149874. */
  149875. set enableVelocity(enable: boolean);
  149876. /**
  149877. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  149878. */
  149879. get enableReflectivity(): boolean;
  149880. /**
  149881. * Sets wether or not objects roughness are enabled for the G buffer.
  149882. */
  149883. set enableReflectivity(enable: boolean);
  149884. /**
  149885. * Gets the scene associated with the buffer.
  149886. */
  149887. get scene(): Scene;
  149888. /**
  149889. * Gets the ratio used by the buffer during its creation.
  149890. * How big is the buffer related to the main canvas.
  149891. */
  149892. get ratio(): number;
  149893. /** @hidden */
  149894. static _SceneComponentInitialization: (scene: Scene) => void;
  149895. /**
  149896. * Creates a new G Buffer for the scene
  149897. * @param scene The scene the buffer belongs to
  149898. * @param ratio How big is the buffer related to the main canvas.
  149899. */
  149900. constructor(scene: Scene, ratio?: number);
  149901. /**
  149902. * Checks wether everything is ready to render a submesh to the G buffer.
  149903. * @param subMesh the submesh to check readiness for
  149904. * @param useInstances is the mesh drawn using instance or not
  149905. * @returns true if ready otherwise false
  149906. */
  149907. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149908. /**
  149909. * Gets the current underlying G Buffer.
  149910. * @returns the buffer
  149911. */
  149912. getGBuffer(): MultiRenderTarget;
  149913. /**
  149914. * Gets the number of samples used to render the buffer (anti aliasing).
  149915. */
  149916. get samples(): number;
  149917. /**
  149918. * Sets the number of samples used to render the buffer (anti aliasing).
  149919. */
  149920. set samples(value: number);
  149921. /**
  149922. * Disposes the renderer and frees up associated resources.
  149923. */
  149924. dispose(): void;
  149925. protected _createRenderTargets(): void;
  149926. private _copyBonesTransformationMatrices;
  149927. }
  149928. }
  149929. declare module BABYLON {
  149930. interface Scene {
  149931. /** @hidden (Backing field) */
  149932. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149933. /**
  149934. * Gets or Sets the current geometry buffer associated to the scene.
  149935. */
  149936. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149937. /**
  149938. * Enables a GeometryBufferRender and associates it with the scene
  149939. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  149940. * @returns the GeometryBufferRenderer
  149941. */
  149942. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  149943. /**
  149944. * Disables the GeometryBufferRender associated with the scene
  149945. */
  149946. disableGeometryBufferRenderer(): void;
  149947. }
  149948. /**
  149949. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149950. * in several rendering techniques.
  149951. */
  149952. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  149953. /**
  149954. * The component name helpful to identify the component in the list of scene components.
  149955. */
  149956. readonly name: string;
  149957. /**
  149958. * The scene the component belongs to.
  149959. */
  149960. scene: Scene;
  149961. /**
  149962. * Creates a new instance of the component for the given scene
  149963. * @param scene Defines the scene to register the component in
  149964. */
  149965. constructor(scene: Scene);
  149966. /**
  149967. * Registers the component in a given scene
  149968. */
  149969. register(): void;
  149970. /**
  149971. * Rebuilds the elements related to this component in case of
  149972. * context lost for instance.
  149973. */
  149974. rebuild(): void;
  149975. /**
  149976. * Disposes the component and the associated ressources
  149977. */
  149978. dispose(): void;
  149979. private _gatherRenderTargets;
  149980. }
  149981. }
  149982. declare module BABYLON {
  149983. /** @hidden */
  149984. export var motionBlurPixelShader: {
  149985. name: string;
  149986. shader: string;
  149987. };
  149988. }
  149989. declare module BABYLON {
  149990. /**
  149991. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  149992. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  149993. * As an example, all you have to do is to create the post-process:
  149994. * var mb = new BABYLON.MotionBlurPostProcess(
  149995. * 'mb', // The name of the effect.
  149996. * scene, // The scene containing the objects to blur according to their velocity.
  149997. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  149998. * camera // The camera to apply the render pass to.
  149999. * );
  150000. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150001. */
  150002. export class MotionBlurPostProcess extends PostProcess {
  150003. /**
  150004. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150005. */
  150006. motionStrength: number;
  150007. /**
  150008. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150009. */
  150010. get motionBlurSamples(): number;
  150011. /**
  150012. * Sets the number of iterations to be used for motion blur quality
  150013. */
  150014. set motionBlurSamples(samples: number);
  150015. private _motionBlurSamples;
  150016. private _geometryBufferRenderer;
  150017. /**
  150018. * Gets a string identifying the name of the class
  150019. * @returns "MotionBlurPostProcess" string
  150020. */
  150021. getClassName(): string;
  150022. /**
  150023. * Creates a new instance MotionBlurPostProcess
  150024. * @param name The name of the effect.
  150025. * @param scene The scene containing the objects to blur according to their velocity.
  150026. * @param options The required width/height ratio to downsize to before computing the render pass.
  150027. * @param camera The camera to apply the render pass to.
  150028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150029. * @param engine The engine which the post process will be applied. (default: current engine)
  150030. * @param reusable If the post process can be reused on the same frame. (default: false)
  150031. * @param textureType Type of textures used when performing the post process. (default: 0)
  150032. * @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)
  150033. */
  150034. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150035. /**
  150036. * Excludes the given skinned mesh from computing bones velocities.
  150037. * 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.
  150038. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150039. */
  150040. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150041. /**
  150042. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150043. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150044. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150045. */
  150046. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150047. /**
  150048. * Disposes the post process.
  150049. * @param camera The camera to dispose the post process on.
  150050. */
  150051. dispose(camera?: Camera): void;
  150052. /** @hidden */
  150053. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150054. }
  150055. }
  150056. declare module BABYLON {
  150057. /** @hidden */
  150058. export var refractionPixelShader: {
  150059. name: string;
  150060. shader: string;
  150061. };
  150062. }
  150063. declare module BABYLON {
  150064. /**
  150065. * Post process which applies a refractin texture
  150066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150067. */
  150068. export class RefractionPostProcess extends PostProcess {
  150069. private _refTexture;
  150070. private _ownRefractionTexture;
  150071. /** the base color of the refraction (used to taint the rendering) */
  150072. color: Color3;
  150073. /** simulated refraction depth */
  150074. depth: number;
  150075. /** the coefficient of the base color (0 to remove base color tainting) */
  150076. colorLevel: number;
  150077. /** Gets the url used to load the refraction texture */
  150078. refractionTextureUrl: string;
  150079. /**
  150080. * Gets or sets the refraction texture
  150081. * Please note that you are responsible for disposing the texture if you set it manually
  150082. */
  150083. get refractionTexture(): Texture;
  150084. set refractionTexture(value: Texture);
  150085. /**
  150086. * Gets a string identifying the name of the class
  150087. * @returns "RefractionPostProcess" string
  150088. */
  150089. getClassName(): string;
  150090. /**
  150091. * Initializes the RefractionPostProcess
  150092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150093. * @param name The name of the effect.
  150094. * @param refractionTextureUrl Url of the refraction texture to use
  150095. * @param color the base color of the refraction (used to taint the rendering)
  150096. * @param depth simulated refraction depth
  150097. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150098. * @param camera The camera to apply the render pass to.
  150099. * @param options The required width/height ratio to downsize to before computing the render pass.
  150100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150101. * @param engine The engine which the post process will be applied. (default: current engine)
  150102. * @param reusable If the post process can be reused on the same frame. (default: false)
  150103. */
  150104. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150105. /**
  150106. * Disposes of the post process
  150107. * @param camera Camera to dispose post process on
  150108. */
  150109. dispose(camera: Camera): void;
  150110. /** @hidden */
  150111. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150112. }
  150113. }
  150114. declare module BABYLON {
  150115. /** @hidden */
  150116. export var sharpenPixelShader: {
  150117. name: string;
  150118. shader: string;
  150119. };
  150120. }
  150121. declare module BABYLON {
  150122. /**
  150123. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150124. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150125. */
  150126. export class SharpenPostProcess extends PostProcess {
  150127. /**
  150128. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150129. */
  150130. colorAmount: number;
  150131. /**
  150132. * How much sharpness should be applied (default: 0.3)
  150133. */
  150134. edgeAmount: number;
  150135. /**
  150136. * Gets a string identifying the name of the class
  150137. * @returns "SharpenPostProcess" string
  150138. */
  150139. getClassName(): string;
  150140. /**
  150141. * Creates a new instance ConvolutionPostProcess
  150142. * @param name The name of the effect.
  150143. * @param options The required width/height ratio to downsize to before computing the render pass.
  150144. * @param camera The camera to apply the render pass to.
  150145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150146. * @param engine The engine which the post process will be applied. (default: current engine)
  150147. * @param reusable If the post process can be reused on the same frame. (default: false)
  150148. * @param textureType Type of textures used when performing the post process. (default: 0)
  150149. * @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)
  150150. */
  150151. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150152. /** @hidden */
  150153. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150154. }
  150155. }
  150156. declare module BABYLON {
  150157. /**
  150158. * PostProcessRenderPipeline
  150159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150160. */
  150161. export class PostProcessRenderPipeline {
  150162. private engine;
  150163. private _renderEffects;
  150164. private _renderEffectsForIsolatedPass;
  150165. /**
  150166. * List of inspectable custom properties (used by the Inspector)
  150167. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150168. */
  150169. inspectableCustomProperties: IInspectable[];
  150170. /**
  150171. * @hidden
  150172. */
  150173. protected _cameras: Camera[];
  150174. /** @hidden */
  150175. _name: string;
  150176. /**
  150177. * Gets pipeline name
  150178. */
  150179. get name(): string;
  150180. /** Gets the list of attached cameras */
  150181. get cameras(): Camera[];
  150182. /**
  150183. * Initializes a PostProcessRenderPipeline
  150184. * @param engine engine to add the pipeline to
  150185. * @param name name of the pipeline
  150186. */
  150187. constructor(engine: Engine, name: string);
  150188. /**
  150189. * Gets the class name
  150190. * @returns "PostProcessRenderPipeline"
  150191. */
  150192. getClassName(): string;
  150193. /**
  150194. * If all the render effects in the pipeline are supported
  150195. */
  150196. get isSupported(): boolean;
  150197. /**
  150198. * Adds an effect to the pipeline
  150199. * @param renderEffect the effect to add
  150200. */
  150201. addEffect(renderEffect: PostProcessRenderEffect): void;
  150202. /** @hidden */
  150203. _rebuild(): void;
  150204. /** @hidden */
  150205. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150206. /** @hidden */
  150207. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150208. /** @hidden */
  150209. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150210. /** @hidden */
  150211. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150212. /** @hidden */
  150213. _attachCameras(cameras: Camera, unique: boolean): void;
  150214. /** @hidden */
  150215. _attachCameras(cameras: Camera[], unique: boolean): void;
  150216. /** @hidden */
  150217. _detachCameras(cameras: Camera): void;
  150218. /** @hidden */
  150219. _detachCameras(cameras: Nullable<Camera[]>): void;
  150220. /** @hidden */
  150221. _update(): void;
  150222. /** @hidden */
  150223. _reset(): void;
  150224. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150225. /**
  150226. * Sets the required values to the prepass renderer.
  150227. * @param prePassRenderer defines the prepass renderer to setup.
  150228. * @returns true if the pre pass is needed.
  150229. */
  150230. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150231. /**
  150232. * Disposes of the pipeline
  150233. */
  150234. dispose(): void;
  150235. }
  150236. }
  150237. declare module BABYLON {
  150238. /**
  150239. * PostProcessRenderPipelineManager class
  150240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150241. */
  150242. export class PostProcessRenderPipelineManager {
  150243. private _renderPipelines;
  150244. /**
  150245. * Initializes a PostProcessRenderPipelineManager
  150246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150247. */
  150248. constructor();
  150249. /**
  150250. * Gets the list of supported render pipelines
  150251. */
  150252. get supportedPipelines(): PostProcessRenderPipeline[];
  150253. /**
  150254. * Adds a pipeline to the manager
  150255. * @param renderPipeline The pipeline to add
  150256. */
  150257. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150258. /**
  150259. * Attaches a camera to the pipeline
  150260. * @param renderPipelineName The name of the pipeline to attach to
  150261. * @param cameras the camera to attach
  150262. * @param unique if the camera can be attached multiple times to the pipeline
  150263. */
  150264. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150265. /**
  150266. * Detaches a camera from the pipeline
  150267. * @param renderPipelineName The name of the pipeline to detach from
  150268. * @param cameras the camera to detach
  150269. */
  150270. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150271. /**
  150272. * Enables an effect by name on a pipeline
  150273. * @param renderPipelineName the name of the pipeline to enable the effect in
  150274. * @param renderEffectName the name of the effect to enable
  150275. * @param cameras the cameras that the effect should be enabled on
  150276. */
  150277. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150278. /**
  150279. * Disables an effect by name on a pipeline
  150280. * @param renderPipelineName the name of the pipeline to disable the effect in
  150281. * @param renderEffectName the name of the effect to disable
  150282. * @param cameras the cameras that the effect should be disabled on
  150283. */
  150284. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150285. /**
  150286. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150287. */
  150288. update(): void;
  150289. /** @hidden */
  150290. _rebuild(): void;
  150291. /**
  150292. * Disposes of the manager and pipelines
  150293. */
  150294. dispose(): void;
  150295. }
  150296. }
  150297. declare module BABYLON {
  150298. interface Scene {
  150299. /** @hidden (Backing field) */
  150300. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150301. /**
  150302. * Gets the postprocess render pipeline manager
  150303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150304. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150305. */
  150306. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150307. }
  150308. /**
  150309. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150310. */
  150311. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150312. /**
  150313. * The component name helpfull to identify the component in the list of scene components.
  150314. */
  150315. readonly name: string;
  150316. /**
  150317. * The scene the component belongs to.
  150318. */
  150319. scene: Scene;
  150320. /**
  150321. * Creates a new instance of the component for the given scene
  150322. * @param scene Defines the scene to register the component in
  150323. */
  150324. constructor(scene: Scene);
  150325. /**
  150326. * Registers the component in a given scene
  150327. */
  150328. register(): void;
  150329. /**
  150330. * Rebuilds the elements related to this component in case of
  150331. * context lost for instance.
  150332. */
  150333. rebuild(): void;
  150334. /**
  150335. * Disposes the component and the associated ressources
  150336. */
  150337. dispose(): void;
  150338. private _gatherRenderTargets;
  150339. }
  150340. }
  150341. declare module BABYLON {
  150342. /**
  150343. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150344. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150345. */
  150346. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150347. private _scene;
  150348. private _camerasToBeAttached;
  150349. /**
  150350. * ID of the sharpen post process,
  150351. */
  150352. private readonly SharpenPostProcessId;
  150353. /**
  150354. * @ignore
  150355. * ID of the image processing post process;
  150356. */
  150357. readonly ImageProcessingPostProcessId: string;
  150358. /**
  150359. * @ignore
  150360. * ID of the Fast Approximate Anti-Aliasing post process;
  150361. */
  150362. readonly FxaaPostProcessId: string;
  150363. /**
  150364. * ID of the chromatic aberration post process,
  150365. */
  150366. private readonly ChromaticAberrationPostProcessId;
  150367. /**
  150368. * ID of the grain post process
  150369. */
  150370. private readonly GrainPostProcessId;
  150371. /**
  150372. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150373. */
  150374. sharpen: SharpenPostProcess;
  150375. private _sharpenEffect;
  150376. private bloom;
  150377. /**
  150378. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150379. */
  150380. depthOfField: DepthOfFieldEffect;
  150381. /**
  150382. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150383. */
  150384. fxaa: FxaaPostProcess;
  150385. /**
  150386. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150387. */
  150388. imageProcessing: ImageProcessingPostProcess;
  150389. /**
  150390. * Chromatic aberration post process which will shift rgb colors in the image
  150391. */
  150392. chromaticAberration: ChromaticAberrationPostProcess;
  150393. private _chromaticAberrationEffect;
  150394. /**
  150395. * Grain post process which add noise to the image
  150396. */
  150397. grain: GrainPostProcess;
  150398. private _grainEffect;
  150399. /**
  150400. * Glow post process which adds a glow to emissive areas of the image
  150401. */
  150402. private _glowLayer;
  150403. /**
  150404. * Animations which can be used to tweak settings over a period of time
  150405. */
  150406. animations: Animation[];
  150407. private _imageProcessingConfigurationObserver;
  150408. private _sharpenEnabled;
  150409. private _bloomEnabled;
  150410. private _depthOfFieldEnabled;
  150411. private _depthOfFieldBlurLevel;
  150412. private _fxaaEnabled;
  150413. private _imageProcessingEnabled;
  150414. private _defaultPipelineTextureType;
  150415. private _bloomScale;
  150416. private _chromaticAberrationEnabled;
  150417. private _grainEnabled;
  150418. private _buildAllowed;
  150419. /**
  150420. * Gets active scene
  150421. */
  150422. get scene(): Scene;
  150423. /**
  150424. * Enable or disable the sharpen process from the pipeline
  150425. */
  150426. set sharpenEnabled(enabled: boolean);
  150427. get sharpenEnabled(): boolean;
  150428. private _resizeObserver;
  150429. private _hardwareScaleLevel;
  150430. private _bloomKernel;
  150431. /**
  150432. * Specifies the size of the bloom blur kernel, relative to the final output size
  150433. */
  150434. get bloomKernel(): number;
  150435. set bloomKernel(value: number);
  150436. /**
  150437. * Specifies the weight of the bloom in the final rendering
  150438. */
  150439. private _bloomWeight;
  150440. /**
  150441. * Specifies the luma threshold for the area that will be blurred by the bloom
  150442. */
  150443. private _bloomThreshold;
  150444. private _hdr;
  150445. /**
  150446. * The strength of the bloom.
  150447. */
  150448. set bloomWeight(value: number);
  150449. get bloomWeight(): number;
  150450. /**
  150451. * The strength of the bloom.
  150452. */
  150453. set bloomThreshold(value: number);
  150454. get bloomThreshold(): number;
  150455. /**
  150456. * The scale of the bloom, lower value will provide better performance.
  150457. */
  150458. set bloomScale(value: number);
  150459. get bloomScale(): number;
  150460. /**
  150461. * Enable or disable the bloom from the pipeline
  150462. */
  150463. set bloomEnabled(enabled: boolean);
  150464. get bloomEnabled(): boolean;
  150465. private _rebuildBloom;
  150466. /**
  150467. * If the depth of field is enabled.
  150468. */
  150469. get depthOfFieldEnabled(): boolean;
  150470. set depthOfFieldEnabled(enabled: boolean);
  150471. /**
  150472. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150473. */
  150474. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150475. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150476. /**
  150477. * If the anti aliasing is enabled.
  150478. */
  150479. set fxaaEnabled(enabled: boolean);
  150480. get fxaaEnabled(): boolean;
  150481. private _samples;
  150482. /**
  150483. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150484. */
  150485. set samples(sampleCount: number);
  150486. get samples(): number;
  150487. /**
  150488. * If image processing is enabled.
  150489. */
  150490. set imageProcessingEnabled(enabled: boolean);
  150491. get imageProcessingEnabled(): boolean;
  150492. /**
  150493. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150494. */
  150495. set glowLayerEnabled(enabled: boolean);
  150496. get glowLayerEnabled(): boolean;
  150497. /**
  150498. * Gets the glow layer (or null if not defined)
  150499. */
  150500. get glowLayer(): Nullable<GlowLayer>;
  150501. /**
  150502. * Enable or disable the chromaticAberration process from the pipeline
  150503. */
  150504. set chromaticAberrationEnabled(enabled: boolean);
  150505. get chromaticAberrationEnabled(): boolean;
  150506. /**
  150507. * Enable or disable the grain process from the pipeline
  150508. */
  150509. set grainEnabled(enabled: boolean);
  150510. get grainEnabled(): boolean;
  150511. /**
  150512. * @constructor
  150513. * @param name - The rendering pipeline name (default: "")
  150514. * @param hdr - If high dynamic range textures should be used (default: true)
  150515. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150516. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150517. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150518. */
  150519. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150520. /**
  150521. * Get the class name
  150522. * @returns "DefaultRenderingPipeline"
  150523. */
  150524. getClassName(): string;
  150525. /**
  150526. * Force the compilation of the entire pipeline.
  150527. */
  150528. prepare(): void;
  150529. private _hasCleared;
  150530. private _prevPostProcess;
  150531. private _prevPrevPostProcess;
  150532. private _setAutoClearAndTextureSharing;
  150533. private _depthOfFieldSceneObserver;
  150534. private _buildPipeline;
  150535. private _disposePostProcesses;
  150536. /**
  150537. * Adds a camera to the pipeline
  150538. * @param camera the camera to be added
  150539. */
  150540. addCamera(camera: Camera): void;
  150541. /**
  150542. * Removes a camera from the pipeline
  150543. * @param camera the camera to remove
  150544. */
  150545. removeCamera(camera: Camera): void;
  150546. /**
  150547. * Dispose of the pipeline and stop all post processes
  150548. */
  150549. dispose(): void;
  150550. /**
  150551. * Serialize the rendering pipeline (Used when exporting)
  150552. * @returns the serialized object
  150553. */
  150554. serialize(): any;
  150555. /**
  150556. * Parse the serialized pipeline
  150557. * @param source Source pipeline.
  150558. * @param scene The scene to load the pipeline to.
  150559. * @param rootUrl The URL of the serialized pipeline.
  150560. * @returns An instantiated pipeline from the serialized object.
  150561. */
  150562. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150563. }
  150564. }
  150565. declare module BABYLON {
  150566. /** @hidden */
  150567. export var lensHighlightsPixelShader: {
  150568. name: string;
  150569. shader: string;
  150570. };
  150571. }
  150572. declare module BABYLON {
  150573. /** @hidden */
  150574. export var depthOfFieldPixelShader: {
  150575. name: string;
  150576. shader: string;
  150577. };
  150578. }
  150579. declare module BABYLON {
  150580. /**
  150581. * BABYLON.JS Chromatic Aberration GLSL Shader
  150582. * Author: Olivier Guyot
  150583. * Separates very slightly R, G and B colors on the edges of the screen
  150584. * Inspired by Francois Tarlier & Martins Upitis
  150585. */
  150586. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150587. /**
  150588. * @ignore
  150589. * The chromatic aberration PostProcess id in the pipeline
  150590. */
  150591. LensChromaticAberrationEffect: string;
  150592. /**
  150593. * @ignore
  150594. * The highlights enhancing PostProcess id in the pipeline
  150595. */
  150596. HighlightsEnhancingEffect: string;
  150597. /**
  150598. * @ignore
  150599. * The depth-of-field PostProcess id in the pipeline
  150600. */
  150601. LensDepthOfFieldEffect: string;
  150602. private _scene;
  150603. private _depthTexture;
  150604. private _grainTexture;
  150605. private _chromaticAberrationPostProcess;
  150606. private _highlightsPostProcess;
  150607. private _depthOfFieldPostProcess;
  150608. private _edgeBlur;
  150609. private _grainAmount;
  150610. private _chromaticAberration;
  150611. private _distortion;
  150612. private _highlightsGain;
  150613. private _highlightsThreshold;
  150614. private _dofDistance;
  150615. private _dofAperture;
  150616. private _dofDarken;
  150617. private _dofPentagon;
  150618. private _blurNoise;
  150619. /**
  150620. * @constructor
  150621. *
  150622. * Effect parameters are as follow:
  150623. * {
  150624. * chromatic_aberration: number; // from 0 to x (1 for realism)
  150625. * edge_blur: number; // from 0 to x (1 for realism)
  150626. * distortion: number; // from 0 to x (1 for realism)
  150627. * grain_amount: number; // from 0 to 1
  150628. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  150629. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  150630. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  150631. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  150632. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  150633. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  150634. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  150635. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  150636. * }
  150637. * Note: if an effect parameter is unset, effect is disabled
  150638. *
  150639. * @param name The rendering pipeline name
  150640. * @param parameters - An object containing all parameters (see above)
  150641. * @param scene The scene linked to this pipeline
  150642. * @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)
  150643. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150644. */
  150645. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  150646. /**
  150647. * Get the class name
  150648. * @returns "LensRenderingPipeline"
  150649. */
  150650. getClassName(): string;
  150651. /**
  150652. * Gets associated scene
  150653. */
  150654. get scene(): Scene;
  150655. /**
  150656. * Gets or sets the edge blur
  150657. */
  150658. get edgeBlur(): number;
  150659. set edgeBlur(value: number);
  150660. /**
  150661. * Gets or sets the grain amount
  150662. */
  150663. get grainAmount(): number;
  150664. set grainAmount(value: number);
  150665. /**
  150666. * Gets or sets the chromatic aberration amount
  150667. */
  150668. get chromaticAberration(): number;
  150669. set chromaticAberration(value: number);
  150670. /**
  150671. * Gets or sets the depth of field aperture
  150672. */
  150673. get dofAperture(): number;
  150674. set dofAperture(value: number);
  150675. /**
  150676. * Gets or sets the edge distortion
  150677. */
  150678. get edgeDistortion(): number;
  150679. set edgeDistortion(value: number);
  150680. /**
  150681. * Gets or sets the depth of field distortion
  150682. */
  150683. get dofDistortion(): number;
  150684. set dofDistortion(value: number);
  150685. /**
  150686. * Gets or sets the darken out of focus amount
  150687. */
  150688. get darkenOutOfFocus(): number;
  150689. set darkenOutOfFocus(value: number);
  150690. /**
  150691. * Gets or sets a boolean indicating if blur noise is enabled
  150692. */
  150693. get blurNoise(): boolean;
  150694. set blurNoise(value: boolean);
  150695. /**
  150696. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  150697. */
  150698. get pentagonBokeh(): boolean;
  150699. set pentagonBokeh(value: boolean);
  150700. /**
  150701. * Gets or sets the highlight grain amount
  150702. */
  150703. get highlightsGain(): number;
  150704. set highlightsGain(value: number);
  150705. /**
  150706. * Gets or sets the highlight threshold
  150707. */
  150708. get highlightsThreshold(): number;
  150709. set highlightsThreshold(value: number);
  150710. /**
  150711. * Sets the amount of blur at the edges
  150712. * @param amount blur amount
  150713. */
  150714. setEdgeBlur(amount: number): void;
  150715. /**
  150716. * Sets edge blur to 0
  150717. */
  150718. disableEdgeBlur(): void;
  150719. /**
  150720. * Sets the amout of grain
  150721. * @param amount Amount of grain
  150722. */
  150723. setGrainAmount(amount: number): void;
  150724. /**
  150725. * Set grain amount to 0
  150726. */
  150727. disableGrain(): void;
  150728. /**
  150729. * Sets the chromatic aberration amount
  150730. * @param amount amount of chromatic aberration
  150731. */
  150732. setChromaticAberration(amount: number): void;
  150733. /**
  150734. * Sets chromatic aberration amount to 0
  150735. */
  150736. disableChromaticAberration(): void;
  150737. /**
  150738. * Sets the EdgeDistortion amount
  150739. * @param amount amount of EdgeDistortion
  150740. */
  150741. setEdgeDistortion(amount: number): void;
  150742. /**
  150743. * Sets edge distortion to 0
  150744. */
  150745. disableEdgeDistortion(): void;
  150746. /**
  150747. * Sets the FocusDistance amount
  150748. * @param amount amount of FocusDistance
  150749. */
  150750. setFocusDistance(amount: number): void;
  150751. /**
  150752. * Disables depth of field
  150753. */
  150754. disableDepthOfField(): void;
  150755. /**
  150756. * Sets the Aperture amount
  150757. * @param amount amount of Aperture
  150758. */
  150759. setAperture(amount: number): void;
  150760. /**
  150761. * Sets the DarkenOutOfFocus amount
  150762. * @param amount amount of DarkenOutOfFocus
  150763. */
  150764. setDarkenOutOfFocus(amount: number): void;
  150765. private _pentagonBokehIsEnabled;
  150766. /**
  150767. * Creates a pentagon bokeh effect
  150768. */
  150769. enablePentagonBokeh(): void;
  150770. /**
  150771. * Disables the pentagon bokeh effect
  150772. */
  150773. disablePentagonBokeh(): void;
  150774. /**
  150775. * Enables noise blur
  150776. */
  150777. enableNoiseBlur(): void;
  150778. /**
  150779. * Disables noise blur
  150780. */
  150781. disableNoiseBlur(): void;
  150782. /**
  150783. * Sets the HighlightsGain amount
  150784. * @param amount amount of HighlightsGain
  150785. */
  150786. setHighlightsGain(amount: number): void;
  150787. /**
  150788. * Sets the HighlightsThreshold amount
  150789. * @param amount amount of HighlightsThreshold
  150790. */
  150791. setHighlightsThreshold(amount: number): void;
  150792. /**
  150793. * Disables highlights
  150794. */
  150795. disableHighlights(): void;
  150796. /**
  150797. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  150798. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  150799. */
  150800. dispose(disableDepthRender?: boolean): void;
  150801. private _createChromaticAberrationPostProcess;
  150802. private _createHighlightsPostProcess;
  150803. private _createDepthOfFieldPostProcess;
  150804. private _createGrainTexture;
  150805. }
  150806. }
  150807. declare module BABYLON {
  150808. /** @hidden */
  150809. export var ssao2PixelShader: {
  150810. name: string;
  150811. shader: string;
  150812. };
  150813. }
  150814. declare module BABYLON {
  150815. /** @hidden */
  150816. export var ssaoCombinePixelShader: {
  150817. name: string;
  150818. shader: string;
  150819. };
  150820. }
  150821. declare module BABYLON {
  150822. /**
  150823. * Render pipeline to produce ssao effect
  150824. */
  150825. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  150826. /**
  150827. * @ignore
  150828. * The PassPostProcess id in the pipeline that contains the original scene color
  150829. */
  150830. SSAOOriginalSceneColorEffect: string;
  150831. /**
  150832. * @ignore
  150833. * The SSAO PostProcess id in the pipeline
  150834. */
  150835. SSAORenderEffect: string;
  150836. /**
  150837. * @ignore
  150838. * The horizontal blur PostProcess id in the pipeline
  150839. */
  150840. SSAOBlurHRenderEffect: string;
  150841. /**
  150842. * @ignore
  150843. * The vertical blur PostProcess id in the pipeline
  150844. */
  150845. SSAOBlurVRenderEffect: string;
  150846. /**
  150847. * @ignore
  150848. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150849. */
  150850. SSAOCombineRenderEffect: string;
  150851. /**
  150852. * The output strength of the SSAO post-process. Default value is 1.0.
  150853. */
  150854. totalStrength: number;
  150855. /**
  150856. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  150857. */
  150858. maxZ: number;
  150859. /**
  150860. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  150861. */
  150862. minZAspect: number;
  150863. private _samples;
  150864. /**
  150865. * Number of samples used for the SSAO calculations. Default value is 8
  150866. */
  150867. set samples(n: number);
  150868. get samples(): number;
  150869. private _textureSamples;
  150870. /**
  150871. * Number of samples to use for antialiasing
  150872. */
  150873. set textureSamples(n: number);
  150874. get textureSamples(): number;
  150875. /**
  150876. * Force rendering the geometry through geometry buffer
  150877. */
  150878. private _forceGeometryBuffer;
  150879. /**
  150880. * Ratio object used for SSAO ratio and blur ratio
  150881. */
  150882. private _ratio;
  150883. /**
  150884. * Dynamically generated sphere sampler.
  150885. */
  150886. private _sampleSphere;
  150887. /**
  150888. * Blur filter offsets
  150889. */
  150890. private _samplerOffsets;
  150891. private _expensiveBlur;
  150892. /**
  150893. * If bilateral blur should be used
  150894. */
  150895. set expensiveBlur(b: boolean);
  150896. get expensiveBlur(): boolean;
  150897. /**
  150898. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  150899. */
  150900. radius: number;
  150901. /**
  150902. * The base color of the SSAO post-process
  150903. * The final result is "base + ssao" between [0, 1]
  150904. */
  150905. base: number;
  150906. /**
  150907. * Support test.
  150908. */
  150909. static get IsSupported(): boolean;
  150910. private _scene;
  150911. private _randomTexture;
  150912. private _originalColorPostProcess;
  150913. private _ssaoPostProcess;
  150914. private _blurHPostProcess;
  150915. private _blurVPostProcess;
  150916. private _ssaoCombinePostProcess;
  150917. private _prePassRenderer;
  150918. /**
  150919. * Gets active scene
  150920. */
  150921. get scene(): Scene;
  150922. /**
  150923. * @constructor
  150924. * @param name The rendering pipeline name
  150925. * @param scene The scene linked to this pipeline
  150926. * @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 }
  150927. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150928. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  150929. */
  150930. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  150931. /**
  150932. * Get the class name
  150933. * @returns "SSAO2RenderingPipeline"
  150934. */
  150935. getClassName(): string;
  150936. /**
  150937. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150938. */
  150939. dispose(disableGeometryBufferRenderer?: boolean): void;
  150940. private _createBlurPostProcess;
  150941. /** @hidden */
  150942. _rebuild(): void;
  150943. private _bits;
  150944. private _radicalInverse_VdC;
  150945. private _hammersley;
  150946. private _hemisphereSample_uniform;
  150947. private _generateHemisphere;
  150948. private _getDefinesForSSAO;
  150949. private _createSSAOPostProcess;
  150950. private _createSSAOCombinePostProcess;
  150951. private _createRandomTexture;
  150952. /**
  150953. * Serialize the rendering pipeline (Used when exporting)
  150954. * @returns the serialized object
  150955. */
  150956. serialize(): any;
  150957. /**
  150958. * Parse the serialized pipeline
  150959. * @param source Source pipeline.
  150960. * @param scene The scene to load the pipeline to.
  150961. * @param rootUrl The URL of the serialized pipeline.
  150962. * @returns An instantiated pipeline from the serialized object.
  150963. */
  150964. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  150965. /**
  150966. * Sets the required values to the prepass renderer.
  150967. * @param prePassRenderer defines the prepass renderer to setup
  150968. * @returns true if the pre pass is needed.
  150969. */
  150970. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150971. }
  150972. }
  150973. declare module BABYLON {
  150974. /** @hidden */
  150975. export var ssaoPixelShader: {
  150976. name: string;
  150977. shader: string;
  150978. };
  150979. }
  150980. declare module BABYLON {
  150981. /**
  150982. * Render pipeline to produce ssao effect
  150983. */
  150984. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  150985. /**
  150986. * @ignore
  150987. * The PassPostProcess id in the pipeline that contains the original scene color
  150988. */
  150989. SSAOOriginalSceneColorEffect: string;
  150990. /**
  150991. * @ignore
  150992. * The SSAO PostProcess id in the pipeline
  150993. */
  150994. SSAORenderEffect: string;
  150995. /**
  150996. * @ignore
  150997. * The horizontal blur PostProcess id in the pipeline
  150998. */
  150999. SSAOBlurHRenderEffect: string;
  151000. /**
  151001. * @ignore
  151002. * The vertical blur PostProcess id in the pipeline
  151003. */
  151004. SSAOBlurVRenderEffect: string;
  151005. /**
  151006. * @ignore
  151007. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151008. */
  151009. SSAOCombineRenderEffect: string;
  151010. /**
  151011. * The output strength of the SSAO post-process. Default value is 1.0.
  151012. */
  151013. totalStrength: number;
  151014. /**
  151015. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151016. */
  151017. radius: number;
  151018. /**
  151019. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151020. * Must not be equal to fallOff and superior to fallOff.
  151021. * Default value is 0.0075
  151022. */
  151023. area: number;
  151024. /**
  151025. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151026. * Must not be equal to area and inferior to area.
  151027. * Default value is 0.000001
  151028. */
  151029. fallOff: number;
  151030. /**
  151031. * The base color of the SSAO post-process
  151032. * The final result is "base + ssao" between [0, 1]
  151033. */
  151034. base: number;
  151035. private _scene;
  151036. private _depthTexture;
  151037. private _randomTexture;
  151038. private _originalColorPostProcess;
  151039. private _ssaoPostProcess;
  151040. private _blurHPostProcess;
  151041. private _blurVPostProcess;
  151042. private _ssaoCombinePostProcess;
  151043. private _firstUpdate;
  151044. /**
  151045. * Gets active scene
  151046. */
  151047. get scene(): Scene;
  151048. /**
  151049. * @constructor
  151050. * @param name - The rendering pipeline name
  151051. * @param scene - The scene linked to this pipeline
  151052. * @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 }
  151053. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151054. */
  151055. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151056. /**
  151057. * Get the class name
  151058. * @returns "SSAORenderingPipeline"
  151059. */
  151060. getClassName(): string;
  151061. /**
  151062. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151063. */
  151064. dispose(disableDepthRender?: boolean): void;
  151065. private _createBlurPostProcess;
  151066. /** @hidden */
  151067. _rebuild(): void;
  151068. private _createSSAOPostProcess;
  151069. private _createSSAOCombinePostProcess;
  151070. private _createRandomTexture;
  151071. }
  151072. }
  151073. declare module BABYLON {
  151074. /** @hidden */
  151075. export var screenSpaceReflectionPixelShader: {
  151076. name: string;
  151077. shader: string;
  151078. };
  151079. }
  151080. declare module BABYLON {
  151081. /**
  151082. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151083. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151084. */
  151085. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151086. /**
  151087. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151088. */
  151089. threshold: number;
  151090. /**
  151091. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151092. */
  151093. strength: number;
  151094. /**
  151095. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151096. */
  151097. reflectionSpecularFalloffExponent: number;
  151098. /**
  151099. * 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]
  151100. */
  151101. step: number;
  151102. /**
  151103. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151104. */
  151105. roughnessFactor: number;
  151106. private _geometryBufferRenderer;
  151107. private _enableSmoothReflections;
  151108. private _reflectionSamples;
  151109. private _smoothSteps;
  151110. /**
  151111. * Gets a string identifying the name of the class
  151112. * @returns "ScreenSpaceReflectionPostProcess" string
  151113. */
  151114. getClassName(): string;
  151115. /**
  151116. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151117. * @param name The name of the effect.
  151118. * @param scene The scene containing the objects to calculate reflections.
  151119. * @param options The required width/height ratio to downsize to before computing the render pass.
  151120. * @param camera The camera to apply the render pass to.
  151121. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151122. * @param engine The engine which the post process will be applied. (default: current engine)
  151123. * @param reusable If the post process can be reused on the same frame. (default: false)
  151124. * @param textureType Type of textures used when performing the post process. (default: 0)
  151125. * @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)
  151126. */
  151127. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151128. /**
  151129. * Gets wether or not smoothing reflections is enabled.
  151130. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151131. */
  151132. get enableSmoothReflections(): boolean;
  151133. /**
  151134. * Sets wether or not smoothing reflections is enabled.
  151135. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151136. */
  151137. set enableSmoothReflections(enabled: boolean);
  151138. /**
  151139. * Gets the number of samples taken while computing reflections. More samples count is high,
  151140. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151141. */
  151142. get reflectionSamples(): number;
  151143. /**
  151144. * Sets the number of samples taken while computing reflections. More samples count is high,
  151145. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151146. */
  151147. set reflectionSamples(samples: number);
  151148. /**
  151149. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151150. * more the post-process will require GPU power and can generate a drop in FPS.
  151151. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151152. */
  151153. get smoothSteps(): number;
  151154. set smoothSteps(steps: number);
  151155. private _updateEffectDefines;
  151156. /** @hidden */
  151157. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151158. }
  151159. }
  151160. declare module BABYLON {
  151161. /** @hidden */
  151162. export var standardPixelShader: {
  151163. name: string;
  151164. shader: string;
  151165. };
  151166. }
  151167. declare module BABYLON {
  151168. /**
  151169. * Standard rendering pipeline
  151170. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151171. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151172. */
  151173. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151174. /**
  151175. * Public members
  151176. */
  151177. /**
  151178. * Post-process which contains the original scene color before the pipeline applies all the effects
  151179. */
  151180. originalPostProcess: Nullable<PostProcess>;
  151181. /**
  151182. * Post-process used to down scale an image x4
  151183. */
  151184. downSampleX4PostProcess: Nullable<PostProcess>;
  151185. /**
  151186. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151187. */
  151188. brightPassPostProcess: Nullable<PostProcess>;
  151189. /**
  151190. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151191. */
  151192. blurHPostProcesses: PostProcess[];
  151193. /**
  151194. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151195. */
  151196. blurVPostProcesses: PostProcess[];
  151197. /**
  151198. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151199. */
  151200. textureAdderPostProcess: Nullable<PostProcess>;
  151201. /**
  151202. * Post-process used to create volumetric lighting effect
  151203. */
  151204. volumetricLightPostProcess: Nullable<PostProcess>;
  151205. /**
  151206. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151207. */
  151208. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151209. /**
  151210. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151211. */
  151212. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151213. /**
  151214. * Post-process used to merge the volumetric light effect and the real scene color
  151215. */
  151216. volumetricLightMergePostProces: Nullable<PostProcess>;
  151217. /**
  151218. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151219. */
  151220. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151221. /**
  151222. * Base post-process used to calculate the average luminance of the final image for HDR
  151223. */
  151224. luminancePostProcess: Nullable<PostProcess>;
  151225. /**
  151226. * Post-processes used to create down sample post-processes in order to get
  151227. * the average luminance of the final image for HDR
  151228. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151229. */
  151230. luminanceDownSamplePostProcesses: PostProcess[];
  151231. /**
  151232. * Post-process used to create a HDR effect (light adaptation)
  151233. */
  151234. hdrPostProcess: Nullable<PostProcess>;
  151235. /**
  151236. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151237. */
  151238. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151239. /**
  151240. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151241. */
  151242. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151243. /**
  151244. * Post-process used to merge the final HDR post-process and the real scene color
  151245. */
  151246. hdrFinalPostProcess: Nullable<PostProcess>;
  151247. /**
  151248. * Post-process used to create a lens flare effect
  151249. */
  151250. lensFlarePostProcess: Nullable<PostProcess>;
  151251. /**
  151252. * Post-process that merges the result of the lens flare post-process and the real scene color
  151253. */
  151254. lensFlareComposePostProcess: Nullable<PostProcess>;
  151255. /**
  151256. * Post-process used to create a motion blur effect
  151257. */
  151258. motionBlurPostProcess: Nullable<PostProcess>;
  151259. /**
  151260. * Post-process used to create a depth of field effect
  151261. */
  151262. depthOfFieldPostProcess: Nullable<PostProcess>;
  151263. /**
  151264. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151265. */
  151266. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151267. /**
  151268. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151269. */
  151270. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151271. /**
  151272. * Represents the brightness threshold in order to configure the illuminated surfaces
  151273. */
  151274. brightThreshold: number;
  151275. /**
  151276. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151277. */
  151278. blurWidth: number;
  151279. /**
  151280. * Sets if the blur for highlighted surfaces must be only horizontal
  151281. */
  151282. horizontalBlur: boolean;
  151283. /**
  151284. * Gets the overall exposure used by the pipeline
  151285. */
  151286. get exposure(): number;
  151287. /**
  151288. * Sets the overall exposure used by the pipeline
  151289. */
  151290. set exposure(value: number);
  151291. /**
  151292. * Texture used typically to simulate "dirty" on camera lens
  151293. */
  151294. lensTexture: Nullable<Texture>;
  151295. /**
  151296. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151297. */
  151298. volumetricLightCoefficient: number;
  151299. /**
  151300. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151301. */
  151302. volumetricLightPower: number;
  151303. /**
  151304. * Used the set the blur intensity to smooth the volumetric lights
  151305. */
  151306. volumetricLightBlurScale: number;
  151307. /**
  151308. * Light (spot or directional) used to generate the volumetric lights rays
  151309. * The source light must have a shadow generate so the pipeline can get its
  151310. * depth map
  151311. */
  151312. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151313. /**
  151314. * For eye adaptation, represents the minimum luminance the eye can see
  151315. */
  151316. hdrMinimumLuminance: number;
  151317. /**
  151318. * For eye adaptation, represents the decrease luminance speed
  151319. */
  151320. hdrDecreaseRate: number;
  151321. /**
  151322. * For eye adaptation, represents the increase luminance speed
  151323. */
  151324. hdrIncreaseRate: number;
  151325. /**
  151326. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151327. */
  151328. get hdrAutoExposure(): boolean;
  151329. /**
  151330. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151331. */
  151332. set hdrAutoExposure(value: boolean);
  151333. /**
  151334. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151335. */
  151336. lensColorTexture: Nullable<Texture>;
  151337. /**
  151338. * The overall strengh for the lens flare effect
  151339. */
  151340. lensFlareStrength: number;
  151341. /**
  151342. * Dispersion coefficient for lens flare ghosts
  151343. */
  151344. lensFlareGhostDispersal: number;
  151345. /**
  151346. * Main lens flare halo width
  151347. */
  151348. lensFlareHaloWidth: number;
  151349. /**
  151350. * Based on the lens distortion effect, defines how much the lens flare result
  151351. * is distorted
  151352. */
  151353. lensFlareDistortionStrength: number;
  151354. /**
  151355. * Configures the blur intensity used for for lens flare (halo)
  151356. */
  151357. lensFlareBlurWidth: number;
  151358. /**
  151359. * Lens star texture must be used to simulate rays on the flares and is available
  151360. * in the documentation
  151361. */
  151362. lensStarTexture: Nullable<Texture>;
  151363. /**
  151364. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151365. * flare effect by taking account of the dirt texture
  151366. */
  151367. lensFlareDirtTexture: Nullable<Texture>;
  151368. /**
  151369. * Represents the focal length for the depth of field effect
  151370. */
  151371. depthOfFieldDistance: number;
  151372. /**
  151373. * Represents the blur intensity for the blurred part of the depth of field effect
  151374. */
  151375. depthOfFieldBlurWidth: number;
  151376. /**
  151377. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151378. */
  151379. get motionStrength(): number;
  151380. /**
  151381. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151382. */
  151383. set motionStrength(strength: number);
  151384. /**
  151385. * Gets wether or not the motion blur post-process is object based or screen based.
  151386. */
  151387. get objectBasedMotionBlur(): boolean;
  151388. /**
  151389. * Sets wether or not the motion blur post-process should be object based or screen based
  151390. */
  151391. set objectBasedMotionBlur(value: boolean);
  151392. /**
  151393. * List of animations for the pipeline (IAnimatable implementation)
  151394. */
  151395. animations: Animation[];
  151396. /**
  151397. * Private members
  151398. */
  151399. private _scene;
  151400. private _currentDepthOfFieldSource;
  151401. private _basePostProcess;
  151402. private _fixedExposure;
  151403. private _currentExposure;
  151404. private _hdrAutoExposure;
  151405. private _hdrCurrentLuminance;
  151406. private _motionStrength;
  151407. private _isObjectBasedMotionBlur;
  151408. private _floatTextureType;
  151409. private _camerasToBeAttached;
  151410. private _ratio;
  151411. private _bloomEnabled;
  151412. private _depthOfFieldEnabled;
  151413. private _vlsEnabled;
  151414. private _lensFlareEnabled;
  151415. private _hdrEnabled;
  151416. private _motionBlurEnabled;
  151417. private _fxaaEnabled;
  151418. private _screenSpaceReflectionsEnabled;
  151419. private _motionBlurSamples;
  151420. private _volumetricLightStepsCount;
  151421. private _samples;
  151422. /**
  151423. * @ignore
  151424. * Specifies if the bloom pipeline is enabled
  151425. */
  151426. get BloomEnabled(): boolean;
  151427. set BloomEnabled(enabled: boolean);
  151428. /**
  151429. * @ignore
  151430. * Specifies if the depth of field pipeline is enabed
  151431. */
  151432. get DepthOfFieldEnabled(): boolean;
  151433. set DepthOfFieldEnabled(enabled: boolean);
  151434. /**
  151435. * @ignore
  151436. * Specifies if the lens flare pipeline is enabed
  151437. */
  151438. get LensFlareEnabled(): boolean;
  151439. set LensFlareEnabled(enabled: boolean);
  151440. /**
  151441. * @ignore
  151442. * Specifies if the HDR pipeline is enabled
  151443. */
  151444. get HDREnabled(): boolean;
  151445. set HDREnabled(enabled: boolean);
  151446. /**
  151447. * @ignore
  151448. * Specifies if the volumetric lights scattering effect is enabled
  151449. */
  151450. get VLSEnabled(): boolean;
  151451. set VLSEnabled(enabled: boolean);
  151452. /**
  151453. * @ignore
  151454. * Specifies if the motion blur effect is enabled
  151455. */
  151456. get MotionBlurEnabled(): boolean;
  151457. set MotionBlurEnabled(enabled: boolean);
  151458. /**
  151459. * Specifies if anti-aliasing is enabled
  151460. */
  151461. get fxaaEnabled(): boolean;
  151462. set fxaaEnabled(enabled: boolean);
  151463. /**
  151464. * Specifies if screen space reflections are enabled.
  151465. */
  151466. get screenSpaceReflectionsEnabled(): boolean;
  151467. set screenSpaceReflectionsEnabled(enabled: boolean);
  151468. /**
  151469. * Specifies the number of steps used to calculate the volumetric lights
  151470. * Typically in interval [50, 200]
  151471. */
  151472. get volumetricLightStepsCount(): number;
  151473. set volumetricLightStepsCount(count: number);
  151474. /**
  151475. * Specifies the number of samples used for the motion blur effect
  151476. * Typically in interval [16, 64]
  151477. */
  151478. get motionBlurSamples(): number;
  151479. set motionBlurSamples(samples: number);
  151480. /**
  151481. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151482. */
  151483. get samples(): number;
  151484. set samples(sampleCount: number);
  151485. /**
  151486. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151487. * @constructor
  151488. * @param name The rendering pipeline name
  151489. * @param scene The scene linked to this pipeline
  151490. * @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)
  151491. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151492. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151493. */
  151494. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151495. private _buildPipeline;
  151496. private _createDownSampleX4PostProcess;
  151497. private _createBrightPassPostProcess;
  151498. private _createBlurPostProcesses;
  151499. private _createTextureAdderPostProcess;
  151500. private _createVolumetricLightPostProcess;
  151501. private _createLuminancePostProcesses;
  151502. private _createHdrPostProcess;
  151503. private _createLensFlarePostProcess;
  151504. private _createDepthOfFieldPostProcess;
  151505. private _createMotionBlurPostProcess;
  151506. private _getDepthTexture;
  151507. private _disposePostProcesses;
  151508. /**
  151509. * Dispose of the pipeline and stop all post processes
  151510. */
  151511. dispose(): void;
  151512. /**
  151513. * Serialize the rendering pipeline (Used when exporting)
  151514. * @returns the serialized object
  151515. */
  151516. serialize(): any;
  151517. /**
  151518. * Parse the serialized pipeline
  151519. * @param source Source pipeline.
  151520. * @param scene The scene to load the pipeline to.
  151521. * @param rootUrl The URL of the serialized pipeline.
  151522. * @returns An instantiated pipeline from the serialized object.
  151523. */
  151524. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151525. /**
  151526. * Luminance steps
  151527. */
  151528. static LuminanceSteps: number;
  151529. }
  151530. }
  151531. declare module BABYLON {
  151532. /** @hidden */
  151533. export var stereoscopicInterlacePixelShader: {
  151534. name: string;
  151535. shader: string;
  151536. };
  151537. }
  151538. declare module BABYLON {
  151539. /**
  151540. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151541. */
  151542. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151543. private _stepSize;
  151544. private _passedProcess;
  151545. /**
  151546. * Gets a string identifying the name of the class
  151547. * @returns "StereoscopicInterlacePostProcessI" string
  151548. */
  151549. getClassName(): string;
  151550. /**
  151551. * Initializes a StereoscopicInterlacePostProcessI
  151552. * @param name The name of the effect.
  151553. * @param rigCameras The rig cameras to be appled to the post process
  151554. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151555. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151557. * @param engine The engine which the post process will be applied. (default: current engine)
  151558. * @param reusable If the post process can be reused on the same frame. (default: false)
  151559. */
  151560. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151561. }
  151562. /**
  151563. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  151564. */
  151565. export class StereoscopicInterlacePostProcess extends PostProcess {
  151566. private _stepSize;
  151567. private _passedProcess;
  151568. /**
  151569. * Gets a string identifying the name of the class
  151570. * @returns "StereoscopicInterlacePostProcess" string
  151571. */
  151572. getClassName(): string;
  151573. /**
  151574. * Initializes a StereoscopicInterlacePostProcess
  151575. * @param name The name of the effect.
  151576. * @param rigCameras The rig cameras to be appled to the post process
  151577. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  151578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151579. * @param engine The engine which the post process will be applied. (default: current engine)
  151580. * @param reusable If the post process can be reused on the same frame. (default: false)
  151581. */
  151582. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151583. }
  151584. }
  151585. declare module BABYLON {
  151586. /** @hidden */
  151587. export var tonemapPixelShader: {
  151588. name: string;
  151589. shader: string;
  151590. };
  151591. }
  151592. declare module BABYLON {
  151593. /** Defines operator used for tonemapping */
  151594. export enum TonemappingOperator {
  151595. /** Hable */
  151596. Hable = 0,
  151597. /** Reinhard */
  151598. Reinhard = 1,
  151599. /** HejiDawson */
  151600. HejiDawson = 2,
  151601. /** Photographic */
  151602. Photographic = 3
  151603. }
  151604. /**
  151605. * Defines a post process to apply tone mapping
  151606. */
  151607. export class TonemapPostProcess extends PostProcess {
  151608. private _operator;
  151609. /** Defines the required exposure adjustement */
  151610. exposureAdjustment: number;
  151611. /**
  151612. * Gets a string identifying the name of the class
  151613. * @returns "TonemapPostProcess" string
  151614. */
  151615. getClassName(): string;
  151616. /**
  151617. * Creates a new TonemapPostProcess
  151618. * @param name defines the name of the postprocess
  151619. * @param _operator defines the operator to use
  151620. * @param exposureAdjustment defines the required exposure adjustement
  151621. * @param camera defines the camera to use (can be null)
  151622. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  151623. * @param engine defines the hosting engine (can be ignore if camera is set)
  151624. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151625. */
  151626. constructor(name: string, _operator: TonemappingOperator,
  151627. /** Defines the required exposure adjustement */
  151628. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  151629. }
  151630. }
  151631. declare module BABYLON {
  151632. /** @hidden */
  151633. export var volumetricLightScatteringPixelShader: {
  151634. name: string;
  151635. shader: string;
  151636. };
  151637. }
  151638. declare module BABYLON {
  151639. /** @hidden */
  151640. export var volumetricLightScatteringPassVertexShader: {
  151641. name: string;
  151642. shader: string;
  151643. };
  151644. }
  151645. declare module BABYLON {
  151646. /** @hidden */
  151647. export var volumetricLightScatteringPassPixelShader: {
  151648. name: string;
  151649. shader: string;
  151650. };
  151651. }
  151652. declare module BABYLON {
  151653. /**
  151654. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  151655. */
  151656. export class VolumetricLightScatteringPostProcess extends PostProcess {
  151657. private _volumetricLightScatteringPass;
  151658. private _volumetricLightScatteringRTT;
  151659. private _viewPort;
  151660. private _screenCoordinates;
  151661. private _cachedDefines;
  151662. /**
  151663. * If not undefined, the mesh position is computed from the attached node position
  151664. */
  151665. attachedNode: {
  151666. position: Vector3;
  151667. };
  151668. /**
  151669. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  151670. */
  151671. customMeshPosition: Vector3;
  151672. /**
  151673. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  151674. */
  151675. useCustomMeshPosition: boolean;
  151676. /**
  151677. * If the post-process should inverse the light scattering direction
  151678. */
  151679. invert: boolean;
  151680. /**
  151681. * The internal mesh used by the post-process
  151682. */
  151683. mesh: Mesh;
  151684. /**
  151685. * @hidden
  151686. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  151687. */
  151688. get useDiffuseColor(): boolean;
  151689. set useDiffuseColor(useDiffuseColor: boolean);
  151690. /**
  151691. * Array containing the excluded meshes not rendered in the internal pass
  151692. */
  151693. excludedMeshes: AbstractMesh[];
  151694. /**
  151695. * Controls the overall intensity of the post-process
  151696. */
  151697. exposure: number;
  151698. /**
  151699. * Dissipates each sample's contribution in range [0, 1]
  151700. */
  151701. decay: number;
  151702. /**
  151703. * Controls the overall intensity of each sample
  151704. */
  151705. weight: number;
  151706. /**
  151707. * Controls the density of each sample
  151708. */
  151709. density: number;
  151710. /**
  151711. * @constructor
  151712. * @param name The post-process name
  151713. * @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)
  151714. * @param camera The camera that the post-process will be attached to
  151715. * @param mesh The mesh used to create the light scattering
  151716. * @param samples The post-process quality, default 100
  151717. * @param samplingModeThe post-process filtering mode
  151718. * @param engine The babylon engine
  151719. * @param reusable If the post-process is reusable
  151720. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  151721. */
  151722. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  151723. /**
  151724. * Returns the string "VolumetricLightScatteringPostProcess"
  151725. * @returns "VolumetricLightScatteringPostProcess"
  151726. */
  151727. getClassName(): string;
  151728. private _isReady;
  151729. /**
  151730. * Sets the new light position for light scattering effect
  151731. * @param position The new custom light position
  151732. */
  151733. setCustomMeshPosition(position: Vector3): void;
  151734. /**
  151735. * Returns the light position for light scattering effect
  151736. * @return Vector3 The custom light position
  151737. */
  151738. getCustomMeshPosition(): Vector3;
  151739. /**
  151740. * Disposes the internal assets and detaches the post-process from the camera
  151741. */
  151742. dispose(camera: Camera): void;
  151743. /**
  151744. * Returns the render target texture used by the post-process
  151745. * @return the render target texture used by the post-process
  151746. */
  151747. getPass(): RenderTargetTexture;
  151748. private _meshExcluded;
  151749. private _createPass;
  151750. private _updateMeshScreenCoordinates;
  151751. /**
  151752. * Creates a default mesh for the Volumeric Light Scattering post-process
  151753. * @param name The mesh name
  151754. * @param scene The scene where to create the mesh
  151755. * @return the default mesh
  151756. */
  151757. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  151758. }
  151759. }
  151760. declare module BABYLON {
  151761. /** @hidden */
  151762. export var screenSpaceCurvaturePixelShader: {
  151763. name: string;
  151764. shader: string;
  151765. };
  151766. }
  151767. declare module BABYLON {
  151768. /**
  151769. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  151770. */
  151771. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  151772. /**
  151773. * Defines how much ridge the curvature effect displays.
  151774. */
  151775. ridge: number;
  151776. /**
  151777. * Defines how much valley the curvature effect displays.
  151778. */
  151779. valley: number;
  151780. private _geometryBufferRenderer;
  151781. /**
  151782. * Gets a string identifying the name of the class
  151783. * @returns "ScreenSpaceCurvaturePostProcess" string
  151784. */
  151785. getClassName(): string;
  151786. /**
  151787. * Creates a new instance ScreenSpaceCurvaturePostProcess
  151788. * @param name The name of the effect.
  151789. * @param scene The scene containing the objects to blur according to their velocity.
  151790. * @param options The required width/height ratio to downsize to before computing the render pass.
  151791. * @param camera The camera to apply the render pass to.
  151792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151793. * @param engine The engine which the post process will be applied. (default: current engine)
  151794. * @param reusable If the post process can be reused on the same frame. (default: false)
  151795. * @param textureType Type of textures used when performing the post process. (default: 0)
  151796. * @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)
  151797. */
  151798. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151799. /**
  151800. * Support test.
  151801. */
  151802. static get IsSupported(): boolean;
  151803. /** @hidden */
  151804. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  151805. }
  151806. }
  151807. declare module BABYLON {
  151808. interface Scene {
  151809. /** @hidden (Backing field) */
  151810. _boundingBoxRenderer: BoundingBoxRenderer;
  151811. /** @hidden (Backing field) */
  151812. _forceShowBoundingBoxes: boolean;
  151813. /**
  151814. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  151815. */
  151816. forceShowBoundingBoxes: boolean;
  151817. /**
  151818. * Gets the bounding box renderer associated with the scene
  151819. * @returns a BoundingBoxRenderer
  151820. */
  151821. getBoundingBoxRenderer(): BoundingBoxRenderer;
  151822. }
  151823. interface AbstractMesh {
  151824. /** @hidden (Backing field) */
  151825. _showBoundingBox: boolean;
  151826. /**
  151827. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  151828. */
  151829. showBoundingBox: boolean;
  151830. }
  151831. /**
  151832. * Component responsible of rendering the bounding box of the meshes in a scene.
  151833. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  151834. */
  151835. export class BoundingBoxRenderer implements ISceneComponent {
  151836. /**
  151837. * The component name helpfull to identify the component in the list of scene components.
  151838. */
  151839. readonly name: string;
  151840. /**
  151841. * The scene the component belongs to.
  151842. */
  151843. scene: Scene;
  151844. /**
  151845. * Color of the bounding box lines placed in front of an object
  151846. */
  151847. frontColor: Color3;
  151848. /**
  151849. * Color of the bounding box lines placed behind an object
  151850. */
  151851. backColor: Color3;
  151852. /**
  151853. * Defines if the renderer should show the back lines or not
  151854. */
  151855. showBackLines: boolean;
  151856. /**
  151857. * Observable raised before rendering a bounding box
  151858. */
  151859. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  151860. /**
  151861. * Observable raised after rendering a bounding box
  151862. */
  151863. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  151864. /**
  151865. * @hidden
  151866. */
  151867. renderList: SmartArray<BoundingBox>;
  151868. private _colorShader;
  151869. private _vertexBuffers;
  151870. private _indexBuffer;
  151871. private _fillIndexBuffer;
  151872. private _fillIndexData;
  151873. /**
  151874. * Instantiates a new bounding box renderer in a scene.
  151875. * @param scene the scene the renderer renders in
  151876. */
  151877. constructor(scene: Scene);
  151878. /**
  151879. * Registers the component in a given scene
  151880. */
  151881. register(): void;
  151882. private _evaluateSubMesh;
  151883. private _activeMesh;
  151884. private _prepareRessources;
  151885. private _createIndexBuffer;
  151886. /**
  151887. * Rebuilds the elements related to this component in case of
  151888. * context lost for instance.
  151889. */
  151890. rebuild(): void;
  151891. /**
  151892. * @hidden
  151893. */
  151894. reset(): void;
  151895. /**
  151896. * Render the bounding boxes of a specific rendering group
  151897. * @param renderingGroupId defines the rendering group to render
  151898. */
  151899. render(renderingGroupId: number): void;
  151900. /**
  151901. * In case of occlusion queries, we can render the occlusion bounding box through this method
  151902. * @param mesh Define the mesh to render the occlusion bounding box for
  151903. */
  151904. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  151905. /**
  151906. * Dispose and release the resources attached to this renderer.
  151907. */
  151908. dispose(): void;
  151909. }
  151910. }
  151911. declare module BABYLON {
  151912. interface Scene {
  151913. /** @hidden (Backing field) */
  151914. _depthRenderer: {
  151915. [id: string]: DepthRenderer;
  151916. };
  151917. /**
  151918. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  151919. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  151920. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  151921. * @returns the created depth renderer
  151922. */
  151923. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  151924. /**
  151925. * Disables a depth renderer for a given camera
  151926. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  151927. */
  151928. disableDepthRenderer(camera?: Nullable<Camera>): void;
  151929. }
  151930. /**
  151931. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  151932. * in several rendering techniques.
  151933. */
  151934. export class DepthRendererSceneComponent implements ISceneComponent {
  151935. /**
  151936. * The component name helpfull to identify the component in the list of scene components.
  151937. */
  151938. readonly name: string;
  151939. /**
  151940. * The scene the component belongs to.
  151941. */
  151942. scene: Scene;
  151943. /**
  151944. * Creates a new instance of the component for the given scene
  151945. * @param scene Defines the scene to register the component in
  151946. */
  151947. constructor(scene: Scene);
  151948. /**
  151949. * Registers the component in a given scene
  151950. */
  151951. register(): void;
  151952. /**
  151953. * Rebuilds the elements related to this component in case of
  151954. * context lost for instance.
  151955. */
  151956. rebuild(): void;
  151957. /**
  151958. * Disposes the component and the associated ressources
  151959. */
  151960. dispose(): void;
  151961. private _gatherRenderTargets;
  151962. private _gatherActiveCameraRenderTargets;
  151963. }
  151964. }
  151965. declare module BABYLON {
  151966. interface AbstractScene {
  151967. /** @hidden (Backing field) */
  151968. _prePassRenderer: Nullable<PrePassRenderer>;
  151969. /**
  151970. * Gets or Sets the current prepass renderer associated to the scene.
  151971. */
  151972. prePassRenderer: Nullable<PrePassRenderer>;
  151973. /**
  151974. * Enables the prepass and associates it with the scene
  151975. * @returns the PrePassRenderer
  151976. */
  151977. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  151978. /**
  151979. * Disables the prepass associated with the scene
  151980. */
  151981. disablePrePassRenderer(): void;
  151982. }
  151983. /**
  151984. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151985. * in several rendering techniques.
  151986. */
  151987. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  151988. /**
  151989. * The component name helpful to identify the component in the list of scene components.
  151990. */
  151991. readonly name: string;
  151992. /**
  151993. * The scene the component belongs to.
  151994. */
  151995. scene: Scene;
  151996. /**
  151997. * Creates a new instance of the component for the given scene
  151998. * @param scene Defines the scene to register the component in
  151999. */
  152000. constructor(scene: Scene);
  152001. /**
  152002. * Registers the component in a given scene
  152003. */
  152004. register(): void;
  152005. private _beforeCameraDraw;
  152006. private _afterCameraDraw;
  152007. private _beforeClearStage;
  152008. /**
  152009. * Serializes the component data to the specified json object
  152010. * @param serializationObject The object to serialize to
  152011. */
  152012. serialize(serializationObject: any): void;
  152013. /**
  152014. * Adds all the elements from the container to the scene
  152015. * @param container the container holding the elements
  152016. */
  152017. addFromContainer(container: AbstractScene): void;
  152018. /**
  152019. * Removes all the elements in the container from the scene
  152020. * @param container contains the elements to remove
  152021. * @param dispose if the removed element should be disposed (default: false)
  152022. */
  152023. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  152024. /**
  152025. * Rebuilds the elements related to this component in case of
  152026. * context lost for instance.
  152027. */
  152028. rebuild(): void;
  152029. /**
  152030. * Disposes the component and the associated ressources
  152031. */
  152032. dispose(): void;
  152033. }
  152034. }
  152035. declare module BABYLON {
  152036. /** @hidden */
  152037. export var outlinePixelShader: {
  152038. name: string;
  152039. shader: string;
  152040. };
  152041. }
  152042. declare module BABYLON {
  152043. /** @hidden */
  152044. export var outlineVertexShader: {
  152045. name: string;
  152046. shader: string;
  152047. };
  152048. }
  152049. declare module BABYLON {
  152050. interface Scene {
  152051. /** @hidden */
  152052. _outlineRenderer: OutlineRenderer;
  152053. /**
  152054. * Gets the outline renderer associated with the scene
  152055. * @returns a OutlineRenderer
  152056. */
  152057. getOutlineRenderer(): OutlineRenderer;
  152058. }
  152059. interface AbstractMesh {
  152060. /** @hidden (Backing field) */
  152061. _renderOutline: boolean;
  152062. /**
  152063. * Gets or sets a boolean indicating if the outline must be rendered as well
  152064. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  152065. */
  152066. renderOutline: boolean;
  152067. /** @hidden (Backing field) */
  152068. _renderOverlay: boolean;
  152069. /**
  152070. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152071. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152072. */
  152073. renderOverlay: boolean;
  152074. }
  152075. /**
  152076. * This class is responsible to draw bothe outline/overlay of meshes.
  152077. * It should not be used directly but through the available method on mesh.
  152078. */
  152079. export class OutlineRenderer implements ISceneComponent {
  152080. /**
  152081. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152082. */
  152083. private static _StencilReference;
  152084. /**
  152085. * The name of the component. Each component must have a unique name.
  152086. */
  152087. name: string;
  152088. /**
  152089. * The scene the component belongs to.
  152090. */
  152091. scene: Scene;
  152092. /**
  152093. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152094. */
  152095. zOffset: number;
  152096. private _engine;
  152097. private _effect;
  152098. private _cachedDefines;
  152099. private _savedDepthWrite;
  152100. /**
  152101. * Instantiates a new outline renderer. (There could be only one per scene).
  152102. * @param scene Defines the scene it belongs to
  152103. */
  152104. constructor(scene: Scene);
  152105. /**
  152106. * Register the component to one instance of a scene.
  152107. */
  152108. register(): void;
  152109. /**
  152110. * Rebuilds the elements related to this component in case of
  152111. * context lost for instance.
  152112. */
  152113. rebuild(): void;
  152114. /**
  152115. * Disposes the component and the associated ressources.
  152116. */
  152117. dispose(): void;
  152118. /**
  152119. * Renders the outline in the canvas.
  152120. * @param subMesh Defines the sumesh to render
  152121. * @param batch Defines the batch of meshes in case of instances
  152122. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152123. */
  152124. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152125. /**
  152126. * Returns whether or not the outline renderer is ready for a given submesh.
  152127. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152128. * @param subMesh Defines the submesh to check readyness for
  152129. * @param useInstances Defines wheter wee are trying to render instances or not
  152130. * @returns true if ready otherwise false
  152131. */
  152132. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152133. private _beforeRenderingMesh;
  152134. private _afterRenderingMesh;
  152135. }
  152136. }
  152137. declare module BABYLON {
  152138. /**
  152139. * Defines the basic options interface of a Sprite Frame Source Size.
  152140. */
  152141. export interface ISpriteJSONSpriteSourceSize {
  152142. /**
  152143. * number of the original width of the Frame
  152144. */
  152145. w: number;
  152146. /**
  152147. * number of the original height of the Frame
  152148. */
  152149. h: number;
  152150. }
  152151. /**
  152152. * Defines the basic options interface of a Sprite Frame Data.
  152153. */
  152154. export interface ISpriteJSONSpriteFrameData {
  152155. /**
  152156. * number of the x offset of the Frame
  152157. */
  152158. x: number;
  152159. /**
  152160. * number of the y offset of the Frame
  152161. */
  152162. y: number;
  152163. /**
  152164. * number of the width of the Frame
  152165. */
  152166. w: number;
  152167. /**
  152168. * number of the height of the Frame
  152169. */
  152170. h: number;
  152171. }
  152172. /**
  152173. * Defines the basic options interface of a JSON Sprite.
  152174. */
  152175. export interface ISpriteJSONSprite {
  152176. /**
  152177. * string name of the Frame
  152178. */
  152179. filename: string;
  152180. /**
  152181. * ISpriteJSONSpriteFrame basic object of the frame data
  152182. */
  152183. frame: ISpriteJSONSpriteFrameData;
  152184. /**
  152185. * boolean to flag is the frame was rotated.
  152186. */
  152187. rotated: boolean;
  152188. /**
  152189. * boolean to flag is the frame was trimmed.
  152190. */
  152191. trimmed: boolean;
  152192. /**
  152193. * ISpriteJSONSpriteFrame basic object of the source data
  152194. */
  152195. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152196. /**
  152197. * ISpriteJSONSpriteFrame basic object of the source data
  152198. */
  152199. sourceSize: ISpriteJSONSpriteSourceSize;
  152200. }
  152201. /**
  152202. * Defines the basic options interface of a JSON atlas.
  152203. */
  152204. export interface ISpriteJSONAtlas {
  152205. /**
  152206. * Array of objects that contain the frame data.
  152207. */
  152208. frames: Array<ISpriteJSONSprite>;
  152209. /**
  152210. * object basic object containing the sprite meta data.
  152211. */
  152212. meta?: object;
  152213. }
  152214. }
  152215. declare module BABYLON {
  152216. /** @hidden */
  152217. export var spriteMapPixelShader: {
  152218. name: string;
  152219. shader: string;
  152220. };
  152221. }
  152222. declare module BABYLON {
  152223. /** @hidden */
  152224. export var spriteMapVertexShader: {
  152225. name: string;
  152226. shader: string;
  152227. };
  152228. }
  152229. declare module BABYLON {
  152230. /**
  152231. * Defines the basic options interface of a SpriteMap
  152232. */
  152233. export interface ISpriteMapOptions {
  152234. /**
  152235. * Vector2 of the number of cells in the grid.
  152236. */
  152237. stageSize?: Vector2;
  152238. /**
  152239. * Vector2 of the size of the output plane in World Units.
  152240. */
  152241. outputSize?: Vector2;
  152242. /**
  152243. * Vector3 of the position of the output plane in World Units.
  152244. */
  152245. outputPosition?: Vector3;
  152246. /**
  152247. * Vector3 of the rotation of the output plane.
  152248. */
  152249. outputRotation?: Vector3;
  152250. /**
  152251. * number of layers that the system will reserve in resources.
  152252. */
  152253. layerCount?: number;
  152254. /**
  152255. * number of max animation frames a single cell will reserve in resources.
  152256. */
  152257. maxAnimationFrames?: number;
  152258. /**
  152259. * number cell index of the base tile when the system compiles.
  152260. */
  152261. baseTile?: number;
  152262. /**
  152263. * boolean flip the sprite after its been repositioned by the framing data.
  152264. */
  152265. flipU?: boolean;
  152266. /**
  152267. * Vector3 scalar of the global RGB values of the SpriteMap.
  152268. */
  152269. colorMultiply?: Vector3;
  152270. }
  152271. /**
  152272. * Defines the IDisposable interface in order to be cleanable from resources.
  152273. */
  152274. export interface ISpriteMap extends IDisposable {
  152275. /**
  152276. * String name of the SpriteMap.
  152277. */
  152278. name: string;
  152279. /**
  152280. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152281. */
  152282. atlasJSON: ISpriteJSONAtlas;
  152283. /**
  152284. * Texture of the SpriteMap.
  152285. */
  152286. spriteSheet: Texture;
  152287. /**
  152288. * The parameters to initialize the SpriteMap with.
  152289. */
  152290. options: ISpriteMapOptions;
  152291. }
  152292. /**
  152293. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152294. */
  152295. export class SpriteMap implements ISpriteMap {
  152296. /** The Name of the spriteMap */
  152297. name: string;
  152298. /** The JSON file with the frame and meta data */
  152299. atlasJSON: ISpriteJSONAtlas;
  152300. /** The systems Sprite Sheet Texture */
  152301. spriteSheet: Texture;
  152302. /** Arguments passed with the Constructor */
  152303. options: ISpriteMapOptions;
  152304. /** Public Sprite Storage array, parsed from atlasJSON */
  152305. sprites: Array<ISpriteJSONSprite>;
  152306. /** Returns the Number of Sprites in the System */
  152307. get spriteCount(): number;
  152308. /** Returns the Position of Output Plane*/
  152309. get position(): Vector3;
  152310. /** Returns the Position of Output Plane*/
  152311. set position(v: Vector3);
  152312. /** Returns the Rotation of Output Plane*/
  152313. get rotation(): Vector3;
  152314. /** Returns the Rotation of Output Plane*/
  152315. set rotation(v: Vector3);
  152316. /** Sets the AnimationMap*/
  152317. get animationMap(): RawTexture;
  152318. /** Sets the AnimationMap*/
  152319. set animationMap(v: RawTexture);
  152320. /** Scene that the SpriteMap was created in */
  152321. private _scene;
  152322. /** Texture Buffer of Float32 that holds tile frame data*/
  152323. private _frameMap;
  152324. /** Texture Buffers of Float32 that holds tileMap data*/
  152325. private _tileMaps;
  152326. /** Texture Buffer of Float32 that holds Animation Data*/
  152327. private _animationMap;
  152328. /** Custom ShaderMaterial Central to the System*/
  152329. private _material;
  152330. /** Custom ShaderMaterial Central to the System*/
  152331. private _output;
  152332. /** Systems Time Ticker*/
  152333. private _time;
  152334. /**
  152335. * Creates a new SpriteMap
  152336. * @param name defines the SpriteMaps Name
  152337. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152338. * @param spriteSheet is the Texture that the Sprites are on.
  152339. * @param options a basic deployment configuration
  152340. * @param scene The Scene that the map is deployed on
  152341. */
  152342. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152343. /**
  152344. * Returns tileID location
  152345. * @returns Vector2 the cell position ID
  152346. */
  152347. getTileID(): Vector2;
  152348. /**
  152349. * Gets the UV location of the mouse over the SpriteMap.
  152350. * @returns Vector2 the UV position of the mouse interaction
  152351. */
  152352. getMousePosition(): Vector2;
  152353. /**
  152354. * Creates the "frame" texture Buffer
  152355. * -------------------------------------
  152356. * Structure of frames
  152357. * "filename": "Falling-Water-2.png",
  152358. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152359. * "rotated": true,
  152360. * "trimmed": true,
  152361. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152362. * "sourceSize": {"w":32,"h":32}
  152363. * @returns RawTexture of the frameMap
  152364. */
  152365. private _createFrameBuffer;
  152366. /**
  152367. * Creates the tileMap texture Buffer
  152368. * @param buffer normally and array of numbers, or a false to generate from scratch
  152369. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  152370. * @returns RawTexture of the tileMap
  152371. */
  152372. private _createTileBuffer;
  152373. /**
  152374. * Modifies the data of the tileMaps
  152375. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  152376. * @param pos is the iVector2 Coordinates of the Tile
  152377. * @param tile The SpriteIndex of the new Tile
  152378. */
  152379. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  152380. /**
  152381. * Creates the animationMap texture Buffer
  152382. * @param buffer normally and array of numbers, or a false to generate from scratch
  152383. * @returns RawTexture of the animationMap
  152384. */
  152385. private _createTileAnimationBuffer;
  152386. /**
  152387. * Modifies the data of the animationMap
  152388. * @param cellID is the Index of the Sprite
  152389. * @param _frame is the target Animation frame
  152390. * @param toCell is the Target Index of the next frame of the animation
  152391. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  152392. * @param speed is a global scalar of the time variable on the map.
  152393. */
  152394. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  152395. /**
  152396. * Exports the .tilemaps file
  152397. */
  152398. saveTileMaps(): void;
  152399. /**
  152400. * Imports the .tilemaps file
  152401. * @param url of the .tilemaps file
  152402. */
  152403. loadTileMaps(url: string): void;
  152404. /**
  152405. * Release associated resources
  152406. */
  152407. dispose(): void;
  152408. }
  152409. }
  152410. declare module BABYLON {
  152411. /**
  152412. * Class used to manage multiple sprites of different sizes on the same spritesheet
  152413. * @see https://doc.babylonjs.com/babylon101/sprites
  152414. */
  152415. export class SpritePackedManager extends SpriteManager {
  152416. /** defines the packed manager's name */
  152417. name: string;
  152418. /**
  152419. * Creates a new sprite manager from a packed sprite sheet
  152420. * @param name defines the manager's name
  152421. * @param imgUrl defines the sprite sheet url
  152422. * @param capacity defines the maximum allowed number of sprites
  152423. * @param scene defines the hosting scene
  152424. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  152425. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  152426. * @param samplingMode defines the smapling mode to use with spritesheet
  152427. * @param fromPacked set to true; do not alter
  152428. */
  152429. constructor(
  152430. /** defines the packed manager's name */
  152431. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  152432. }
  152433. }
  152434. declare module BABYLON {
  152435. /**
  152436. * Defines the list of states available for a task inside a AssetsManager
  152437. */
  152438. export enum AssetTaskState {
  152439. /**
  152440. * Initialization
  152441. */
  152442. INIT = 0,
  152443. /**
  152444. * Running
  152445. */
  152446. RUNNING = 1,
  152447. /**
  152448. * Done
  152449. */
  152450. DONE = 2,
  152451. /**
  152452. * Error
  152453. */
  152454. ERROR = 3
  152455. }
  152456. /**
  152457. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  152458. */
  152459. export abstract class AbstractAssetTask {
  152460. /**
  152461. * Task name
  152462. */ name: string;
  152463. /**
  152464. * Callback called when the task is successful
  152465. */
  152466. onSuccess: (task: any) => void;
  152467. /**
  152468. * Callback called when the task is not successful
  152469. */
  152470. onError: (task: any, message?: string, exception?: any) => void;
  152471. /**
  152472. * Creates a new AssetsManager
  152473. * @param name defines the name of the task
  152474. */
  152475. constructor(
  152476. /**
  152477. * Task name
  152478. */ name: string);
  152479. private _isCompleted;
  152480. private _taskState;
  152481. private _errorObject;
  152482. /**
  152483. * Get if the task is completed
  152484. */
  152485. get isCompleted(): boolean;
  152486. /**
  152487. * Gets the current state of the task
  152488. */
  152489. get taskState(): AssetTaskState;
  152490. /**
  152491. * Gets the current error object (if task is in error)
  152492. */
  152493. get errorObject(): {
  152494. message?: string;
  152495. exception?: any;
  152496. };
  152497. /**
  152498. * Internal only
  152499. * @hidden
  152500. */
  152501. _setErrorObject(message?: string, exception?: any): void;
  152502. /**
  152503. * Execute the current task
  152504. * @param scene defines the scene where you want your assets to be loaded
  152505. * @param onSuccess is a callback called when the task is successfully executed
  152506. * @param onError is a callback called if an error occurs
  152507. */
  152508. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152509. /**
  152510. * Execute the current task
  152511. * @param scene defines the scene where you want your assets to be loaded
  152512. * @param onSuccess is a callback called when the task is successfully executed
  152513. * @param onError is a callback called if an error occurs
  152514. */
  152515. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152516. /**
  152517. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  152518. * This can be used with failed tasks that have the reason for failure fixed.
  152519. */
  152520. reset(): void;
  152521. private onErrorCallback;
  152522. private onDoneCallback;
  152523. }
  152524. /**
  152525. * Define the interface used by progress events raised during assets loading
  152526. */
  152527. export interface IAssetsProgressEvent {
  152528. /**
  152529. * Defines the number of remaining tasks to process
  152530. */
  152531. remainingCount: number;
  152532. /**
  152533. * Defines the total number of tasks
  152534. */
  152535. totalCount: number;
  152536. /**
  152537. * Defines the task that was just processed
  152538. */
  152539. task: AbstractAssetTask;
  152540. }
  152541. /**
  152542. * Class used to share progress information about assets loading
  152543. */
  152544. export class AssetsProgressEvent implements IAssetsProgressEvent {
  152545. /**
  152546. * Defines the number of remaining tasks to process
  152547. */
  152548. remainingCount: number;
  152549. /**
  152550. * Defines the total number of tasks
  152551. */
  152552. totalCount: number;
  152553. /**
  152554. * Defines the task that was just processed
  152555. */
  152556. task: AbstractAssetTask;
  152557. /**
  152558. * Creates a AssetsProgressEvent
  152559. * @param remainingCount defines the number of remaining tasks to process
  152560. * @param totalCount defines the total number of tasks
  152561. * @param task defines the task that was just processed
  152562. */
  152563. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  152564. }
  152565. /**
  152566. * Define a task used by AssetsManager to load assets into a container
  152567. */
  152568. export class ContainerAssetTask extends AbstractAssetTask {
  152569. /**
  152570. * Defines the name of the task
  152571. */
  152572. name: string;
  152573. /**
  152574. * Defines the list of mesh's names you want to load
  152575. */
  152576. meshesNames: any;
  152577. /**
  152578. * Defines the root url to use as a base to load your meshes and associated resources
  152579. */
  152580. rootUrl: string;
  152581. /**
  152582. * Defines the filename or File of the scene to load from
  152583. */
  152584. sceneFilename: string | File;
  152585. /**
  152586. * Get the loaded asset container
  152587. */
  152588. loadedContainer: AssetContainer;
  152589. /**
  152590. * Gets the list of loaded meshes
  152591. */
  152592. loadedMeshes: Array<AbstractMesh>;
  152593. /**
  152594. * Gets the list of loaded particle systems
  152595. */
  152596. loadedParticleSystems: Array<IParticleSystem>;
  152597. /**
  152598. * Gets the list of loaded skeletons
  152599. */
  152600. loadedSkeletons: Array<Skeleton>;
  152601. /**
  152602. * Gets the list of loaded animation groups
  152603. */
  152604. loadedAnimationGroups: Array<AnimationGroup>;
  152605. /**
  152606. * Callback called when the task is successful
  152607. */
  152608. onSuccess: (task: ContainerAssetTask) => void;
  152609. /**
  152610. * Callback called when the task is successful
  152611. */
  152612. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  152613. /**
  152614. * Creates a new ContainerAssetTask
  152615. * @param name defines the name of the task
  152616. * @param meshesNames defines the list of mesh's names you want to load
  152617. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152618. * @param sceneFilename defines the filename or File of the scene to load from
  152619. */
  152620. constructor(
  152621. /**
  152622. * Defines the name of the task
  152623. */
  152624. name: string,
  152625. /**
  152626. * Defines the list of mesh's names you want to load
  152627. */
  152628. meshesNames: any,
  152629. /**
  152630. * Defines the root url to use as a base to load your meshes and associated resources
  152631. */
  152632. rootUrl: string,
  152633. /**
  152634. * Defines the filename or File of the scene to load from
  152635. */
  152636. sceneFilename: string | File);
  152637. /**
  152638. * Execute the current task
  152639. * @param scene defines the scene where you want your assets to be loaded
  152640. * @param onSuccess is a callback called when the task is successfully executed
  152641. * @param onError is a callback called if an error occurs
  152642. */
  152643. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152644. }
  152645. /**
  152646. * Define a task used by AssetsManager to load meshes
  152647. */
  152648. export class MeshAssetTask extends AbstractAssetTask {
  152649. /**
  152650. * Defines the name of the task
  152651. */
  152652. name: string;
  152653. /**
  152654. * Defines the list of mesh's names you want to load
  152655. */
  152656. meshesNames: any;
  152657. /**
  152658. * Defines the root url to use as a base to load your meshes and associated resources
  152659. */
  152660. rootUrl: string;
  152661. /**
  152662. * Defines the filename or File of the scene to load from
  152663. */
  152664. sceneFilename: string | File;
  152665. /**
  152666. * Gets the list of loaded meshes
  152667. */
  152668. loadedMeshes: Array<AbstractMesh>;
  152669. /**
  152670. * Gets the list of loaded particle systems
  152671. */
  152672. loadedParticleSystems: Array<IParticleSystem>;
  152673. /**
  152674. * Gets the list of loaded skeletons
  152675. */
  152676. loadedSkeletons: Array<Skeleton>;
  152677. /**
  152678. * Gets the list of loaded animation groups
  152679. */
  152680. loadedAnimationGroups: Array<AnimationGroup>;
  152681. /**
  152682. * Callback called when the task is successful
  152683. */
  152684. onSuccess: (task: MeshAssetTask) => void;
  152685. /**
  152686. * Callback called when the task is successful
  152687. */
  152688. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  152689. /**
  152690. * Creates a new MeshAssetTask
  152691. * @param name defines the name of the task
  152692. * @param meshesNames defines the list of mesh's names you want to load
  152693. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152694. * @param sceneFilename defines the filename or File of the scene to load from
  152695. */
  152696. constructor(
  152697. /**
  152698. * Defines the name of the task
  152699. */
  152700. name: string,
  152701. /**
  152702. * Defines the list of mesh's names you want to load
  152703. */
  152704. meshesNames: any,
  152705. /**
  152706. * Defines the root url to use as a base to load your meshes and associated resources
  152707. */
  152708. rootUrl: string,
  152709. /**
  152710. * Defines the filename or File of the scene to load from
  152711. */
  152712. sceneFilename: string | File);
  152713. /**
  152714. * Execute the current task
  152715. * @param scene defines the scene where you want your assets to be loaded
  152716. * @param onSuccess is a callback called when the task is successfully executed
  152717. * @param onError is a callback called if an error occurs
  152718. */
  152719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152720. }
  152721. /**
  152722. * Define a task used by AssetsManager to load text content
  152723. */
  152724. export class TextFileAssetTask extends AbstractAssetTask {
  152725. /**
  152726. * Defines the name of the task
  152727. */
  152728. name: string;
  152729. /**
  152730. * Defines the location of the file to load
  152731. */
  152732. url: string;
  152733. /**
  152734. * Gets the loaded text string
  152735. */
  152736. text: string;
  152737. /**
  152738. * Callback called when the task is successful
  152739. */
  152740. onSuccess: (task: TextFileAssetTask) => void;
  152741. /**
  152742. * Callback called when the task is successful
  152743. */
  152744. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  152745. /**
  152746. * Creates a new TextFileAssetTask object
  152747. * @param name defines the name of the task
  152748. * @param url defines the location of the file to load
  152749. */
  152750. constructor(
  152751. /**
  152752. * Defines the name of the task
  152753. */
  152754. name: string,
  152755. /**
  152756. * Defines the location of the file to load
  152757. */
  152758. url: string);
  152759. /**
  152760. * Execute the current task
  152761. * @param scene defines the scene where you want your assets to be loaded
  152762. * @param onSuccess is a callback called when the task is successfully executed
  152763. * @param onError is a callback called if an error occurs
  152764. */
  152765. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152766. }
  152767. /**
  152768. * Define a task used by AssetsManager to load binary data
  152769. */
  152770. export class BinaryFileAssetTask extends AbstractAssetTask {
  152771. /**
  152772. * Defines the name of the task
  152773. */
  152774. name: string;
  152775. /**
  152776. * Defines the location of the file to load
  152777. */
  152778. url: string;
  152779. /**
  152780. * Gets the lodaded data (as an array buffer)
  152781. */
  152782. data: ArrayBuffer;
  152783. /**
  152784. * Callback called when the task is successful
  152785. */
  152786. onSuccess: (task: BinaryFileAssetTask) => void;
  152787. /**
  152788. * Callback called when the task is successful
  152789. */
  152790. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  152791. /**
  152792. * Creates a new BinaryFileAssetTask object
  152793. * @param name defines the name of the new task
  152794. * @param url defines the location of the file to load
  152795. */
  152796. constructor(
  152797. /**
  152798. * Defines the name of the task
  152799. */
  152800. name: string,
  152801. /**
  152802. * Defines the location of the file to load
  152803. */
  152804. url: string);
  152805. /**
  152806. * Execute the current task
  152807. * @param scene defines the scene where you want your assets to be loaded
  152808. * @param onSuccess is a callback called when the task is successfully executed
  152809. * @param onError is a callback called if an error occurs
  152810. */
  152811. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152812. }
  152813. /**
  152814. * Define a task used by AssetsManager to load images
  152815. */
  152816. export class ImageAssetTask extends AbstractAssetTask {
  152817. /**
  152818. * Defines the name of the task
  152819. */
  152820. name: string;
  152821. /**
  152822. * Defines the location of the image to load
  152823. */
  152824. url: string;
  152825. /**
  152826. * Gets the loaded images
  152827. */
  152828. image: HTMLImageElement;
  152829. /**
  152830. * Callback called when the task is successful
  152831. */
  152832. onSuccess: (task: ImageAssetTask) => void;
  152833. /**
  152834. * Callback called when the task is successful
  152835. */
  152836. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  152837. /**
  152838. * Creates a new ImageAssetTask
  152839. * @param name defines the name of the task
  152840. * @param url defines the location of the image to load
  152841. */
  152842. constructor(
  152843. /**
  152844. * Defines the name of the task
  152845. */
  152846. name: string,
  152847. /**
  152848. * Defines the location of the image to load
  152849. */
  152850. url: string);
  152851. /**
  152852. * Execute the current task
  152853. * @param scene defines the scene where you want your assets to be loaded
  152854. * @param onSuccess is a callback called when the task is successfully executed
  152855. * @param onError is a callback called if an error occurs
  152856. */
  152857. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152858. }
  152859. /**
  152860. * Defines the interface used by texture loading tasks
  152861. */
  152862. export interface ITextureAssetTask<TEX extends BaseTexture> {
  152863. /**
  152864. * Gets the loaded texture
  152865. */
  152866. texture: TEX;
  152867. }
  152868. /**
  152869. * Define a task used by AssetsManager to load 2D textures
  152870. */
  152871. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  152872. /**
  152873. * Defines the name of the task
  152874. */
  152875. name: string;
  152876. /**
  152877. * Defines the location of the file to load
  152878. */
  152879. url: string;
  152880. /**
  152881. * Defines if mipmap should not be generated (default is false)
  152882. */
  152883. noMipmap?: boolean | undefined;
  152884. /**
  152885. * Defines if texture must be inverted on Y axis (default is true)
  152886. */
  152887. invertY: boolean;
  152888. /**
  152889. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152890. */
  152891. samplingMode: number;
  152892. /**
  152893. * Gets the loaded texture
  152894. */
  152895. texture: Texture;
  152896. /**
  152897. * Callback called when the task is successful
  152898. */
  152899. onSuccess: (task: TextureAssetTask) => void;
  152900. /**
  152901. * Callback called when the task is successful
  152902. */
  152903. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  152904. /**
  152905. * Creates a new TextureAssetTask object
  152906. * @param name defines the name of the task
  152907. * @param url defines the location of the file to load
  152908. * @param noMipmap defines if mipmap should not be generated (default is false)
  152909. * @param invertY defines if texture must be inverted on Y axis (default is true)
  152910. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152911. */
  152912. constructor(
  152913. /**
  152914. * Defines the name of the task
  152915. */
  152916. name: string,
  152917. /**
  152918. * Defines the location of the file to load
  152919. */
  152920. url: string,
  152921. /**
  152922. * Defines if mipmap should not be generated (default is false)
  152923. */
  152924. noMipmap?: boolean | undefined,
  152925. /**
  152926. * Defines if texture must be inverted on Y axis (default is true)
  152927. */
  152928. invertY?: boolean,
  152929. /**
  152930. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152931. */
  152932. samplingMode?: number);
  152933. /**
  152934. * Execute the current task
  152935. * @param scene defines the scene where you want your assets to be loaded
  152936. * @param onSuccess is a callback called when the task is successfully executed
  152937. * @param onError is a callback called if an error occurs
  152938. */
  152939. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152940. }
  152941. /**
  152942. * Define a task used by AssetsManager to load cube textures
  152943. */
  152944. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  152945. /**
  152946. * Defines the name of the task
  152947. */
  152948. name: string;
  152949. /**
  152950. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152951. */
  152952. url: string;
  152953. /**
  152954. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152955. */
  152956. extensions?: string[] | undefined;
  152957. /**
  152958. * Defines if mipmaps should not be generated (default is false)
  152959. */
  152960. noMipmap?: boolean | undefined;
  152961. /**
  152962. * Defines the explicit list of files (undefined by default)
  152963. */
  152964. files?: string[] | undefined;
  152965. /**
  152966. * Gets the loaded texture
  152967. */
  152968. texture: CubeTexture;
  152969. /**
  152970. * Callback called when the task is successful
  152971. */
  152972. onSuccess: (task: CubeTextureAssetTask) => void;
  152973. /**
  152974. * Callback called when the task is successful
  152975. */
  152976. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  152977. /**
  152978. * Creates a new CubeTextureAssetTask
  152979. * @param name defines the name of the task
  152980. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152981. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152982. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152983. * @param files defines the explicit list of files (undefined by default)
  152984. */
  152985. constructor(
  152986. /**
  152987. * Defines the name of the task
  152988. */
  152989. name: string,
  152990. /**
  152991. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152992. */
  152993. url: string,
  152994. /**
  152995. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152996. */
  152997. extensions?: string[] | undefined,
  152998. /**
  152999. * Defines if mipmaps should not be generated (default is false)
  153000. */
  153001. noMipmap?: boolean | undefined,
  153002. /**
  153003. * Defines the explicit list of files (undefined by default)
  153004. */
  153005. files?: string[] | undefined);
  153006. /**
  153007. * Execute the current task
  153008. * @param scene defines the scene where you want your assets to be loaded
  153009. * @param onSuccess is a callback called when the task is successfully executed
  153010. * @param onError is a callback called if an error occurs
  153011. */
  153012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153013. }
  153014. /**
  153015. * Define a task used by AssetsManager to load HDR cube textures
  153016. */
  153017. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  153018. /**
  153019. * Defines the name of the task
  153020. */
  153021. name: string;
  153022. /**
  153023. * Defines the location of the file to load
  153024. */
  153025. url: string;
  153026. /**
  153027. * Defines the desired size (the more it increases the longer the generation will be)
  153028. */
  153029. size: number;
  153030. /**
  153031. * Defines if mipmaps should not be generated (default is false)
  153032. */
  153033. noMipmap: boolean;
  153034. /**
  153035. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153036. */
  153037. generateHarmonics: boolean;
  153038. /**
  153039. * 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)
  153040. */
  153041. gammaSpace: boolean;
  153042. /**
  153043. * Internal Use Only
  153044. */
  153045. reserved: boolean;
  153046. /**
  153047. * Gets the loaded texture
  153048. */
  153049. texture: HDRCubeTexture;
  153050. /**
  153051. * Callback called when the task is successful
  153052. */
  153053. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  153054. /**
  153055. * Callback called when the task is successful
  153056. */
  153057. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  153058. /**
  153059. * Creates a new HDRCubeTextureAssetTask object
  153060. * @param name defines the name of the task
  153061. * @param url defines the location of the file to load
  153062. * @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.
  153063. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153064. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153065. * @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)
  153066. * @param reserved Internal use only
  153067. */
  153068. constructor(
  153069. /**
  153070. * Defines the name of the task
  153071. */
  153072. name: string,
  153073. /**
  153074. * Defines the location of the file to load
  153075. */
  153076. url: string,
  153077. /**
  153078. * Defines the desired size (the more it increases the longer the generation will be)
  153079. */
  153080. size: number,
  153081. /**
  153082. * Defines if mipmaps should not be generated (default is false)
  153083. */
  153084. noMipmap?: boolean,
  153085. /**
  153086. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153087. */
  153088. generateHarmonics?: boolean,
  153089. /**
  153090. * 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)
  153091. */
  153092. gammaSpace?: boolean,
  153093. /**
  153094. * Internal Use Only
  153095. */
  153096. reserved?: boolean);
  153097. /**
  153098. * Execute the current task
  153099. * @param scene defines the scene where you want your assets to be loaded
  153100. * @param onSuccess is a callback called when the task is successfully executed
  153101. * @param onError is a callback called if an error occurs
  153102. */
  153103. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153104. }
  153105. /**
  153106. * Define a task used by AssetsManager to load Equirectangular cube textures
  153107. */
  153108. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153109. /**
  153110. * Defines the name of the task
  153111. */
  153112. name: string;
  153113. /**
  153114. * Defines the location of the file to load
  153115. */
  153116. url: string;
  153117. /**
  153118. * Defines the desired size (the more it increases the longer the generation will be)
  153119. */
  153120. size: number;
  153121. /**
  153122. * Defines if mipmaps should not be generated (default is false)
  153123. */
  153124. noMipmap: boolean;
  153125. /**
  153126. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153127. * but the standard material would require them in Gamma space) (default is true)
  153128. */
  153129. gammaSpace: boolean;
  153130. /**
  153131. * Gets the loaded texture
  153132. */
  153133. texture: EquiRectangularCubeTexture;
  153134. /**
  153135. * Callback called when the task is successful
  153136. */
  153137. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153138. /**
  153139. * Callback called when the task is successful
  153140. */
  153141. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153142. /**
  153143. * Creates a new EquiRectangularCubeTextureAssetTask object
  153144. * @param name defines the name of the task
  153145. * @param url defines the location of the file to load
  153146. * @param size defines the desired size (the more it increases the longer the generation will be)
  153147. * If the size is omitted this implies you are using a preprocessed cubemap.
  153148. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153149. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153150. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153151. * (default is true)
  153152. */
  153153. constructor(
  153154. /**
  153155. * Defines the name of the task
  153156. */
  153157. name: string,
  153158. /**
  153159. * Defines the location of the file to load
  153160. */
  153161. url: string,
  153162. /**
  153163. * Defines the desired size (the more it increases the longer the generation will be)
  153164. */
  153165. size: number,
  153166. /**
  153167. * Defines if mipmaps should not be generated (default is false)
  153168. */
  153169. noMipmap?: boolean,
  153170. /**
  153171. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153172. * but the standard material would require them in Gamma space) (default is true)
  153173. */
  153174. gammaSpace?: boolean);
  153175. /**
  153176. * Execute the current task
  153177. * @param scene defines the scene where you want your assets to be loaded
  153178. * @param onSuccess is a callback called when the task is successfully executed
  153179. * @param onError is a callback called if an error occurs
  153180. */
  153181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153182. }
  153183. /**
  153184. * This class can be used to easily import assets into a scene
  153185. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153186. */
  153187. export class AssetsManager {
  153188. private _scene;
  153189. private _isLoading;
  153190. protected _tasks: AbstractAssetTask[];
  153191. protected _waitingTasksCount: number;
  153192. protected _totalTasksCount: number;
  153193. /**
  153194. * Callback called when all tasks are processed
  153195. */
  153196. onFinish: (tasks: AbstractAssetTask[]) => void;
  153197. /**
  153198. * Callback called when a task is successful
  153199. */
  153200. onTaskSuccess: (task: AbstractAssetTask) => void;
  153201. /**
  153202. * Callback called when a task had an error
  153203. */
  153204. onTaskError: (task: AbstractAssetTask) => void;
  153205. /**
  153206. * Callback called when a task is done (whatever the result is)
  153207. */
  153208. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153209. /**
  153210. * Observable called when all tasks are processed
  153211. */
  153212. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153213. /**
  153214. * Observable called when a task had an error
  153215. */
  153216. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153217. /**
  153218. * Observable called when all tasks were executed
  153219. */
  153220. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153221. /**
  153222. * Observable called when a task is done (whatever the result is)
  153223. */
  153224. onProgressObservable: Observable<IAssetsProgressEvent>;
  153225. /**
  153226. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153227. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153228. */
  153229. useDefaultLoadingScreen: boolean;
  153230. /**
  153231. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153232. * when all assets have been downloaded.
  153233. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153234. */
  153235. autoHideLoadingUI: boolean;
  153236. /**
  153237. * Creates a new AssetsManager
  153238. * @param scene defines the scene to work on
  153239. */
  153240. constructor(scene: Scene);
  153241. /**
  153242. * Add a ContainerAssetTask to the list of active tasks
  153243. * @param taskName defines the name of the new task
  153244. * @param meshesNames defines the name of meshes to load
  153245. * @param rootUrl defines the root url to use to locate files
  153246. * @param sceneFilename defines the filename of the scene file
  153247. * @returns a new ContainerAssetTask object
  153248. */
  153249. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153250. /**
  153251. * Add a MeshAssetTask to the list of active tasks
  153252. * @param taskName defines the name of the new task
  153253. * @param meshesNames defines the name of meshes to load
  153254. * @param rootUrl defines the root url to use to locate files
  153255. * @param sceneFilename defines the filename of the scene file
  153256. * @returns a new MeshAssetTask object
  153257. */
  153258. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153259. /**
  153260. * Add a TextFileAssetTask to the list of active tasks
  153261. * @param taskName defines the name of the new task
  153262. * @param url defines the url of the file to load
  153263. * @returns a new TextFileAssetTask object
  153264. */
  153265. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153266. /**
  153267. * Add a BinaryFileAssetTask to the list of active tasks
  153268. * @param taskName defines the name of the new task
  153269. * @param url defines the url of the file to load
  153270. * @returns a new BinaryFileAssetTask object
  153271. */
  153272. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153273. /**
  153274. * Add a ImageAssetTask to the list of active tasks
  153275. * @param taskName defines the name of the new task
  153276. * @param url defines the url of the file to load
  153277. * @returns a new ImageAssetTask object
  153278. */
  153279. addImageTask(taskName: string, url: string): ImageAssetTask;
  153280. /**
  153281. * Add a TextureAssetTask to the list of active tasks
  153282. * @param taskName defines the name of the new task
  153283. * @param url defines the url of the file to load
  153284. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153285. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153286. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153287. * @returns a new TextureAssetTask object
  153288. */
  153289. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153290. /**
  153291. * Add a CubeTextureAssetTask to the list of active tasks
  153292. * @param taskName defines the name of the new task
  153293. * @param url defines the url of the file to load
  153294. * @param extensions defines the extension to use to load the cube map (can be null)
  153295. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153296. * @param files defines the list of files to load (can be null)
  153297. * @returns a new CubeTextureAssetTask object
  153298. */
  153299. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153300. /**
  153301. *
  153302. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153303. * @param taskName defines the name of the new task
  153304. * @param url defines the url of the file to load
  153305. * @param size defines the size you want for the cubemap (can be null)
  153306. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153307. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153308. * @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)
  153309. * @param reserved Internal use only
  153310. * @returns a new HDRCubeTextureAssetTask object
  153311. */
  153312. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153313. /**
  153314. *
  153315. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153316. * @param taskName defines the name of the new task
  153317. * @param url defines the url of the file to load
  153318. * @param size defines the size you want for the cubemap (can be null)
  153319. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153320. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153321. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153322. * @returns a new EquiRectangularCubeTextureAssetTask object
  153323. */
  153324. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153325. /**
  153326. * Remove a task from the assets manager.
  153327. * @param task the task to remove
  153328. */
  153329. removeTask(task: AbstractAssetTask): void;
  153330. private _decreaseWaitingTasksCount;
  153331. private _runTask;
  153332. /**
  153333. * Reset the AssetsManager and remove all tasks
  153334. * @return the current instance of the AssetsManager
  153335. */
  153336. reset(): AssetsManager;
  153337. /**
  153338. * Start the loading process
  153339. * @return the current instance of the AssetsManager
  153340. */
  153341. load(): AssetsManager;
  153342. /**
  153343. * Start the loading process as an async operation
  153344. * @return a promise returning the list of failed tasks
  153345. */
  153346. loadAsync(): Promise<void>;
  153347. }
  153348. }
  153349. declare module BABYLON {
  153350. /**
  153351. * Wrapper class for promise with external resolve and reject.
  153352. */
  153353. export class Deferred<T> {
  153354. /**
  153355. * The promise associated with this deferred object.
  153356. */
  153357. readonly promise: Promise<T>;
  153358. private _resolve;
  153359. private _reject;
  153360. /**
  153361. * The resolve method of the promise associated with this deferred object.
  153362. */
  153363. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153364. /**
  153365. * The reject method of the promise associated with this deferred object.
  153366. */
  153367. get reject(): (reason?: any) => void;
  153368. /**
  153369. * Constructor for this deferred object.
  153370. */
  153371. constructor();
  153372. }
  153373. }
  153374. declare module BABYLON {
  153375. /**
  153376. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  153377. */
  153378. export class MeshExploder {
  153379. private _centerMesh;
  153380. private _meshes;
  153381. private _meshesOrigins;
  153382. private _toCenterVectors;
  153383. private _scaledDirection;
  153384. private _newPosition;
  153385. private _centerPosition;
  153386. /**
  153387. * Explodes meshes from a center mesh.
  153388. * @param meshes The meshes to explode.
  153389. * @param centerMesh The mesh to be center of explosion.
  153390. */
  153391. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  153392. private _setCenterMesh;
  153393. /**
  153394. * Get class name
  153395. * @returns "MeshExploder"
  153396. */
  153397. getClassName(): string;
  153398. /**
  153399. * "Exploded meshes"
  153400. * @returns Array of meshes with the centerMesh at index 0.
  153401. */
  153402. getMeshes(): Array<Mesh>;
  153403. /**
  153404. * Explodes meshes giving a specific direction
  153405. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  153406. */
  153407. explode(direction?: number): void;
  153408. }
  153409. }
  153410. declare module BABYLON {
  153411. /**
  153412. * Class used to help managing file picking and drag'n'drop
  153413. */
  153414. export class FilesInput {
  153415. /**
  153416. * List of files ready to be loaded
  153417. */
  153418. static get FilesToLoad(): {
  153419. [key: string]: File;
  153420. };
  153421. /**
  153422. * Callback called when a file is processed
  153423. */
  153424. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  153425. private _engine;
  153426. private _currentScene;
  153427. private _sceneLoadedCallback;
  153428. private _progressCallback;
  153429. private _additionalRenderLoopLogicCallback;
  153430. private _textureLoadingCallback;
  153431. private _startingProcessingFilesCallback;
  153432. private _onReloadCallback;
  153433. private _errorCallback;
  153434. private _elementToMonitor;
  153435. private _sceneFileToLoad;
  153436. private _filesToLoad;
  153437. /**
  153438. * Creates a new FilesInput
  153439. * @param engine defines the rendering engine
  153440. * @param scene defines the hosting scene
  153441. * @param sceneLoadedCallback callback called when scene is loaded
  153442. * @param progressCallback callback called to track progress
  153443. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  153444. * @param textureLoadingCallback callback called when a texture is loading
  153445. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  153446. * @param onReloadCallback callback called when a reload is requested
  153447. * @param errorCallback callback call if an error occurs
  153448. */
  153449. 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>);
  153450. private _dragEnterHandler;
  153451. private _dragOverHandler;
  153452. private _dropHandler;
  153453. /**
  153454. * Calls this function to listen to drag'n'drop events on a specific DOM element
  153455. * @param elementToMonitor defines the DOM element to track
  153456. */
  153457. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  153458. /** Gets the current list of files to load */
  153459. get filesToLoad(): File[];
  153460. /**
  153461. * Release all associated resources
  153462. */
  153463. dispose(): void;
  153464. private renderFunction;
  153465. private drag;
  153466. private drop;
  153467. private _traverseFolder;
  153468. private _processFiles;
  153469. /**
  153470. * Load files from a drop event
  153471. * @param event defines the drop event to use as source
  153472. */
  153473. loadFiles(event: any): void;
  153474. private _processReload;
  153475. /**
  153476. * Reload the current scene from the loaded files
  153477. */
  153478. reload(): void;
  153479. }
  153480. }
  153481. declare module BABYLON {
  153482. /**
  153483. * Defines the root class used to create scene optimization to use with SceneOptimizer
  153484. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153485. */
  153486. export class SceneOptimization {
  153487. /**
  153488. * Defines the priority of this optimization (0 by default which means first in the list)
  153489. */
  153490. priority: number;
  153491. /**
  153492. * Gets a string describing the action executed by the current optimization
  153493. * @returns description string
  153494. */
  153495. getDescription(): string;
  153496. /**
  153497. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153498. * @param scene defines the current scene where to apply this optimization
  153499. * @param optimizer defines the current optimizer
  153500. * @returns true if everything that can be done was applied
  153501. */
  153502. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153503. /**
  153504. * Creates the SceneOptimization object
  153505. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153506. * @param desc defines the description associated with the optimization
  153507. */
  153508. constructor(
  153509. /**
  153510. * Defines the priority of this optimization (0 by default which means first in the list)
  153511. */
  153512. priority?: number);
  153513. }
  153514. /**
  153515. * Defines an optimization used to reduce the size of render target textures
  153516. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153517. */
  153518. export class TextureOptimization extends SceneOptimization {
  153519. /**
  153520. * Defines the priority of this optimization (0 by default which means first in the list)
  153521. */
  153522. priority: number;
  153523. /**
  153524. * 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
  153525. */
  153526. maximumSize: number;
  153527. /**
  153528. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153529. */
  153530. step: number;
  153531. /**
  153532. * Gets a string describing the action executed by the current optimization
  153533. * @returns description string
  153534. */
  153535. getDescription(): string;
  153536. /**
  153537. * Creates the TextureOptimization object
  153538. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153539. * @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
  153540. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153541. */
  153542. constructor(
  153543. /**
  153544. * Defines the priority of this optimization (0 by default which means first in the list)
  153545. */
  153546. priority?: number,
  153547. /**
  153548. * 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
  153549. */
  153550. maximumSize?: number,
  153551. /**
  153552. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153553. */
  153554. step?: number);
  153555. /**
  153556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153557. * @param scene defines the current scene where to apply this optimization
  153558. * @param optimizer defines the current optimizer
  153559. * @returns true if everything that can be done was applied
  153560. */
  153561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153562. }
  153563. /**
  153564. * Defines an optimization used to increase or decrease the rendering resolution
  153565. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153566. */
  153567. export class HardwareScalingOptimization extends SceneOptimization {
  153568. /**
  153569. * Defines the priority of this optimization (0 by default which means first in the list)
  153570. */
  153571. priority: number;
  153572. /**
  153573. * Defines the maximum scale to use (2 by default)
  153574. */
  153575. maximumScale: number;
  153576. /**
  153577. * Defines the step to use between two passes (0.5 by default)
  153578. */
  153579. step: number;
  153580. private _currentScale;
  153581. private _directionOffset;
  153582. /**
  153583. * Gets a string describing the action executed by the current optimization
  153584. * @return description string
  153585. */
  153586. getDescription(): string;
  153587. /**
  153588. * Creates the HardwareScalingOptimization object
  153589. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153590. * @param maximumScale defines the maximum scale to use (2 by default)
  153591. * @param step defines the step to use between two passes (0.5 by default)
  153592. */
  153593. constructor(
  153594. /**
  153595. * Defines the priority of this optimization (0 by default which means first in the list)
  153596. */
  153597. priority?: number,
  153598. /**
  153599. * Defines the maximum scale to use (2 by default)
  153600. */
  153601. maximumScale?: number,
  153602. /**
  153603. * Defines the step to use between two passes (0.5 by default)
  153604. */
  153605. step?: number);
  153606. /**
  153607. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153608. * @param scene defines the current scene where to apply this optimization
  153609. * @param optimizer defines the current optimizer
  153610. * @returns true if everything that can be done was applied
  153611. */
  153612. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153613. }
  153614. /**
  153615. * Defines an optimization used to remove shadows
  153616. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153617. */
  153618. export class ShadowsOptimization extends SceneOptimization {
  153619. /**
  153620. * Gets a string describing the action executed by the current optimization
  153621. * @return description string
  153622. */
  153623. getDescription(): string;
  153624. /**
  153625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153626. * @param scene defines the current scene where to apply this optimization
  153627. * @param optimizer defines the current optimizer
  153628. * @returns true if everything that can be done was applied
  153629. */
  153630. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153631. }
  153632. /**
  153633. * Defines an optimization used to turn post-processes off
  153634. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153635. */
  153636. export class PostProcessesOptimization extends SceneOptimization {
  153637. /**
  153638. * Gets a string describing the action executed by the current optimization
  153639. * @return description string
  153640. */
  153641. getDescription(): string;
  153642. /**
  153643. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153644. * @param scene defines the current scene where to apply this optimization
  153645. * @param optimizer defines the current optimizer
  153646. * @returns true if everything that can be done was applied
  153647. */
  153648. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153649. }
  153650. /**
  153651. * Defines an optimization used to turn lens flares off
  153652. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153653. */
  153654. export class LensFlaresOptimization extends SceneOptimization {
  153655. /**
  153656. * Gets a string describing the action executed by the current optimization
  153657. * @return description string
  153658. */
  153659. getDescription(): string;
  153660. /**
  153661. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153662. * @param scene defines the current scene where to apply this optimization
  153663. * @param optimizer defines the current optimizer
  153664. * @returns true if everything that can be done was applied
  153665. */
  153666. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153667. }
  153668. /**
  153669. * Defines an optimization based on user defined callback.
  153670. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153671. */
  153672. export class CustomOptimization extends SceneOptimization {
  153673. /**
  153674. * Callback called to apply the custom optimization.
  153675. */
  153676. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  153677. /**
  153678. * Callback called to get custom description
  153679. */
  153680. onGetDescription: () => string;
  153681. /**
  153682. * Gets a string describing the action executed by the current optimization
  153683. * @returns description string
  153684. */
  153685. getDescription(): string;
  153686. /**
  153687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153688. * @param scene defines the current scene where to apply this optimization
  153689. * @param optimizer defines the current optimizer
  153690. * @returns true if everything that can be done was applied
  153691. */
  153692. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153693. }
  153694. /**
  153695. * Defines an optimization used to turn particles off
  153696. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153697. */
  153698. export class ParticlesOptimization extends SceneOptimization {
  153699. /**
  153700. * Gets a string describing the action executed by the current optimization
  153701. * @return description string
  153702. */
  153703. getDescription(): string;
  153704. /**
  153705. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153706. * @param scene defines the current scene where to apply this optimization
  153707. * @param optimizer defines the current optimizer
  153708. * @returns true if everything that can be done was applied
  153709. */
  153710. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153711. }
  153712. /**
  153713. * Defines an optimization used to turn render targets off
  153714. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153715. */
  153716. export class RenderTargetsOptimization extends SceneOptimization {
  153717. /**
  153718. * Gets a string describing the action executed by the current optimization
  153719. * @return description string
  153720. */
  153721. getDescription(): string;
  153722. /**
  153723. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153724. * @param scene defines the current scene where to apply this optimization
  153725. * @param optimizer defines the current optimizer
  153726. * @returns true if everything that can be done was applied
  153727. */
  153728. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153729. }
  153730. /**
  153731. * Defines an optimization used to merge meshes with compatible materials
  153732. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153733. */
  153734. export class MergeMeshesOptimization extends SceneOptimization {
  153735. private static _UpdateSelectionTree;
  153736. /**
  153737. * Gets or sets a boolean which defines if optimization octree has to be updated
  153738. */
  153739. static get UpdateSelectionTree(): boolean;
  153740. /**
  153741. * Gets or sets a boolean which defines if optimization octree has to be updated
  153742. */
  153743. static set UpdateSelectionTree(value: boolean);
  153744. /**
  153745. * Gets a string describing the action executed by the current optimization
  153746. * @return description string
  153747. */
  153748. getDescription(): string;
  153749. private _canBeMerged;
  153750. /**
  153751. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153752. * @param scene defines the current scene where to apply this optimization
  153753. * @param optimizer defines the current optimizer
  153754. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  153755. * @returns true if everything that can be done was applied
  153756. */
  153757. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  153758. }
  153759. /**
  153760. * Defines a list of options used by SceneOptimizer
  153761. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153762. */
  153763. export class SceneOptimizerOptions {
  153764. /**
  153765. * Defines the target frame rate to reach (60 by default)
  153766. */
  153767. targetFrameRate: number;
  153768. /**
  153769. * Defines the interval between two checkes (2000ms by default)
  153770. */
  153771. trackerDuration: number;
  153772. /**
  153773. * Gets the list of optimizations to apply
  153774. */
  153775. optimizations: SceneOptimization[];
  153776. /**
  153777. * Creates a new list of options used by SceneOptimizer
  153778. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  153779. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  153780. */
  153781. constructor(
  153782. /**
  153783. * Defines the target frame rate to reach (60 by default)
  153784. */
  153785. targetFrameRate?: number,
  153786. /**
  153787. * Defines the interval between two checkes (2000ms by default)
  153788. */
  153789. trackerDuration?: number);
  153790. /**
  153791. * Add a new optimization
  153792. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  153793. * @returns the current SceneOptimizerOptions
  153794. */
  153795. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  153796. /**
  153797. * Add a new custom optimization
  153798. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  153799. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  153800. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153801. * @returns the current SceneOptimizerOptions
  153802. */
  153803. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  153804. /**
  153805. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  153806. * @param targetFrameRate defines the target frame rate (60 by default)
  153807. * @returns a SceneOptimizerOptions object
  153808. */
  153809. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153810. /**
  153811. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  153812. * @param targetFrameRate defines the target frame rate (60 by default)
  153813. * @returns a SceneOptimizerOptions object
  153814. */
  153815. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153816. /**
  153817. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  153818. * @param targetFrameRate defines the target frame rate (60 by default)
  153819. * @returns a SceneOptimizerOptions object
  153820. */
  153821. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153822. }
  153823. /**
  153824. * Class used to run optimizations in order to reach a target frame rate
  153825. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153826. */
  153827. export class SceneOptimizer implements IDisposable {
  153828. private _isRunning;
  153829. private _options;
  153830. private _scene;
  153831. private _currentPriorityLevel;
  153832. private _targetFrameRate;
  153833. private _trackerDuration;
  153834. private _currentFrameRate;
  153835. private _sceneDisposeObserver;
  153836. private _improvementMode;
  153837. /**
  153838. * Defines an observable called when the optimizer reaches the target frame rate
  153839. */
  153840. onSuccessObservable: Observable<SceneOptimizer>;
  153841. /**
  153842. * Defines an observable called when the optimizer enables an optimization
  153843. */
  153844. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  153845. /**
  153846. * Defines an observable called when the optimizer is not able to reach the target frame rate
  153847. */
  153848. onFailureObservable: Observable<SceneOptimizer>;
  153849. /**
  153850. * Gets a boolean indicating if the optimizer is in improvement mode
  153851. */
  153852. get isInImprovementMode(): boolean;
  153853. /**
  153854. * Gets the current priority level (0 at start)
  153855. */
  153856. get currentPriorityLevel(): number;
  153857. /**
  153858. * Gets the current frame rate checked by the SceneOptimizer
  153859. */
  153860. get currentFrameRate(): number;
  153861. /**
  153862. * Gets or sets the current target frame rate (60 by default)
  153863. */
  153864. get targetFrameRate(): number;
  153865. /**
  153866. * Gets or sets the current target frame rate (60 by default)
  153867. */
  153868. set targetFrameRate(value: number);
  153869. /**
  153870. * Gets or sets the current interval between two checks (every 2000ms by default)
  153871. */
  153872. get trackerDuration(): number;
  153873. /**
  153874. * Gets or sets the current interval between two checks (every 2000ms by default)
  153875. */
  153876. set trackerDuration(value: number);
  153877. /**
  153878. * Gets the list of active optimizations
  153879. */
  153880. get optimizations(): SceneOptimization[];
  153881. /**
  153882. * Creates a new SceneOptimizer
  153883. * @param scene defines the scene to work on
  153884. * @param options defines the options to use with the SceneOptimizer
  153885. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  153886. * @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)
  153887. */
  153888. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  153889. /**
  153890. * Stops the current optimizer
  153891. */
  153892. stop(): void;
  153893. /**
  153894. * Reset the optimizer to initial step (current priority level = 0)
  153895. */
  153896. reset(): void;
  153897. /**
  153898. * Start the optimizer. By default it will try to reach a specific framerate
  153899. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  153900. */
  153901. start(): void;
  153902. private _checkCurrentState;
  153903. /**
  153904. * Release all resources
  153905. */
  153906. dispose(): void;
  153907. /**
  153908. * Helper function to create a SceneOptimizer with one single line of code
  153909. * @param scene defines the scene to work on
  153910. * @param options defines the options to use with the SceneOptimizer
  153911. * @param onSuccess defines a callback to call on success
  153912. * @param onFailure defines a callback to call on failure
  153913. * @returns the new SceneOptimizer object
  153914. */
  153915. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  153916. }
  153917. }
  153918. declare module BABYLON {
  153919. /**
  153920. * Class used to serialize a scene into a string
  153921. */
  153922. export class SceneSerializer {
  153923. /**
  153924. * Clear cache used by a previous serialization
  153925. */
  153926. static ClearCache(): void;
  153927. /**
  153928. * Serialize a scene into a JSON compatible object
  153929. * @param scene defines the scene to serialize
  153930. * @returns a JSON compatible object
  153931. */
  153932. static Serialize(scene: Scene): any;
  153933. /**
  153934. * Serialize a mesh into a JSON compatible object
  153935. * @param toSerialize defines the mesh to serialize
  153936. * @param withParents defines if parents must be serialized as well
  153937. * @param withChildren defines if children must be serialized as well
  153938. * @returns a JSON compatible object
  153939. */
  153940. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  153941. }
  153942. }
  153943. declare module BABYLON {
  153944. /**
  153945. * Class used to host texture specific utilities
  153946. */
  153947. export class TextureTools {
  153948. /**
  153949. * Uses the GPU to create a copy texture rescaled at a given size
  153950. * @param texture Texture to copy from
  153951. * @param width defines the desired width
  153952. * @param height defines the desired height
  153953. * @param useBilinearMode defines if bilinear mode has to be used
  153954. * @return the generated texture
  153955. */
  153956. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  153957. }
  153958. }
  153959. declare module BABYLON {
  153960. /**
  153961. * This represents the different options available for the video capture.
  153962. */
  153963. export interface VideoRecorderOptions {
  153964. /** Defines the mime type of the video. */
  153965. mimeType: string;
  153966. /** Defines the FPS the video should be recorded at. */
  153967. fps: number;
  153968. /** Defines the chunk size for the recording data. */
  153969. recordChunckSize: number;
  153970. /** The audio tracks to attach to the recording. */
  153971. audioTracks?: MediaStreamTrack[];
  153972. }
  153973. /**
  153974. * This can help with recording videos from BabylonJS.
  153975. * This is based on the available WebRTC functionalities of the browser.
  153976. *
  153977. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  153978. */
  153979. export class VideoRecorder {
  153980. private static readonly _defaultOptions;
  153981. /**
  153982. * Returns whether or not the VideoRecorder is available in your browser.
  153983. * @param engine Defines the Babylon Engine.
  153984. * @returns true if supported otherwise false.
  153985. */
  153986. static IsSupported(engine: Engine): boolean;
  153987. private readonly _options;
  153988. private _canvas;
  153989. private _mediaRecorder;
  153990. private _recordedChunks;
  153991. private _fileName;
  153992. private _resolve;
  153993. private _reject;
  153994. /**
  153995. * True when a recording is already in progress.
  153996. */
  153997. get isRecording(): boolean;
  153998. /**
  153999. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  154000. * @param engine Defines the BabylonJS Engine you wish to record.
  154001. * @param options Defines options that can be used to customize the capture.
  154002. */
  154003. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  154004. /**
  154005. * Stops the current recording before the default capture timeout passed in the startRecording function.
  154006. */
  154007. stopRecording(): void;
  154008. /**
  154009. * Starts recording the canvas for a max duration specified in parameters.
  154010. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  154011. * If null no automatic download will start and you can rely on the promise to get the data back.
  154012. * @param maxDuration Defines the maximum recording time in seconds.
  154013. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  154014. * @return A promise callback at the end of the recording with the video data in Blob.
  154015. */
  154016. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  154017. /**
  154018. * Releases internal resources used during the recording.
  154019. */
  154020. dispose(): void;
  154021. private _handleDataAvailable;
  154022. private _handleError;
  154023. private _handleStop;
  154024. }
  154025. }
  154026. declare module BABYLON {
  154027. /**
  154028. * Class containing a set of static utilities functions for screenshots
  154029. */
  154030. export class ScreenshotTools {
  154031. /**
  154032. * Captures a screenshot of the current rendering
  154033. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154034. * @param engine defines the rendering engine
  154035. * @param camera defines the source camera
  154036. * @param size This parameter can be set to a single number or to an object with the
  154037. * following (optional) properties: precision, width, height. If a single number is passed,
  154038. * it will be used for both width and height. If an object is passed, the screenshot size
  154039. * will be derived from the parameters. The precision property is a multiplier allowing
  154040. * rendering at a higher or lower resolution
  154041. * @param successCallback defines the callback receives a single parameter which contains the
  154042. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154043. * src parameter of an <img> to display it
  154044. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154045. * Check your browser for supported MIME types
  154046. */
  154047. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  154048. /**
  154049. * Captures a screenshot of the current rendering
  154050. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154051. * @param engine defines the rendering engine
  154052. * @param camera defines the source camera
  154053. * @param size This parameter can be set to a single number or to an object with the
  154054. * following (optional) properties: precision, width, height. If a single number is passed,
  154055. * it will be used for both width and height. If an object is passed, the screenshot size
  154056. * will be derived from the parameters. The precision property is a multiplier allowing
  154057. * rendering at a higher or lower resolution
  154058. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154059. * Check your browser for supported MIME types
  154060. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154061. * to the src parameter of an <img> to display it
  154062. */
  154063. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  154064. /**
  154065. * Generates an image screenshot from the specified camera.
  154066. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154067. * @param engine The engine to use for rendering
  154068. * @param camera The camera to use for rendering
  154069. * @param size This parameter can be set to a single number or to an object with the
  154070. * following (optional) properties: precision, width, height. If a single number is passed,
  154071. * it will be used for both width and height. If an object is passed, the screenshot size
  154072. * will be derived from the parameters. The precision property is a multiplier allowing
  154073. * rendering at a higher or lower resolution
  154074. * @param successCallback The callback receives a single parameter which contains the
  154075. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154076. * src parameter of an <img> to display it
  154077. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154078. * Check your browser for supported MIME types
  154079. * @param samples Texture samples (default: 1)
  154080. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154081. * @param fileName A name for for the downloaded file.
  154082. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154083. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154084. */
  154085. 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;
  154086. /**
  154087. * Generates an image screenshot from the specified camera.
  154088. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154089. * @param engine The engine to use for rendering
  154090. * @param camera The camera to use for rendering
  154091. * @param size This parameter can be set to a single number or to an object with the
  154092. * following (optional) properties: precision, width, height. If a single number is passed,
  154093. * it will be used for both width and height. If an object is passed, the screenshot size
  154094. * will be derived from the parameters. The precision property is a multiplier allowing
  154095. * rendering at a higher or lower resolution
  154096. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154097. * Check your browser for supported MIME types
  154098. * @param samples Texture samples (default: 1)
  154099. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154100. * @param fileName A name for for the downloaded file.
  154101. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154102. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154103. * to the src parameter of an <img> to display it
  154104. */
  154105. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154106. /**
  154107. * Gets height and width for screenshot size
  154108. * @private
  154109. */
  154110. private static _getScreenshotSize;
  154111. }
  154112. }
  154113. declare module BABYLON {
  154114. /**
  154115. * Interface for a data buffer
  154116. */
  154117. export interface IDataBuffer {
  154118. /**
  154119. * Reads bytes from the data buffer.
  154120. * @param byteOffset The byte offset to read
  154121. * @param byteLength The byte length to read
  154122. * @returns A promise that resolves when the bytes are read
  154123. */
  154124. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154125. /**
  154126. * The byte length of the buffer.
  154127. */
  154128. readonly byteLength: number;
  154129. }
  154130. /**
  154131. * Utility class for reading from a data buffer
  154132. */
  154133. export class DataReader {
  154134. /**
  154135. * The data buffer associated with this data reader.
  154136. */
  154137. readonly buffer: IDataBuffer;
  154138. /**
  154139. * The current byte offset from the beginning of the data buffer.
  154140. */
  154141. byteOffset: number;
  154142. private _dataView;
  154143. private _dataByteOffset;
  154144. /**
  154145. * Constructor
  154146. * @param buffer The buffer to read
  154147. */
  154148. constructor(buffer: IDataBuffer);
  154149. /**
  154150. * Loads the given byte length.
  154151. * @param byteLength The byte length to load
  154152. * @returns A promise that resolves when the load is complete
  154153. */
  154154. loadAsync(byteLength: number): Promise<void>;
  154155. /**
  154156. * Read a unsigned 32-bit integer from the currently loaded data range.
  154157. * @returns The 32-bit integer read
  154158. */
  154159. readUint32(): number;
  154160. /**
  154161. * Read a byte array from the currently loaded data range.
  154162. * @param byteLength The byte length to read
  154163. * @returns The byte array read
  154164. */
  154165. readUint8Array(byteLength: number): Uint8Array;
  154166. /**
  154167. * Read a string from the currently loaded data range.
  154168. * @param byteLength The byte length to read
  154169. * @returns The string read
  154170. */
  154171. readString(byteLength: number): string;
  154172. /**
  154173. * Skips the given byte length the currently loaded data range.
  154174. * @param byteLength The byte length to skip
  154175. */
  154176. skipBytes(byteLength: number): void;
  154177. }
  154178. }
  154179. declare module BABYLON {
  154180. /**
  154181. * Class for storing data to local storage if available or in-memory storage otherwise
  154182. */
  154183. export class DataStorage {
  154184. private static _Storage;
  154185. private static _GetStorage;
  154186. /**
  154187. * Reads a string from the data storage
  154188. * @param key The key to read
  154189. * @param defaultValue The value if the key doesn't exist
  154190. * @returns The string value
  154191. */
  154192. static ReadString(key: string, defaultValue: string): string;
  154193. /**
  154194. * Writes a string to the data storage
  154195. * @param key The key to write
  154196. * @param value The value to write
  154197. */
  154198. static WriteString(key: string, value: string): void;
  154199. /**
  154200. * Reads a boolean from the data storage
  154201. * @param key The key to read
  154202. * @param defaultValue The value if the key doesn't exist
  154203. * @returns The boolean value
  154204. */
  154205. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154206. /**
  154207. * Writes a boolean to the data storage
  154208. * @param key The key to write
  154209. * @param value The value to write
  154210. */
  154211. static WriteBoolean(key: string, value: boolean): void;
  154212. /**
  154213. * Reads a number from the data storage
  154214. * @param key The key to read
  154215. * @param defaultValue The value if the key doesn't exist
  154216. * @returns The number value
  154217. */
  154218. static ReadNumber(key: string, defaultValue: number): number;
  154219. /**
  154220. * Writes a number to the data storage
  154221. * @param key The key to write
  154222. * @param value The value to write
  154223. */
  154224. static WriteNumber(key: string, value: number): void;
  154225. }
  154226. }
  154227. declare module BABYLON {
  154228. /**
  154229. * Class used to record delta files between 2 scene states
  154230. */
  154231. export class SceneRecorder {
  154232. private _trackedScene;
  154233. private _savedJSON;
  154234. /**
  154235. * Track a given scene. This means the current scene state will be considered the original state
  154236. * @param scene defines the scene to track
  154237. */
  154238. track(scene: Scene): void;
  154239. /**
  154240. * Get the delta between current state and original state
  154241. * @returns a string containing the delta
  154242. */
  154243. getDelta(): any;
  154244. private _compareArray;
  154245. private _compareObjects;
  154246. private _compareCollections;
  154247. private static GetShadowGeneratorById;
  154248. /**
  154249. * Apply a given delta to a given scene
  154250. * @param deltaJSON defines the JSON containing the delta
  154251. * @param scene defines the scene to apply the delta to
  154252. */
  154253. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154254. private static _ApplyPropertiesToEntity;
  154255. private static _ApplyDeltaForEntity;
  154256. }
  154257. }
  154258. declare module BABYLON {
  154259. /**
  154260. * An interface for all Hit test features
  154261. */
  154262. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  154263. /**
  154264. * Triggered when new babylon (transformed) hit test results are available
  154265. */
  154266. onHitTestResultObservable: Observable<T[]>;
  154267. }
  154268. /**
  154269. * Options used for hit testing
  154270. */
  154271. export interface IWebXRLegacyHitTestOptions {
  154272. /**
  154273. * Only test when user interacted with the scene. Default - hit test every frame
  154274. */
  154275. testOnPointerDownOnly?: boolean;
  154276. /**
  154277. * The node to use to transform the local results to world coordinates
  154278. */
  154279. worldParentNode?: TransformNode;
  154280. }
  154281. /**
  154282. * Interface defining the babylon result of raycasting/hit-test
  154283. */
  154284. export interface IWebXRLegacyHitResult {
  154285. /**
  154286. * Transformation matrix that can be applied to a node that will put it in the hit point location
  154287. */
  154288. transformationMatrix: Matrix;
  154289. /**
  154290. * The native hit test result
  154291. */
  154292. xrHitResult: XRHitResult | XRHitTestResult;
  154293. }
  154294. /**
  154295. * The currently-working hit-test module.
  154296. * Hit test (or Ray-casting) is used to interact with the real world.
  154297. * For further information read here - https://github.com/immersive-web/hit-test
  154298. */
  154299. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  154300. /**
  154301. * options to use when constructing this feature
  154302. */
  154303. readonly options: IWebXRLegacyHitTestOptions;
  154304. private _direction;
  154305. private _mat;
  154306. private _onSelectEnabled;
  154307. private _origin;
  154308. /**
  154309. * The module's name
  154310. */
  154311. static readonly Name: string;
  154312. /**
  154313. * The (Babylon) version of this module.
  154314. * This is an integer representing the implementation version.
  154315. * This number does not correspond to the WebXR specs version
  154316. */
  154317. static readonly Version: number;
  154318. /**
  154319. * Populated with the last native XR Hit Results
  154320. */
  154321. lastNativeXRHitResults: XRHitResult[];
  154322. /**
  154323. * Triggered when new babylon (transformed) hit test results are available
  154324. */
  154325. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  154326. /**
  154327. * Creates a new instance of the (legacy version) hit test feature
  154328. * @param _xrSessionManager an instance of WebXRSessionManager
  154329. * @param options options to use when constructing this feature
  154330. */
  154331. constructor(_xrSessionManager: WebXRSessionManager,
  154332. /**
  154333. * options to use when constructing this feature
  154334. */
  154335. options?: IWebXRLegacyHitTestOptions);
  154336. /**
  154337. * execute a hit test with an XR Ray
  154338. *
  154339. * @param xrSession a native xrSession that will execute this hit test
  154340. * @param xrRay the ray (position and direction) to use for ray-casting
  154341. * @param referenceSpace native XR reference space to use for the hit-test
  154342. * @param filter filter function that will filter the results
  154343. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154344. */
  154345. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  154346. /**
  154347. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  154348. * @param event the (select) event to use to select with
  154349. * @param referenceSpace the reference space to use for this hit test
  154350. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154351. */
  154352. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154353. /**
  154354. * attach this feature
  154355. * Will usually be called by the features manager
  154356. *
  154357. * @returns true if successful.
  154358. */
  154359. attach(): boolean;
  154360. /**
  154361. * detach this feature.
  154362. * Will usually be called by the features manager
  154363. *
  154364. * @returns true if successful.
  154365. */
  154366. detach(): boolean;
  154367. /**
  154368. * Dispose this feature and all of the resources attached
  154369. */
  154370. dispose(): void;
  154371. protected _onXRFrame(frame: XRFrame): void;
  154372. private _onHitTestResults;
  154373. private _onSelect;
  154374. }
  154375. }
  154376. declare module BABYLON {
  154377. /**
  154378. * Options used for hit testing (version 2)
  154379. */
  154380. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  154381. /**
  154382. * Do not create a permanent hit test. Will usually be used when only
  154383. * transient inputs are needed.
  154384. */
  154385. disablePermanentHitTest?: boolean;
  154386. /**
  154387. * Enable transient (for example touch-based) hit test inspections
  154388. */
  154389. enableTransientHitTest?: boolean;
  154390. /**
  154391. * Offset ray for the permanent hit test
  154392. */
  154393. offsetRay?: Vector3;
  154394. /**
  154395. * Offset ray for the transient hit test
  154396. */
  154397. transientOffsetRay?: Vector3;
  154398. /**
  154399. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  154400. */
  154401. useReferenceSpace?: boolean;
  154402. /**
  154403. * Override the default entity type(s) of the hit-test result
  154404. */
  154405. entityTypes?: XRHitTestTrackableType[];
  154406. }
  154407. /**
  154408. * Interface defining the babylon result of hit-test
  154409. */
  154410. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  154411. /**
  154412. * The input source that generated this hit test (if transient)
  154413. */
  154414. inputSource?: XRInputSource;
  154415. /**
  154416. * Is this a transient hit test
  154417. */
  154418. isTransient?: boolean;
  154419. /**
  154420. * Position of the hit test result
  154421. */
  154422. position: Vector3;
  154423. /**
  154424. * Rotation of the hit test result
  154425. */
  154426. rotationQuaternion: Quaternion;
  154427. /**
  154428. * The native hit test result
  154429. */
  154430. xrHitResult: XRHitTestResult;
  154431. }
  154432. /**
  154433. * The currently-working hit-test module.
  154434. * Hit test (or Ray-casting) is used to interact with the real world.
  154435. * For further information read here - https://github.com/immersive-web/hit-test
  154436. *
  154437. * Tested on chrome (mobile) 80.
  154438. */
  154439. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  154440. /**
  154441. * options to use when constructing this feature
  154442. */
  154443. readonly options: IWebXRHitTestOptions;
  154444. private _tmpMat;
  154445. private _tmpPos;
  154446. private _tmpQuat;
  154447. private _transientXrHitTestSource;
  154448. private _xrHitTestSource;
  154449. private initHitTestSource;
  154450. /**
  154451. * The module's name
  154452. */
  154453. static readonly Name: string;
  154454. /**
  154455. * The (Babylon) version of this module.
  154456. * This is an integer representing the implementation version.
  154457. * This number does not correspond to the WebXR specs version
  154458. */
  154459. static readonly Version: number;
  154460. /**
  154461. * When set to true, each hit test will have its own position/rotation objects
  154462. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  154463. * the developers will clone them or copy them as they see fit.
  154464. */
  154465. autoCloneTransformation: boolean;
  154466. /**
  154467. * Triggered when new babylon (transformed) hit test results are available
  154468. * Note - this will be called when results come back from the device. It can be an empty array!!
  154469. */
  154470. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  154471. /**
  154472. * Use this to temporarily pause hit test checks.
  154473. */
  154474. paused: boolean;
  154475. /**
  154476. * Creates a new instance of the hit test feature
  154477. * @param _xrSessionManager an instance of WebXRSessionManager
  154478. * @param options options to use when constructing this feature
  154479. */
  154480. constructor(_xrSessionManager: WebXRSessionManager,
  154481. /**
  154482. * options to use when constructing this feature
  154483. */
  154484. options?: IWebXRHitTestOptions);
  154485. /**
  154486. * attach this feature
  154487. * Will usually be called by the features manager
  154488. *
  154489. * @returns true if successful.
  154490. */
  154491. attach(): boolean;
  154492. /**
  154493. * detach this feature.
  154494. * Will usually be called by the features manager
  154495. *
  154496. * @returns true if successful.
  154497. */
  154498. detach(): boolean;
  154499. /**
  154500. * Dispose this feature and all of the resources attached
  154501. */
  154502. dispose(): void;
  154503. protected _onXRFrame(frame: XRFrame): void;
  154504. private _processWebXRHitTestResult;
  154505. }
  154506. }
  154507. declare module BABYLON {
  154508. /**
  154509. * Configuration options of the anchor system
  154510. */
  154511. export interface IWebXRAnchorSystemOptions {
  154512. /**
  154513. * a node that will be used to convert local to world coordinates
  154514. */
  154515. worldParentNode?: TransformNode;
  154516. /**
  154517. * If set to true a reference of the created anchors will be kept until the next session starts
  154518. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  154519. */
  154520. doNotRemoveAnchorsOnSessionEnded?: boolean;
  154521. }
  154522. /**
  154523. * A babylon container for an XR Anchor
  154524. */
  154525. export interface IWebXRAnchor {
  154526. /**
  154527. * A babylon-assigned ID for this anchor
  154528. */
  154529. id: number;
  154530. /**
  154531. * Transformation matrix to apply to an object attached to this anchor
  154532. */
  154533. transformationMatrix: Matrix;
  154534. /**
  154535. * The native anchor object
  154536. */
  154537. xrAnchor: XRAnchor;
  154538. /**
  154539. * if defined, this object will be constantly updated by the anchor's position and rotation
  154540. */
  154541. attachedNode?: TransformNode;
  154542. }
  154543. /**
  154544. * An implementation of the anchor system for WebXR.
  154545. * For further information see https://github.com/immersive-web/anchors/
  154546. */
  154547. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  154548. private _options;
  154549. private _lastFrameDetected;
  154550. private _trackedAnchors;
  154551. private _referenceSpaceForFrameAnchors;
  154552. private _futureAnchors;
  154553. /**
  154554. * The module's name
  154555. */
  154556. static readonly Name: string;
  154557. /**
  154558. * The (Babylon) version of this module.
  154559. * This is an integer representing the implementation version.
  154560. * This number does not correspond to the WebXR specs version
  154561. */
  154562. static readonly Version: number;
  154563. /**
  154564. * Observers registered here will be executed when a new anchor was added to the session
  154565. */
  154566. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  154567. /**
  154568. * Observers registered here will be executed when an anchor was removed from the session
  154569. */
  154570. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  154571. /**
  154572. * Observers registered here will be executed when an existing anchor updates
  154573. * This can execute N times every frame
  154574. */
  154575. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  154576. /**
  154577. * Set the reference space to use for anchor creation, when not using a hit test.
  154578. * Will default to the session's reference space if not defined
  154579. */
  154580. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  154581. /**
  154582. * constructs a new anchor system
  154583. * @param _xrSessionManager an instance of WebXRSessionManager
  154584. * @param _options configuration object for this feature
  154585. */
  154586. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  154587. private _tmpVector;
  154588. private _tmpQuaternion;
  154589. private _populateTmpTransformation;
  154590. /**
  154591. * Create a new anchor point using a hit test result at a specific point in the scene
  154592. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154593. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154594. *
  154595. * @param hitTestResult The hit test result to use for this anchor creation
  154596. * @param position an optional position offset for this anchor
  154597. * @param rotationQuaternion an optional rotation offset for this anchor
  154598. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154599. */
  154600. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  154601. /**
  154602. * Add a new anchor at a specific position and rotation
  154603. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  154604. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  154605. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154606. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154607. *
  154608. * @param position the position in which to add an anchor
  154609. * @param rotationQuaternion an optional rotation for the anchor transformation
  154610. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  154611. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154612. */
  154613. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  154614. /**
  154615. * detach this feature.
  154616. * Will usually be called by the features manager
  154617. *
  154618. * @returns true if successful.
  154619. */
  154620. detach(): boolean;
  154621. /**
  154622. * Dispose this feature and all of the resources attached
  154623. */
  154624. dispose(): void;
  154625. protected _onXRFrame(frame: XRFrame): void;
  154626. /**
  154627. * avoiding using Array.find for global support.
  154628. * @param xrAnchor the plane to find in the array
  154629. */
  154630. private _findIndexInAnchorArray;
  154631. private _updateAnchorWithXRFrame;
  154632. private _createAnchorAtTransformation;
  154633. }
  154634. }
  154635. declare module BABYLON {
  154636. /**
  154637. * Options used in the plane detector module
  154638. */
  154639. export interface IWebXRPlaneDetectorOptions {
  154640. /**
  154641. * The node to use to transform the local results to world coordinates
  154642. */
  154643. worldParentNode?: TransformNode;
  154644. /**
  154645. * If set to true a reference of the created planes will be kept until the next session starts
  154646. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  154647. */
  154648. doNotRemovePlanesOnSessionEnded?: boolean;
  154649. }
  154650. /**
  154651. * A babylon interface for a WebXR plane.
  154652. * A Plane is actually a polygon, built from N points in space
  154653. *
  154654. * Supported in chrome 79, not supported in canary 81 ATM
  154655. */
  154656. export interface IWebXRPlane {
  154657. /**
  154658. * a babylon-assigned ID for this polygon
  154659. */
  154660. id: number;
  154661. /**
  154662. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  154663. */
  154664. polygonDefinition: Array<Vector3>;
  154665. /**
  154666. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  154667. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  154668. */
  154669. transformationMatrix: Matrix;
  154670. /**
  154671. * the native xr-plane object
  154672. */
  154673. xrPlane: XRPlane;
  154674. }
  154675. /**
  154676. * The plane detector is used to detect planes in the real world when in AR
  154677. * For more information see https://github.com/immersive-web/real-world-geometry/
  154678. */
  154679. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  154680. private _options;
  154681. private _detectedPlanes;
  154682. private _enabled;
  154683. private _lastFrameDetected;
  154684. /**
  154685. * The module's name
  154686. */
  154687. static readonly Name: string;
  154688. /**
  154689. * The (Babylon) version of this module.
  154690. * This is an integer representing the implementation version.
  154691. * This number does not correspond to the WebXR specs version
  154692. */
  154693. static readonly Version: number;
  154694. /**
  154695. * Observers registered here will be executed when a new plane was added to the session
  154696. */
  154697. onPlaneAddedObservable: Observable<IWebXRPlane>;
  154698. /**
  154699. * Observers registered here will be executed when a plane is no longer detected in the session
  154700. */
  154701. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  154702. /**
  154703. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  154704. * This can execute N times every frame
  154705. */
  154706. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  154707. /**
  154708. * construct a new Plane Detector
  154709. * @param _xrSessionManager an instance of xr Session manager
  154710. * @param _options configuration to use when constructing this feature
  154711. */
  154712. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  154713. /**
  154714. * detach this feature.
  154715. * Will usually be called by the features manager
  154716. *
  154717. * @returns true if successful.
  154718. */
  154719. detach(): boolean;
  154720. /**
  154721. * Dispose this feature and all of the resources attached
  154722. */
  154723. dispose(): void;
  154724. protected _onXRFrame(frame: XRFrame): void;
  154725. private _init;
  154726. private _updatePlaneWithXRPlane;
  154727. /**
  154728. * avoiding using Array.find for global support.
  154729. * @param xrPlane the plane to find in the array
  154730. */
  154731. private findIndexInPlaneArray;
  154732. }
  154733. }
  154734. declare module BABYLON {
  154735. /**
  154736. * Options interface for the background remover plugin
  154737. */
  154738. export interface IWebXRBackgroundRemoverOptions {
  154739. /**
  154740. * Further background meshes to disable when entering AR
  154741. */
  154742. backgroundMeshes?: AbstractMesh[];
  154743. /**
  154744. * flags to configure the removal of the environment helper.
  154745. * If not set, the entire background will be removed. If set, flags should be set as well.
  154746. */
  154747. environmentHelperRemovalFlags?: {
  154748. /**
  154749. * Should the skybox be removed (default false)
  154750. */
  154751. skyBox?: boolean;
  154752. /**
  154753. * Should the ground be removed (default false)
  154754. */
  154755. ground?: boolean;
  154756. };
  154757. /**
  154758. * don't disable the environment helper
  154759. */
  154760. ignoreEnvironmentHelper?: boolean;
  154761. }
  154762. /**
  154763. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  154764. */
  154765. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  154766. /**
  154767. * read-only options to be used in this module
  154768. */
  154769. readonly options: IWebXRBackgroundRemoverOptions;
  154770. /**
  154771. * The module's name
  154772. */
  154773. static readonly Name: string;
  154774. /**
  154775. * The (Babylon) version of this module.
  154776. * This is an integer representing the implementation version.
  154777. * This number does not correspond to the WebXR specs version
  154778. */
  154779. static readonly Version: number;
  154780. /**
  154781. * registered observers will be triggered when the background state changes
  154782. */
  154783. onBackgroundStateChangedObservable: Observable<boolean>;
  154784. /**
  154785. * constructs a new background remover module
  154786. * @param _xrSessionManager the session manager for this module
  154787. * @param options read-only options to be used in this module
  154788. */
  154789. constructor(_xrSessionManager: WebXRSessionManager,
  154790. /**
  154791. * read-only options to be used in this module
  154792. */
  154793. options?: IWebXRBackgroundRemoverOptions);
  154794. /**
  154795. * attach this feature
  154796. * Will usually be called by the features manager
  154797. *
  154798. * @returns true if successful.
  154799. */
  154800. attach(): boolean;
  154801. /**
  154802. * detach this feature.
  154803. * Will usually be called by the features manager
  154804. *
  154805. * @returns true if successful.
  154806. */
  154807. detach(): boolean;
  154808. /**
  154809. * Dispose this feature and all of the resources attached
  154810. */
  154811. dispose(): void;
  154812. protected _onXRFrame(_xrFrame: XRFrame): void;
  154813. private _setBackgroundState;
  154814. }
  154815. }
  154816. declare module BABYLON {
  154817. /**
  154818. * Options for the controller physics feature
  154819. */
  154820. export class IWebXRControllerPhysicsOptions {
  154821. /**
  154822. * Should the headset get its own impostor
  154823. */
  154824. enableHeadsetImpostor?: boolean;
  154825. /**
  154826. * Optional parameters for the headset impostor
  154827. */
  154828. headsetImpostorParams?: {
  154829. /**
  154830. * The type of impostor to create. Default is sphere
  154831. */
  154832. impostorType: number;
  154833. /**
  154834. * the size of the impostor. Defaults to 10cm
  154835. */
  154836. impostorSize?: number | {
  154837. width: number;
  154838. height: number;
  154839. depth: number;
  154840. };
  154841. /**
  154842. * Friction definitions
  154843. */
  154844. friction?: number;
  154845. /**
  154846. * Restitution
  154847. */
  154848. restitution?: number;
  154849. };
  154850. /**
  154851. * The physics properties of the future impostors
  154852. */
  154853. physicsProperties?: {
  154854. /**
  154855. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  154856. * Note that this requires a physics engine that supports mesh impostors!
  154857. */
  154858. useControllerMesh?: boolean;
  154859. /**
  154860. * The type of impostor to create. Default is sphere
  154861. */
  154862. impostorType?: number;
  154863. /**
  154864. * the size of the impostor. Defaults to 10cm
  154865. */
  154866. impostorSize?: number | {
  154867. width: number;
  154868. height: number;
  154869. depth: number;
  154870. };
  154871. /**
  154872. * Friction definitions
  154873. */
  154874. friction?: number;
  154875. /**
  154876. * Restitution
  154877. */
  154878. restitution?: number;
  154879. };
  154880. /**
  154881. * the xr input to use with this pointer selection
  154882. */
  154883. xrInput: WebXRInput;
  154884. }
  154885. /**
  154886. * Add physics impostor to your webxr controllers,
  154887. * including naive calculation of their linear and angular velocity
  154888. */
  154889. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  154890. private readonly _options;
  154891. private _attachController;
  154892. private _controllers;
  154893. private _debugMode;
  154894. private _delta;
  154895. private _headsetImpostor?;
  154896. private _headsetMesh?;
  154897. private _lastTimestamp;
  154898. private _tmpQuaternion;
  154899. private _tmpVector;
  154900. /**
  154901. * The module's name
  154902. */
  154903. static readonly Name: string;
  154904. /**
  154905. * The (Babylon) version of this module.
  154906. * This is an integer representing the implementation version.
  154907. * This number does not correspond to the webxr specs version
  154908. */
  154909. static readonly Version: number;
  154910. /**
  154911. * Construct a new Controller Physics Feature
  154912. * @param _xrSessionManager the corresponding xr session manager
  154913. * @param _options options to create this feature with
  154914. */
  154915. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  154916. /**
  154917. * @hidden
  154918. * enable debugging - will show console outputs and the impostor mesh
  154919. */
  154920. _enablePhysicsDebug(): void;
  154921. /**
  154922. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  154923. * @param xrController the controller to add
  154924. */
  154925. addController(xrController: WebXRInputSource): void;
  154926. /**
  154927. * attach this feature
  154928. * Will usually be called by the features manager
  154929. *
  154930. * @returns true if successful.
  154931. */
  154932. attach(): boolean;
  154933. /**
  154934. * detach this feature.
  154935. * Will usually be called by the features manager
  154936. *
  154937. * @returns true if successful.
  154938. */
  154939. detach(): boolean;
  154940. /**
  154941. * Get the headset impostor, if enabled
  154942. * @returns the impostor
  154943. */
  154944. getHeadsetImpostor(): PhysicsImpostor | undefined;
  154945. /**
  154946. * Get the physics impostor of a specific controller.
  154947. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  154948. * @param controller the controller or the controller id of which to get the impostor
  154949. * @returns the impostor or null
  154950. */
  154951. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  154952. /**
  154953. * Update the physics properties provided in the constructor
  154954. * @param newProperties the new properties object
  154955. */
  154956. setPhysicsProperties(newProperties: {
  154957. impostorType?: number;
  154958. impostorSize?: number | {
  154959. width: number;
  154960. height: number;
  154961. depth: number;
  154962. };
  154963. friction?: number;
  154964. restitution?: number;
  154965. }): void;
  154966. protected _onXRFrame(_xrFrame: any): void;
  154967. private _detachController;
  154968. }
  154969. }
  154970. declare module BABYLON {
  154971. /**
  154972. * A babylon interface for a "WebXR" feature point.
  154973. * Represents the position and confidence value of a given feature point.
  154974. */
  154975. export interface IWebXRFeaturePoint {
  154976. /**
  154977. * Represents the position of the feature point in world space.
  154978. */
  154979. position: Vector3;
  154980. /**
  154981. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  154982. */
  154983. confidenceValue: number;
  154984. }
  154985. /**
  154986. * The feature point system is used to detect feature points from real world geometry.
  154987. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  154988. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  154989. */
  154990. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  154991. private _enabled;
  154992. private _featurePointCloud;
  154993. /**
  154994. * The module's name
  154995. */
  154996. static readonly Name: string;
  154997. /**
  154998. * The (Babylon) version of this module.
  154999. * This is an integer representing the implementation version.
  155000. * This number does not correspond to the WebXR specs version
  155001. */
  155002. static readonly Version: number;
  155003. /**
  155004. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  155005. * Will notify the observers about which feature points have been added.
  155006. */
  155007. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  155008. /**
  155009. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  155010. * Will notify the observers about which feature points have been updated.
  155011. */
  155012. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  155013. /**
  155014. * The current feature point cloud maintained across frames.
  155015. */
  155016. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  155017. /**
  155018. * construct the feature point system
  155019. * @param _xrSessionManager an instance of xr Session manager
  155020. */
  155021. constructor(_xrSessionManager: WebXRSessionManager);
  155022. /**
  155023. * Detach this feature.
  155024. * Will usually be called by the features manager
  155025. *
  155026. * @returns true if successful.
  155027. */
  155028. detach(): boolean;
  155029. /**
  155030. * Dispose this feature and all of the resources attached
  155031. */
  155032. dispose(): void;
  155033. /**
  155034. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  155035. */
  155036. protected _onXRFrame(frame: XRFrame): void;
  155037. /**
  155038. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  155039. */
  155040. private _init;
  155041. }
  155042. }
  155043. declare module BABYLON {
  155044. /**
  155045. * Configuration interface for the hand tracking feature
  155046. */
  155047. export interface IWebXRHandTrackingOptions {
  155048. /**
  155049. * The xrInput that will be used as source for new hands
  155050. */
  155051. xrInput: WebXRInput;
  155052. /**
  155053. * Configuration object for the joint meshes
  155054. */
  155055. jointMeshes?: {
  155056. /**
  155057. * Should the meshes created be invisible (defaults to false)
  155058. */
  155059. invisible?: boolean;
  155060. /**
  155061. * A source mesh to be used to create instances. Defaults to a sphere.
  155062. * This mesh will be the source for all other (25) meshes.
  155063. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  155064. */
  155065. sourceMesh?: Mesh;
  155066. /**
  155067. * Should the source mesh stay visible. Defaults to false
  155068. */
  155069. keepOriginalVisible?: boolean;
  155070. /**
  155071. * Scale factor for all instances (defaults to 2)
  155072. */
  155073. scaleFactor?: number;
  155074. /**
  155075. * Should each instance have its own physics impostor
  155076. */
  155077. enablePhysics?: boolean;
  155078. /**
  155079. * If enabled, override default physics properties
  155080. */
  155081. physicsProps?: {
  155082. friction?: number;
  155083. restitution?: number;
  155084. impostorType?: number;
  155085. };
  155086. /**
  155087. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155088. */
  155089. handMesh?: AbstractMesh;
  155090. };
  155091. }
  155092. /**
  155093. * Parts of the hands divided to writs and finger names
  155094. */
  155095. export const enum HandPart {
  155096. /**
  155097. * HandPart - Wrist
  155098. */
  155099. WRIST = "wrist",
  155100. /**
  155101. * HandPart - The THumb
  155102. */
  155103. THUMB = "thumb",
  155104. /**
  155105. * HandPart - Index finger
  155106. */
  155107. INDEX = "index",
  155108. /**
  155109. * HandPart - Middle finger
  155110. */
  155111. MIDDLE = "middle",
  155112. /**
  155113. * HandPart - Ring finger
  155114. */
  155115. RING = "ring",
  155116. /**
  155117. * HandPart - Little finger
  155118. */
  155119. LITTLE = "little"
  155120. }
  155121. /**
  155122. * Representing a single hand (with its corresponding native XRHand object)
  155123. */
  155124. export class WebXRHand implements IDisposable {
  155125. /** the controller to which the hand correlates */
  155126. readonly xrController: WebXRInputSource;
  155127. /** the meshes to be used to track the hand joints */
  155128. readonly trackedMeshes: AbstractMesh[];
  155129. /**
  155130. * Hand-parts definition (key is HandPart)
  155131. */
  155132. handPartsDefinition: {
  155133. [key: string]: number[];
  155134. };
  155135. /**
  155136. * Populate the HandPartsDefinition object.
  155137. * This is called as a side effect since certain browsers don't have XRHand defined.
  155138. */
  155139. private generateHandPartsDefinition;
  155140. /**
  155141. * Construct a new hand object
  155142. * @param xrController the controller to which the hand correlates
  155143. * @param trackedMeshes the meshes to be used to track the hand joints
  155144. */
  155145. constructor(
  155146. /** the controller to which the hand correlates */
  155147. xrController: WebXRInputSource,
  155148. /** the meshes to be used to track the hand joints */
  155149. trackedMeshes: AbstractMesh[]);
  155150. /**
  155151. * Update this hand from the latest xr frame
  155152. * @param xrFrame xrFrame to update from
  155153. * @param referenceSpace The current viewer reference space
  155154. * @param scaleFactor optional scale factor for the meshes
  155155. */
  155156. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  155157. /**
  155158. * Get meshes of part of the hand
  155159. * @param part the part of hand to get
  155160. * @returns An array of meshes that correlate to the hand part requested
  155161. */
  155162. getHandPartMeshes(part: HandPart): AbstractMesh[];
  155163. /**
  155164. * Dispose this Hand object
  155165. */
  155166. dispose(): void;
  155167. }
  155168. /**
  155169. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  155170. */
  155171. export class WebXRHandTracking extends WebXRAbstractFeature {
  155172. /**
  155173. * options to use when constructing this feature
  155174. */
  155175. readonly options: IWebXRHandTrackingOptions;
  155176. private static _idCounter;
  155177. /**
  155178. * The module's name
  155179. */
  155180. static readonly Name: string;
  155181. /**
  155182. * The (Babylon) version of this module.
  155183. * This is an integer representing the implementation version.
  155184. * This number does not correspond to the WebXR specs version
  155185. */
  155186. static readonly Version: number;
  155187. /**
  155188. * This observable will notify registered observers when a new hand object was added and initialized
  155189. */
  155190. onHandAddedObservable: Observable<WebXRHand>;
  155191. /**
  155192. * This observable will notify its observers right before the hand object is disposed
  155193. */
  155194. onHandRemovedObservable: Observable<WebXRHand>;
  155195. private _hands;
  155196. /**
  155197. * Creates a new instance of the hit test feature
  155198. * @param _xrSessionManager an instance of WebXRSessionManager
  155199. * @param options options to use when constructing this feature
  155200. */
  155201. constructor(_xrSessionManager: WebXRSessionManager,
  155202. /**
  155203. * options to use when constructing this feature
  155204. */
  155205. options: IWebXRHandTrackingOptions);
  155206. /**
  155207. * Check if the needed objects are defined.
  155208. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155209. */
  155210. isCompatible(): boolean;
  155211. /**
  155212. * attach this feature
  155213. * Will usually be called by the features manager
  155214. *
  155215. * @returns true if successful.
  155216. */
  155217. attach(): boolean;
  155218. /**
  155219. * detach this feature.
  155220. * Will usually be called by the features manager
  155221. *
  155222. * @returns true if successful.
  155223. */
  155224. detach(): boolean;
  155225. /**
  155226. * Dispose this feature and all of the resources attached
  155227. */
  155228. dispose(): void;
  155229. /**
  155230. * Get the hand object according to the controller id
  155231. * @param controllerId the controller id to which we want to get the hand
  155232. * @returns null if not found or the WebXRHand object if found
  155233. */
  155234. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155235. /**
  155236. * Get a hand object according to the requested handedness
  155237. * @param handedness the handedness to request
  155238. * @returns null if not found or the WebXRHand object if found
  155239. */
  155240. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  155241. protected _onXRFrame(_xrFrame: XRFrame): void;
  155242. private _attachHand;
  155243. private _detachHand;
  155244. }
  155245. }
  155246. declare module BABYLON {
  155247. /**
  155248. * The motion controller class for all microsoft mixed reality controllers
  155249. */
  155250. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  155251. protected readonly _mapping: {
  155252. defaultButton: {
  155253. valueNodeName: string;
  155254. unpressedNodeName: string;
  155255. pressedNodeName: string;
  155256. };
  155257. defaultAxis: {
  155258. valueNodeName: string;
  155259. minNodeName: string;
  155260. maxNodeName: string;
  155261. };
  155262. buttons: {
  155263. "xr-standard-trigger": {
  155264. rootNodeName: string;
  155265. componentProperty: string;
  155266. states: string[];
  155267. };
  155268. "xr-standard-squeeze": {
  155269. rootNodeName: string;
  155270. componentProperty: string;
  155271. states: string[];
  155272. };
  155273. "xr-standard-touchpad": {
  155274. rootNodeName: string;
  155275. labelAnchorNodeName: string;
  155276. touchPointNodeName: string;
  155277. };
  155278. "xr-standard-thumbstick": {
  155279. rootNodeName: string;
  155280. componentProperty: string;
  155281. states: string[];
  155282. };
  155283. };
  155284. axes: {
  155285. "xr-standard-touchpad": {
  155286. "x-axis": {
  155287. rootNodeName: string;
  155288. };
  155289. "y-axis": {
  155290. rootNodeName: string;
  155291. };
  155292. };
  155293. "xr-standard-thumbstick": {
  155294. "x-axis": {
  155295. rootNodeName: string;
  155296. };
  155297. "y-axis": {
  155298. rootNodeName: string;
  155299. };
  155300. };
  155301. };
  155302. };
  155303. /**
  155304. * The base url used to load the left and right controller models
  155305. */
  155306. static MODEL_BASE_URL: string;
  155307. /**
  155308. * The name of the left controller model file
  155309. */
  155310. static MODEL_LEFT_FILENAME: string;
  155311. /**
  155312. * The name of the right controller model file
  155313. */
  155314. static MODEL_RIGHT_FILENAME: string;
  155315. profileId: string;
  155316. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155317. protected _getFilenameAndPath(): {
  155318. filename: string;
  155319. path: string;
  155320. };
  155321. protected _getModelLoadingConstraints(): boolean;
  155322. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155323. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155324. protected _updateModel(): void;
  155325. }
  155326. }
  155327. declare module BABYLON {
  155328. /**
  155329. * The motion controller class for oculus touch (quest, rift).
  155330. * This class supports legacy mapping as well the standard xr mapping
  155331. */
  155332. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  155333. private _forceLegacyControllers;
  155334. private _modelRootNode;
  155335. /**
  155336. * The base url used to load the left and right controller models
  155337. */
  155338. static MODEL_BASE_URL: string;
  155339. /**
  155340. * The name of the left controller model file
  155341. */
  155342. static MODEL_LEFT_FILENAME: string;
  155343. /**
  155344. * The name of the right controller model file
  155345. */
  155346. static MODEL_RIGHT_FILENAME: string;
  155347. /**
  155348. * Base Url for the Quest controller model.
  155349. */
  155350. static QUEST_MODEL_BASE_URL: string;
  155351. profileId: string;
  155352. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  155353. protected _getFilenameAndPath(): {
  155354. filename: string;
  155355. path: string;
  155356. };
  155357. protected _getModelLoadingConstraints(): boolean;
  155358. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155359. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155360. protected _updateModel(): void;
  155361. /**
  155362. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  155363. * between the touch and touch 2.
  155364. */
  155365. private _isQuest;
  155366. }
  155367. }
  155368. declare module BABYLON {
  155369. /**
  155370. * The motion controller class for the standard HTC-Vive controllers
  155371. */
  155372. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  155373. private _modelRootNode;
  155374. /**
  155375. * The base url used to load the left and right controller models
  155376. */
  155377. static MODEL_BASE_URL: string;
  155378. /**
  155379. * File name for the controller model.
  155380. */
  155381. static MODEL_FILENAME: string;
  155382. profileId: string;
  155383. /**
  155384. * Create a new Vive motion controller object
  155385. * @param scene the scene to use to create this controller
  155386. * @param gamepadObject the corresponding gamepad object
  155387. * @param handedness the handedness of the controller
  155388. */
  155389. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155390. protected _getFilenameAndPath(): {
  155391. filename: string;
  155392. path: string;
  155393. };
  155394. protected _getModelLoadingConstraints(): boolean;
  155395. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155396. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155397. protected _updateModel(): void;
  155398. }
  155399. }
  155400. declare module BABYLON {
  155401. /**
  155402. * A cursor which tracks a point on a path
  155403. */
  155404. export class PathCursor {
  155405. private path;
  155406. /**
  155407. * Stores path cursor callbacks for when an onchange event is triggered
  155408. */
  155409. private _onchange;
  155410. /**
  155411. * The value of the path cursor
  155412. */
  155413. value: number;
  155414. /**
  155415. * The animation array of the path cursor
  155416. */
  155417. animations: Animation[];
  155418. /**
  155419. * Initializes the path cursor
  155420. * @param path The path to track
  155421. */
  155422. constructor(path: Path2);
  155423. /**
  155424. * Gets the cursor point on the path
  155425. * @returns A point on the path cursor at the cursor location
  155426. */
  155427. getPoint(): Vector3;
  155428. /**
  155429. * Moves the cursor ahead by the step amount
  155430. * @param step The amount to move the cursor forward
  155431. * @returns This path cursor
  155432. */
  155433. moveAhead(step?: number): PathCursor;
  155434. /**
  155435. * Moves the cursor behind by the step amount
  155436. * @param step The amount to move the cursor back
  155437. * @returns This path cursor
  155438. */
  155439. moveBack(step?: number): PathCursor;
  155440. /**
  155441. * Moves the cursor by the step amount
  155442. * If the step amount is greater than one, an exception is thrown
  155443. * @param step The amount to move the cursor
  155444. * @returns This path cursor
  155445. */
  155446. move(step: number): PathCursor;
  155447. /**
  155448. * Ensures that the value is limited between zero and one
  155449. * @returns This path cursor
  155450. */
  155451. private ensureLimits;
  155452. /**
  155453. * Runs onchange callbacks on change (used by the animation engine)
  155454. * @returns This path cursor
  155455. */
  155456. private raiseOnChange;
  155457. /**
  155458. * Executes a function on change
  155459. * @param f A path cursor onchange callback
  155460. * @returns This path cursor
  155461. */
  155462. onchange(f: (cursor: PathCursor) => void): PathCursor;
  155463. }
  155464. }
  155465. declare module BABYLON {
  155466. /** @hidden */
  155467. export var blurPixelShader: {
  155468. name: string;
  155469. shader: string;
  155470. };
  155471. }
  155472. declare module BABYLON {
  155473. /** @hidden */
  155474. export var pointCloudVertexDeclaration: {
  155475. name: string;
  155476. shader: string;
  155477. };
  155478. }
  155479. // Mixins
  155480. interface Window {
  155481. mozIndexedDB: IDBFactory;
  155482. webkitIndexedDB: IDBFactory;
  155483. msIndexedDB: IDBFactory;
  155484. webkitURL: typeof URL;
  155485. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  155486. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  155487. WebGLRenderingContext: WebGLRenderingContext;
  155488. MSGesture: MSGesture;
  155489. CANNON: any;
  155490. AudioContext: AudioContext;
  155491. webkitAudioContext: AudioContext;
  155492. PointerEvent: any;
  155493. Math: Math;
  155494. Uint8Array: Uint8ArrayConstructor;
  155495. Float32Array: Float32ArrayConstructor;
  155496. mozURL: typeof URL;
  155497. msURL: typeof URL;
  155498. VRFrameData: any; // WebVR, from specs 1.1
  155499. DracoDecoderModule: any;
  155500. setImmediate(handler: (...args: any[]) => void): number;
  155501. }
  155502. interface HTMLCanvasElement {
  155503. requestPointerLock(): void;
  155504. msRequestPointerLock?(): void;
  155505. mozRequestPointerLock?(): void;
  155506. webkitRequestPointerLock?(): void;
  155507. /** Track wether a record is in progress */
  155508. isRecording: boolean;
  155509. /** Capture Stream method defined by some browsers */
  155510. captureStream(fps?: number): MediaStream;
  155511. }
  155512. interface CanvasRenderingContext2D {
  155513. msImageSmoothingEnabled: boolean;
  155514. }
  155515. interface MouseEvent {
  155516. mozMovementX: number;
  155517. mozMovementY: number;
  155518. webkitMovementX: number;
  155519. webkitMovementY: number;
  155520. msMovementX: number;
  155521. msMovementY: number;
  155522. }
  155523. interface Navigator {
  155524. mozGetVRDevices: (any: any) => any;
  155525. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155526. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155527. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155528. webkitGetGamepads(): Gamepad[];
  155529. msGetGamepads(): Gamepad[];
  155530. webkitGamepads(): Gamepad[];
  155531. }
  155532. interface HTMLVideoElement {
  155533. mozSrcObject: any;
  155534. }
  155535. interface Math {
  155536. fround(x: number): number;
  155537. imul(a: number, b: number): number;
  155538. }
  155539. interface WebGLRenderingContext {
  155540. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  155541. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  155542. vertexAttribDivisor(index: number, divisor: number): void;
  155543. createVertexArray(): any;
  155544. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  155545. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  155546. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  155547. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  155548. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  155549. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  155550. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  155551. // Queries
  155552. createQuery(): WebGLQuery;
  155553. deleteQuery(query: WebGLQuery): void;
  155554. beginQuery(target: number, query: WebGLQuery): void;
  155555. endQuery(target: number): void;
  155556. getQueryParameter(query: WebGLQuery, pname: number): any;
  155557. getQuery(target: number, pname: number): any;
  155558. MAX_SAMPLES: number;
  155559. RGBA8: number;
  155560. READ_FRAMEBUFFER: number;
  155561. DRAW_FRAMEBUFFER: number;
  155562. UNIFORM_BUFFER: number;
  155563. HALF_FLOAT_OES: number;
  155564. RGBA16F: number;
  155565. RGBA32F: number;
  155566. R32F: number;
  155567. RG32F: number;
  155568. RGB32F: number;
  155569. R16F: number;
  155570. RG16F: number;
  155571. RGB16F: number;
  155572. RED: number;
  155573. RG: number;
  155574. R8: number;
  155575. RG8: number;
  155576. UNSIGNED_INT_24_8: number;
  155577. DEPTH24_STENCIL8: number;
  155578. MIN: number;
  155579. MAX: number;
  155580. /* Multiple Render Targets */
  155581. drawBuffers(buffers: number[]): void;
  155582. readBuffer(src: number): void;
  155583. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  155584. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  155585. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  155586. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  155587. // Occlusion Query
  155588. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  155589. ANY_SAMPLES_PASSED: number;
  155590. QUERY_RESULT_AVAILABLE: number;
  155591. QUERY_RESULT: number;
  155592. }
  155593. interface WebGLProgram {
  155594. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  155595. }
  155596. interface EXT_disjoint_timer_query {
  155597. QUERY_COUNTER_BITS_EXT: number;
  155598. TIME_ELAPSED_EXT: number;
  155599. TIMESTAMP_EXT: number;
  155600. GPU_DISJOINT_EXT: number;
  155601. QUERY_RESULT_EXT: number;
  155602. QUERY_RESULT_AVAILABLE_EXT: number;
  155603. queryCounterEXT(query: WebGLQuery, target: number): void;
  155604. createQueryEXT(): WebGLQuery;
  155605. beginQueryEXT(target: number, query: WebGLQuery): void;
  155606. endQueryEXT(target: number): void;
  155607. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  155608. deleteQueryEXT(query: WebGLQuery): void;
  155609. }
  155610. interface WebGLUniformLocation {
  155611. _currentState: any;
  155612. }
  155613. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  155614. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  155615. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  155616. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155617. interface WebGLRenderingContext {
  155618. readonly RASTERIZER_DISCARD: number;
  155619. readonly DEPTH_COMPONENT24: number;
  155620. readonly TEXTURE_3D: number;
  155621. readonly TEXTURE_2D_ARRAY: number;
  155622. readonly TEXTURE_COMPARE_FUNC: number;
  155623. readonly TEXTURE_COMPARE_MODE: number;
  155624. readonly COMPARE_REF_TO_TEXTURE: number;
  155625. readonly TEXTURE_WRAP_R: number;
  155626. readonly HALF_FLOAT: number;
  155627. readonly RGB8: number;
  155628. readonly RED_INTEGER: number;
  155629. readonly RG_INTEGER: number;
  155630. readonly RGB_INTEGER: number;
  155631. readonly RGBA_INTEGER: number;
  155632. readonly R8_SNORM: number;
  155633. readonly RG8_SNORM: number;
  155634. readonly RGB8_SNORM: number;
  155635. readonly RGBA8_SNORM: number;
  155636. readonly R8I: number;
  155637. readonly RG8I: number;
  155638. readonly RGB8I: number;
  155639. readonly RGBA8I: number;
  155640. readonly R8UI: number;
  155641. readonly RG8UI: number;
  155642. readonly RGB8UI: number;
  155643. readonly RGBA8UI: number;
  155644. readonly R16I: number;
  155645. readonly RG16I: number;
  155646. readonly RGB16I: number;
  155647. readonly RGBA16I: number;
  155648. readonly R16UI: number;
  155649. readonly RG16UI: number;
  155650. readonly RGB16UI: number;
  155651. readonly RGBA16UI: number;
  155652. readonly R32I: number;
  155653. readonly RG32I: number;
  155654. readonly RGB32I: number;
  155655. readonly RGBA32I: number;
  155656. readonly R32UI: number;
  155657. readonly RG32UI: number;
  155658. readonly RGB32UI: number;
  155659. readonly RGBA32UI: number;
  155660. readonly RGB10_A2UI: number;
  155661. readonly R11F_G11F_B10F: number;
  155662. readonly RGB9_E5: number;
  155663. readonly RGB10_A2: number;
  155664. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  155665. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  155666. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  155667. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  155668. readonly DEPTH_COMPONENT32F: number;
  155669. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  155670. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  155671. 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;
  155672. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  155673. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  155674. readonly TRANSFORM_FEEDBACK: number;
  155675. readonly INTERLEAVED_ATTRIBS: number;
  155676. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  155677. createTransformFeedback(): WebGLTransformFeedback;
  155678. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  155679. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  155680. beginTransformFeedback(primitiveMode: number): void;
  155681. endTransformFeedback(): void;
  155682. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  155683. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155684. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155685. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155686. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  155687. }
  155688. interface ImageBitmap {
  155689. readonly width: number;
  155690. readonly height: number;
  155691. close(): void;
  155692. }
  155693. interface WebGLQuery extends WebGLObject {
  155694. }
  155695. declare var WebGLQuery: {
  155696. prototype: WebGLQuery;
  155697. new(): WebGLQuery;
  155698. };
  155699. interface WebGLSampler extends WebGLObject {
  155700. }
  155701. declare var WebGLSampler: {
  155702. prototype: WebGLSampler;
  155703. new(): WebGLSampler;
  155704. };
  155705. interface WebGLSync extends WebGLObject {
  155706. }
  155707. declare var WebGLSync: {
  155708. prototype: WebGLSync;
  155709. new(): WebGLSync;
  155710. };
  155711. interface WebGLTransformFeedback extends WebGLObject {
  155712. }
  155713. declare var WebGLTransformFeedback: {
  155714. prototype: WebGLTransformFeedback;
  155715. new(): WebGLTransformFeedback;
  155716. };
  155717. interface WebGLVertexArrayObject extends WebGLObject {
  155718. }
  155719. declare var WebGLVertexArrayObject: {
  155720. prototype: WebGLVertexArrayObject;
  155721. new(): WebGLVertexArrayObject;
  155722. };
  155723. // Type definitions for WebVR API
  155724. // Project: https://w3c.github.io/webvr/
  155725. // Definitions by: six a <https://github.com/lostfictions>
  155726. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155727. interface VRDisplay extends EventTarget {
  155728. /**
  155729. * Dictionary of capabilities describing the VRDisplay.
  155730. */
  155731. readonly capabilities: VRDisplayCapabilities;
  155732. /**
  155733. * z-depth defining the far plane of the eye view frustum
  155734. * enables mapping of values in the render target depth
  155735. * attachment to scene coordinates. Initially set to 10000.0.
  155736. */
  155737. depthFar: number;
  155738. /**
  155739. * z-depth defining the near plane of the eye view frustum
  155740. * enables mapping of values in the render target depth
  155741. * attachment to scene coordinates. Initially set to 0.01.
  155742. */
  155743. depthNear: number;
  155744. /**
  155745. * An identifier for this distinct VRDisplay. Used as an
  155746. * association point in the Gamepad API.
  155747. */
  155748. readonly displayId: number;
  155749. /**
  155750. * A display name, a user-readable name identifying it.
  155751. */
  155752. readonly displayName: string;
  155753. readonly isConnected: boolean;
  155754. readonly isPresenting: boolean;
  155755. /**
  155756. * If this VRDisplay supports room-scale experiences, the optional
  155757. * stage attribute contains details on the room-scale parameters.
  155758. */
  155759. readonly stageParameters: VRStageParameters | null;
  155760. /**
  155761. * Passing the value returned by `requestAnimationFrame` to
  155762. * `cancelAnimationFrame` will unregister the callback.
  155763. * @param handle Define the hanle of the request to cancel
  155764. */
  155765. cancelAnimationFrame(handle: number): void;
  155766. /**
  155767. * Stops presenting to the VRDisplay.
  155768. * @returns a promise to know when it stopped
  155769. */
  155770. exitPresent(): Promise<void>;
  155771. /**
  155772. * Return the current VREyeParameters for the given eye.
  155773. * @param whichEye Define the eye we want the parameter for
  155774. * @returns the eye parameters
  155775. */
  155776. getEyeParameters(whichEye: string): VREyeParameters;
  155777. /**
  155778. * Populates the passed VRFrameData with the information required to render
  155779. * the current frame.
  155780. * @param frameData Define the data structure to populate
  155781. * @returns true if ok otherwise false
  155782. */
  155783. getFrameData(frameData: VRFrameData): boolean;
  155784. /**
  155785. * Get the layers currently being presented.
  155786. * @returns the list of VR layers
  155787. */
  155788. getLayers(): VRLayer[];
  155789. /**
  155790. * Return a VRPose containing the future predicted pose of the VRDisplay
  155791. * when the current frame will be presented. The value returned will not
  155792. * change until JavaScript has returned control to the browser.
  155793. *
  155794. * The VRPose will contain the position, orientation, velocity,
  155795. * and acceleration of each of these properties.
  155796. * @returns the pose object
  155797. */
  155798. getPose(): VRPose;
  155799. /**
  155800. * Return the current instantaneous pose of the VRDisplay, with no
  155801. * prediction applied.
  155802. * @returns the current instantaneous pose
  155803. */
  155804. getImmediatePose(): VRPose;
  155805. /**
  155806. * The callback passed to `requestAnimationFrame` will be called
  155807. * any time a new frame should be rendered. When the VRDisplay is
  155808. * presenting the callback will be called at the native refresh
  155809. * rate of the HMD. When not presenting this function acts
  155810. * identically to how window.requestAnimationFrame acts. Content should
  155811. * make no assumptions of frame rate or vsync behavior as the HMD runs
  155812. * asynchronously from other displays and at differing refresh rates.
  155813. * @param callback Define the eaction to run next frame
  155814. * @returns the request handle it
  155815. */
  155816. requestAnimationFrame(callback: FrameRequestCallback): number;
  155817. /**
  155818. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  155819. * Repeat calls while already presenting will update the VRLayers being displayed.
  155820. * @param layers Define the list of layer to present
  155821. * @returns a promise to know when the request has been fulfilled
  155822. */
  155823. requestPresent(layers: VRLayer[]): Promise<void>;
  155824. /**
  155825. * Reset the pose for this display, treating its current position and
  155826. * orientation as the "origin/zero" values. VRPose.position,
  155827. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  155828. * updated when calling resetPose(). This should be called in only
  155829. * sitting-space experiences.
  155830. */
  155831. resetPose(): void;
  155832. /**
  155833. * The VRLayer provided to the VRDisplay will be captured and presented
  155834. * in the HMD. Calling this function has the same effect on the source
  155835. * canvas as any other operation that uses its source image, and canvases
  155836. * created without preserveDrawingBuffer set to true will be cleared.
  155837. * @param pose Define the pose to submit
  155838. */
  155839. submitFrame(pose?: VRPose): void;
  155840. }
  155841. declare var VRDisplay: {
  155842. prototype: VRDisplay;
  155843. new(): VRDisplay;
  155844. };
  155845. interface VRLayer {
  155846. leftBounds?: number[] | Float32Array | null;
  155847. rightBounds?: number[] | Float32Array | null;
  155848. source?: HTMLCanvasElement | null;
  155849. }
  155850. interface VRDisplayCapabilities {
  155851. readonly canPresent: boolean;
  155852. readonly hasExternalDisplay: boolean;
  155853. readonly hasOrientation: boolean;
  155854. readonly hasPosition: boolean;
  155855. readonly maxLayers: number;
  155856. }
  155857. interface VREyeParameters {
  155858. /** @deprecated */
  155859. readonly fieldOfView: VRFieldOfView;
  155860. readonly offset: Float32Array;
  155861. readonly renderHeight: number;
  155862. readonly renderWidth: number;
  155863. }
  155864. interface VRFieldOfView {
  155865. readonly downDegrees: number;
  155866. readonly leftDegrees: number;
  155867. readonly rightDegrees: number;
  155868. readonly upDegrees: number;
  155869. }
  155870. interface VRFrameData {
  155871. readonly leftProjectionMatrix: Float32Array;
  155872. readonly leftViewMatrix: Float32Array;
  155873. readonly pose: VRPose;
  155874. readonly rightProjectionMatrix: Float32Array;
  155875. readonly rightViewMatrix: Float32Array;
  155876. readonly timestamp: number;
  155877. }
  155878. interface VRPose {
  155879. readonly angularAcceleration: Float32Array | null;
  155880. readonly angularVelocity: Float32Array | null;
  155881. readonly linearAcceleration: Float32Array | null;
  155882. readonly linearVelocity: Float32Array | null;
  155883. readonly orientation: Float32Array | null;
  155884. readonly position: Float32Array | null;
  155885. readonly timestamp: number;
  155886. }
  155887. interface VRStageParameters {
  155888. sittingToStandingTransform?: Float32Array;
  155889. sizeX?: number;
  155890. sizeY?: number;
  155891. }
  155892. interface Navigator {
  155893. getVRDisplays(): Promise<VRDisplay[]>;
  155894. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  155895. }
  155896. interface Window {
  155897. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  155898. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  155899. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  155900. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155901. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155902. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  155903. }
  155904. interface Gamepad {
  155905. readonly displayId: number;
  155906. }
  155907. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  155908. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  155909. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  155910. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  155911. type XRHandedness = "none" | "left" | "right";
  155912. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  155913. type XREye = "none" | "left" | "right";
  155914. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  155915. interface XRSpace extends EventTarget {}
  155916. interface XRRenderState {
  155917. depthNear?: number;
  155918. depthFar?: number;
  155919. inlineVerticalFieldOfView?: number;
  155920. baseLayer?: XRWebGLLayer;
  155921. }
  155922. interface XRInputSource {
  155923. handedness: XRHandedness;
  155924. targetRayMode: XRTargetRayMode;
  155925. targetRaySpace: XRSpace;
  155926. gripSpace: XRSpace | undefined;
  155927. gamepad: Gamepad | undefined;
  155928. profiles: Array<string>;
  155929. hand: XRHand | undefined;
  155930. }
  155931. interface XRSessionInit {
  155932. optionalFeatures?: string[];
  155933. requiredFeatures?: string[];
  155934. }
  155935. interface XRSession {
  155936. addEventListener: Function;
  155937. removeEventListener: Function;
  155938. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  155939. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  155940. requestAnimationFrame: Function;
  155941. end(): Promise<void>;
  155942. renderState: XRRenderState;
  155943. inputSources: Array<XRInputSource>;
  155944. // hit test
  155945. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  155946. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  155947. // legacy AR hit test
  155948. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155949. // legacy plane detection
  155950. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  155951. }
  155952. interface XRReferenceSpace extends XRSpace {
  155953. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  155954. onreset: any;
  155955. }
  155956. type XRPlaneSet = Set<XRPlane>;
  155957. type XRAnchorSet = Set<XRAnchor>;
  155958. interface XRFrame {
  155959. session: XRSession;
  155960. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  155961. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  155962. // AR
  155963. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  155964. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  155965. // Anchors
  155966. trackedAnchors?: XRAnchorSet;
  155967. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  155968. // Planes
  155969. worldInformation: {
  155970. detectedPlanes?: XRPlaneSet;
  155971. };
  155972. // Hand tracking
  155973. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  155974. }
  155975. interface XRViewerPose extends XRPose {
  155976. views: Array<XRView>;
  155977. }
  155978. interface XRPose {
  155979. transform: XRRigidTransform;
  155980. emulatedPosition: boolean;
  155981. }
  155982. interface XRWebGLLayerOptions {
  155983. antialias?: boolean;
  155984. depth?: boolean;
  155985. stencil?: boolean;
  155986. alpha?: boolean;
  155987. multiview?: boolean;
  155988. framebufferScaleFactor?: number;
  155989. }
  155990. declare var XRWebGLLayer: {
  155991. prototype: XRWebGLLayer;
  155992. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  155993. };
  155994. interface XRWebGLLayer {
  155995. framebuffer: WebGLFramebuffer;
  155996. framebufferWidth: number;
  155997. framebufferHeight: number;
  155998. getViewport: Function;
  155999. }
  156000. declare class XRRigidTransform {
  156001. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  156002. position: DOMPointReadOnly;
  156003. orientation: DOMPointReadOnly;
  156004. matrix: Float32Array;
  156005. inverse: XRRigidTransform;
  156006. }
  156007. interface XRView {
  156008. eye: XREye;
  156009. projectionMatrix: Float32Array;
  156010. transform: XRRigidTransform;
  156011. }
  156012. interface XRInputSourceChangeEvent {
  156013. session: XRSession;
  156014. removed: Array<XRInputSource>;
  156015. added: Array<XRInputSource>;
  156016. }
  156017. interface XRInputSourceEvent extends Event {
  156018. readonly frame: XRFrame;
  156019. readonly inputSource: XRInputSource;
  156020. }
  156021. // Experimental(er) features
  156022. declare class XRRay {
  156023. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  156024. origin: DOMPointReadOnly;
  156025. direction: DOMPointReadOnly;
  156026. matrix: Float32Array;
  156027. }
  156028. declare enum XRHitTestTrackableType {
  156029. "point",
  156030. "plane",
  156031. "mesh",
  156032. }
  156033. interface XRHitResult {
  156034. hitMatrix: Float32Array;
  156035. }
  156036. interface XRTransientInputHitTestResult {
  156037. readonly inputSource: XRInputSource;
  156038. readonly results: Array<XRHitTestResult>;
  156039. }
  156040. interface XRHitTestResult {
  156041. getPose(baseSpace: XRSpace): XRPose | undefined;
  156042. // When anchor system is enabled
  156043. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  156044. }
  156045. interface XRHitTestSource {
  156046. cancel(): void;
  156047. }
  156048. interface XRTransientInputHitTestSource {
  156049. cancel(): void;
  156050. }
  156051. interface XRHitTestOptionsInit {
  156052. space: XRSpace;
  156053. entityTypes?: Array<XRHitTestTrackableType>;
  156054. offsetRay?: XRRay;
  156055. }
  156056. interface XRTransientInputHitTestOptionsInit {
  156057. profile: string;
  156058. entityTypes?: Array<XRHitTestTrackableType>;
  156059. offsetRay?: XRRay;
  156060. }
  156061. interface XRAnchor {
  156062. anchorSpace: XRSpace;
  156063. delete(): void;
  156064. }
  156065. interface XRPlane {
  156066. orientation: "Horizontal" | "Vertical";
  156067. planeSpace: XRSpace;
  156068. polygon: Array<DOMPointReadOnly>;
  156069. lastChangedTime: number;
  156070. }
  156071. interface XRJointSpace extends XRSpace {}
  156072. interface XRJointPose extends XRPose {
  156073. radius: number | undefined;
  156074. }
  156075. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156076. readonly length: number;
  156077. [index: number]: XRJointSpace;
  156078. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156079. readonly WRIST: number;
  156080. readonly THUMB_METACARPAL: number;
  156081. readonly THUMB_PHALANX_PROXIMAL: number;
  156082. readonly THUMB_PHALANX_DISTAL: number;
  156083. readonly THUMB_PHALANX_TIP: number;
  156084. readonly INDEX_METACARPAL: number;
  156085. readonly INDEX_PHALANX_PROXIMAL: number;
  156086. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156087. readonly INDEX_PHALANX_DISTAL: number;
  156088. readonly INDEX_PHALANX_TIP: number;
  156089. readonly MIDDLE_METACARPAL: number;
  156090. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156091. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156092. readonly MIDDLE_PHALANX_DISTAL: number;
  156093. readonly MIDDLE_PHALANX_TIP: number;
  156094. readonly RING_METACARPAL: number;
  156095. readonly RING_PHALANX_PROXIMAL: number;
  156096. readonly RING_PHALANX_INTERMEDIATE: number;
  156097. readonly RING_PHALANX_DISTAL: number;
  156098. readonly RING_PHALANX_TIP: number;
  156099. readonly LITTLE_METACARPAL: number;
  156100. readonly LITTLE_PHALANX_PROXIMAL: number;
  156101. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156102. readonly LITTLE_PHALANX_DISTAL: number;
  156103. readonly LITTLE_PHALANX_TIP: number;
  156104. }
  156105. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156106. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156107. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156108. interface XRSession {
  156109. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156110. }
  156111. interface XRFrame {
  156112. featurePointCloud? : Array<number>;
  156113. }